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
style: cargo format all
  • Loading branch information
liujingx committed Mar 4, 2025
commit c20a832374ea1cd7f72f94c2e20c556ae78b30de
2 changes: 1 addition & 1 deletion api/ruxos_posix_api/src/imp/io_mpx/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use ruxfdtable::{FileLike, RuxStat};
use ruxhal::time::current_time;

use crate::{ctypes, imp::fs::flags_to_options};
use ruxtask::fs::{add_file_like, get_file_like};
use ruxfs::AbsPath;
use ruxtask::fs::{add_file_like, get_file_like};

pub struct EpollInstance {
events: Mutex<BTreeMap<usize, ctypes::epoll_event>>,
Expand Down
2 changes: 1 addition & 1 deletion api/ruxos_posix_api/src/imp/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use alloc::{sync::Arc, vec, vec::Vec};
use core::ffi::{c_char, c_int, c_void};
use core::mem::size_of;
use core::net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4};
use ruxfs::{AbsPath, fops};
use ruxfs::{fops, AbsPath};

use axerrno::{LinuxError, LinuxResult};
use axio::PollState;
Expand Down
64 changes: 49 additions & 15 deletions crates/axfs_devfs/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ fn test_devfs_ops(devfs: &DeviceFileSystem) -> VfsResult {
assert!(root.get_attr()?.is_dir());
assert_eq!(root.get_attr()?.file_type(), VfsNodeType::Dir);
assert_eq!(
root.clone().lookup(&RelPath::new_canonicalized("urandom")).err(),
root.clone()
.lookup(&RelPath::new_canonicalized("urandom"))
.err(),
Some(VfsError::NotFound)
);

Expand All @@ -32,32 +34,46 @@ fn test_devfs_ops(devfs: &DeviceFileSystem) -> VfsResult {
assert_eq!(node.read_at(0, &mut buf)?, 0);
assert_eq!(buf, [1; N]);
assert_eq!(node.write_at(N as _, &buf)?, N);
assert_eq!(node.lookup(&RelPath::new_canonicalized("/")).err(), Some(VfsError::NotADirectory));
assert_eq!(
node.lookup(&RelPath::new_canonicalized("/")).err(),
Some(VfsError::NotADirectory)
);

let node = devfs.root_dir().lookup(&RelPath::new_canonicalized(".///.//././/.////zero"))?;
let node = devfs
.root_dir()
.lookup(&RelPath::new_canonicalized(".///.//././/.////zero"))?;
assert_eq!(node.get_attr()?.file_type(), VfsNodeType::CharDevice);
assert!(!node.get_attr()?.is_dir());
assert_eq!(node.get_attr()?.size(), 0);
assert_eq!(node.read_at(10, &mut buf)?, N);
assert_eq!(buf, [0; N]);
assert_eq!(node.write_at(0, &buf)?, N);

let foo = devfs.root_dir().lookup(&RelPath::new_canonicalized(".///.//././/.////foo"))?;
let foo = devfs
.root_dir()
.lookup(&RelPath::new_canonicalized(".///.//././/.////foo"))?;
assert!(foo.get_attr()?.is_dir());
assert_eq!(
foo.read_at(10, &mut buf).err(),
Some(VfsError::IsADirectory)
);
assert!(Arc::ptr_eq(
&foo.clone().lookup(&RelPath::new_canonicalized("/f2"))?,
&devfs.root_dir().lookup(&RelPath::new_canonicalized(".//./foo///f2"))?,
&devfs
.root_dir()
.lookup(&RelPath::new_canonicalized(".//./foo///f2"))?,
));
assert_eq!(
foo.clone().lookup(&RelPath::new_canonicalized("/bar//f1"))?.get_attr()?.file_type(),
foo.clone()
.lookup(&RelPath::new_canonicalized("/bar//f1"))?
.get_attr()?
.file_type(),
VfsNodeType::CharDevice
);
assert_eq!(
foo.lookup(&RelPath::new_canonicalized("/bar///"))?.get_attr()?.file_type(),
foo.lookup(&RelPath::new_canonicalized("/bar///"))?
.get_attr()?
.file_type(),
VfsNodeType::Dir
);

Expand All @@ -71,25 +87,43 @@ fn test_get_parent(devfs: &DeviceFileSystem) -> VfsResult {
let node = root.clone().lookup(&RelPath::new_canonicalized("null"))?;
assert!(node.parent().is_none());

let node = root.clone().lookup(&RelPath::new_canonicalized(".//foo/bar"))?;
let node = root
.clone()
.lookup(&RelPath::new_canonicalized(".//foo/bar"))?;
assert!(node.parent().is_some());
let parent = node.parent().unwrap();
assert!(Arc::ptr_eq(&parent, &root.clone().lookup(&RelPath::new_canonicalized("foo"))?));
assert!(Arc::ptr_eq(
&parent,
&root.clone().lookup(&RelPath::new_canonicalized("foo"))?
));
assert!(parent.lookup(&RelPath::new_canonicalized("bar")).is_ok());

let node = root.clone().lookup(&RelPath::new_canonicalized("foo/.."))?;
assert!(Arc::ptr_eq(&node, &root.clone().lookup(&RelPath::new_canonicalized("."))?));
assert!(Arc::ptr_eq(
&node,
&root.clone().lookup(&RelPath::new_canonicalized("."))?
));

assert!(Arc::ptr_eq(
&root.clone().lookup(&RelPath::new_canonicalized("/foo/.."))?,
&devfs.root_dir().lookup(&RelPath::new_canonicalized(".//./foo/././bar/../.."))?,
&root
.clone()
.lookup(&RelPath::new_canonicalized("/foo/.."))?,
&devfs
.root_dir()
.lookup(&RelPath::new_canonicalized(".//./foo/././bar/../.."))?,
));
assert!(Arc::ptr_eq(
&root.clone().lookup(&RelPath::new_canonicalized("././/foo//./../foo//bar///..//././"))?,
&devfs.root_dir().lookup(&RelPath::new_canonicalized(".//./foo/"))?,
&root.clone().lookup(&RelPath::new_canonicalized(
"././/foo//./../foo//bar///..//././"
))?,
&devfs
.root_dir()
.lookup(&RelPath::new_canonicalized(".//./foo/"))?,
));
assert!(Arc::ptr_eq(
&root.clone().lookup(&RelPath::new_canonicalized("///foo//bar///../f2"))?,
&root
.clone()
.lookup(&RelPath::new_canonicalized("///foo//bar///../f2"))?,
&root.lookup(&RelPath::new_canonicalized("foo/.//f2"))?,
));

Expand Down
106 changes: 81 additions & 25 deletions crates/axfs_ramfs/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ fn test_ramfs_ops(devfs: &RamFileSystem) -> VfsResult {
assert!(root.get_attr()?.is_dir());
assert_eq!(root.get_attr()?.file_type(), VfsNodeType::Dir);
assert_eq!(
root.clone().lookup(&RelPath::new_canonicalized("urandom")).err(),
root.clone()
.lookup(&RelPath::new_canonicalized("urandom"))
.err(),
Some(VfsError::NotFound)
);

Expand All @@ -37,24 +39,36 @@ fn test_ramfs_ops(devfs: &RamFileSystem) -> VfsResult {
assert_eq!(node.read_at(0, &mut buf)?, N);
assert_eq!(buf[..N_HALF], [0; N_HALF]);
assert_eq!(buf[N_HALF..], [1; N_HALF]);
assert_eq!(node.lookup(&RelPath::new_canonicalized("/")).err(), Some(VfsError::NotADirectory));
assert_eq!(
node.lookup(&RelPath::new_canonicalized("/")).err(),
Some(VfsError::NotADirectory)
);

let foo = devfs.root_dir().lookup(&RelPath::new_canonicalized(".///.//././/.////foo"))?;
let foo = devfs
.root_dir()
.lookup(&RelPath::new_canonicalized(".///.//././/.////foo"))?;
assert!(foo.get_attr()?.is_dir());
assert_eq!(
foo.read_at(10, &mut buf).err(),
Some(VfsError::IsADirectory)
);
assert!(Arc::ptr_eq(
&foo.clone().lookup(&RelPath::new_canonicalized("/f3"))?,
&devfs.root_dir().lookup(&RelPath::new_canonicalized(".//./foo///f3"))?,
&devfs
.root_dir()
.lookup(&RelPath::new_canonicalized(".//./foo///f3"))?,
));
assert_eq!(
foo.clone().lookup(&RelPath::new_canonicalized("/bar//f4"))?.get_attr()?.file_type(),
foo.clone()
.lookup(&RelPath::new_canonicalized("/bar//f4"))?
.get_attr()?
.file_type(),
VfsNodeType::File
);
assert_eq!(
foo.lookup(&RelPath::new_canonicalized("/bar///"))?.get_attr()?.file_type(),
foo.lookup(&RelPath::new_canonicalized("/bar///"))?
.get_attr()?
.file_type(),
VfsNodeType::Dir
);

Expand All @@ -68,25 +82,43 @@ fn test_get_parent(devfs: &RamFileSystem) -> VfsResult {
let node = root.clone().lookup(&RelPath::new_canonicalized("f1"))?;
assert!(node.parent().is_none());

let node = root.clone().lookup(&RelPath::new_canonicalized(".//foo/bar"))?;
let node = root
.clone()
.lookup(&RelPath::new_canonicalized(".//foo/bar"))?;
assert!(node.parent().is_some());
let parent = node.parent().unwrap();
assert!(Arc::ptr_eq(&parent, &root.clone().lookup(&RelPath::new_canonicalized("foo"))?));
assert!(Arc::ptr_eq(
&parent,
&root.clone().lookup(&RelPath::new_canonicalized("foo"))?
));
assert!(parent.lookup(&RelPath::new_canonicalized("bar")).is_ok());

let node = root.clone().lookup(&RelPath::new_canonicalized("foo/.."))?;
assert!(Arc::ptr_eq(&node, &root.clone().lookup(&RelPath::new_canonicalized("."))?));
assert!(Arc::ptr_eq(
&node,
&root.clone().lookup(&RelPath::new_canonicalized("."))?
));

assert!(Arc::ptr_eq(
&root.clone().lookup(&RelPath::new_canonicalized("/foo/.."))?,
&devfs.root_dir().lookup(&RelPath::new_canonicalized(".//./foo/././bar/../.."))?,
&root
.clone()
.lookup(&RelPath::new_canonicalized("/foo/.."))?,
&devfs
.root_dir()
.lookup(&RelPath::new_canonicalized(".//./foo/././bar/../.."))?,
));
assert!(Arc::ptr_eq(
&root.clone().lookup(&RelPath::new_canonicalized("././/foo//./../foo//bar///..//././"))?,
&devfs.root_dir().lookup(&RelPath::new_canonicalized(".//./foo/"))?,
&root.clone().lookup(&RelPath::new_canonicalized(
"././/foo//./../foo//bar///..//././"
))?,
&devfs
.root_dir()
.lookup(&RelPath::new_canonicalized(".//./foo/"))?,
));
assert!(Arc::ptr_eq(
&root.clone().lookup(&RelPath::new_canonicalized("///foo//bar///../f3"))?,
&root
.clone()
.lookup(&RelPath::new_canonicalized("///foo//bar///../f3"))?,
&root.lookup(&RelPath::new_canonicalized("foo/.//f3"))?,
));

Expand All @@ -105,16 +137,25 @@ fn test_ramfs() {

let ramfs = RamFileSystem::new();
let root = ramfs.root_dir();
root.create(&RelPath::new_canonicalized("f1"), VfsNodeType::File).unwrap();
root.create(&RelPath::new_canonicalized("f2"), VfsNodeType::File).unwrap();
root.create(&RelPath::new_canonicalized("foo"), VfsNodeType::Dir).unwrap();
root.create(&RelPath::new_canonicalized("f1"), VfsNodeType::File)
.unwrap();
root.create(&RelPath::new_canonicalized("f2"), VfsNodeType::File)
.unwrap();
root.create(&RelPath::new_canonicalized("foo"), VfsNodeType::Dir)
.unwrap();

let dir_foo = root.lookup(&RelPath::new_canonicalized("foo")).unwrap();
dir_foo.create(&RelPath::new_canonicalized("f3"), VfsNodeType::File).unwrap();
dir_foo.create(&RelPath::new_canonicalized("bar"), VfsNodeType::Dir).unwrap();
dir_foo
.create(&RelPath::new_canonicalized("f3"), VfsNodeType::File)
.unwrap();
dir_foo
.create(&RelPath::new_canonicalized("bar"), VfsNodeType::Dir)
.unwrap();

let dir_bar = dir_foo.lookup(&RelPath::new_canonicalized("bar")).unwrap();
dir_bar.create(&RelPath::new_canonicalized("f4"), VfsNodeType::File).unwrap();
dir_bar
.create(&RelPath::new_canonicalized("f4"), VfsNodeType::File)
.unwrap();

let mut entries = ramfs.root_dir_node().get_entries();
entries.sort();
Expand All @@ -126,16 +167,31 @@ fn test_ramfs() {
let root = ramfs.root_dir();
assert_eq!(root.unlink(&RelPath::new_canonicalized("f1")), Ok(()));
assert_eq!(root.unlink(&RelPath::new_canonicalized("//f2")), Ok(()));
assert_eq!(root.unlink(&RelPath::new_canonicalized("f3")).err(), Some(VfsError::NotFound));
assert_eq!(root.unlink(&RelPath::new_canonicalized("foo")).err(), Some(VfsError::DirectoryNotEmpty));
assert_eq!(root.unlink(&RelPath::new_canonicalized("foo/..")).err(), Some(VfsError::InvalidInput));
assert_eq!(
root.unlink(&RelPath::new_canonicalized("f3")).err(),
Some(VfsError::NotFound)
);
assert_eq!(
root.unlink(&RelPath::new_canonicalized("foo")).err(),
Some(VfsError::DirectoryNotEmpty)
);
assert_eq!(
root.unlink(&RelPath::new_canonicalized("foo/..")).err(),
Some(VfsError::InvalidInput)
);
assert_eq!(
root.unlink(&RelPath::new_canonicalized("foo/./bar")).err(),
Some(VfsError::DirectoryNotEmpty)
);
assert_eq!(root.unlink(&RelPath::new_canonicalized("foo/bar/f4")), Ok(()));
assert_eq!(
root.unlink(&RelPath::new_canonicalized("foo/bar/f4")),
Ok(())
);
assert_eq!(root.unlink(&RelPath::new_canonicalized("foo/bar")), Ok(()));
assert_eq!(root.unlink(&RelPath::new_canonicalized("./foo//.//f3")), Ok(()));
assert_eq!(
root.unlink(&RelPath::new_canonicalized("./foo//.//f3")),
Ok(())
);
assert_eq!(root.unlink(&RelPath::new_canonicalized("./foo")), Ok(()));
assert!(ramfs.root_dir_node().get_entries().is_empty());
}
4 changes: 2 additions & 2 deletions modules/rux9p/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
use crate::drv::{self, Drv9pOps};
use alloc::{string::String, string::ToString, sync::Arc, sync::Weak, vec::Vec};
use axfs_vfs::{
VfsDirEntry, VfsError, VfsNodeAttr, VfsNodeOps, VfsNodePerm, VfsNodeRef, VfsNodeType, VfsOps,
VfsResult, AbsPath, RelPath
AbsPath, RelPath, VfsDirEntry, VfsError, VfsNodeAttr, VfsNodeOps, VfsNodePerm, VfsNodeRef,
VfsNodeType, VfsOps, VfsResult,
};
use log::*;
use spin::{once::Once, RwLock};
Expand Down
4 changes: 2 additions & 2 deletions modules/rux9p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ mod fs;
#[cfg(feature = "net-9p")]
mod netdev;

use alloc::{sync::Arc, borrow::ToOwned};
use alloc::{borrow::ToOwned, sync::Arc};
use log::*;
use ruxfs::{AbsPath, root::MountPoint};
use ruxfs::{root::MountPoint, AbsPath};
use spin::RwLock;

#[cfg(feature = "virtio-9p")]
Expand Down
6 changes: 3 additions & 3 deletions modules/ruxfs/src/fs/another_ext4.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Reference:
//! Reference:
//! - another_ext4: https://github.com/LJxTHUCS/another_ext4
//! - axfs: https://github.com/Starry-OS/axfs

Expand All @@ -8,7 +8,7 @@ use another_ext4::{
Block, BlockDevice, ErrCode as Ext4ErrorCode, Ext4, Ext4Error, FileType as EXt4FileType,
InodeMode as Ext4InodeMode, BLOCK_SIZE as EXT4_BLOCK_SIZE, EXT4_ROOT_INO,
};
use axfs_vfs::{VfsDirEntry, VfsError, VfsNodePerm, VfsResult, RelPath};
use axfs_vfs::{RelPath, VfsDirEntry, VfsError, VfsNodePerm, VfsResult};
use axfs_vfs::{VfsNodeAttr, VfsNodeOps, VfsNodeRef, VfsNodeType, VfsOps};
use axsync::Mutex;

Expand Down Expand Up @@ -282,4 +282,4 @@ fn map_perm(perm: Ext4InodeMode) -> VfsNodePerm {
vfs_perm |= VfsNodePerm::OTHER_EXEC;
}
vfs_perm
}
}
6 changes: 3 additions & 3 deletions modules/ruxfs/src/fs/ext4_rs.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! Reference:
//! Reference:
//! - ext4_rs: https://github.com/yuoo655/ext4_rs
//! - axfs: https://github.com/Starry-OS/axfs

use crate::dev::Disk;
use alloc::sync::Arc;
use alloc::vec;
use alloc::vec::*;
use axfs_vfs::{VfsDirEntry, VfsError, VfsNodePerm, VfsResult, RelPath};
use axfs_vfs::{RelPath, VfsDirEntry, VfsError, VfsNodePerm, VfsResult};
use axfs_vfs::{VfsNodeAttr, VfsNodeOps, VfsNodeRef, VfsNodeType, VfsOps};
use axsync::Mutex;
use core::cell::RefCell;
Expand Down Expand Up @@ -411,4 +411,4 @@ fn map_imode(imode: u16) -> (VfsNodeType, VfsNodePerm) {
}

(ty, vfs_perm)
}
}
2 changes: 1 addition & 1 deletion modules/ruxfs/src/fs/fatfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl VfsNodeOps for DirWrapper<'static> {
fn unlink(&self, path: &RelPath) -> VfsResult {
debug!("remove at fatfs: {}", path);
if path.is_empty() {
return ax_err!(PermissionDenied)
return ax_err!(PermissionDenied);
}
self.0.remove(path).map_err(as_vfs_err)
}
Expand Down
Loading