fs-util: Allow xopenat() to reopen existing file descriptors

This commit is contained in:
Daan De Meyer
2023-03-23 17:31:55 +01:00
parent 1d5240cfaa
commit 06ca2db39d
2 changed files with 11 additions and 1 deletions
+5
View File
@@ -1104,6 +1104,11 @@ int xopenat(int dir_fd, const char *path, int flags, mode_t mode) {
assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
assert(path);
if (isempty(path)) {
assert(!FLAGS_SET(flags, O_CREAT|O_EXCL));
return fd_reopen(dir_fd, flags);
}
if (FLAGS_SET(flags, O_DIRECTORY|O_CREAT)) {
r = RET_NERRNO(mkdirat(dir_fd, path, mode));
if (r == -EEXIST) {