From a06ef0192d9e7c5172baa8b719197ea53d6357e2 Mon Sep 17 00:00:00 2001 From: Daniel Hammer Date: Sat, 8 Aug 2026 14:42:42 +0200 Subject: [PATCH] fix: ramdisk - dereference symlinks, they pack as zero-byte files Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01NQRTGoYgnZQsh7uCh6Jsxm --- scripts/mkramdisk.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/mkramdisk.sh b/scripts/mkramdisk.sh index a02c962..62fc9be 100755 --- a/scripts/mkramdisk.sh +++ b/scripts/mkramdisk.sh @@ -14,7 +14,18 @@ if [ ! -d "$INPUT_DIR" ]; then echo "MontaukOS ramdisk" > "$INPUT_DIR/readme.txt" fi -# Create USTAR tar archive -tar --format=ustar -cf "$OUTPUT_PATH" -C "$INPUT_DIR" . +# Create USTAR tar archive. +# +# -h (dereference) is NOT optional: Fs/Ramdisk.cpp only recognises typeflag +# '5' (directory), so a symlink entry unpacks as a zero-length regular file -- +# silently, with no error anywhere. A staged tree containing symlinks would +# ship empty files. Copying the target in is the only faithful representation. +tar --format=ustar -h -cf "$OUTPUT_PATH" -C "$INPUT_DIR" . + +if tar -tvf "$OUTPUT_PATH" | grep -q '^l'; then + echo "mkramdisk: ERROR: symlink survived into $OUTPUT_PATH (would unpack as an empty file)" >&2 + tar -tvf "$OUTPUT_PATH" | grep '^l' >&2 + exit 1 +fi echo "mkramdisk: created $OUTPUT_PATH from $INPUT_DIR ($(wc -c < "$OUTPUT_PATH") bytes)"