Merge pull request #26949 from DaanDeMeyer/xopenat-reopen

loop-util: Add loop_device_make_by_path_at()
This commit is contained in:
Luca Boccassi
2023-03-23 23:08:21 +00:00
committed by GitHub
4 changed files with 35 additions and 8 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) {