Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ext4 #55

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/axfeat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fs = ["alloc", "paging", "axdriver/virtio-blk", "dep:axfs", "axruntime/fs"] # TO
fatfs = ["axfs/fatfs"]
ext4fs = ["axfs/ext4fs"]
myfs = ["axfs?/myfs"]
ext4_rs = ["axfs/ext4_rs"]

# Networking
net = ["alloc", "paging", "axdriver/virtio-net", "dep:axnet", "axruntime/net"]
Expand Down
2 changes: 2 additions & 0 deletions modules/axfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ myfs = ["dep:crate_interface"]
use-ramdisk = []
monolithic = []
fatfs = ["dep:fatfs"]
ext4_rs = ["dep:ext4_rs", "devfs", "ramfs", "procfs", "sysfs"]
ext4fs = ["dep:lwext4_rust", "devfs", "ramfs", "procfs", "sysfs",]
default = ["devfs", "ramfs", "fatfs", "procfs", "sysfs"]

Expand All @@ -33,6 +34,7 @@ axconfig = { path = "../axconfig", optional = true }
axfs_vfs = { path = "../../crates/axfs_vfs" }
axfs_devfs = { path = "../../crates/axfs_devfs", optional = true }
axfs_ramfs = { path = "../../crates/axfs_ramfs", optional = true }
ext4_rs = { path = "https://github.com/yuoo655/ext4_rs.git", optional = true }
lwext4_rust = { git = "https://github.com/elliott10/lwext4_rust.git", rev = "f3048f87", optional = true }
axdriver = { path = "../axdriver", features = ["block"] }
axsync = { path = "../axsync" }
Expand Down
17 changes: 17 additions & 0 deletions modules/axfs/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,21 @@ impl Disk {
};
Ok(write_size)
}

/// Read a single block starting from the specified offset.
pub fn read_offset(&mut self, offset: usize) -> [u8; BLOCK_SIZE] {
let block_id = offset / BLOCK_SIZE;
let mut block_data = [0u8; BLOCK_SIZE];
self.dev.read_block(block_id as u64, &mut block_data).unwrap();
block_data
}

/// Write single block starting from the specified offset.
pub fn write_offset(&mut self, offset: usize, buf: &[u8]) -> DevResult<usize> {
assert!(buf.len() == BLOCK_SIZE, "Buffer length must be equal to BLOCK_SIZE");
assert!(offset % BLOCK_SIZE == 0);
let block_id = offset / BLOCK_SIZE;
self.dev.write_block(block_id as u64, buf).unwrap();
Ok(buf.len())
}
}
Loading
Loading