fuchsia_storage_benchmarks/filesystems/
minfs.rs

1// Copyright 2023 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::filesystems::FsManagementFilesystemInstance;
6use async_trait::async_trait;
7use storage_benchmarks::{BlockDeviceConfig, BlockDeviceFactory, FilesystemConfig};
8
9/// Config object for starting Minfs instances.
10#[derive(Clone)]
11pub struct Minfs;
12
13#[async_trait]
14impl FilesystemConfig for Minfs {
15    type Filesystem = FsManagementFilesystemInstance;
16
17    async fn start_filesystem(
18        &self,
19        block_device_factory: &dyn BlockDeviceFactory,
20    ) -> FsManagementFilesystemInstance {
21        let block_device = block_device_factory
22            .create_block_device(&BlockDeviceConfig {
23                requires_fvm: true,
24                use_zxcrypt: true,
25                volume_size: None,
26            })
27            .await;
28        FsManagementFilesystemInstance::new(
29            fs_management::Minfs::default(),
30            block_device,
31            None,
32            /*as_blob=*/ false,
33        )
34        .await
35    }
36
37    fn name(&self) -> String {
38        "minfs".to_owned()
39    }
40}
41
42#[cfg(test)]
43mod tests {
44    use super::Minfs;
45    use crate::filesystems::testing::check_filesystem;
46
47    #[fuchsia::test]
48    async fn start_minfs() {
49        check_filesystem(Minfs).await;
50    }
51}