DragonFlyBSD Kernel Audit
DF-2568 / setup.sh
← back to finding ↓ download raw
#!/bin/sh
# setup.sh (run as ROOT) - prepare an isolated hammer2 filesystem for racing.
# Creates a 2G vnode-backed hammer2 volume, newfs's it, mounts at /h2mnt,
# and makes /h2mnt/race writable by the unprivileged user (maxx).
set -e

IMG=/root/h2test.img
DEV=vn1
MNT=/h2mnt
RACEUSER=maxx

# Clean up any prior mount/config
umount "$MNT" 2>/dev/null || true
vnconfig -u "$DEV" 2>/dev/null || true
rm -f "$IMG"

# Create backing file and vnode device
dd if=/dev/zero of="$IMG" bs=1m count=2048 status=none
vnconfig -c "$DEV" "$IMG"

# newfs_hammer2 with a label
newfs_hammer2 -L TEST "/dev/$DEV" >/dev/null 2>&1

# Mount
mkdir -p "$MNT"
mount_hammer2 "$DEV@TEST" "$MNT"

# Race dir owned by the unprivileged user
mkdir -p "$MNT/race"
chown "$RACEUSER":"$RACEUSER" "$MNT/race"
chmod 0777 "$MNT/race"

echo "SETUP_OK"
df -h "$MNT"