From 351b913d1e8e3ddf8a4202ca34bda8988ebfc267 Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Thu, 27 Feb 2020 14:09:56 +0100 Subject: [PATCH] pxar::decoder: Return the correct symlink target size. This eliminates also repeated calls to readlink in fuse, which occur when the preallocated buffer to store the symlink target path is to small. Signed-off-by: Christian Ebner --- src/pxar/decoder.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/pxar/decoder.rs b/src/pxar/decoder.rs index ceee62dc..023be6da 100644 --- a/src/pxar/decoder.rs +++ b/src/pxar/decoder.rs @@ -137,13 +137,12 @@ impl Decoder { check_ca_header::(&head, PXAR_ENTRY)?; let entry: PxarEntry = self.inner.read_item()?; let (header, xattr) = self.inner.read_attributes()?; - let (size, payload_offset) = match header.htype { - PXAR_PAYLOAD => (header.size - HEADER_SIZE, Some(self.seek(SeekFrom::Current(0))?)), - _ => (0, None), - }; - let target = match header.htype { - PXAR_SYMLINK => Some(self.inner.read_link(header.size)?), - _ => None, + let (size, payload_offset, target) = match header.htype { + PXAR_PAYLOAD => + (header.size - HEADER_SIZE, Some(self.seek(SeekFrom::Current(0))?), None), + PXAR_SYMLINK => + (header.size - HEADER_SIZE, None, Some(self.inner.read_link(header.size)?)), + _ => (0, None, None), }; Ok(DirectoryEntry {