From: Filip Schauer <f.schauer@proxmox.com>
To: pbs-devel@lists.proxmox.com
Cc: Wolfgang Bumiller <w.bumiller@proxmox.com>
Subject: [pbs-devel] [PATCH v4 vma-to-pbs 2/6] cargo fmt
Date: Tue, 5 Mar 2024 14:56:41 +0100 [thread overview]
Message-ID: <20240305135645.96347-3-f.schauer@proxmox.com> (raw)
In-Reply-To: <20240305135645.96347-1-f.schauer@proxmox.com>
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Filip Schauer <f.schauer@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-05 13:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 13:56 [pbs-devel] [PATCH v4 vma-to-pbs 0/6] Implement vma-to-pbs tool Filip Schauer
2024-03-05 13:56 ` [pbs-devel] [PATCH v4 vma-to-pbs 1/6] Initial commit Filip Schauer
2024-03-06 15:49 ` Max Carrara
2024-03-05 13:56 ` Filip Schauer [this message]
2024-03-05 13:56 ` [pbs-devel] [PATCH v4 vma-to-pbs 3/6] bump proxmox-backup-qemu Filip Schauer
2024-03-05 13:56 ` [pbs-devel] [PATCH v4 vma-to-pbs 4/6] Add the ability to provide credentials via files Filip Schauer
2024-03-06 15:49 ` Max Carrara
2024-03-05 13:56 ` [pbs-devel] [PATCH v4 vma-to-pbs 5/6] Add support for streaming the VMA file via stdin Filip Schauer
2024-03-06 15:49 ` Max Carrara
2024-03-12 14:04 ` Filip Schauer
2024-03-05 13:56 ` [pbs-devel] [PATCH v4 vma-to-pbs 6/6] Add a fallback for the --fingerprint argument Filip Schauer
2024-03-06 15:49 ` [pbs-devel] [PATCH v4 vma-to-pbs 0/6] Implement vma-to-pbs tool Max Carrara
2024-03-06 15:57 ` Wolfgang Bumiller
2024-03-20 14:18 ` 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=20240305135645.96347-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox