]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
generic/791: don't run if kernel misses FANOTIFY
authorAndrey Albershteyn <aalbersh@kernel.org>
Thu, 21 May 2026 08:26:46 +0000 (10:26 +0200)
committerZorro Lang <zlang@kernel.org>
Fri, 29 May 2026 07:22:08 +0000 (15:22 +0800)
If FANOTIFY=no in the kernel, then fs-monitor will fail to start. Fix
fs-monitor error codes to detect and skip the test on "Function not
implemented" code.

Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
src/fs-monitor.c
tests/generic/791

index 0cf09677a3efda0e03e4a76cde430737b02fa363..dd91a5d7f623211204a9a86b5b5b194806f6fe15 100644 (file)
@@ -117,6 +117,8 @@ next_event:
 int main(int argc, char **argv)
 {
        int fd;
+       int opt;
+       int check = 0;
 
        char buffer[BUFSIZ];
 
@@ -125,14 +127,29 @@ int main(int argc, char **argv)
                return 1;
        }
 
+       while ((opt = getopt(argc, argv, "c")) != -1) {
+               switch (opt) {
+               case 'c':
+                       check = 1;
+                       break;
+               default:
+                       fprintf(stderr, "Usage: %s [-c] path\n",
+                               argv[0]);
+                       exit(EXIT_FAILURE);
+               }
+       }
+
        fd = fanotify_init(FAN_CLASS_NOTIF|FAN_REPORT_FID, O_RDONLY);
+       if (check)
+               exit(fd < 0);
+
        if (fd < 0) {
                perror("fanotify_init");
                errx(1, "fanotify_init");
        }
 
        if (fanotify_mark(fd, FAN_MARK_ADD|FAN_MARK_FILESYSTEM,
-                         FAN_FS_ERROR, AT_FDCWD, argv[1])) {
+                         FAN_FS_ERROR, AT_FDCWD, argv[optind])) {
                perror("fanotify_mark");
                errx(1, "fanotify_mark");
        }
index 90242292cba2ae532a1bdc24a979679b8d226ad1..edefbb7767c38c044a6dbcdeb219b685cbefda2e 100755 (executable)
@@ -65,6 +65,9 @@ _dmerror_mount >> $seqres.full 2>&1
 
 test $FSTYP = xfs && _xfs_force_bdev data $SCRATCH_MNT
 
+$here/src/fs-monitor -c $SCRATCH_MNT &> /dev/null || \
+               _notrun "fanotify too old"
+
 # Write a file with 4 file blocks worth of data, figure out the LBA to target
 victim=$SCRATCH_MNT/a
 file_blksz=$(_get_file_block_size $SCRATCH_MNT)