50 lines
1.5 KiB
Bash
Executable File
50 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Builds the k-os disk: one ext4 filesystem holding every program init may
|
|
# start, in /bin. 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}/bin/${dst}"
|
|
fi
|
|
}
|
|
|
|
mkdir -p "${ROOT}/bin"
|
|
copy echo echo
|
|
copy snake snake
|
|
copy display-qemu display
|
|
copy input-qemu input
|
|
copy log-server log
|
|
copy permission-manager permission
|
|
copy session-server session
|
|
copy terminal-server terminal
|
|
copy shell shell
|
|
copy cat cat
|
|
copy ls ls
|
|
copy sleep sleep
|
|
# Files that ship on the disk, programs' manifests among them.
|
|
cp -r disk/. "${ROOT}/"
|
|
# Only the test image: its presence makes init run the self-test.
|
|
if [ -n "${SMPTEST:-}" ]; then
|
|
copy smptest smptest
|
|
copy spawntest spawntest
|
|
copy hello hello
|
|
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}" "${ROOT}/bin"
|