fuchsia_storage_benchmarks_lib/filesystems/
minfs.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2023 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

use crate::filesystems::FsManagementFilesystemInstance;
use async_trait::async_trait;
use storage_benchmarks::{BlockDeviceConfig, BlockDeviceFactory, FilesystemConfig};

/// Config object for starting Minfs instances.
#[derive(Clone)]
pub struct Minfs;

#[async_trait]
impl FilesystemConfig for Minfs {
    type Filesystem = FsManagementFilesystemInstance;

    async fn start_filesystem(
        &self,
        block_device_factory: &dyn BlockDeviceFactory,
    ) -> FsManagementFilesystemInstance {
        let block_device = block_device_factory
            .create_block_device(&BlockDeviceConfig { use_zxcrypt: true, fvm_volume_size: None })
            .await;
        FsManagementFilesystemInstance::new(
            fs_management::Minfs::default(),
            block_device,
            None,
            /*as_blob=*/ false,
        )
        .await
    }

    fn name(&self) -> String {
        "minfs".to_owned()
    }
}

#[cfg(test)]
mod tests {
    use super::Minfs;
    use crate::filesystems::testing::check_filesystem;

    #[fuchsia::test]
    async fn start_minfs() {
        check_filesystem(Minfs).await;
    }
}