chiark / gitweb /
path-util: don't eat up ENOENT in path_is_mount_point()
authorLennart Poettering <lennart@poettering.net>
Sun, 5 Apr 2015 09:26:58 +0000 (11:26 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 06:50:10 +0000 (07:50 +0100)
There's no reason to eat up ENOENT, it should be OK to simply report the
error back.

src/shared/path-util.c

index 8487d26fca5bb0566afff21ac000430a81751779..a01475a6144e94e40b712bafe52ea96ca868a6d6 100644 (file)
@@ -496,8 +496,6 @@ int fd_is_mount_point(int fd) {
                          * mount point), otherwise fallback to the
                          * traditional stat() logic */
                         nosupp = true;
-                else if (errno == ENOENT)
-                        return 0;
                 else
                         return -errno;
         }
@@ -537,12 +535,8 @@ int fd_is_mount_point(int fd) {
 
 fallback:
         r = fstatat(fd, "", &a, AT_EMPTY_PATH);
-        if (r < 0) {
-                if (errno == ENOENT)
-                        return 0;
-
+        if (r < 0)
                 return -errno;
-        }
 
         r = fstatat(fd, "..", &b, 0);
         if (r < 0)
@@ -559,18 +553,15 @@ fallback:
 
 int path_is_mount_point(const char *t, bool allow_symlink) {
         _cleanup_close_ int fd = -1;
+
         assert(t);
 
         if (path_equal(t, "/"))
                 return 1;
 
         fd = openat(AT_FDCWD, t, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|(allow_symlink ? 0 : O_PATH));
-        if (fd < 0) {
-                if (errno == ENOENT)
-                        return 0;
-
+        if (fd < 0)
                 return -errno;
-        }
 
         return fd_is_mount_point(fd);
 }