Commit a352d7c7 authored by Jeremy Soller's avatar Jeremy Soller

Merge branch 'add-getuuid' into 'master'

redoxfs: Add '--get-uuid' support

See merge request !44
parents b4df131a 37aab3e5
Pipeline #3286 failed with stages
in 39 seconds
......@@ -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