summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChuyan Zhang <me@zcy.moe>2023-12-01 21:18:52 -0800
committerChuyan Zhang <me@zcy.moe>2023-12-01 21:18:52 -0800
commit4e8448778cdec05f994f0e2772432fd90b6219d5 (patch)
treec02e3f9dd7ef0993178e785f2ce85844bbf1b2bf
parent4c34414b26bf71e747ea3ecb2586645bab4aba52 (diff)
downloadmyfs-4e8448778cdec05f994f0e2772432fd90b6219d5.tar.gz
myfs-4e8448778cdec05f994f0e2772432fd90b6219d5.zip
Fix mount options
-rw-r--r--ayafs-core/src/bin/main.rs16
-rw-r--r--ayafs-core/src/bin/mem_run.rs15
-rw-r--r--mkfs.aya/src/main.rs11
3 files changed, 28 insertions, 14 deletions
diff --git a/ayafs-core/src/bin/main.rs b/ayafs-core/src/bin/main.rs
index a2d838c..e61f6c6 100644
--- a/ayafs-core/src/bin/main.rs
+++ b/ayafs-core/src/bin/main.rs
@@ -16,7 +16,7 @@ struct Args {
#[arg(long)]
auto_unmount: bool,
#[arg(long)]
- allow_root: bool,
+ allow_other: bool,
}
fn main() {
@@ -32,12 +32,16 @@ fn main() {
_ => LevelFilter::Trace,
};
env_logger::builder().filter_level(log_level).init();
- let options = vec![
- // MountOption::RO,
- MountOption::FSName("hello".to_string()),
- MountOption::AutoUnmount,
- MountOption::AllowRoot,
+ let mut options = vec![
+ MountOption::FSName("Aya".to_string()),
];
+ if args.auto_unmount {
+ options.push(MountOption::AutoUnmount);
+ }
+ if args.allow_other {
+ options.push(MountOption::AllowOther);
+ }
+
let disk = Arc::new(Disk::new(PathBuf::from(device_path)));
let filesystem = AyaFS::load(disk);
diff --git a/ayafs-core/src/bin/mem_run.rs b/ayafs-core/src/bin/mem_run.rs
index 7ba6f4e..0ba4c9c 100644
--- a/ayafs-core/src/bin/mem_run.rs
+++ b/ayafs-core/src/bin/mem_run.rs
@@ -15,7 +15,7 @@ struct Args {
#[arg(long)]
auto_unmount: bool,
#[arg(long)]
- allow_root: bool,
+ allow_other: bool,
}
fn main() {
@@ -30,12 +30,15 @@ fn main() {
_ => LevelFilter::Trace,
};
env_logger::builder().filter_level(log_level).init();
- let options = vec![
- // MountOption::RO,
- MountOption::FSName("hello".to_string()),
- MountOption::AutoUnmount,
- MountOption::AllowRoot,
+ let mut options = vec![
+ MountOption::FSName("Aya".to_string()),
];
+ if args.auto_unmount {
+ options.push(MountOption::AutoUnmount);
+ }
+ if args.allow_other {
+ options.push(MountOption::AllowOther);
+ }
let disk = Arc::new(MemoryDisk::new(16384));
let filesystem = AyaFS::new(disk, 16384, get_current_uid(), get_current_gid());
diff --git a/mkfs.aya/src/main.rs b/mkfs.aya/src/main.rs
index 00bef5b..939f9d1 100644
--- a/mkfs.aya/src/main.rs
+++ b/mkfs.aya/src/main.rs
@@ -16,6 +16,10 @@ use crate::ioctl::ioctl_blkgetsize64;
#[command(author, version, about)]
struct Args {
block_device: Option<PathBuf>,
+ #[arg(short, long)]
+ user_id: Option<u32>,
+ #[arg(short, long)]
+ group_id: Option<u32>,
#[arg(short, action = clap::ArgAction::Count)]
verbosity: u8,
}
@@ -40,6 +44,9 @@ fn main() {
let device_path = args.block_device
.expect("Not device path specified.");
let verbosity = args.verbosity;
+ let uid = args.user_id.unwrap_or_else(get_current_uid);
+ let gid = args.group_id.unwrap_or_else(get_current_gid);
+
let log_level = match verbosity {
0 => LevelFilter::Error,
1 => LevelFilter::Warn,
@@ -53,8 +60,8 @@ fn main() {
let mut fs = AyaFS::new(
disk,
device_size as usize / BLOCK_SIZE,
- get_current_uid(),
- get_current_gid(),
+ uid,
+ gid,
);
fs.write_back();
}