1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 09:21:26 +03:00

path-util: don't eat up ENOENT in path_is_mount_point()

There's no reason to eat up ENOENT, it should be OK to simply report the
error back.
This commit is contained in:
Lennart Poettering 2015-04-05 11:26:58 +02:00
parent 05d990efd7
commit e792e890fe

View File

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