#!/bin/bash
-# XXX explain purpose of script
+# Script to demonstrate extended attributes (EAs) in wrapfs,
+# and then unmounting and remounting to check EA persistence.
-echo "XXX"
-mount -t wrapfs lower upper || exit $?
+LOWER="/mnt/lower"
+UPPER="/mnt/upper"
-echo "XXX"
-touch upper/foo
+echo "Mount /dev/sdb1 on lower"
+mount -t ext4 /dev/sdb1 "$LOWER" || exit $?
+
+echo "Mounting wrapfs lower=$LOWER, upper=$UPPER"
+mount -t wrapfs "$LOWER" "$UPPER" || exit $?
+
+echo "Creating file foo in upper"
+touch "$UPPER/foo" || exit $?
echo "set EA user.test someval"
-setfattr -n user.test -v someval upper/foo
+setfattr -n user.test -v someval "$UPPER/foo" || exit $?
echo "set EA trusted.trusttest trustval"
-setfattr -n trusted.trusttest -v trustedval upper/foo
+setfattr -n trusted.trusttest -v trustedval "$UPPER/foo" || exit $?
echo "list EA"
-getfattr -d upper/foo
-getfattr -d -m '^trusted\.' upper/foo
+getfattr -d "$UPPER/foo" || exit $?
+getfattr -d -m '^trusted\.' "$UPPER/foo" || exit $?
echo "Unmount the upper directory"
-umount upper
+umount "$UPPER" || exit $?
+
+echo "Unmount the lower directory"
+umount "$LOWER" || exit $?
-# XXX: TODO: unmount lower, then remount lower
+echo "Remount the lower directory"
+mount -t ext4 /dev/sdb1 "$LOWER" || exit $?
echo "Remount the upper directory"
-mount -t wrapfs lower upper
+mount -t wrapfs "$LOWER" "$UPPER" || exit $?
echo "list EA"
-getfattr -d upper/foo
-getfattr -d -m '^trusted\.' upper/foo
+getfattr -d "$UPPER/foo" || exit $?
+getfattr -d -m '^trusted\.' "$UPPER/foo" || exit $?
echo "cleanup"
-rm -rf upper/foo
-umount upper
+rm -rf "$UPPER/foo" || exit $?
+umount "$UPPER" || exit $?
+umount "$LOWER" || exit $?
+++ /dev/null
-#!/bin/bash
-
-mount -t wrapfs lower upper
-touch upper/foo
-echo -e "set EA user.test someval"
-setfattr -n user.test -v someval upper/foo
-echo -e "\nset EA trusted.trusttest trustval"
-setfattr -n trusted.trusttest -v trustedval upper/foo
-echo -e "\nlist EA"
-getfattr -d upper/foo
-getfattr -d -m '^trusted\.' upper/foo
-echo -e "\nUnmount the upper directory"
-umount upper
-echo -e "\nRemount the upper directory"
-mount -t wrapfs lower upper
-echo -e "\nlist EA"
-getfattr -d upper/foo
-getfattr -d -m '^trusted\.' upper/foo
-rm -rf upper/foo
-umount upper