48 lines
1.5 KiB
Bash
Executable File
48 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Builds the k-os disk: one ext4 filesystem holding every program init may
|
|
# start. Init and storage themselves are packed into the kernel image.
|
|
set -euo pipefail
|
|
|
|
IMG="${IMG:-boot.img}"
|
|
SIZE="${SIZE:-16M}"
|
|
TARGET="riscv64gc-unknown-none-elf"
|
|
BUILD_DIR="target/${TARGET}/release"
|
|
# What the storage server's ext4 driver does not maintain, switched off so it
|
|
# can write to the disk (see storage-server's tests/ext4_real.rs).
|
|
FEATURES="^has_journal,^metadata_csum,^64bit,^dir_index,^huge_file,^orphan_file,^metadata_csum_seed"
|
|
|
|
ROOT="$(mktemp -d)"
|
|
trap 'rm -rf "${ROOT}"' EXIT
|
|
|
|
copy() {
|
|
local src="$1" dst="$2"
|
|
if [ -f "${BUILD_DIR}/${src}" ]; then
|
|
cp "${BUILD_DIR}/${src}" "${ROOT}/${dst}"
|
|
fi
|
|
}
|
|
|
|
copy echo "echo.elf"
|
|
copy snake "snake.elf"
|
|
copy display-qemu "display.elf"
|
|
copy input-qemu "input.elf"
|
|
copy log-server "log.elf"
|
|
copy permission-manager "permis.elf"
|
|
copy session-server "session.elf"
|
|
copy terminal-server "terminal.elf"
|
|
copy shell "shell.elf"
|
|
copy cat "cat.elf"
|
|
copy ls "ls.elf"
|
|
# Files that ship on the disk.
|
|
cp -r disk/. "${ROOT}/"
|
|
# Only the test image: its presence makes init run the self-test.
|
|
if [ -n "${SMPTEST:-}" ]; then
|
|
copy smptest "smptest.elf"
|
|
copy spawntest "spawntst.elf"
|
|
copy hello "hello.elf"
|
|
fi
|
|
|
|
rm -f "${IMG}"
|
|
mkfs.ext4 -q -F -b 4096 -L k-os -O "${FEATURES}" -d "${ROOT}" "${IMG}" "${SIZE}"
|
|
echo "=== ${IMG}: ext4, ${SIZE} ==="
|
|
ls -1 "${ROOT}"
|