summaryrefslogtreecommitdiff
path: root/src/core/namespace.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-03-07 11:19:35 +0100
committerLennart Poettering <lennart@poettering.net>2023-03-09 21:56:42 +0100
commit117e7034470251a7da4061c83cb49df32c0defe0 (patch)
tree21791eea4fdbbe73e1bee7dec824a52d5c0fd447 /src/core/namespace.c
parentde1461ac5e85049cfa14bee04363ae4547d1fdb1 (diff)
downloadsystemd-117e7034470251a7da4061c83cb49df32c0defe0.tar.gz
mountpoint-util: generalize mount_option_supported()
Diffstat (limited to 'src/core/namespace.c')
-rw-r--r--src/core/namespace.c26
1 files changed, 3 insertions, 23 deletions
diff --git a/src/core/namespace.c b/src/core/namespace.c
index 3b0896039b..252f5c9d2c 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -1099,27 +1099,6 @@ static int mount_bind_sysfs(const MountEntry *m) {
return 1;
}
-static bool mount_option_supported(const char *fstype, const char *key, const char *value) {
- _cleanup_close_ int fd = -EBADF;
- int r;
-
- /* This function assumes support by default. Only if the fsconfig() call fails with -EINVAL/-EOPNOTSUPP
- * will it report that the option/value is not supported. */
-
- fd = fsopen(fstype, FSOPEN_CLOEXEC);
- if (fd < 0) {
- if (errno != ENOSYS)
- log_debug_errno(errno, "Failed to open superblock context for '%s': %m", fstype);
- return true; /* If fsopen() fails for whatever reason, assume the value is supported. */
- }
-
- r = fsconfig(fd, FSCONFIG_SET_STRING, key, value, 0);
- if (r < 0 && !IN_SET(errno, EINVAL, EOPNOTSUPP, ENOSYS))
- log_debug_errno(errno, "Failed to set '%s=%s' on '%s' superblock context: %m", key, value, fstype);
-
- return r >= 0 || !IN_SET(errno, EINVAL, EOPNOTSUPP);
-}
-
static int mount_procfs(const MountEntry *m, const NamespaceInfo *ns_info) {
_cleanup_free_ char *opts = NULL;
const char *entry_path;
@@ -1147,13 +1126,14 @@ static int mount_procfs(const MountEntry *m, const NamespaceInfo *ns_info) {
* fsopen()/fsconfig() was also backported on some distros which allows us to detect
* hidepid=/subset= support in even more scenarios. */
- if (mount_option_supported("proc", "hidepid", hpv)) {
+ if (mount_option_supported("proc", "hidepid", hpv) != 0) {
opts = strjoin("hidepid=", hpv);
if (!opts)
return -ENOMEM;
}
- if (ns_info->proc_subset == PROC_SUBSET_PID && mount_option_supported("proc", "subset", "pid"))
+ if (ns_info->proc_subset == PROC_SUBSET_PID &&
+ mount_option_supported("proc", "subset", "pid") != 0)
if (!strextend_with_separator(&opts, ",", "subset=pid"))
return -ENOMEM;
}