diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-02-28 06:15:48 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-02-28 06:15:48 -0500 |
commit | 8a7e3344fe089b3e2c6c45f00ade217e3d55a958 (patch) | |
tree | 801bec15e86816d8c87da17f0ce4f5e21299c0f6 /rust-src/src | |
parent | daebbc085d74dc7666dd704f48fa4ed5c0005f75 (diff) |
rust: Filesystem options now supported
This implements opt_set!(), which works exactly the same as the C
version and allows filesystem options to be specified in Rust code.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'rust-src/src')
-rw-r--r-- | rust-src/src/cmd_list.rs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/rust-src/src/cmd_list.rs b/rust-src/src/cmd_list.rs index 15f3f71f..c89ba4f0 100644 --- a/rust-src/src/cmd_list.rs +++ b/rust-src/src/cmd_list.rs @@ -1,6 +1,7 @@ use atty::Stream; use bch_bindgen::error; use bch_bindgen::bcachefs; +use bch_bindgen::opt_set; use bch_bindgen::fs::Fs; use bch_bindgen::btree::BtreeTrans; use bch_bindgen::btree::BtreeIter; @@ -22,7 +23,6 @@ fn list_keys(fs: &Fs, opt: Cli) -> anyhow::Result<()> { } println!("{}", k.to_text(fs)); - iter.advance(); } @@ -92,15 +92,29 @@ struct Cli { colorize: bool, /// Verbose mode - #[arg(short, long, action = clap::ArgAction::Count)] - verbose: u8, + #[arg(short, long)] + verbose: bool, #[arg(required(true))] devices: Vec<std::path::PathBuf>, } fn cmd_list_inner(opt: Cli) -> anyhow::Result<()> { - let fs_opts: bcachefs::bch_opts = Default::default(); + let mut fs_opts: bcachefs::bch_opts = Default::default(); + + opt_set!(fs_opts, nochanges, 1); + opt_set!(fs_opts, norecovery, 1); + opt_set!(fs_opts, degraded, 1); + opt_set!(fs_opts, errors, bcachefs::bch_error_actions::BCH_ON_ERROR_continue as u8); + + if opt.fsck { + opt_set!(fs_opts, fix_errors, bcachefs::fsck_err_opts::FSCK_OPT_YES as u8); + opt_set!(fs_opts, norecovery, 0); + } + + if opt.verbose { + opt_set!(fs_opts, verbose, 1); + } let fs = Fs::open(&opt.devices, fs_opts)?; |