Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
e4f67d1
fix: getdents
Oct 10, 2024
5baf6cb
test: add test harness
Oct 10, 2024
e01d516
fix: openat directory flag
Oct 16, 2024
8a18da3
fix: open with absolute path
Oct 16, 2024
d99b6c9
refactor: define AbsPath and RelPath type
Oct 16, 2024
ec5095e
refactor: devfs use new path defs
Oct 16, 2024
86a14b3
refactor: ramfs use new path defs
Oct 24, 2024
fc064b8
fix: ruxfs api and posix api
Oct 28, 2024
90128f8
refactor: implement simple ruxfs operations
Oct 29, 2024
f90c2ea
refacotr: fs posix api
Oct 31, 2024
07e55ce
fix: root directory lookup path
Oct 31, 2024
ff00a8b
feat: rmdir mkdirat unlink unlinkat api
Oct 31, 2024
8265722
fix: unlinkat with removedir
Nov 6, 2024
50977bb
test: use specific test dir
Nov 7, 2024
f5d3a63
feat: support fatfs and ext4 fs
Nov 14, 2024
d51a242
feat: make ext4 fs scripts
Nov 14, 2024
ed5d31c
fix: path canonicalization
Nov 18, 2024
840dbdd
feat: vfs add link and setattr fn
Nov 18, 2024
6acc1c3
fix: ramfs and devfs support new vfs trait
Nov 18, 2024
c9c8ee6
refactor: ruxfs and posix_api compats with new vfs
Nov 21, 2024
c392acc
feat: add inode number in vfsattr
Nov 21, 2024
8af1c3e
refactor: remove fops with relative path
Nov 25, 2024
e3e07e3
fix: path lifetime
Nov 27, 2024
abf3a6c
refactor: filelike path method
Nov 27, 2024
0e806a0
refactor: fs posix api with absolute path
Nov 27, 2024
0b37197
fix: FileLike stat
Nov 28, 2024
8cf6918
feat: directory check empty
Nov 28, 2024
2bef77f
fix: unlinkat
Nov 28, 2024
41879f9
Update ruxfs dependencies
Nov 28, 2024
0e58f4e
fix: blkfs features
Nov 28, 2024
52247a2
feat: ruxfs high-level api
Nov 28, 2024
b80d765
feat: fs arceos api
Nov 28, 2024
c9c0963
feat: axstd fs api
Nov 28, 2024
a98c3e7
fix: devfs and ramfs lookup
Nov 28, 2024
454bb3d
doc: axfs_vfs and ruxfs doc comments
Nov 28, 2024
01e9eee
fix: remove harness from workspace
Nov 28, 2024
4a99179
refactor: remove test harness
Feb 15, 2025
18bc4a9
fix: incompatible interfaces
Feb 19, 2025
3e55f9e
style: ruxos_posix_api fs syscalls
Feb 20, 2025
c99c128
fix: make fs img
Feb 26, 2025
e8d90f6
fix: ruxruntime fs test
Feb 26, 2025
aa5895a
fix: unit test
Feb 27, 2025
790e423
fix: clippy
Feb 27, 2025
ee46070
fix: aarch64 & riscv64 openat
Feb 27, 2025
8c699bc
fix: build fs shell
Feb 27, 2025
9c9b775
fix: build iperf & redis
Feb 27, 2025
e3fdd09
fix: log dep version
Feb 27, 2025
e14b5fb
fix: temporarily remove lwext4_rust
Mar 4, 2025
287ed72
fix: update another_ext4 dep
Mar 4, 2025
c20a832
style: cargo format all
Mar 4, 2025
0f85878
fix: docs
Mar 4, 2025
f883f12
Merge branch 'dev'
Mar 4, 2025
b18325e
fix: getdents
Mar 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: fs arceos api
  • Loading branch information
liujingx committed Feb 19, 2025
commit b80d7657862c88e20969f22042f071af289eb63e
56 changes: 32 additions & 24 deletions api/arceos_api/src/imp/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@

use alloc::string::String;
use axerrno::AxResult;
use ruxfs::fops::{Directory, File};
use ruxfs::{
api::{Directory, File},
AbsPath, RelPath,
};
use axio::{Read, Write, Seek};

pub use ruxfs::fops::DirEntry as AxDirEntry;
pub use ruxfs::fops::FileAttr as AxFileAttr;
pub use ruxfs::fops::FilePerm as AxFilePerm;
pub use ruxfs::fops::FileType as AxFileType;
pub use ruxfs::fops::OpenOptions as AxOpenOptions;
pub use axio::SeekFrom as AxSeekFrom;
pub use ruxfs::api::DirEntry as AxDirEntry;
pub use ruxfs::api::FileAttr as AxFileAttr;
pub use ruxfs::api::FilePerm as AxFilePerm;
pub use ruxfs::api::FileType as AxFileType;
pub use ruxfs::api::OpenOptions as AxOpenOptions;

#[cfg(feature = "myfs")]
pub use ruxfs::fops::{Disk as AxDisk, MyFileSystemIf};
Expand All @@ -28,29 +32,25 @@ pub struct AxFileHandle(File);
pub struct AxDirHandle(Directory);

pub fn ax_open_file(path: &str, opts: &AxOpenOptions) -> AxResult<AxFileHandle> {
Ok(AxFileHandle(File::open(path, opts)?))
Ok(AxFileHandle(opts.open(&parse_path(path)?)?))
}

pub fn ax_open_dir(path: &str, opts: &AxOpenOptions) -> AxResult<AxDirHandle> {
Ok(AxDirHandle(Directory::open_dir(path, opts)?))
pub fn ax_open_dir(path: &str, _opts: &AxOpenOptions) -> AxResult<AxDirHandle> {
Ok(AxDirHandle(Directory::open(parse_path(path)?)?))
}

pub fn ax_read_file(file: &mut AxFileHandle, buf: &mut [u8]) -> AxResult<usize> {
file.0.read(buf)
pub fn ax_get_attr(path: &str) -> AxResult<AxFileAttr> {
ruxfs::api::get_attr(&parse_path(path)?)
}

pub fn ax_read_file_at(file: &AxFileHandle, offset: u64, buf: &mut [u8]) -> AxResult<usize> {
file.0.read_at(offset, buf)
pub fn ax_read_file(file: &mut AxFileHandle, buf: &mut [u8]) -> AxResult<usize> {
file.0.read(buf)
}

pub fn ax_write_file(file: &mut AxFileHandle, buf: &[u8]) -> AxResult<usize> {
file.0.write(buf)
}

pub fn ax_write_file_at(file: &AxFileHandle, offset: u64, buf: &[u8]) -> AxResult<usize> {
file.0.write_at(offset, buf)
}

pub fn ax_truncate_file(file: &AxFileHandle, size: u64) -> AxResult {
file.0.truncate(size)
}
Expand All @@ -72,29 +72,37 @@ pub fn ax_read_dir(dir: &mut AxDirHandle, dirents: &mut [AxDirEntry]) -> AxResul
}

pub fn ax_create_dir(path: &str) -> AxResult {
ruxfs::api::create_dir(path)
ruxfs::api::create_dir(&parse_path(path)?)
}

pub fn ax_create_dir_all(path: &str) -> AxResult {
ruxfs::api::create_dir_all(path)
ruxfs::api::create_dir_all(&parse_path(path)?)
}

pub fn ax_remove_dir(path: &str) -> AxResult {
ruxfs::api::remove_dir(path)
ruxfs::api::remove_dir(&parse_path(path)?)
}

pub fn ax_remove_file(path: &str) -> AxResult {
ruxfs::api::remove_file(path)
ruxfs::api::remove_file(&parse_path(path)?)
}

pub fn ax_rename(old: &str, new: &str) -> AxResult {
ruxfs::api::rename(old, new)
ruxfs::api::rename(&parse_path(old)?, &parse_path(new)?)
}

pub fn ax_current_dir() -> AxResult<String> {
ruxfs::api::current_dir()
ruxfs::api::current_dir().map(|path| path.to_string())
}

pub fn ax_set_current_dir(path: &str) -> AxResult {
ruxfs::api::set_current_dir(path)
ruxfs::api::set_current_dir(parse_path(path)?)
}

fn parse_path(path: &str) -> AxResult<AbsPath<'static>> {
if path.starts_with('/') {
Ok(AbsPath::new_canonicalized(path))
} else {
ruxfs::api::current_dir().map(|cwd| cwd.join(&RelPath::new_canonicalized(path)))
}
}
11 changes: 2 additions & 9 deletions api/arceos_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,26 +174,19 @@ pub mod fs {
/// Opens a directory at the path relative to the current directory with
/// the options specified by `opts`.
pub fn ax_open_dir(path: &str, opts: &AxOpenOptions) -> AxResult<AxDirHandle>;
/// Returns attributes of a file or directory at the given path.
pub fn ax_get_attr(path: &str) -> AxResult<AxFileAttr>;

/// Reads the file at the current position, returns the number of bytes read.
///
/// After the read, the cursor will be advanced by the number of bytes read.
pub fn ax_read_file(file: &mut AxFileHandle, buf: &mut [u8]) -> AxResult<usize>;
/// Reads the file at the given position, returns the number of bytes read.
///
/// It does not update the file cursor.
pub fn ax_read_file_at(file: &AxFileHandle, offset: u64, buf: &mut [u8]) -> AxResult<usize>;
/// Writes the file at the current position, returns the number of bytes
/// written.
///
/// After the write, the cursor will be advanced by the number of bytes
/// written.
pub fn ax_write_file(file: &mut AxFileHandle, buf: &[u8]) -> AxResult<usize>;
/// Writes the file at the given position, returns the number of bytes
/// written.
///
/// It does not update the file cursor.
pub fn ax_write_file_at(file: &AxFileHandle, offset: u64, buf: &[u8]) -> AxResult<usize>;
/// Truncates the file to the specified size.
pub fn ax_truncate_file(file: &AxFileHandle, size: u64) -> AxResult;
/// Flushes the file, writes all buffered data to the underlying device.
Expand Down