public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] client: catalog shell: drop payload offset in `stat` output
@ 2024-10-24  9:10 Christian Ebner
  2024-10-25 12:41 ` [pbs-devel] applied: " Fabian Grünbichler
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Ebner @ 2024-10-24  9:10 UTC (permalink / raw)
  To: pbs-devel

Drop the payload offset output for the multi line formatting helper,
as the formatting was skewed anyways and the `stat` output is not
intended for debugging.

Commit 51e8fa96 ("client: pxar: include payload offset in entry
listing") introduced the payload offset output for pxar entries
in case of split archives for both, single line and multi line
formatting helpers with debugging prupose.

While the payload offset output is fine for the single line entry
formatting (generates the pxar dump output in debugging mode),
it should not be included in the multi line entry formatting helper,
used to generate the output for the `stat` command of the catalog
shell.

Fixes: 51e8fa96 ("client: pxar: include payload offset in entry listing")

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 pbs-client/src/pxar/tools.rs | 72 +++++++++++-------------------------
 1 file changed, 22 insertions(+), 50 deletions(-)

diff --git a/pbs-client/src/pxar/tools.rs b/pbs-client/src/pxar/tools.rs
index 7a4d75522..b076daf6b 100644
--- a/pbs-client/src/pxar/tools.rs
+++ b/pbs-client/src/pxar/tools.rs
@@ -187,30 +187,23 @@ pub fn format_multi_line_entry(entry: &Entry) -> String {
 
     let meta = entry.metadata();
 
-    let (size, link, type_name, payload_offset) = match entry.kind() {
-        EntryKind::Version(version) => (format!("{version:?}"), String::new(), "version", None),
+    let (size, link, type_name) = match entry.kind() {
+        EntryKind::Version(version) => (format!("{version:?}"), String::new(), "version"),
         EntryKind::Prelude(prelude) => (
             "0".to_string(),
             format!("raw data: {:?} bytes", prelude.data.len()),
             "prelude",
-            None,
         ),
-        EntryKind::File {
-            size,
-            payload_offset,
-            ..
-        } => (format!("{}", *size), String::new(), "file", *payload_offset),
+        EntryKind::File { size, .. } => (format!("{}", *size), String::new(), "file"),
         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),
@@ -222,12 +215,11 @@ pub fn format_multi_line_entry(entry: &Entry) -> String {
             } else {
                 "device"
             },
-            None,
         ),
-        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),
+        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"),
     };
 
     let file_name = match std::str::from_utf8(entry.path().as_os_str().as_bytes()) {
@@ -235,41 +227,21 @@ pub fn format_multi_line_entry(entry: &Entry) -> String {
         Err(_) => std::borrow::Cow::Owned(format!("{:?}", entry.path())),
     };
 
-    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),
-        )
-    }
+    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),
+    )
 }
 
 /// Look up the directory entries of the given directory `path` in a pxar archive via it's given
-- 
2.39.5



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup] client: catalog shell: drop payload offset in `stat` output
  2024-10-24  9:10 [pbs-devel] [PATCH proxmox-backup] client: catalog shell: drop payload offset in `stat` output Christian Ebner
@ 2024-10-25 12:41 ` Fabian Grünbichler
  0 siblings, 0 replies; 2+ messages in thread
From: Fabian Grünbichler @ 2024-10-25 12:41 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion

thanks!

On October 24, 2024 11:10 am, Christian Ebner wrote:
> Drop the payload offset output for the multi line formatting helper,
> as the formatting was skewed anyways and the `stat` output is not
> intended for debugging.
> 
> Commit 51e8fa96 ("client: pxar: include payload offset in entry
> listing") introduced the payload offset output for pxar entries
> in case of split archives for both, single line and multi line
> formatting helpers with debugging prupose.
> 
> While the payload offset output is fine for the single line entry
> formatting (generates the pxar dump output in debugging mode),
> it should not be included in the multi line entry formatting helper,
> used to generate the output for the `stat` command of the catalog
> shell.
> 
> Fixes: 51e8fa96 ("client: pxar: include payload offset in entry listing")
> 
> Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
> ---
>  pbs-client/src/pxar/tools.rs | 72 +++++++++++-------------------------
>  1 file changed, 22 insertions(+), 50 deletions(-)
> 
> diff --git a/pbs-client/src/pxar/tools.rs b/pbs-client/src/pxar/tools.rs
> index 7a4d75522..b076daf6b 100644
> --- a/pbs-client/src/pxar/tools.rs
> +++ b/pbs-client/src/pxar/tools.rs
> @@ -187,30 +187,23 @@ pub fn format_multi_line_entry(entry: &Entry) -> String {
>  
>      let meta = entry.metadata();
>  
> -    let (size, link, type_name, payload_offset) = match entry.kind() {
> -        EntryKind::Version(version) => (format!("{version:?}"), String::new(), "version", None),
> +    let (size, link, type_name) = match entry.kind() {
> +        EntryKind::Version(version) => (format!("{version:?}"), String::new(), "version"),
>          EntryKind::Prelude(prelude) => (
>              "0".to_string(),
>              format!("raw data: {:?} bytes", prelude.data.len()),
>              "prelude",
> -            None,
>          ),
> -        EntryKind::File {
> -            size,
> -            payload_offset,
> -            ..
> -        } => (format!("{}", *size), String::new(), "file", *payload_offset),
> +        EntryKind::File { size, .. } => (format!("{}", *size), String::new(), "file"),
>          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),
> @@ -222,12 +215,11 @@ pub fn format_multi_line_entry(entry: &Entry) -> String {
>              } else {
>                  "device"
>              },
> -            None,
>          ),
> -        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),
> +        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"),
>      };
>  
>      let file_name = match std::str::from_utf8(entry.path().as_os_str().as_bytes()) {
> @@ -235,41 +227,21 @@ pub fn format_multi_line_entry(entry: &Entry) -> String {
>          Err(_) => std::borrow::Cow::Owned(format!("{:?}", entry.path())),
>      };
>  
> -    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),
> -        )
> -    }
> +    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),
> +    )
>  }
>  
>  /// Look up the directory entries of the given directory `path` in a pxar archive via it's given
> -- 
> 2.39.5
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-25 12:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-24  9:10 [pbs-devel] [PATCH proxmox-backup] client: catalog shell: drop payload offset in `stat` output Christian Ebner
2024-10-25 12:41 ` [pbs-devel] applied: " Fabian Grünbichler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal