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#![feature(doc_auto_cfg)]
24
25#[macro_use]
26extern crate log;
27extern crate alloc;
28
29mod dev;
30mod fs;
31mod mounts;
32mod root;
33
34pub mod api;
35pub mod fops;
36pub use root::{CURRENT_DIR, CURRENT_DIR_PATH};
37
38use axdriver::{AxDeviceContainer, prelude::*};
39
40/// Initializes filesystems by block devices.
41pub fn init_filesystems(mut blk_devs: AxDeviceContainer<AxBlockDevice>) {
42 info!("Initialize filesystems...");
43
44 let dev = blk_devs.take_one().expect("No block device found!");
45 info!(" use block device 0: {:?}", dev.device_name());
46 self::root::init_rootfs(self::dev::Disk::new(dev));
47}