From: Lennart Poettering Date: Mon, 5 Feb 2024 14:38:20 +0000 (+0100) Subject: mountpoint-util: add small helper that checks if a path is below the API VFS hierarchies X-Git-Tag: v256-rc1~961^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fb08bd5e3097ecd79def22872ef3c522d2a3114;p=thirdparty%2Fsystemd.git mountpoint-util: add small helper that checks if a path is below the API VFS hierarchies --- diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c index 0ff1ed60187..5f1887c6c96 100644 --- a/src/basic/mountpoint-util.c +++ b/src/basic/mountpoint-util.c @@ -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"); +} diff --git a/src/basic/mountpoint-util.h b/src/basic/mountpoint-util.h index 499403a4d89..b95d1985fa6 100644 --- a/src/basic/mountpoint-util.h +++ b/src/basic/mountpoint-util.h @@ -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); diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c index 1a9b99d7618..ca6d36e0549 100644 --- a/src/shutdown/umount.c +++ b/src/shutdown/umount.c @@ -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);