From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 31A20978BA for ; Tue, 5 Mar 2024 14:56:54 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1A3979599 for ; Tue, 5 Mar 2024 14:56:54 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 5 Mar 2024 14:56:53 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2A6CC487DA for ; Tue, 5 Mar 2024 14:56:53 +0100 (CET) From: Filip Schauer To: pbs-devel@lists.proxmox.com Cc: Wolfgang Bumiller Date: Tue, 5 Mar 2024 14:56:41 +0100 Message-Id: <20240305135645.96347-3-f.schauer@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305135645.96347-1-f.schauer@proxmox.com> References: <20240305135645.96347-1-f.schauer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.098 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [vma.rs, main.rs] Subject: [pbs-devel] [PATCH v4 vma-to-pbs 2/6] cargo fmt X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Mar 2024 13:56:54 -0000 From: Wolfgang Bumiller Signed-off-by: Wolfgang Bumiller Signed-off-by: Filip Schauer --- 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::("repository").unwrap().to_string(); let vmid = matches.get_one::("vmid").unwrap().to_string(); - let fingerprint = matches.get_one::("fingerprint").unwrap().to_string(); + let fingerprint = matches + .get_one::("fingerprint") + .unwrap() + .to_string(); let keyfile = matches.get_one::("keyfile"); let master_keyfile = matches.get_one::("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