]> git.proxmox.com Git - pxar.git/commitdiff
encoder: use relative hardlink offsets
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 5 Jun 2020 14:26:13 +0000 (16:26 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 5 Jun 2020 14:26:13 +0000 (16:26 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/encoder/mod.rs

index 73ee887b219981b392426c02f1dd5f71b9d1dd40..1189d0bbadd40b7f83cdce76291ee62a3fa7991f 100644 (file)
@@ -364,10 +364,15 @@ impl<'a, T: SeqWrite + 'a> EncoderImpl<'a, T> {
         &mut self,
         file_name: &Path,
         target: &Path,
-        offset: LinkOffset,
+        target_offset: LinkOffset,
     ) -> io::Result<()> {
+        let current_offset = seq_write_position(&mut self.output).await?;
+        if current_offset <= target_offset.0 {
+            io_bail!("invalid hardlink offset, can only point to prior files");
+        }
+
         let hardlink = format::Hardlink {
-            offset: offset.0,
+            offset: current_offset - target_offset.0,
             data: target.as_os_str().as_bytes().to_vec(),
         };
         let hardlink = unsafe {