Merge pull request #315 from tmuehlbacher/variety-changes

Variety changes
This commit is contained in:
koverstreet 2024-07-20 19:37:06 -04:00 committed by GitHub
commit 201b1e8216
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 62 additions and 64 deletions

2
.gitignore vendored
View File

@ -10,8 +10,6 @@ TAGS
cscope*
bcachefs-tools
compile_commands.json
tests/test_helper
tests/__pycache__/
# dot-files that we don't want to ignore
!.gitignore

46
Cargo.lock generated
View File

@ -73,7 +73,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bcachefs-tools"
version = "1.9.5"
version = "0.0.0"
dependencies = [
"anyhow",
"bch_bindgen",
@ -85,6 +85,7 @@ dependencies = [
"errno 0.2.8",
"libc",
"log",
"owo-colors",
"rustix",
"strum",
"strum_macros",
@ -258,9 +259,7 @@ version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
dependencies = [
"is-terminal",
"log",
"termcolor",
]
[[package]]
@ -306,12 +305,6 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]]
name = "home"
version = "0.5.9"
@ -321,17 +314,6 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "is-terminal"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b"
dependencies = [
"hermit-abi",
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "itertools"
version = "0.12.1"
@ -428,6 +410,12 @@ version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "owo-colors"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f"
[[package]]
name = "paste"
version = "1.0.14"
@ -567,15 +555,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "termcolor"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
dependencies = [
"winapi-util",
]
[[package]]
name = "terminal_size"
version = "0.3.0"
@ -643,15 +622,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"

View File

@ -1,6 +1,5 @@
[package]
name = "bcachefs-tools"
version = "1.9.5"
authors = ["Yuxuan Shui <yshuiv7@gmail.com>", "Kayla Firestack <dev@kaylafire.me>", "Kent Overstreet <kent.overstreet@linux.dev>" ]
edition = "2021"
rust-version = "1.70"
@ -25,11 +24,11 @@ strum = { version = "0.26", features = ["derive"] }
strum_macros = "0.26"
zeroize = { version = "1", features = ["std", "zeroize_derive"] }
rustix = { version = "0.38.34", features = ["termios"] }
owo-colors = "4"
[dependencies.env_logger]
version = "0.10"
default-features = false
features = ["auto-color"]
[profile.release]
strip = "none"

View File

@ -48,7 +48,10 @@ fn mount_inner(
let err = errno::errno().0;
if ret == 0 || (err != libc::EACCES && err != libc::EROFS) || (mountflags & libc::MS_RDONLY) != 0 {
if ret == 0
|| (err != libc::EACCES && err != libc::EROFS)
|| (mountflags & libc::MS_RDONLY) != 0
{
break;
}
@ -333,35 +336,38 @@ fn cmd_mount_inner(cli: &Cli) -> Result<()> {
// Grab the udev information once
let udev_info = udev_bcachefs_info()?;
let (devices, mut sbs) = if let Some(("UUID" | "OLD_BLKID_UUID", uuid)) = cli.dev.split_once('=') {
devs_str_sbs_from_uuid(&udev_info, uuid)?
} else if cli.dev.contains(':') {
// If the device string contains ":" we will assume the user knows the
// entire list. If they supply a single device it could be either the FS
// only has 1 device or it's only 1 of a number of devices which are
// part of the FS. This appears to be the case when we get called during
// fstab mount processing and the fstab specifies a UUID.
let (devices, mut sbs) =
if let Some(("UUID" | "OLD_BLKID_UUID", uuid)) = cli.dev.split_once('=') {
devs_str_sbs_from_uuid(&udev_info, uuid)?
} else if cli.dev.contains(':') {
// If the device string contains ":" we will assume the user knows the
// entire list. If they supply a single device it could be either the FS
// only has 1 device or it's only 1 of a number of devices which are
// part of the FS. This appears to be the case when we get called during
// fstab mount processing and the fstab specifies a UUID.
let sbs = cli
.dev
.split(':')
.map(read_super_silent)
.collect::<Result<Vec<_>>>()?;
let sbs = cli
.dev
.split(':')
.map(read_super_silent)
.collect::<Result<Vec<_>>>()?;
(cli.dev.clone(), sbs)
} else {
devs_str_sbs_from_device(&udev_info, Path::new(&cli.dev))?
};
(cli.dev.clone(), sbs)
} else {
devs_str_sbs_from_device(&udev_info, Path::new(&cli.dev))?
};
ensure!(!sbs.is_empty(), "No device(s) to mount specified");
let first_sb = &sbs[0];
if unsafe { bcachefs::bch2_sb_is_encrypted(first_sb.sb) } {
handle_unlock(cli, &first_sb)?;
handle_unlock(cli, first_sb)?;
}
for sb in &mut sbs {
unsafe { bch_bindgen::sb_io::bch2_free_super(sb); }
unsafe {
bch_bindgen::sb_io::bch2_free_super(sb);
}
}
drop(sbs);

View File

@ -1,9 +1,12 @@
use std::io::Write;
use env_logger::WriteStyle;
use log::LevelFilter;
use log::{Level, LevelFilter};
use owo_colors::{OwoColorize, Style};
pub fn setup(verbose: u8, color: bool) {
let level_filter = match verbose {
0 => LevelFilter::Off,
0 => LevelFilter::Warn,
1 => LevelFilter::Info,
2 => LevelFilter::Debug,
_ => LevelFilter::Trace,
@ -19,5 +22,27 @@ pub fn setup(verbose: u8, color: bool) {
.filter_level(level_filter)
.write_style(style)
.parse_env("BCACHEFS_LOG")
.format(move |buf, record| {
let style = if style == WriteStyle::Never {
Style::new()
} else {
match record.level() {
Level::Trace => Style::new().cyan(),
Level::Debug => Style::new().blue(),
Level::Info => Style::new().green(),
Level::Warn => Style::new().yellow(),
Level::Error => Style::new().red().bold(),
}
};
writeln!(
buf,
"[{:<5} {}:{}] {}",
record.level().style(style),
record.file().unwrap(),
record.line().unwrap(),
record.args()
)
})
.init();
}