]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fs-util: simplify open_parent_at() a bit
authorMike Yuan <me@yhndnzj.com>
Fri, 14 Nov 2025 20:36:16 +0000 (21:36 +0100)
committerMike Yuan <me@yhndnzj.com>
Fri, 14 Nov 2025 20:51:28 +0000 (21:51 +0100)
Let's refrain from specifying any access mode when opening
a directory, which matches our usual style and allows us
to drop one condition.

src/basic/fs-util.c

index 8cbe29fc0f0876d8a914a05e735f7e1a0b8f5b58..893e95c3c126ee9639d1a0ccc2f799055a2b6adc 100644 (file)
@@ -868,10 +868,8 @@ int open_parent_at(int dir_fd, const char *path, int flags, mode_t mode) {
         /* Let's insist on O_DIRECTORY since the parent of a file or directory is a directory. Except if we open an
          * O_TMPFILE file, because in that case we are actually create a regular file below the parent directory. */
 
-        if (FLAGS_SET(flags, O_PATH))
+        if (!FLAGS_SET(flags, O_TMPFILE))
                 flags |= O_DIRECTORY;
-        else if (!FLAGS_SET(flags, O_TMPFILE))
-                flags |= O_DIRECTORY|O_RDONLY;
 
         return RET_NERRNO(openat(dir_fd, parent, flags, mode));
 }