pub async fn volume_directory(fs: &Arc<FxFilesystem>) -> Result<VolumeDirectory, Error> {
    let root_store = fs.root_store();
    let volume_info_object_id = fs.volume_info_object_id();
    if volume_info_object_id == INVALID_OBJECT_ID {
        // Create the volume directory
        // Add a directory as the root of all volumes. The root store's root object ID will be
        // this directory.
        // TODO(csuter): This needs locking.
        let mut transaction = Transaction::new();
        let handle = root_store.create_object(&mut transaction, HandleOptions::default()).await?;
        fs.set_volume_info_object_id(handle.object_id());
        let mut serialized_volume_info = Vec::new();
        let directory = root_store.create_directory(&mut transaction).await?;
        let info = VolumeInfo { root_directory_object_id: directory.object_id() };
        serialize_into(&mut serialized_volume_info, &info)?;
        // TODO(jfsulliv): Can we find out how big the object will be in advance and serialize
        // directly into bufer?
        let mut buf = handle.allocate_buffer(serialized_volume_info.len());
        buf.as_mut_slice().copy_from_slice(&serialized_volume_info[..]);
        handle.txn_write(&mut transaction, 0u64, buf.as_ref()).await?;
        fs.commit_transaction(transaction).await;
        Ok(VolumeDirectory { directory, filesystem: fs.clone() })
    } else {
        let handle =
            root_store.open_object(volume_info_object_id, HandleOptions::default()).await?;
        let info: VolumeInfo = deserialize_from(
            &*handle
                .contents(MAX_VOLUME_INFO_SERIALIZED_SIZE)
                .await
                .context("unable to read volume info")?,
        )
        .context("unable to deserialize volume info")?;
        Ok(VolumeDirectory {
            directory: root_store
                .open_directory(info.root_directory_object_id)
                .await
                .context("unable to open volume directory")?,
            filesystem: fs.clone(),
        })
    }
}
/// Returns the volume directory for the filesystem or creates it if it does not exist.
Returns the volume directory for the filesystem or creates it if it does not exist.
Returns the volume directory for the filesystem or creates it if it does not exist .
pub async fn volume_directory(fs: &Arc<FxFilesystem>) -> Result<VolumeDirectory, Error> {
    let root_store = fs.root_store();
    let volume_info_object_id = fs.volume_info_object_id();
    if volume_info_object_id == INVALID_OBJECT_ID {
        // Create the volume directory
        // Add a directory as the root of all volumes. The root store's root object ID will be
        // this directory.
        // TODO(csuter): This needs locking.
        let mut transaction = Transaction::new();
        let handle = root_store.create_object(&mut transaction, HandleOptions::default()).await?;
        fs.set_volume_info_object_id(handle.object_id());
        let mut serialized_volume_info = Vec::new();
        let directory = root_store.create_directory(&mut transaction).await?;
        let info = VolumeInfo { root_directory_object_id: directory.object_id() };
        serialize_into(&mut serialized_volume_info, &info)?;
        // TODO(jfsulliv): Can we find out how big the object will be in advance and serialize
        // directly into bufer?
        let mut buf = handle.allocate_buffer(serialized_volume_info.len());
        buf.as_mut_slice().copy_from_slice(&serialized_volume_info[..]);
        handle.txn_write(&mut transaction, 0u64, buf.as_ref()).await?;
        fs.commit_transaction(transaction).await;
        Ok(VolumeDirectory { directory, filesystem: fs.clone() })
    } else {
        let handle =
            root_store.open_object(volume_info_object_id, HandleOptions::default()).await?;
        let info: VolumeInfo = deserialize_from(
            &*handle
                .contents(MAX_VOLUME_INFO_SERIALIZED_SIZE)
                .await
                .context("unable to read volume info")?,
        )
        .context("unable to deserialize volume info")?;
        Ok(VolumeDirectory {
            directory: root_store
                .open_directory(info.root_directory_object_id)
                .await
                .context("unable to open volume directory")?,
            filesystem: fs.clone(),
        })
    }
}
pub async fn volume_directory ( fs : & Arc < FxFilesystem > ) -> Result < VolumeDirectory , Error > { let root_store = fs . root_store ( ) ; let volume_info_object_id = fs . volume_info_object_id ( ) ; if volume_info_object_id == INVALID_OBJECT_ID { // Create the volume directory // Add a directory as the root of all volumes. The root store's root object ID will be // this directory. // TODO(csuter): This needs locking. let mut transaction = Transaction :: new ( ) ; let handle = root_store . create_object ( & mut transaction , HandleOptions :: default ( ) ) . await ? ; fs . set_volume_info_object_id ( handle . object_id ( ) ) ; let mut serialized_volume_info = Vec :: new ( ) ; let directory = root_store . create_directory ( & mut transaction ) . await ? ; let info = VolumeInfo { root_directory_object_id : directory . object_id ( ) } ; serialize_into ( & mut serialized_volume_info , & info ) ? ; // TODO(jfsulliv): Can we find out how big the object will be in advance and serialize // directly into bufer? let mut buf = handle . allocate_buffer ( serialized_volume_info . len ( ) ) ; buf . as_mut_slice ( ) . copy_from_slice ( & serialized_volume_info [ .. ] ) ; handle . txn_write ( & mut transaction , 0u64 , buf . as_ref ( ) ) . await ? ; fs . commit_transaction ( transaction ) . await ; Ok ( VolumeDirectory { directory , filesystem : fs . clone ( ) } ) } else { let handle = root_store . open_object ( volume_info_object_id , HandleOptions :: default ( ) ) . await ? ; let info : VolumeInfo = deserialize_from ( & * handle . contents ( MAX_VOLUME_INFO_SERIALIZED_SIZE ) . await . context ( " " ) ? , ) . context ( " " ) ? ; Ok ( VolumeDirectory { directory : root_store . open_directory ( info . root_directory_object_id ) . await . context ( " " ) ? , filesystem : fs . clone ( ) , } ) } }
Returns the volume directory for the filesystem or creates it if it does not exist.
Returns the volume directory for the filesystem or creates it if it does not exist .
fs
&Arc<FxFilesystem>
fs
&Arc<FxFilesystem>