mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
refactor: treat harmless clippy::pedantic
lints
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
This commit is contained in:
parent
96843fc95d
commit
20f7954cdb
@ -63,7 +63,7 @@ fn handle_c_command(mut argv: Vec<String>, symlink_cmd: Option<&str>) -> i32 {
|
|||||||
"fusemount" => c::cmd_fusemount(argc, argv),
|
"fusemount" => c::cmd_fusemount(argc, argv),
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
println!("Unknown command {}", cmd);
|
println!("Unknown command {cmd}");
|
||||||
c::bcachefs_usage();
|
c::bcachefs_usage();
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ use clap::Parser;
|
|||||||
use log::error;
|
use log::error;
|
||||||
use std::io::{stdout, IsTerminal};
|
use std::io::{stdout, IsTerminal};
|
||||||
|
|
||||||
fn list_keys(fs: &Fs, opt: Cli) -> anyhow::Result<()> {
|
fn list_keys(fs: &Fs, opt: &Cli) -> anyhow::Result<()> {
|
||||||
let trans = BtreeTrans::new(fs);
|
let trans = BtreeTrans::new(fs);
|
||||||
let mut iter = BtreeIter::new(
|
let mut iter = BtreeIter::new(
|
||||||
&trans,
|
&trans,
|
||||||
@ -38,7 +38,7 @@ fn list_keys(fs: &Fs, opt: Cli) -> anyhow::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_btree_formats(fs: &Fs, opt: Cli) -> anyhow::Result<()> {
|
fn list_btree_formats(fs: &Fs, opt: &Cli) -> anyhow::Result<()> {
|
||||||
let trans = BtreeTrans::new(fs);
|
let trans = BtreeTrans::new(fs);
|
||||||
let mut iter = BtreeNodeIter::new(
|
let mut iter = BtreeNodeIter::new(
|
||||||
&trans,
|
&trans,
|
||||||
@ -61,7 +61,7 @@ fn list_btree_formats(fs: &Fs, opt: Cli) -> anyhow::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_btree_nodes(fs: &Fs, opt: Cli) -> anyhow::Result<()> {
|
fn list_btree_nodes(fs: &Fs, opt: &Cli) -> anyhow::Result<()> {
|
||||||
let trans = BtreeTrans::new(fs);
|
let trans = BtreeTrans::new(fs);
|
||||||
let mut iter = BtreeNodeIter::new(
|
let mut iter = BtreeNodeIter::new(
|
||||||
&trans,
|
&trans,
|
||||||
@ -84,7 +84,7 @@ fn list_btree_nodes(fs: &Fs, opt: Cli) -> anyhow::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_nodes_ondisk(fs: &Fs, opt: Cli) -> anyhow::Result<()> {
|
fn list_nodes_ondisk(fs: &Fs, opt: &Cli) -> anyhow::Result<()> {
|
||||||
let trans = BtreeTrans::new(fs);
|
let trans = BtreeTrans::new(fs);
|
||||||
let mut iter = BtreeNodeIter::new(
|
let mut iter = BtreeNodeIter::new(
|
||||||
&trans,
|
&trans,
|
||||||
@ -157,8 +157,8 @@ pub struct Cli {
|
|||||||
devices: Vec<std::path::PathBuf>,
|
devices: Vec<std::path::PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cmd_list_inner(opt: Cli) -> anyhow::Result<()> {
|
fn cmd_list_inner(opt: &Cli) -> anyhow::Result<()> {
|
||||||
let mut fs_opts: bcachefs::bch_opts = Default::default();
|
let mut fs_opts = bcachefs::bch_opts::default();
|
||||||
|
|
||||||
opt_set!(fs_opts, nochanges, 1);
|
opt_set!(fs_opts, nochanges, 1);
|
||||||
opt_set!(fs_opts, read_only, 1);
|
opt_set!(fs_opts, read_only, 1);
|
||||||
@ -197,7 +197,7 @@ fn cmd_list_inner(opt: Cli) -> anyhow::Result<()> {
|
|||||||
pub fn list(argv: Vec<String>) -> i32 {
|
pub fn list(argv: Vec<String>) -> i32 {
|
||||||
let opt = Cli::parse_from(argv);
|
let opt = Cli::parse_from(argv);
|
||||||
colored::control::set_override(opt.colorize);
|
colored::control::set_override(opt.colorize);
|
||||||
if let Err(e) = cmd_list_inner(opt) {
|
if let Err(e) = cmd_list_inner(&opt) {
|
||||||
error!("Fatal error: {}", e);
|
error!("Fatal error: {}", e);
|
||||||
1
|
1
|
||||||
} else {
|
} else {
|
||||||
|
@ -49,7 +49,8 @@ fn mount_inner(
|
|||||||
/// Parse a comma-separated mount options and split out mountflags and filesystem
|
/// Parse a comma-separated mount options and split out mountflags and filesystem
|
||||||
/// specific options.
|
/// specific options.
|
||||||
fn parse_mount_options(options: impl AsRef<str>) -> (Option<String>, libc::c_ulong) {
|
fn parse_mount_options(options: impl AsRef<str>) -> (Option<String>, libc::c_ulong) {
|
||||||
use either::Either::*;
|
use either::Either::{Left, Right};
|
||||||
|
|
||||||
debug!("parsing mount options: {}", options.as_ref());
|
debug!("parsing mount options: {}", options.as_ref());
|
||||||
let (opts, flags) = options
|
let (opts, flags) = options
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -66,10 +67,9 @@ fn parse_mount_options(options: impl AsRef<str>) -> (Option<String>, libc::c_ulo
|
|||||||
"relatime" => Left(libc::MS_RELATIME),
|
"relatime" => Left(libc::MS_RELATIME),
|
||||||
"remount" => Left(libc::MS_REMOUNT),
|
"remount" => Left(libc::MS_REMOUNT),
|
||||||
"ro" => Left(libc::MS_RDONLY),
|
"ro" => Left(libc::MS_RDONLY),
|
||||||
"rw" => Left(0),
|
"rw" | "" => Left(0),
|
||||||
"strictatime" => Left(libc::MS_STRICTATIME),
|
"strictatime" => Left(libc::MS_STRICTATIME),
|
||||||
"sync" => Left(libc::MS_SYNCHRONOUS),
|
"sync" => Left(libc::MS_SYNCHRONOUS),
|
||||||
"" => Left(0),
|
|
||||||
o => Right(o),
|
o => Right(o),
|
||||||
})
|
})
|
||||||
.fold((Vec::new(), 0), |(mut opts, flags), next| match next {
|
.fold((Vec::new(), 0), |(mut opts, flags), next| match next {
|
||||||
@ -127,7 +127,7 @@ fn udev_bcachefs_info() -> anyhow::Result<HashMap<String, Vec<String>>> {
|
|||||||
|
|
||||||
for m in udev
|
for m in udev
|
||||||
.scan_devices()?
|
.scan_devices()?
|
||||||
.filter(|dev| dev.is_initialized())
|
.filter(udev::Device::is_initialized)
|
||||||
.map(|dev| device_property_map(&dev))
|
.map(|dev| device_property_map(&dev))
|
||||||
.filter(|m| m.contains_key("ID_FS_UUID") && m.contains_key("DEVNAME"))
|
.filter(|m| m.contains_key("ID_FS_UUID") && m.contains_key("DEVNAME"))
|
||||||
{
|
{
|
||||||
@ -140,11 +140,8 @@ fn udev_bcachefs_info() -> anyhow::Result<HashMap<String, Vec<String>>> {
|
|||||||
Ok(info)
|
Ok(info)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_super_blocks(
|
fn get_super_blocks(uuid: Uuid, devices: &[String]) -> Vec<(PathBuf, bch_sb_handle)> {
|
||||||
uuid: Uuid,
|
devices
|
||||||
devices: &[String],
|
|
||||||
) -> anyhow::Result<Vec<(PathBuf, bch_sb_handle)>> {
|
|
||||||
Ok(devices
|
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|dev| {
|
.filter_map(|dev| {
|
||||||
read_super_silent(PathBuf::from(dev))
|
read_super_silent(PathBuf::from(dev))
|
||||||
@ -152,7 +149,7 @@ fn get_super_blocks(
|
|||||||
.map(|sb| (PathBuf::from(dev), sb))
|
.map(|sb| (PathBuf::from(dev), sb))
|
||||||
})
|
})
|
||||||
.filter(|(_, sb)| sb.sb().uuid() == uuid)
|
.filter(|(_, sb)| sb.sb().uuid() == uuid)
|
||||||
.collect::<Vec<_>>())
|
.collect::<Vec<_>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_all_block_devnodes() -> anyhow::Result<Vec<String>> {
|
fn get_all_block_devnodes() -> anyhow::Result<Vec<String>> {
|
||||||
@ -189,7 +186,7 @@ fn get_devices_by_uuid(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
get_super_blocks(uuid, &devices)
|
Ok(get_super_blocks(uuid, &devices))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
|
@ -37,9 +37,9 @@ enum Subcommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn subvolume(argv: Vec<String>) -> i32 {
|
pub fn subvolume(argv: Vec<String>) -> i32 {
|
||||||
let args = Cli::parse_from(argv);
|
let cli = Cli::parse_from(argv);
|
||||||
|
|
||||||
match args.subcommands {
|
match cli.subcommands {
|
||||||
Subcommands::Create { targets } => {
|
Subcommands::Create { targets } => {
|
||||||
for target in targets {
|
for target in targets {
|
||||||
if let Some(dirname) = target.parent() {
|
if let Some(dirname) = target.parent() {
|
||||||
|
Loading…
Reference in New Issue
Block a user