diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-02-17 07:18:42 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-02-17 07:18:42 +0900 |
commit | ea61e2e9bd435eba9faf114757a531b375869830 (patch) | |
tree | 5b99587d86fcb04f53f40f911c61ee613724a903 /src/basic | |
parent | ca8b1d68c56129180c4c41c0485cef8ef8df62c8 (diff) | |
download | systemd-ea61e2e9bd435eba9faf114757a531b375869830.tar.gz |
fd-util: introduce a simple helper to check a file descriptor has O_PATH
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/fd-util.c | 12 | ||||
-rw-r--r-- | src/basic/fd-util.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index 4d6d01cd99..430db0c879 100644 --- a/src/basic/fd-util.c +++ b/src/basic/fd-util.c @@ -808,6 +808,18 @@ int fd_reopen_condition( return new_fd; } +int fd_is_opath(int fd) { + int r; + + assert(fd >= 0); + + r = fcntl(fd, F_GETFL); + if (r < 0) + return -errno; + + return FLAGS_SET(r, O_PATH); +} + int read_nr_open(void) { _cleanup_free_ char *nr_open = NULL; int r; diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h index 952afdd64f..f5357860f5 100644 --- a/src/basic/fd-util.h +++ b/src/basic/fd-util.h @@ -104,6 +104,7 @@ static inline int make_null_stdio(void) { int fd_reopen(int fd, int flags); int fd_reopen_condition(int fd, int flags, int mask, int *ret_new_fd); +int fd_is_opath(int fd); int read_nr_open(void); int fd_get_diskseq(int fd, uint64_t *ret); |