Commit 37aab3e5 authored by Robin Randhawa's avatar Robin Randhawa

redoxfs: Add '--get-uuid' support

With this, `redoxfs --get-uuid <disk>` prints out the UUID of the
provided redoxfs disk image.

This is needed especially for aarch64 kernels where the UUID of the boot
disk needs to be passed to the kernel by the bootloader. With this
extension to the mount command, the kernel build glue can query the
prepared redoxfs image for it's UUID.
parent b4df131a
......@@ -187,6 +187,18 @@ fn daemon(disk_id: &DiskId, mountpoint: &str, mut write: File) -> ! {
process::exit(1);
}
fn print_uuid(path: &str) {
match DiskFile::open(&path).map(|image| DiskCache::new(image)) {
Ok(disk) => match redoxfs::FileSystem::open(disk) {
Ok(filesystem) => {
println!("{}", Uuid::from_bytes(&filesystem.header.1.uuid).unwrap().hyphenated());
},
Err(err) => println!("redoxfs: failed to open filesystem {}: {}", path, err)
},
Err(err) => println!("redoxfs: failed to open image {}: {}", path, err)
}
}
fn main() {
let mut args = env::args().skip(1);
......@@ -209,6 +221,18 @@ fn main() {
};
DiskId::Uuid(uuid)
} else if arg == "--get-uuid" {
match args.next() {
Some(arg) => {
print_uuid(&arg);
process::exit(1);
},
None => {
println!("redoxfs: no disk provided");
usage();
process::exit(1);
},
};
} else {
DiskId::Path(arg)
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment