axfs/
lib.rs

1//! [ArceOS](https://github.com/arceos-org/arceos) filesystem module.
2//!
3//! It provides unified filesystem operations for various filesystems.
4//!
5//! # Cargo Features
6//!
7//! - `fatfs`: Use [FAT] as the main filesystem and mount it on `/`. This feature
8//!   is **enabled** by default.
9//! - `devfs`: Mount [`axfs_devfs::DeviceFileSystem`] on `/dev`. This feature is
10//!   **enabled** by default.
11//! - `ramfs`: Mount [`axfs_ramfs::RamFileSystem`] on `/tmp`. This feature is
12//!   **enabled** by default.
13//! - `myfs`: Allow users to define their custom filesystems to override the
14//!   default. In this case, [`MyFileSystemIf`] is required to be implemented
15//!   to create and initialize other filesystems. This feature is **disabled** by
16//!   by default, but it will override other filesystem selection features if
17//!   both are enabled.
18//!
19//! [FAT]: https://en.wikipedia.org/wiki/File_Allocation_Table
20//! [`MyFileSystemIf`]: fops::MyFileSystemIf
21
22#![cfg_attr(all(not(test), not(doc)), no_std)]
23
24#[macro_use]
25extern crate log;
26extern crate alloc;
27
28mod dev;
29mod fs;
30mod mounts;
31mod root;
32
33pub mod api;
34pub mod fops;
35
36use axdriver::{AxDeviceContainer, prelude::*};
37
38/// Initializes filesystems by block devices.
39pub fn init_filesystems(mut blk_devs: AxDeviceContainer<AxBlockDevice>) {
40    info!("Initialize filesystems...");
41
42    let dev = blk_devs.take_one().expect("No block device found!");
43    info!("  use block device 0: {:?}", dev.device_name());
44    self::root::init_rootfs(self::dev::Disk::new(dev));
45}