mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-05-28 12:06:43 +00:00
file restore: clippy and format argument fixes
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
a57413a54c
commit
3165853468
@ -88,7 +88,7 @@ fn make_name(repo: &BackupRepository, ns: &BackupNamespace, snap: &BackupDir) ->
|
|||||||
} else {
|
} else {
|
||||||
format!("qemu_{repo}:{ns}/{snap}")
|
format!("qemu_{repo}:{ns}/{snap}")
|
||||||
};
|
};
|
||||||
proxmox_sys::systemd::escape_unit(&full, false)
|
proxmox_sys::systemd::escape_unit(full, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// remove non-responsive VMs from given map, returns 'true' if map was modified
|
/// remove non-responsive VMs from given map, returns 'true' if map was modified
|
||||||
|
@ -35,7 +35,7 @@ pub async fn append_file<W: AsyncWrite + Unpin, R: AsyncRead + Unpin>(
|
|||||||
print_cpio_hex(&mut target, entry.uid as u64).await?; // c_uid
|
print_cpio_hex(&mut target, entry.uid as u64).await?; // c_uid
|
||||||
print_cpio_hex(&mut target, entry.gid as u64).await?; // c_gid
|
print_cpio_hex(&mut target, entry.gid as u64).await?; // c_gid
|
||||||
print_cpio_hex(&mut target, 0).await?; // c_nlink
|
print_cpio_hex(&mut target, 0).await?; // c_nlink
|
||||||
print_cpio_hex(&mut target, entry.mtime as u64).await?; // c_mtime
|
print_cpio_hex(&mut target, entry.mtime).await?; // c_mtime
|
||||||
print_cpio_hex(&mut target, entry.size as u64).await?; // c_filesize
|
print_cpio_hex(&mut target, entry.size as u64).await?; // c_filesize
|
||||||
print_cpio_hex(&mut target, 0).await?; // c_devmajor
|
print_cpio_hex(&mut target, 0).await?; // c_devmajor
|
||||||
print_cpio_hex(&mut target, 0).await?; // c_devminor
|
print_cpio_hex(&mut target, 0).await?; // c_devminor
|
||||||
|
@ -381,13 +381,13 @@ impl DiskState {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let sys_path: &str = &format!("/sys/block/{}", name);
|
let sys_path: &str = &format!("/sys/block/{name}");
|
||||||
|
|
||||||
let serial = fs::file_read_string(&format!("{}/serial", sys_path));
|
let serial = fs::file_read_string(format!("{sys_path}/serial"));
|
||||||
let fidx = match serial {
|
let fidx = match serial {
|
||||||
Ok(serial) => serial,
|
Ok(serial) => serial,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!("disk '{}': could not read serial file - {}", name, err);
|
warn!("disk '{name}': could not read serial file - {err}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -405,10 +405,7 @@ impl DiskState {
|
|||||||
});
|
});
|
||||||
if filesystems.ensure_mounted(&mut dfs_bucket).is_ok() {
|
if filesystems.ensure_mounted(&mut dfs_bucket).is_ok() {
|
||||||
// mount succeeded, add bucket and skip any other checks for the disk
|
// mount succeeded, add bucket and skip any other checks for the disk
|
||||||
info!(
|
info!("drive '{name}' ('{fidx}', '{dev_node}') contains fs directly ({size}B)");
|
||||||
"drive '{}' ('{}', '{}') contains fs directly ({}B)",
|
|
||||||
name, fidx, dev_node, size
|
|
||||||
);
|
|
||||||
disk_map.insert(fidx, vec![dfs_bucket]);
|
disk_map.insert(fidx, vec![dfs_bucket]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -418,19 +415,18 @@ impl DiskState {
|
|||||||
.filter_map(Result::ok)
|
.filter_map(Result::ok)
|
||||||
{
|
{
|
||||||
let part_name = unsafe { entry.file_name_utf8_unchecked() };
|
let part_name = unsafe { entry.file_name_utf8_unchecked() };
|
||||||
let dev_node = format!("/dev/{}", part_name);
|
let dev_node = format!("/dev/{part_name}");
|
||||||
let part_path = format!("/sys/block/{}/{}", name, part_name);
|
let part_path = format!("/sys/block/{name}/{part_name}");
|
||||||
|
|
||||||
// create partition device node for further use
|
// create partition device node for further use
|
||||||
let size = Self::make_dev_node(&dev_node, &part_path)?;
|
let size = Self::make_dev_node(&dev_node, &part_path)?;
|
||||||
|
|
||||||
let number = fs::file_read_firstline(&format!("{}/partition", part_path))?
|
let number = fs::file_read_firstline(format!("{part_path}/partition"))?
|
||||||
.trim()
|
.trim()
|
||||||
.parse::<i32>()?;
|
.parse::<i32>()?;
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
"drive '{}' ('{}'): found partition '{}' ({}, {}B)",
|
"drive '{name}' ('{fidx}'): found partition '{dev_node}' ({number}, {size}B)"
|
||||||
name, fidx, dev_node, number, size
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let bucket = Bucket::Partition(PartitionBucketData {
|
let bucket = Bucket::Partition(PartitionBucketData {
|
||||||
@ -549,7 +545,7 @@ impl DiskState {
|
|||||||
cmd.args(["-ay", "-y", &format!("{}/{}", vg_name, metadata)].iter());
|
cmd.args(["-ay", "-y", &format!("{}/{}", vg_name, metadata)].iter());
|
||||||
if let Err(err) = run_command(cmd, None) {
|
if let Err(err) = run_command(cmd, None) {
|
||||||
// not critical, will simply mean its children can't be loaded
|
// not critical, will simply mean its children can't be loaded
|
||||||
warn!("LVM: activating thinpool failed: {}", err);
|
warn!("LVM: activating thinpool failed: {err}");
|
||||||
} else {
|
} else {
|
||||||
thinpools.push((vg_name, metadata));
|
thinpools.push((vg_name, metadata));
|
||||||
}
|
}
|
||||||
@ -562,7 +558,7 @@ impl DiskState {
|
|||||||
// cannot leave the metadata LV active, otherwise child-LVs won't activate
|
// cannot leave the metadata LV active, otherwise child-LVs won't activate
|
||||||
for (vg_name, metadata) in thinpools {
|
for (vg_name, metadata) in thinpools {
|
||||||
let mut cmd = Command::new("/sbin/lvchange");
|
let mut cmd = Command::new("/sbin/lvchange");
|
||||||
cmd.args(["-an", "-y", &format!("{}/{}", vg_name, metadata)].iter());
|
cmd.args(["-an", "-y", &format!("{vg_name}/{metadata}")].iter());
|
||||||
let _ = run_command(cmd, None);
|
let _ = run_command(cmd, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,19 +583,15 @@ impl DiskState {
|
|||||||
// activate the LV so 'vgscan' can create a node later - this may fail, and if it
|
// activate the LV so 'vgscan' can create a node later - this may fail, and if it
|
||||||
// does, we ignore it and continue
|
// does, we ignore it and continue
|
||||||
let mut cmd = Command::new("/sbin/lvchange");
|
let mut cmd = Command::new("/sbin/lvchange");
|
||||||
cmd.args(["-ay", &format!("{}/{}", vg_name, lv_name)].iter());
|
cmd.args(["-ay", &format!("{vg_name}/{lv_name}")].iter());
|
||||||
if let Err(err) = run_command(cmd, None) {
|
if let Err(err) = run_command(cmd, None) {
|
||||||
warn!(
|
warn!(
|
||||||
"LVM: LV '{}' on '{}' ({}B) failed to activate: {}",
|
"LVM: LV '{lv_name}' on '{vg_name}' ({lv_size}B) failed to activate: {err}"
|
||||||
lv_name, vg_name, lv_size, err
|
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
info!(
|
info!("LVM: found LV '{lv_name}' on '{vg_name}' ({lv_size}B)");
|
||||||
"LVM: found LV '{}' on '{}' ({}B)",
|
|
||||||
lv_name, vg_name, lv_size
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Some(drives) = pv_map.get(vg_name) {
|
if let Some(drives) = pv_map.get(vg_name) {
|
||||||
for fidx in drives {
|
for fidx in drives {
|
||||||
@ -647,7 +639,7 @@ impl DiskState {
|
|||||||
.unwrap_or_else(|| req_fidx.as_ref()),
|
.unwrap_or_else(|| req_fidx.as_ref()),
|
||||||
) {
|
) {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => bail!("given image '{}' not found", req_fidx),
|
None => bail!("given image '{req_fidx}' not found"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let bucket_type = match cmp.next() {
|
let bucket_type = match cmp.next() {
|
||||||
@ -698,9 +690,7 @@ impl DiskState {
|
|||||||
let bucket = match Bucket::filter_mut(buckets, &bucket_type, &components) {
|
let bucket = match Bucket::filter_mut(buckets, &bucket_type, &components) {
|
||||||
Some(bucket) => bucket,
|
Some(bucket) => bucket,
|
||||||
None => bail!(
|
None => bail!(
|
||||||
"bucket/component path not found: {}/{}/{}",
|
"bucket/component path not found: {req_fidx}/{bucket_type}/{}",
|
||||||
req_fidx,
|
|
||||||
bucket_type,
|
|
||||||
components.join("/")
|
components.join("/")
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
@ -708,11 +698,8 @@ impl DiskState {
|
|||||||
// bucket found, check mount
|
// bucket found, check mount
|
||||||
let mountpoint = self.filesystems.ensure_mounted(bucket).map_err(|err| {
|
let mountpoint = self.filesystems.ensure_mounted(bucket).map_err(|err| {
|
||||||
format_err!(
|
format_err!(
|
||||||
"mounting '{}/{}/{}' failed: {}",
|
"mounting '{req_fidx}/{bucket_type}/{}' failed: {err}",
|
||||||
req_fidx,
|
|
||||||
bucket_type,
|
|
||||||
components.join("/"),
|
components.join("/"),
|
||||||
err
|
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@ -726,13 +713,13 @@ impl DiskState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn make_dev_node(devnode: &str, sys_path: &str) -> Result<u64, Error> {
|
fn make_dev_node(devnode: &str, sys_path: &str) -> Result<u64, Error> {
|
||||||
let dev_num_str = fs::file_read_firstline(&format!("{}/dev", sys_path))?;
|
let dev_num_str = fs::file_read_firstline(format!("{sys_path}/dev"))?;
|
||||||
let (major, minor) = dev_num_str.split_at(dev_num_str.find(':').unwrap());
|
let (major, minor) = dev_num_str.split_at(dev_num_str.find(':').unwrap());
|
||||||
Self::mknod_blk(devnode, major.parse()?, minor[1..].trim_end().parse()?)?;
|
Self::mknod_blk(devnode, major.parse()?, minor[1..].trim_end().parse()?)?;
|
||||||
|
|
||||||
// this *always* contains the number of 512-byte sectors, regardless of the true
|
// this *always* contains the number of 512-byte sectors, regardless of the true
|
||||||
// blocksize of this disk - which should always be 512 here anyway
|
// blocksize of this disk - which should always be 512 here anyway
|
||||||
let size = fs::file_read_firstline(&format!("{}/size", sys_path))?
|
let size = fs::file_read_firstline(format!("{sys_path}/size"))?
|
||||||
.trim()
|
.trim()
|
||||||
.parse::<u64>()?
|
.parse::<u64>()?
|
||||||
* 512;
|
* 512;
|
||||||
|
Loading…
Reference in New Issue
Block a user