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 <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2020-02-27 14:09:56 +01:00 committed by Dietmar Maurer
parent 189996cf4a
commit 351b913d1e
1 changed files with 6 additions and 7 deletions

View File

@ -137,13 +137,12 @@ impl Decoder {
check_ca_header::<PxarEntry>(&head, PXAR_ENTRY)?; check_ca_header::<PxarEntry>(&head, PXAR_ENTRY)?;
let entry: PxarEntry = self.inner.read_item()?; let entry: PxarEntry = self.inner.read_item()?;
let (header, xattr) = self.inner.read_attributes()?; let (header, xattr) = self.inner.read_attributes()?;
let (size, payload_offset) = match header.htype { let (size, payload_offset, target) = match header.htype {
PXAR_PAYLOAD => (header.size - HEADER_SIZE, Some(self.seek(SeekFrom::Current(0))?)), PXAR_PAYLOAD =>
_ => (0, None), (header.size - HEADER_SIZE, Some(self.seek(SeekFrom::Current(0))?), None),
}; PXAR_SYMLINK =>
let target = match header.htype { (header.size - HEADER_SIZE, None, Some(self.inner.read_link(header.size)?)),
PXAR_SYMLINK => Some(self.inner.read_link(header.size)?), _ => (0, None, None),
_ => None,
}; };
Ok(DirectoryEntry { Ok(DirectoryEntry {