/// Creates an empty filesystem with the minimum viable objects (including a root parent and
/// root store but no further child stores).  Nothing is written to the device until sync is
/// called.
Creates an empty filesystem with the minimum viable objects (including a root parent and
root store but no further child stores).  Nothing is written to the device until sync is
called.
Creates an empty filesystem with the minimum viable objects ( including a root parent and root store but no further child stores ) . Nothing is written to the device until sync is called .
pub async fn init_empty(&self, filesystem: Arc<dyn Filesystem>) -> Result<(), Error> {
        // The following constants are only used at format time. When mounting, the recorded values
        // in the superblock should be used.  The root parent store does not have a parent, but
        // needs an object ID to be registered with ObjectManager, so it cannot collide (i.e. have
        // the same object ID) with any objects in the root store that use the journal to track
        // mutations.
        const INIT_ROOT_PARENT_STORE_OBJECT_ID: u64 = 2;
        const INIT_ROOT_STORE_OBJECT_ID: u64 = 3;
        const INIT_ALLOCATOR_OBJECT_ID: u64 = 4;
        let checkpoint = self.writer.lock().await.journal_file_checkpoint();
        let root_parent =
            ObjectStore::new_empty(None, INIT_ROOT_PARENT_STORE_OBJECT_ID, filesystem.clone());
        self.objects.set_root_parent_store_object_id(root_parent.store_object_id());
        let allocator =
            Arc::new(SimpleAllocator::new(filesystem.clone(), INIT_ALLOCATOR_OBJECT_ID, true));
        self.objects.set_allocator(allocator.clone());
        let mut transaction = Transaction::new();
        let root_store = root_parent
            .create_child_store_with_id(&mut transaction, INIT_ROOT_STORE_OBJECT_ID)
            .await?;
        self.objects.set_root_store_object_id(root_store.store_object_id());
        // Create the super-block object...
        SuperBlock::create_object(&mut transaction, &root_store).await?;
        // and the journal object...
        let journal_handle =
            root_parent.create_object(&mut transaction, journal_handle_options()).await?;
        journal_handle.preallocate_range(&mut transaction, 0..self.chunk_size()).await?;
        self.commit(transaction).await;
        // Cache the super-block.
        self.inner.lock().unwrap().super_block = SuperBlock::new(
            root_parent.store_object_id(),
            root_store.store_object_id(),
            allocator.object_id(),
            journal_handle.object_id(),
            checkpoint,
        );
        // Initialize the journal writer.
        self.writer.lock().await.set_handle(journal_handle);
        Ok(())
    }
pub async fn init_empty ( & self , filesystem : Arc < dyn Filesystem > ) -> Result < ( ) , Error > { // The following constants are only used at format time. When mounting, the recorded values // in the superblock should be used.  The root parent store does not have a parent, but // needs an object ID to be registered with ObjectManager, so it cannot collide (i.e. have // the same object ID) with any objects in the root store that use the journal to track // mutations. const INIT_ROOT_PARENT_STORE_OBJECT_ID : u64 = 2 ; const INIT_ROOT_STORE_OBJECT_ID : u64 = 3 ; const INIT_ALLOCATOR_OBJECT_ID : u64 = 4 ; let checkpoint = self . writer . lock ( ) . await . journal_file_checkpoint ( ) ; let root_parent = ObjectStore :: new_empty ( None , INIT_ROOT_PARENT_STORE_OBJECT_ID , filesystem . clone ( ) ) ; self . objects . set_root_parent_store_object_id ( root_parent . store_object_id ( ) ) ; let allocator = Arc :: new ( SimpleAllocator :: new ( filesystem . clone ( ) , INIT_ALLOCATOR_OBJECT_ID , true ) ) ; self . objects . set_allocator ( allocator . clone ( ) ) ; let mut transaction = Transaction :: new ( ) ; let root_store = root_parent . create_child_store_with_id ( & mut transaction , INIT_ROOT_STORE_OBJECT_ID ) . await ? ; self . objects . set_root_store_object_id ( root_store . store_object_id ( ) ) ; // Create the super-block object... SuperBlock :: create_object ( & mut transaction , & root_store ) . await ? ; // and the journal object... let journal_handle = root_parent . create_object ( & mut transaction , journal_handle_options ( ) ) . await ? ; journal_handle . preallocate_range ( & mut transaction , 0 .. self . chunk_size ( ) ) . await ? ; self . commit ( transaction ) . await ; // Cache the super-block. self . inner . lock ( ) . unwrap ( ) . super_block = SuperBlock :: new ( root_parent . store_object_id ( ) , root_store . store_object_id ( ) , allocator . object_id ( ) , journal_handle . object_id ( ) , checkpoint , ) ; // Initialize the journal writer. self . writer . lock ( ) . await . set_handle ( journal_handle ) ; Ok ( ( ) ) }
Creates an empty filesystem with the minimum viable objects (including a root parent and
root store but no further child stores).
Creates an empty filesystem with the minimum viable objects ( including a root parent and root store but no further child stores ) .
&self
filesystem
Arc<dyn Filesystem>