From 04135b0208b9e9379d08e030821ac64668a1615f Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Sat, 14 May 2022 19:01:51 -0400 Subject: [PATCH] update idmap-test.sh --- idmap-tests/idmap-test.sh | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 idmap-tests/idmap-test.sh diff --git a/idmap-tests/idmap-test.sh b/idmap-tests/idmap-test.sh new file mode 100755 index 0000000..40359fb --- /dev/null +++ b/idmap-tests/idmap-test.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# XXX: fill in + +SCRATCH_DEV=/dev/sdb +SCRATCH_DIR=/n/scratch +LOWER_DIR=/n/lower +TMP_DIR=/n/tmp +FS_TYPE=ext4 + +function runcmd +{ + echo "CMD: $@" + sleep 0.25 + $@ + ret=$? + if test $ret -ne 0 && test "$1 $2 $3" != 'mount -t wrapfs'; then + echo "$0: exit code $ret" + exit $ret + fi +} + +dirs="$TMP_DIR $LOWER_DIR $SCRATCH_DIR" +for d in $dirs; do + echo checking dir $d + if cat /proc/mounts | grep $d; then + runcmd umount $d + fi +done + +runcmd mkfs -t $FS_TYPE $SCRATCH_DEV <<< y +runcmd mount $SCRATCH_DEV $SCRATCH_DIR +runcmd rm -rf $SCRATCH_DIR/* +runcmd touch $SCRATCH_DIR/root +runcmd touch $SCRATCH_DIR/ubuntu +runcmd chown ubuntu $SCRATCH_DIR/ubuntu +runcmd touch $SCRATCH_DIR/luser +runcmd chown luser $SCRATCH_DIR/luser +ls1=$(ls -l $SCRATCH_DIR) + +runcmd ./mount-idmapped --map-mount b:0:1000:1 --map-mount b:1000:1001:1 --map-mount b:1001:0:1 $SCRATCH_DIR $LOWER_DIR +runcmd mount -t wrapfs $LOWER_DIR $TMP_DIR +if test $ret != 32; then + echo wrapfs returned unexpected error: $ret +else + echo wrapfs returned correct error attempting to mount on idmapped mount +fi + +#ls2=$(ls -l $TMP_DIR) +#echo $ls1 +#echo $ls2 -- 2.34.1