summaryrefslogtreecommitdiff
path: root/src/basic/fd-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-09-23 18:16:34 +0200
committerLennart Poettering <lennart@poettering.net>2020-09-23 18:20:38 +0200
commit8fe8f3aabad344b2a237f4ec022516fd835031c4 (patch)
tree68e31e8c7444937f9fdddfdd2d049f7db3d56ae0 /src/basic/fd-util.c
parente59d030ff8b3c6b250c87a6c7e07207bc637ab24 (diff)
downloadsystemd-8fe8f3aabad344b2a237f4ec022516fd835031c4.tar.gz
basic: update fd_get_path() to use proc_mounted() helper
We use it pretty much everywhere else, hence use it here too. This also changes the error generated from EOPNOTSUPP to ENOSYS, to match the other cases where we do such a check. One user checked for EOPNOTSUPP which is updated to check for ENOSYS instead.
Diffstat (limited to 'src/basic/fd-util.c')
-rw-r--r--src/basic/fd-util.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c
index 14b12b2706..56700bc057 100644
--- a/src/basic/fd-util.c
+++ b/src/basic/fd-util.c
@@ -385,11 +385,9 @@ int fd_get_path(int fd, char **ret) {
/* ENOENT can mean two things: that the fd does not exist or that /proc is not mounted. Let's make
* things debuggable and distinguish the two. */
- if (access("/proc/self/fd/", F_OK) < 0)
- /* /proc is not available or not set up properly, we're most likely in some chroot
- * environment. */
- return errno == ENOENT ? -EOPNOTSUPP : -errno;
-
+ if (proc_mounted() == 0)
+ return -ENOSYS; /* /proc is not available or not set up properly, we're most likely in some chroot
+ * environment. */
return -EBADF; /* The directory exists, hence it's the fd that doesn't. */
}