From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 677051FF389 for ; Wed, 5 Jun 2024 13:02:00 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CA94132743; Wed, 5 Jun 2024 13:02:31 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Wed, 5 Jun 2024 12:53:38 +0200 Message-Id: <20240605105416.278748-21-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240605105416.278748-1-c.ebner@proxmox.com> References: <20240605105416.278748-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 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. [tools.rs] Subject: [pbs-devel] [PATCH v9 proxmox-backup 20/58] client: pxar: include payload offset in entry listing 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Also display the payload offset as listing output when the regular file entry had a payload reference rather than the payload encoded in the archive. This allows for debugging by inspecting the raw payload data file at given offset. Signed-off-by: Christian Ebner --- changes since version 8: - no changes pbs-client/src/pxar/tools.rs | 116 ++++++++++++++++++++++++----------- 1 file changed, 80 insertions(+), 36 deletions(-) diff --git a/pbs-client/src/pxar/tools.rs b/pbs-client/src/pxar/tools.rs index 0cfbaf5b9..459951d50 100644 --- a/pbs-client/src/pxar/tools.rs +++ b/pbs-client/src/pxar/tools.rs @@ -128,25 +128,42 @@ pub fn format_single_line_entry(entry: &Entry) -> String { let meta = entry.metadata(); - let (size, link) = match entry.kind() { - EntryKind::File { size, .. } => (format!("{}", *size), String::new()), - EntryKind::Symlink(link) => ("0".to_string(), format!(" -> {:?}", link.as_os_str())), - EntryKind::Hardlink(link) => ("0".to_string(), format!(" -> {:?}", link.as_os_str())), - EntryKind::Device(dev) => (format!("{},{}", dev.major, dev.minor), String::new()), - _ => ("0".to_string(), String::new()), + let (size, link, payload_offset) = match entry.kind() { + EntryKind::File { + size, + payload_offset, + .. + } => (format!("{}", *size), String::new(), *payload_offset), + EntryKind::Symlink(link) => ("0".to_string(), format!(" -> {:?}", link.as_os_str()), None), + EntryKind::Hardlink(link) => ("0".to_string(), format!(" -> {:?}", link.as_os_str()), None), + EntryKind::Device(dev) => (format!("{},{}", dev.major, dev.minor), String::new(), None), + _ => ("0".to_string(), String::new(), None), }; let owner_string = format!("{}/{}", meta.stat.uid, meta.stat.gid); - format!( - "{} {:<13} {} {:>8} {:?}{}", - mode_string, - owner_string, - format_mtime(&meta.stat.mtime), - size, - entry.path(), - link, - ) + if let Some(offset) = payload_offset { + format!( + "{} {:<13} {} {:>8} {:?}{} {}", + mode_string, + owner_string, + format_mtime(&meta.stat.mtime), + size, + entry.path(), + link, + offset, + ) + } else { + format!( + "{} {:<13} {} {:>8} {:?}{}", + mode_string, + owner_string, + format_mtime(&meta.stat.mtime), + size, + entry.path(), + link, + ) + } } pub fn format_multi_line_entry(entry: &Entry) -> String { @@ -154,17 +171,23 @@ pub fn format_multi_line_entry(entry: &Entry) -> String { let meta = entry.metadata(); - let (size, link, type_name) = match entry.kind() { - EntryKind::File { size, .. } => (format!("{}", *size), String::new(), "file"), + let (size, link, type_name, payload_offset) = match entry.kind() { + EntryKind::File { + size, + payload_offset, + .. + } => (format!("{}", *size), String::new(), "file", *payload_offset), EntryKind::Symlink(link) => ( "0".to_string(), format!(" -> {:?}", link.as_os_str()), "symlink", + None, ), EntryKind::Hardlink(link) => ( "0".to_string(), format!(" -> {:?}", link.as_os_str()), "symlink", + None, ), EntryKind::Device(dev) => ( format!("{},{}", dev.major, dev.minor), @@ -176,11 +199,12 @@ pub fn format_multi_line_entry(entry: &Entry) -> String { } else { "device" }, + None, ), - EntryKind::Socket => ("0".to_string(), String::new(), "socket"), - EntryKind::Fifo => ("0".to_string(), String::new(), "fifo"), - EntryKind::Directory => ("0".to_string(), String::new(), "directory"), - EntryKind::GoodbyeTable => ("0".to_string(), String::new(), "bad entry"), + EntryKind::Socket => ("0".to_string(), String::new(), "socket", None), + EntryKind::Fifo => ("0".to_string(), String::new(), "fifo", None), + EntryKind::Directory => ("0".to_string(), String::new(), "directory", None), + EntryKind::GoodbyeTable => ("0".to_string(), String::new(), "bad entry", None), }; let file_name = match std::str::from_utf8(entry.path().as_os_str().as_bytes()) { @@ -188,19 +212,39 @@ pub fn format_multi_line_entry(entry: &Entry) -> String { Err(_) => std::borrow::Cow::Owned(format!("{:?}", entry.path())), }; - format!( - " File: {}{}\n \ - Size: {:<13} Type: {}\n\ - Access: ({:o}/{}) Uid: {:<5} Gid: {:<5}\n\ - Modify: {}\n", - file_name, - link, - size, - type_name, - meta.file_mode(), - mode_string, - meta.stat.uid, - meta.stat.gid, - format_mtime(&meta.stat.mtime), - ) + if let Some(offset) = payload_offset { + format!( + " File: {}{}\n \ + Size: {:<13} Type: {}\n\ + Access: ({:o}/{}) Uid: {:<5} Gid: {:<5}\n\ + Modify: {}\n + PayloadOffset: {}\n", + file_name, + link, + size, + type_name, + meta.file_mode(), + mode_string, + meta.stat.uid, + meta.stat.gid, + format_mtime(&meta.stat.mtime), + offset, + ) + } else { + format!( + " File: {}{}\n \ + Size: {:<13} Type: {}\n\ + Access: ({:o}/{}) Uid: {:<5} Gid: {:<5}\n\ + Modify: {}\n", + file_name, + link, + size, + type_name, + meta.file_mode(), + mode_string, + meta.stat.uid, + meta.stat.gid, + format_mtime(&meta.stat.mtime), + ) + } } -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel