summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-01-20 20:29:48 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-01-20 22:32:00 -0500
commit5e224596cfdf9ad9413536482224e2fe79b9e387 (patch)
treed2a2b3f4066cf8e656f4fc56890b07de97829721
parentb5fd066153c40a70a29caa1ea7987723ab687763 (diff)
Remove gag usage
Possibly-fixes: https://github.com/koverstreet/bcachefs-tools/issues/217 Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--Cargo.lock108
-rw-r--r--Cargo.toml1
-rw-r--r--bch_bindgen/Cargo.lock12
-rw-r--r--bch_bindgen/src/lib.rs2
-rw-r--r--bch_bindgen/src/sb_io.rs (renamed from bch_bindgen/src/rs.rs)20
-rw-r--r--src/commands/cmd_mount.rs5
6 files changed, 44 insertions, 104 deletions
diff --git a/Cargo.lock b/Cargo.lock
index cf561fb7..c1a98e38 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -96,7 +96,6 @@ dependencies = [
"colored",
"either",
"errno 0.2.8",
- "gag",
"libc",
"log",
"rpassword",
@@ -152,9 +151,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
-version = "2.4.1"
+version = "2.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
+checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf"
[[package]]
name = "byteorder"
@@ -181,12 +180,6 @@ dependencies = [
]
[[package]]
-name = "cfg-if"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
-
-[[package]]
name = "clang-sys"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -302,33 +295,6 @@ dependencies = [
]
[[package]]
-name = "fastrand"
-version = "2.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
-
-[[package]]
-name = "filedescriptor"
-version = "0.8.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7199d965852c3bac31f779ef99cbb4537f80e952e2d6aa0ffeb30cce00f4f46e"
-dependencies = [
- "libc",
- "thiserror",
- "winapi",
-]
-
-[[package]]
-name = "gag"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a713bee13966e9fbffdf7193af71d54a6b35a0bb34997cd6c9519ebeb5005972"
-dependencies = [
- "filedescriptor",
- "tempfile",
-]
-
-[[package]]
name = "glob"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -351,9 +317,9 @@ dependencies = [
[[package]]
name = "hermit-abi"
-version = "0.3.3"
+version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
+checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f"
[[package]]
name = "io-lifetimes"
@@ -361,7 +327,7 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
dependencies = [
- "hermit-abi 0.3.3",
+ "hermit-abi 0.3.4",
"libc",
"windows-sys 0.48.0",
]
@@ -372,7 +338,7 @@ version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455"
dependencies = [
- "hermit-abi 0.3.3",
+ "hermit-abi 0.3.4",
"rustix 0.38.30",
"windows-sys 0.52.0",
]
@@ -413,9 +379,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
[[package]]
name = "linux-raw-sys"
-version = "0.4.12"
+version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"
+checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
[[package]]
name = "log"
@@ -474,15 +440,15 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "pkg-config"
-version = "0.3.28"
+version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a"
+checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb"
[[package]]
name = "proc-macro2"
-version = "1.0.76"
+version = "1.0.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c"
+checksum = "9f9b1511a24c627ab3e92b48be4b32f8d0ea91ee351edd87fbf650aadd336340"
dependencies = [
"unicode-ident",
]
@@ -497,15 +463,6 @@ dependencies = [
]
[[package]]
-name = "redox_syscall"
-version = "0.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
-dependencies = [
- "bitflags 1.3.2",
-]
-
-[[package]]
name = "regex"
version = "1.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -581,10 +538,10 @@ version = "0.38.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca"
dependencies = [
- "bitflags 2.4.1",
+ "bitflags 2.4.2",
"errno 0.3.8",
"libc",
- "linux-raw-sys 0.4.12",
+ "linux-raw-sys 0.4.13",
"windows-sys 0.52.0",
]
@@ -623,19 +580,6 @@ dependencies = [
]
[[package]]
-name = "tempfile"
-version = "3.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa"
-dependencies = [
- "cfg-if",
- "fastrand",
- "redox_syscall",
- "rustix 0.38.30",
- "windows-sys 0.52.0",
-]
-
-[[package]]
name = "terminal_size"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -646,26 +590,6 @@ dependencies = [
]
[[package]]
-name = "thiserror"
-version = "1.0.56"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad"
-dependencies = [
- "thiserror-impl",
-]
-
-[[package]]
-name = "thiserror-impl"
-version = "1.0.56"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.48",
-]
-
-[[package]]
name = "udev"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -690,9 +614,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "uuid"
-version = "1.6.1"
+version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560"
+checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a"
[[package]]
name = "winapi"
diff --git a/Cargo.toml b/Cargo.toml
index e5478e6d..49c32e50 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,7 +19,6 @@ anyhow = "1.0"
libc = "0.2.69"
udev = "0.7.0"
uuid = "1.2.2"
-gag = "1.0.0"
errno = "0.2"
either = "1.5"
rpassword = "7"
diff --git a/bch_bindgen/Cargo.lock b/bch_bindgen/Cargo.lock
index 521c77c2..57348433 100644
--- a/bch_bindgen/Cargo.lock
+++ b/bch_bindgen/Cargo.lock
@@ -163,15 +163,15 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "pkg-config"
-version = "0.3.28"
+version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a"
+checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb"
[[package]]
name = "proc-macro2"
-version = "1.0.76"
+version = "1.0.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c"
+checksum = "9f9b1511a24c627ab3e92b48be4b32f8d0ea91ee351edd87fbf650aadd336340"
dependencies = [
"unicode-ident",
]
@@ -245,6 +245,6 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "uuid"
-version = "1.6.1"
+version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560"
+checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a"
diff --git a/bch_bindgen/src/lib.rs b/bch_bindgen/src/lib.rs
index 4c549442..deb69a51 100644
--- a/bch_bindgen/src/lib.rs
+++ b/bch_bindgen/src/lib.rs
@@ -3,7 +3,7 @@ pub mod btree;
pub mod bkey;
pub mod errcode;
pub mod keyutils;
-pub mod rs;
+pub mod sb_io;
pub mod fs;
pub mod opts;
pub use paste::paste;
diff --git a/bch_bindgen/src/rs.rs b/bch_bindgen/src/sb_io.rs
index 24594ae1..172584d7 100644
--- a/bch_bindgen/src/rs.rs
+++ b/bch_bindgen/src/sb_io.rs
@@ -27,3 +27,23 @@ pub fn read_super(path: &std::path::Path) -> anyhow::Result<bch_sb_handle> {
let opts = bcachefs::bch_opts::default();
read_super_opts(path, opts)
}
+
+pub fn read_super_silent(
+ path: &std::path::Path,
+ mut opts: bch_opts,
+) -> anyhow::Result<bch_sb_handle> {
+ use std::os::unix::ffi::OsStrExt;
+ let path = std::ffi::CString::new(path.as_os_str().as_bytes()).unwrap();
+
+ let mut sb = std::mem::MaybeUninit::zeroed();
+
+ let ret =
+ unsafe { crate::bcachefs::bch2_read_super_silent(path.as_ptr(), &mut opts, sb.as_mut_ptr()) };
+
+ if ret != 0 {
+ let err: bch_errcode = unsafe { ::std::mem::transmute(ret) };
+ Err(anyhow!(err))
+ } else {
+ Ok(unsafe { sb.assume_init() })
+ }
+}
diff --git a/src/commands/cmd_mount.rs b/src/commands/cmd_mount.rs
index b120c91e..c644767e 100644
--- a/src/commands/cmd_mount.rs
+++ b/src/commands/cmd_mount.rs
@@ -101,13 +101,10 @@ fn mount(
}
fn read_super_silent(path: &std::path::PathBuf) -> anyhow::Result<bch_sb_handle> {
- // Stop libbcachefs from spamming the output
- let _gag = gag::BufferRedirect::stdout().unwrap();
-
let mut opts = bcachefs::bch_opts::default();
opt_set!(opts, noexcl, 1);
- bch_bindgen::rs::read_super_opts(&path, opts)
+ bch_bindgen::sb_io::read_super_silent(&path, opts)
}
fn get_devices_by_uuid(uuid: Uuid) -> anyhow::Result<Vec<(PathBuf, bch_sb_handle)>> {