diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-06-01 14:26:35 +0200 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-06-06 14:42:03 +0200 |
commit | 8a65b0b2c945df0c8001299eff7b293efbd55995 (patch) | |
tree | eec6287c13aa20706371be7b02291fcc3d0e900f /src/basic/fd-util.h | |
parent | btrfs-util: Add btrfs_is_subvol_at() (diff) | |
download | systemd-8a65b0b2c945df0c8001299eff7b293efbd55995.tar.xz systemd-8a65b0b2c945df0c8001299eff7b293efbd55995.zip |
fd-util: Add path_is_root_at()
A generalization of dir_fd_is_root() that allows passing a path
component.
Diffstat (limited to 'src/basic/fd-util.h')
-rw-r--r-- | src/basic/fd-util.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h index 2f59e334c5..c870a1b899 100644 --- a/src/basic/fd-util.h +++ b/src/basic/fd-util.h @@ -101,9 +101,12 @@ int fd_is_opath(int fd); int read_nr_open(void); int fd_get_diskseq(int fd, uint64_t *ret); -int dir_fd_is_root(int dir_fd); +int path_is_root_at(int dir_fd, const char *path); +static inline int dir_fd_is_root(int dir_fd) { + return path_is_root_at(dir_fd, NULL); +} static inline int dir_fd_is_root_or_cwd(int dir_fd) { - return dir_fd == AT_FDCWD ? true : dir_fd_is_root(dir_fd); + return dir_fd == AT_FDCWD ? true : path_is_root_at(dir_fd, NULL); } /* The maximum length a buffer for a /proc/self/fd/<fd> path needs */ |