diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-11-29 15:30:55 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-11-29 15:33:51 +0100 |
commit | f1cab3d6dcb882f4537891e465dc2f080301015e (patch) | |
tree | f26a14d1667bb698a8390a69570ffcf4c1c9ef4f /src/shared/btrfs-util.c | |
parent | fd-util: add new helper fd_reopen_conditional() (diff) | |
download | systemd-f1cab3d6dcb882f4537891e465dc2f080301015e.tar.xz systemd-f1cab3d6dcb882f4537891e465dc2f080301015e.zip |
btrfs-util: convert to fd_reopen_condition()
Diffstat (limited to '')
-rw-r--r-- | src/shared/btrfs-util.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c index 4574a7899e..41e01e0b10 100644 --- a/src/shared/btrfs-util.c +++ b/src/shared/btrfs-util.c @@ -107,19 +107,11 @@ int btrfs_subvol_make_fd(int fd, const char *subvolume) { if (r < 0) return r; - r = fcntl(fd, F_GETFL); - if (r < 0) - return -errno; - if (FLAGS_SET(r, O_PATH)) { - /* An O_PATH fd was specified, let's convert here to a proper one, as btrfs ioctl's can't deal with - * O_PATH. */ - - real_fd = fd_reopen(fd, O_RDONLY|O_CLOEXEC|O_DIRECTORY); - if (real_fd < 0) - return real_fd; - - fd = real_fd; - } + /* If an O_PATH fd was specified, let's convert here to a proper one, as btrfs ioctl's can't deal + * with O_PATH. */ + fd = fd_reopen_condition(fd, O_RDONLY|O_CLOEXEC|O_DIRECTORY, O_PATH|O_DIRECTORY, &real_fd); + if (fd < 0) + return fd; strncpy(args.name, subvolume, sizeof(args.name)-1); |