]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fd-util: Add extra shortcut to path_is_root_at()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 13 Jun 2023 13:54:21 +0000 (15:54 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 13 Jun 2023 14:13:43 +0000 (16:13 +0200)
src/basic/fd-util.c

index ecbe58a9f83fca94233ae2932f33e0799af2c428..d9ef7ec9326dd0bd49f73e6eeaeb17e045386a4d 100644 (file)
@@ -900,9 +900,9 @@ int path_is_root_at(int dir_fd, const char *path) {
         assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
 
         if (!isempty(path)) {
-                fd = openat(dir_fd, path, O_PATH|O_CLOEXEC);
+                fd = openat(dir_fd, path, O_PATH|O_DIRECTORY|O_CLOEXEC);
                 if (fd < 0)
-                        return -errno;
+                        return errno == ENOTDIR ? false : -errno;
 
                 dir_fd = fd;
         }