]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_healer_start: check listmount when doing a --check
authorDarrick J. Wong <djwong@kernel.org>
Thu, 11 Jun 2026 14:05:37 +0000 (07:05 -0700)
committerAndrey Albershteyn <aalbersh@kernel.org>
Wed, 17 Jun 2026 10:49:27 +0000 (12:49 +0200)
Codex noticed that xfs_healer_start doesn't try out listmount() when
it's doing a --check.  Because systemd uses --check for an
ExecCondition, if it's run on a pre-6.9 kernel (very unlikely) then the
service will fail instead of simply not being run.  Fix that.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
healer/xfs_healer_start.c

index 19fd132808611cbedd2de7ec0ca1f818ffc3a778..6bf2b9bf854e6d9c9b4af7d6e7bcbb9845107e13 100644 (file)
@@ -157,6 +157,28 @@ handle_mount_event(
        }
 }
 
+/* Make sure listmount actually works so we can start up existing mounts */
+static int
+check_listmount(
+       int                     mnt_ns_fd)
+{
+       uint64_t                mnt_ids[1];
+       uint64_t                cursor = LISTMOUNT_INIT_CURSOR;
+       int                     ret;
+
+       ret = libfrog_listmount(LSMT_ROOT, mnt_ns_fd, &cursor, mnt_ids, 1);
+       if (ret >= 0)
+               return 0;
+
+       if (errno == ENOSYS)
+               fprintf(stderr, "%s\n",
+ _("This program requires the listmount system call."));
+       else
+               perror("listmount");
+
+       return -1;
+}
+
 #define NR_MNT_IDS             (32)
 
 /* Start healer services for existing XFS mounts. */
@@ -336,6 +358,10 @@ main(
        }
 
        if (support_check) {
+               ret = check_listmount(mnt_ns_fd);
+               if (ret)
+                       goto out;
+
                /*
                 * We're being run as an ExecCondition process and we've
                 * decided to start the main service.  There is no need to wait