From 37aab3e5665b69f7b6f0f18dfb0861f515fc804b Mon Sep 17 00:00:00 2001 From: Robin Randhawa Date: Wed, 16 Jan 2019 18:22:49 +0000 Subject: [PATCH] redoxfs: Add '--get-uuid' support With this, `redoxfs --get-uuid ` 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. --- src/bin/mount.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/bin/mount.rs b/src/bin/mount.rs index d91654110a..3474a9e0c9 100644 --- a/src/bin/mount.rs +++ b/src/bin/mount.rs @@ -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) },