client: pxar: include payload offset in entry listing
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 <c.ebner@proxmox.com>
This commit is contained in:
parent
d83839ddf3
commit
51e8fa9648
@ -128,25 +128,42 @@ pub fn format_single_line_entry(entry: &Entry) -> String {
|
|||||||
|
|
||||||
let meta = entry.metadata();
|
let meta = entry.metadata();
|
||||||
|
|
||||||
let (size, link) = match entry.kind() {
|
let (size, link, payload_offset) = match entry.kind() {
|
||||||
EntryKind::File { size, .. } => (format!("{}", *size), String::new()),
|
EntryKind::File {
|
||||||
EntryKind::Symlink(link) => ("0".to_string(), format!(" -> {:?}", link.as_os_str())),
|
size,
|
||||||
EntryKind::Hardlink(link) => ("0".to_string(), format!(" -> {:?}", link.as_os_str())),
|
payload_offset,
|
||||||
EntryKind::Device(dev) => (format!("{},{}", dev.major, dev.minor), String::new()),
|
..
|
||||||
_ => ("0".to_string(), String::new()),
|
} => (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);
|
let owner_string = format!("{}/{}", meta.stat.uid, meta.stat.gid);
|
||||||
|
|
||||||
format!(
|
if let Some(offset) = payload_offset {
|
||||||
"{} {:<13} {} {:>8} {:?}{}",
|
format!(
|
||||||
mode_string,
|
"{} {:<13} {} {:>8} {:?}{} {}",
|
||||||
owner_string,
|
mode_string,
|
||||||
format_mtime(&meta.stat.mtime),
|
owner_string,
|
||||||
size,
|
format_mtime(&meta.stat.mtime),
|
||||||
entry.path(),
|
size,
|
||||||
link,
|
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 {
|
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 meta = entry.metadata();
|
||||||
|
|
||||||
let (size, link, type_name) = match entry.kind() {
|
let (size, link, type_name, payload_offset) = match entry.kind() {
|
||||||
EntryKind::File { size, .. } => (format!("{}", *size), String::new(), "file"),
|
EntryKind::File {
|
||||||
|
size,
|
||||||
|
payload_offset,
|
||||||
|
..
|
||||||
|
} => (format!("{}", *size), String::new(), "file", *payload_offset),
|
||||||
EntryKind::Symlink(link) => (
|
EntryKind::Symlink(link) => (
|
||||||
"0".to_string(),
|
"0".to_string(),
|
||||||
format!(" -> {:?}", link.as_os_str()),
|
format!(" -> {:?}", link.as_os_str()),
|
||||||
"symlink",
|
"symlink",
|
||||||
|
None,
|
||||||
),
|
),
|
||||||
EntryKind::Hardlink(link) => (
|
EntryKind::Hardlink(link) => (
|
||||||
"0".to_string(),
|
"0".to_string(),
|
||||||
format!(" -> {:?}", link.as_os_str()),
|
format!(" -> {:?}", link.as_os_str()),
|
||||||
"symlink",
|
"symlink",
|
||||||
|
None,
|
||||||
),
|
),
|
||||||
EntryKind::Device(dev) => (
|
EntryKind::Device(dev) => (
|
||||||
format!("{},{}", dev.major, dev.minor),
|
format!("{},{}", dev.major, dev.minor),
|
||||||
@ -176,11 +199,12 @@ pub fn format_multi_line_entry(entry: &Entry) -> String {
|
|||||||
} else {
|
} else {
|
||||||
"device"
|
"device"
|
||||||
},
|
},
|
||||||
|
None,
|
||||||
),
|
),
|
||||||
EntryKind::Socket => ("0".to_string(), String::new(), "socket"),
|
EntryKind::Socket => ("0".to_string(), String::new(), "socket", None),
|
||||||
EntryKind::Fifo => ("0".to_string(), String::new(), "fifo"),
|
EntryKind::Fifo => ("0".to_string(), String::new(), "fifo", None),
|
||||||
EntryKind::Directory => ("0".to_string(), String::new(), "directory"),
|
EntryKind::Directory => ("0".to_string(), String::new(), "directory", None),
|
||||||
EntryKind::GoodbyeTable => ("0".to_string(), String::new(), "bad entry"),
|
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()) {
|
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())),
|
Err(_) => std::borrow::Cow::Owned(format!("{:?}", entry.path())),
|
||||||
};
|
};
|
||||||
|
|
||||||
format!(
|
if let Some(offset) = payload_offset {
|
||||||
" File: {}{}\n \
|
format!(
|
||||||
Size: {:<13} Type: {}\n\
|
" File: {}{}\n \
|
||||||
Access: ({:o}/{}) Uid: {:<5} Gid: {:<5}\n\
|
Size: {:<13} Type: {}\n\
|
||||||
Modify: {}\n",
|
Access: ({:o}/{}) Uid: {:<5} Gid: {:<5}\n\
|
||||||
file_name,
|
Modify: {}\n
|
||||||
link,
|
PayloadOffset: {}\n",
|
||||||
size,
|
file_name,
|
||||||
type_name,
|
link,
|
||||||
meta.file_mode(),
|
size,
|
||||||
mode_string,
|
type_name,
|
||||||
meta.stat.uid,
|
meta.file_mode(),
|
||||||
meta.stat.gid,
|
mode_string,
|
||||||
format_mtime(&meta.stat.mtime),
|
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),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user