Files
claude-os/scripts/gen_initrd.sh
AI a6e6e3d8ca feat: hello-world user-mode app loaded from initrd via VFS
- Created apps/hello-world/hello-world.S: AT&T assembly user program that
  calls SYS_WRITE to print 'Hello, World' then SYS_EXIT(0)
- Created apps/user.ld: linker script for user apps at 0x08048000
- Created scripts/build_apps.sh: builds each app dir into flat binary
- Updated CMakeLists.txt: added apps build target in ISO pipeline
- Updated gen_initrd.sh: packs built binaries from build/apps_bin/
- Updated kernel.c: replaced inline machine code with VFS-based loading
  of hello-world from /initrd/hello-world via cpio_find()

Verified: hello-world binary (49 bytes) loads from CPIO initrd,
prints 'Hello, World', and exits with code 0.
2026-02-23 12:30:36 +00:00

17 lines
521 B
Bash
Executable File

#!/bin/sh
# Generate CPIO initial ramdisk from built application binaries.
# Usage: gen_initrd.sh <binaries_dir> <output_file>
# Packs all files in <binaries_dir> into a newc-format CPIO archive.
set -e
BIN_DIR="$1"
OUTPUT="$2"
# Ensure output directory exists
mkdir -p "$(dirname "$OUTPUT")"
cd "$BIN_DIR"
# Only pack actual binary files (no .o, .elf intermediates)
find . -maxdepth 1 -type f ! -name '*.o' ! -name '*.elf' | cpio -o -H newc > "$OUTPUT" 2>/dev/null
echo "Generated initrd: $(wc -c < "$OUTPUT") bytes"