fd-util: introduce a simple helper to check a file descriptor has O_PATH

This commit is contained in:
Yu Watanabe
2023-02-17 07:18:42 +09:00
parent ca8b1d68c5
commit ea61e2e9bd
2 changed files with 13 additions and 0 deletions
+12
View File
@@ -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;