]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mountpoint-util: add small helper that checks if a path is below the API VFS hierarchies
authorLennart Poettering <lennart@poettering.net>
Mon, 5 Feb 2024 14:38:20 +0000 (15:38 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 6 Feb 2024 10:13:28 +0000 (11:13 +0100)
src/basic/mountpoint-util.c
src/basic/mountpoint-util.h
src/shutdown/umount.c

index 0ff1ed601878682d93a63d14af54823cf8291158..5f1887c6c964554d0b813c4168c94ffc451609e1 100644 (file)
@@ -785,3 +785,10 @@ int mount_option_supported(const char *fstype, const char *key, const char *valu
 
         return true; /* works! */
 }
+
+bool path_below_api_vfs(const char *p) {
+        assert(p);
+
+        /* API VFS are either directly mounted on any of these three paths, or below it. */
+        return PATH_STARTSWITH_SET(p, "/dev", "/sys", "/proc");
+}
index 499403a4d89494530b4ef591d110d1553adb3c65..b95d1985fa6f2a959bf18e20c327266c9ae6194b 100644 (file)
@@ -69,3 +69,5 @@ bool mount_new_api_supported(void);
 unsigned long ms_nosymfollow_supported(void);
 
 int mount_option_supported(const char *fstype, const char *key, const char *value);
+
+bool path_below_api_vfs(const char *p);
index 1a9b99d76184b32ee2328978515b997bfa4f05a5..ca6d36e0549eff3513394d2648ce8deade2d7abc 100644 (file)
@@ -95,7 +95,7 @@ int mount_points_list_get(const char *mountinfo, MountPoint **head) {
                  * we might lack the rights to unmount these things, hence don't bother. */
                 if (mount_point_is_api(path) ||
                     mount_point_ignore(path) ||
-                    PATH_STARTSWITH_SET(path, "/dev", "/sys", "/proc"))
+                    path_below_api_vfs(path))
                         continue;
 
                 is_api_vfs = fstype_is_api_vfs(fstype);