diff options
Diffstat (limited to 'src/commands/subvolume.rs')
-rw-r--r-- | src/commands/subvolume.rs | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/src/commands/subvolume.rs b/src/commands/subvolume.rs index 5f7cdc76..0691e34d 100644 --- a/src/commands/subvolume.rs +++ b/src/commands/subvolume.rs @@ -17,13 +17,13 @@ enum Subcommands { #[command(visible_aliases = ["new"])] Create { /// Paths - targets: Vec<PathBuf> + targets: Vec<PathBuf>, }, #[command(visible_aliases = ["del"])] Delete { /// Path - target: PathBuf + target: PathBuf, }, #[command(allow_missing_positional = true, visible_aliases = ["snap"])] @@ -31,9 +31,9 @@ enum Subcommands { /// Make snapshot read only #[arg(long, short)] read_only: bool, - source: Option<PathBuf>, - dest: PathBuf - } + source: Option<PathBuf>, + dest: PathBuf, + }, } pub fn subvolume(argv: Vec<String>) -> i32 { @@ -44,24 +44,42 @@ pub fn subvolume(argv: Vec<String>) -> i32 { for target in targets { if let Some(dirname) = target.parent() { let fs = unsafe { BcachefsHandle::open(dirname) }; - fs.create_subvolume(target).expect("Failed to create the subvolume"); + fs.create_subvolume(target) + .expect("Failed to create the subvolume"); } } } - , Subcommands::Delete { target } => { if let Some(dirname) = target.parent() { let fs = unsafe { BcachefsHandle::open(dirname) }; - fs.delete_subvolume(target).expect("Failed to delete the subvolume"); + fs.delete_subvolume(target) + .expect("Failed to delete the subvolume"); } - }, - Subcommands::Snapshot { read_only, source, dest } => { + } + Subcommands::Snapshot { + read_only, + source, + dest, + } => { if let Some(dirname) = dest.parent() { let dot = PathBuf::from("."); - let dir = if dirname.as_os_str().is_empty() { &dot } else { dirname }; + let dir = if dirname.as_os_str().is_empty() { + &dot + } else { + dirname + }; let fs = unsafe { BcachefsHandle::open(dir) }; - fs.snapshot_subvolume(if read_only { BCH_SUBVOL_SNAPSHOT_RO } else { 0x0 }, source, dest).expect("Failed to snapshot the subvolume"); + fs.snapshot_subvolume( + if read_only { + BCH_SUBVOL_SNAPSHOT_RO + } else { + 0x0 + }, + source, + dest, + ) + .expect("Failed to snapshot the subvolume"); } } } |