aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@suse.de>2021-12-03 13:44:34 +0100
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>2021-12-10 08:06:40 -0500
commit0af11c5ea5018a3e1049a2207a9a671049651876 (patch)
tree8e4c8d2d4853d48ed583561266120f375578b007
parent3326e4c957d0499495d9e91182fc574b960ace86 (diff)
downloaddracut-0af11c5ea5018a3e1049a2207a9a671049651876.tar.gz
fix(cpio): write zeros instead of seek for padding and alignment
This is a workaround for GRUB2's Btrfs implementation, which doesn't correctly handle gaps between extents. A fix has already been proposed upstream via https://lists.gnu.org/archive/html/grub-devel/2021-10/msg00206.html Given that this bug is severe, it makes sense to include this minimal workaround. Signed-off-by: David Disseldorp <ddiss@suse.de>
-rw-r--r--src/dracut-cpio/src/main.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/dracut-cpio/src/main.rs b/src/dracut-cpio/src/main.rs
index f1562e55..1c622c40 100644
--- a/src/dracut-cpio/src/main.rs
+++ b/src/dracut-cpio/src/main.rs
@@ -255,7 +255,10 @@ impl ArchiveState {
self.off += fname.len() as u64;
// +1 as padding starts after fname nulterm
let seeklen = 1 + archive_padlen(self.off + 1, 4);
- writer.seek(io::SeekFrom::Current(seeklen as i64))?;
+ {
+ let z = vec![0u8; seeklen.try_into().unwrap()];
+ writer.write_all(&z)?;
+ }
self.off += seeklen;
}
*mapped_ino = Some((*hl).mapped_ino);
@@ -469,7 +472,10 @@ fn archive_path<W: Seek + Write>(
let padding_len = archive_padlen(state.off + seek_len as u64, 4);
seek_len += padding_len as i64;
}
- writer.seek(io::SeekFrom::Current(seek_len))?;
+ {
+ let z = vec![0u8; seek_len.try_into().unwrap()];
+ writer.write_all(&z)?;
+ }
state.off += seek_len as u64;
// io::copy() can reflink: https://github.com/rust-lang/rust/pull/75272 \o/