test-scripts: Updated xattr-test.sh script
authorAnuraag Reddy Patllollu <apatllollu@cs.stonybrook.edu>
Sat, 28 Sep 2024 03:48:42 +0000 (23:48 -0400)
committerAnuraag Reddy Patllollu <apatllollu@cs.stonybrook.edu>
Sat, 28 Sep 2024 03:48:42 +0000 (23:48 -0400)
The script now has proper documentation before each shell command
and the lower directory is mounted and remounted too.

test-scripts/xattr_test.sh
xattr_test.sh [deleted file]

index f4d4e8c184b4876b3b0d60d1dbe3f2aeb0146dcb..0e1e114e0ffe37fc5a334785061a683ae0a54cdc 100755 (executable)
@@ -1,35 +1,47 @@
 #!/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 $?
diff --git a/xattr_test.sh b/xattr_test.sh
deleted file mode 100755 (executable)
index c7dc80c..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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