#!/bin/sh
set -e
set -x
TDIR=`mktemp -d test.XXXXXXXXX`
mkdir ${TDIR}/somedir
truncate -s 1024k ${TDIR}/somedir/somefile
chmod 000 ${TDIR}/somedir/somefile
makefs ${TDIR}.ufs ${TDIR}
rm -rf ${TDIR}
mdu=`sudo mdconfig -a -f ${TDIR}.ufs`
sudo mount -o ro /dev/${mdu} /mnt
ls /mnt/somedir/somefile
sudo umount /mnt
sudo mdconfig -d -u ${mdu}
rm ${TDIR}.ufs