Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/scripts/ck_fat_boot_test.sh # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / scripts / ck_fat_boot_test.sh` 36 lines ยท 2369 bytes Raw Blame History 1 #!/bin/sh 2 # ck_fat_boot_test.sh -- host test of the AIENOS boot section: the EFI System 3 # Partition added in unused space (native/kernel/dev/gpt_add.c) and the FAT32 4 # volume holding \EFI\BOOT\BOOTX64.EFI (native/kernel/dev/fat_boot.c), with 5 # power cuts. See native/kernel/dev/tests/fat_boot_test.c. The volumes it 6 # writes are then read by outside tools as judges: fsck.fat must find nothing 7 # to repair and mtools must read back BOOTX64.EFI byte for byte. Hosted only. 8 # Ends with "AIENOS_FAT_BOOT: PASS" or "AIENOS_FAT_BOOT: FAIL ". 9 set -u 10 cd "$(dirname "$0")/.." 11 K=native/kernel 12 N=native 13 W=$(mktemp -d "${TMPDIR:-/tmp}/ck_fat_boot.XXXXXX") 14 trap 'rm -rf "$W"' EXIT 15 fail() { echo "AIENOS_FAT_BOOT: FAIL $*"; exit 1; } 16 CC=${HOSTCC:-cc} 17 $CC -std=c11 -D_DEFAULT_SOURCE -O2 -Wall -Wextra -Werror -I$K/dev -I$K/tools -I$N/disk -I$N/argus \ 18 -o "$W/test" $K/dev/tests/fat_boot_test.c $K/dev/fat_boot.c $K/dev/gpt_add.c $K/dev/disk_part.c \ 19 $K/tools/gpt_write.c $N/disk/disk.c $N/disk/disk_file.c $N/argus/sha256.c || fail "test does not build" 20 "$W/test" "$W" || fail "boot section checks" 21 FSCK=$(command -v fsck.fat || echo /usr/sbin/fsck.fat) 22 for v in part1 part2 part3; do 23 "$FSCK" -n "$W/$v.img" >"$W/$v.fsck" 2>&1 || { cat "$W/$v.fsck"; fail "fsck.fat finds faults in $v"; } 24 done 25 "$FSCK" -n -v "$W/part1.img" | grep -q "2 FATs, 32 bit entries" || fail "fsck.fat does not see FAT32" 26 export MTOOLS_SKIP_CHECK=1 27 mtype -i "$W/part1.img" ::/EFI/BOOT/BOOTX64.EFI >"$W/got1" || fail "mtools cannot read BOOTX64.EFI (part1)" 28 cmp -s "$W/got1" "$W/img1.bin" || fail "BOOTX64.EFI read by mtools differs from the image (part1)" 29 mtype -i "$W/part2.img" ::/EFI/BOOT/BOOTX64.EFI >"$W/got2" || fail "mtools cannot read BOOTX64.EFI (part2)" 30 cmp -s "$W/got2" "$W/img2.bin" || fail "BOOTX64.EFI read by mtools differs from the image (part2)" 31 mtype -i "$W/part3.img" ::/EFI/BOOT/BOOTX64.EFI >"$W/got3" || fail "mtools cannot read BOOTX64.EFI (part3)" 32 cmp -s "$W/got3" "$W/img1.bin" || fail "BOOTX64.EFI read by mtools differs from the image (part3)" 33 mdir -i "$W/part2.img" -b ::/EFI/BOOT | grep -qx "::/EFI/BOOT/BOOTX64.MAN" || fail "no BOOTX64.MAN" 34 [ "$(mdir -i "$W/part2.img" -b ::/EFI/BOOT | wc -l)" = 2 ] || fail "\\EFI\\BOOT holds more than the two files" 35 echo "note: fsck.fat clean on all three volumes; mtools reads BOOTX64.EFI exactly" 36 echo "AIENOS_FAT_BOOT: PASS"