From: Filip Schauer <f.schauer@proxmox.com>
To: pbs-devel@lists.proxmox.com
Cc: Wolfgang Bumiller <w.bumiller@proxmox.com>
Subject: [pbs-devel] [PATCH vma-to-pbs 02/10] cargo fmt
Date: Wed, 20 Mar 2024 15:15:08 +0100 [thread overview]
Message-ID: <20240320141516.213930-3-f.schauer@proxmox.com> (raw)
In-Reply-To: <20240320141516.213930-1-f.schauer@proxmox.com>
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@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
next prev parent reply other threads:[~2024-03-20 14:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 14:15 [pbs-devel] [PATCH v5 vma-to-pbs 00/10] Implement vma-to-pbs tool Filip Schauer
2024-03-20 14:15 ` [pbs-devel] [PATCH vma-to-pbs 01/10] Initial commit Filip Schauer
2024-03-25 9:42 ` Filip Schauer
2024-03-20 14:15 ` Filip Schauer [this message]
2024-03-25 9:43 ` [pbs-devel] [PATCH vma-to-pbs 02/10] cargo fmt Filip Schauer
2024-03-20 14:15 ` [pbs-devel] [PATCH vma-to-pbs 03/10] bump proxmox-backup-qemu Filip Schauer
2024-03-25 9:43 ` Filip Schauer
2024-03-20 14:15 ` [pbs-devel] [PATCH vma-to-pbs 04/10] Add the ability to provide credentials via files Filip Schauer
2024-03-25 12:33 ` Max Carrara
2024-03-25 15:26 ` Thomas Lamprecht
2024-03-20 14:15 ` [pbs-devel] [PATCH vma-to-pbs 05/10] bump proxmox-backup-qemu Filip Schauer
2024-03-25 12:33 ` Max Carrara
2024-03-20 14:15 ` [pbs-devel] [PATCH vma-to-pbs 06/10] remove unnecessary "extern crate" declarations Filip Schauer
2024-03-20 14:15 ` [pbs-devel] [PATCH vma-to-pbs 07/10] add support for streaming the VMA file via stdin Filip Schauer
2024-03-25 12:34 ` Max Carrara
2024-03-20 14:15 ` [pbs-devel] [PATCH vma-to-pbs 08/10] add a fallback for the --fingerprint argument Filip Schauer
2024-03-25 12:35 ` Max Carrara
2024-03-20 14:15 ` [pbs-devel] [PATCH vma-to-pbs 09/10] refactor error handling with anyhow Filip Schauer
2024-03-25 12:35 ` Max Carrara
2024-03-20 14:15 ` [pbs-devel] [PATCH vma-to-pbs 10/10] Makefile: remove reference to unused submodule Filip Schauer
2024-03-25 12:38 ` [pbs-devel] [PATCH v5 vma-to-pbs 00/10] Implement vma-to-pbs tool Max Carrara
2024-03-25 12:52 ` Wolfgang Bumiller
2024-04-03 9:56 ` Filip Schauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240320141516.213930-3-f.schauer@proxmox.com \
--to=f.schauer@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
--cc=w.bumiller@proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.