From 1eac97eea4ec0bcef0be061a2cba93a584355283 Mon Sep 17 00:00:00 2001 From: Chuyan Zhang Date: Thu, 30 Nov 2023 02:15:06 -0800 Subject: Add real disk i/o, add mkfs.aya (not yet implemented) --- mkfs.aya/Cargo.toml | 8 ++++++++ mkfs.aya/src/block_device.rs | 5 +++++ mkfs.aya/src/main.rs | 21 +++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 mkfs.aya/Cargo.toml create mode 100644 mkfs.aya/src/block_device.rs create mode 100644 mkfs.aya/src/main.rs (limited to 'mkfs.aya') diff --git a/mkfs.aya/Cargo.toml b/mkfs.aya/Cargo.toml new file mode 100644 index 0000000..c75e3cb --- /dev/null +++ b/mkfs.aya/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "mkayafs" +version = "0.1.0" +edition = "2021" + +[dependencies] +users = "0.11.0" +clap = { version = "4.4.10", features = ["derive"] } \ No newline at end of file diff --git a/mkfs.aya/src/block_device.rs b/mkfs.aya/src/block_device.rs new file mode 100644 index 0000000..295b357 --- /dev/null +++ b/mkfs.aya/src/block_device.rs @@ -0,0 +1,5 @@ +pub(crate) const BLOCK_SIZE: usize = 4096; +pub(crate) trait BlockDevice { + fn read(&self, block_id: usize, buffer: &mut [u8]); + fn write(&self, block_id: usize, buffer: &[u8]); +} \ No newline at end of file diff --git a/mkfs.aya/src/main.rs b/mkfs.aya/src/main.rs new file mode 100644 index 0000000..57ca3fc --- /dev/null +++ b/mkfs.aya/src/main.rs @@ -0,0 +1,21 @@ +mod block_device; + +use std::fs::File; +use std::path::PathBuf; +use clap::Parser; +use users::{get_current_gid, get_current_uid}; + +#[derive(Parser, Debug)] +#[command(author, version, about)] +struct Args { + block_device: Option, + start_point: Option, + length: Option, +} + +fn main() { + let args = Args::parse(); + let device_path = args.block_device.unwrap(); + println!("{:?}", device_path.as_path()); + let mut device = File::open(device_path.as_path()).unwrap(); +} \ No newline at end of file -- cgit v1.2.3-70-g09d2