From 83772acf00186e845c7519a81541f2bc8081ea1a Mon Sep 17 00:00:00 2001 From: Jon Tourville Date: Wed, 3 May 2023 08:08:53 +0000 Subject: [PATCH] Check for newer mount options in regression test The mount options MS_LAZYTIME and MS_NOSYMFOLLOW were added in kernels 4.0 and 5.10, respectively. Update the mount test script and helper to skip testing those options if they are not available. Signed-off-by: Jon Tourville (cherry picked from commit 9a760def8d73f3af07d1a860d9c705e862681aac) Signed-off-by: Jon Tourville --- tests/regression/apparmor/Makefile | 3 +++ tests/regression/apparmor/mount.c | 6 ++++++ tests/regression/apparmor/mount.sh | 17 ++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/regression/apparmor/Makefile b/tests/regression/apparmor/Makefile index 882bf8384..871afd576 100644 --- a/tests/regression/apparmor/Makefile +++ b/tests/regression/apparmor/Makefile @@ -328,6 +328,9 @@ unix_fd_client: unix_fd_client.c unix_fd_common.o attach_disconnected: attach_disconnected.c unix_fd_common.o ${CC} ${CFLAGS} ${LDFLAGS} $^ -o $@ ${LDLIBS} +mount: mount.c + ${CC} ${CFLAGS} -std=gnu99 ${LDFLAGS} $^ -o $@ ${LDLIBS} + build-dep: @if [ `whoami` = "root" ] ;\ then \ diff --git a/tests/regression/apparmor/mount.c b/tests/regression/apparmor/mount.c index 2362d3c7c..73e771eec 100644 --- a/tests/regression/apparmor/mount.c +++ b/tests/regression/apparmor/mount.c @@ -56,8 +56,11 @@ static struct mnt_keyword_table mnt_opts_table[] = { { "nostrictatime", 0, MS_STRICTATIME }, /* kernel default atime */ { "strictatime", MS_STRICTATIME, 0 }, /* strict atime semantics */ +/* MS_LAZYTIME added in 4.0 kernel */ +#ifdef MS_LAZYTIME { "nolazytime", 0, MS_LAZYTIME }, { "lazytime", MS_LAZYTIME, 0 }, /* update {a,m,c}time on the in-memory inode only */ +#endif { "acl", MS_POSIXACL, 0 }, { "noacl", 0, MS_POSIXACL }, @@ -68,8 +71,11 @@ static struct mnt_keyword_table mnt_opts_table[] = { { "dirsync", MS_DIRSYNC, 0 }, /* synchronous directory modifications */ { "nodirsync", 0, MS_DIRSYNC }, +/* MS_NOSYMFOLLOW added in 5.10 kernel */ +#ifdef MS_NOSYMFOLLOW { "nosymfollow", MS_NOSYMFOLLOW, 0 }, { "symfollow", 0, MS_NOSYMFOLLOW }, +#endif { "bind", MS_BIND, 0 }, /* remount part of the tree elsewhere */ { "rbind", MS_BIND | MS_REC, 0 }, /* idem, plus mounted subtrees */ diff --git a/tests/regression/apparmor/mount.sh b/tests/regression/apparmor/mount.sh index b58462a49..c42838868 100755 --- a/tests/regression/apparmor/mount.sh +++ b/tests/regression/apparmor/mount.sh @@ -111,10 +111,14 @@ options=( "noiversion,iversion" "diratime,nodiratime" "nostrictatime,strictatime" - "nolazytime,lazytime" "norelatime,relatime" "nodirsync,dirsync" "noacl,acl" +) + +# Options added in newer kernels +new_options=( + "nolazytime,lazytime" "symfollow,nosymfollow" ) @@ -270,6 +274,17 @@ setup_mnt runchecktest "UMOUNT (unconfined)" pass umount ${loop_device} ${mount_point} remove_mnt +# Check mount options that may not be available on this kernel +for i in "${new_options[@]}"; do + default="${i%,*}" + if "$bin/mount" mount ${loop_device} ${mount_point} -o $default > /dev/null 2>&1; then + remove_mnt + options+=($i) + else + echo " not supported by kernel - skipping mount options=($i)," + fi +done + for i in "${options[@]}"; do default="${i%,*}" nondefault="${i#*,}"