[pbs-devel] [PATCH vma-to-pbs 02/10] cargo fmt
Filip Schauer
f.schauer at proxmox.com
Wed Mar 20 15:15:08 CET 2024
From: Wolfgang Bumiller <w.bumiller at proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
src/main.rs | 17 +++++++++++++----
src/vma.rs | 27 ++++++++++++++++++---------
2 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index 1aefd29..8d95b11 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -37,7 +37,10 @@ fn backup_vma_to_pbs(
println!("compress: {}", compress);
println!("encrypt: {}", encrypt);
- let backup_time = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();
+ let backup_time = SystemTime::now()
+ .duration_since(UNIX_EPOCH)
+ .unwrap()
+ .as_secs();
println!("backup time: {}", backup_time);
let mut pbs_err: *mut c_char = ptr::null_mut();
@@ -51,7 +54,9 @@ fn backup_vma_to_pbs(
let key_password_cstr = key_password.map(|v| CString::new(v).unwrap());
let key_password_ptr = key_password_cstr.map(|v| v.as_ptr()).unwrap_or(ptr::null());
let master_keyfile_cstr = master_keyfile.map(|v| CString::new(v).unwrap());
- let master_keyfile_ptr = master_keyfile_cstr.map(|v| v.as_ptr()).unwrap_or(ptr::null());
+ let master_keyfile_ptr = master_keyfile_cstr
+ .map(|v| v.as_ptr())
+ .unwrap_or(ptr::null());
let pbs = proxmox_backup_new_ns(
pbs_repository_cstr.as_ptr(),
@@ -154,7 +159,8 @@ fn backup_vma_to_pbs(
}
}
- let mut image_chunk_buffer = proxmox_io::boxed::zeroed(PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE as usize);
+ let mut image_chunk_buffer =
+ proxmox_io::boxed::zeroed(PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE as usize);
let mut bytes_transferred = 0;
while bytes_transferred < device_size {
@@ -279,7 +285,10 @@ fn main() -> Result<()> {
let pbs_repository = matches.get_one::<String>("repository").unwrap().to_string();
let vmid = matches.get_one::<String>("vmid").unwrap().to_string();
- let fingerprint = matches.get_one::<String>("fingerprint").unwrap().to_string();
+ let fingerprint = matches
+ .get_one::<String>("fingerprint")
+ .unwrap()
+ .to_string();
let keyfile = matches.get_one::<String>("keyfile");
let master_keyfile = matches.get_one::<String>("master_keyfile");
diff --git a/src/vma.rs b/src/vma.rs
index e2c3475..5ec3822 100644
--- a/src/vma.rs
+++ b/src/vma.rs
@@ -164,8 +164,10 @@ impl VmaReader {
continue;
}
- let config_name_file_offset = (vma_header.blob_buffer_offset + config_name_offset) as u64;
- let config_data_file_offset = (vma_header.blob_buffer_offset + config_data_offset) as u64;
+ let config_name_file_offset =
+ (vma_header.blob_buffer_offset + config_name_offset) as u64;
+ let config_data_file_offset =
+ (vma_header.blob_buffer_offset + config_data_offset) as u64;
let config_name = Self::read_string_from_file(vma_file, config_name_file_offset)?;
let config_data = Self::read_string_from_file(vma_file, config_data_file_offset)?;
@@ -190,8 +192,10 @@ impl VmaReader {
return None;
}
- let device_name_file_offset = (self.vma_header.blob_buffer_offset + device_name_offset) as u64;
- let device_name = Self::read_string_from_file(&mut self.vma_file, device_name_file_offset).unwrap();
+ let device_name_file_offset =
+ (self.vma_header.blob_buffer_offset + device_name_offset) as u64;
+ let device_name =
+ Self::read_string_from_file(&mut self.vma_file, device_name_file_offset).unwrap();
return Some(device_name.to_string());
}
@@ -252,7 +256,8 @@ impl VmaReader {
mask: 0,
};
- self.block_index[device_id].resize(device_cluster_count as usize, block_index_entry_placeholder);
+ self.block_index[device_id]
+ .resize(device_cluster_count as usize, block_index_entry_placeholder);
}
let mut file_offset = self.vma_header.header_size as u64;
@@ -275,7 +280,8 @@ impl VmaReader {
mask: blockinfo.mask,
};
- self.block_index[blockinfo.dev_id as usize][blockinfo.cluster_num as usize] = block_index_entry;
+ self.block_index[blockinfo.dev_id as usize][blockinfo.cluster_num as usize] =
+ block_index_entry;
file_offset += blockinfo.mask.count_ones() as u64 * 4096;
}
}
@@ -313,8 +319,10 @@ impl VmaReader {
let mut buffer_is_zero = true;
while buffer_offset < length {
- let block_index_entry = &this_device_block_index[(offset as usize + buffer_offset) / (4096 * 16)];
- self.vma_file.seek(SeekFrom::Start(block_index_entry.cluster_file_offset))?;
+ let block_index_entry =
+ &this_device_block_index[(offset as usize + buffer_offset) / (4096 * 16)];
+ self.vma_file
+ .seek(SeekFrom::Start(block_index_entry.cluster_file_offset))?;
for i in 0..16 {
if buffer_offset >= length {
@@ -325,7 +333,8 @@ impl VmaReader {
let block_mask = ((block_index_entry.mask >> i) & 1) == 1;
if block_mask {
- self.vma_file.read_exact(&mut buffer[buffer_offset..block_buffer_end])?;
+ self.vma_file
+ .read_exact(&mut buffer[buffer_offset..block_buffer_end])?;
buffer_is_zero = false;
} else {
buffer[buffer_offset..block_buffer_end].fill(0);
--
2.39.2
More information about the pbs-devel
mailing list