]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fileio: add shortcut for xopendirat() when called in opendir() compatible mode
authorLennart Poettering <lennart@poettering.net>
Fri, 1 Oct 2021 13:47:53 +0000 (15:47 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 7 Oct 2021 09:58:26 +0000 (11:58 +0200)
src/basic/fileio.c

index cced1dd564b26bf02e28bf4097f5c0fdf6b96540..0a483854f2a4ab62dd7e20002314922f2eb74a75 100644 (file)
@@ -928,6 +928,9 @@ DIR *xopendirat(int fd, const char *name, int flags) {
 
         assert(!(flags & O_CREAT));
 
+        if (fd == AT_FDCWD && flags == 0)
+                return opendir(name);
+
         nfd = openat(fd, name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|flags, 0);
         if (nfd < 0)
                 return NULL;