diff options
Diffstat (limited to 'src/basic/fs-util.h')
-rw-r--r-- | src/basic/fs-util.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h index 5ee7417eeb..b2c0107990 100644 --- a/src/basic/fs-util.h +++ b/src/basic/fs-util.h @@ -163,3 +163,21 @@ static inline int xopenat_lock(int dir_fd, const char *path, int open_flags, Loc int link_fd(int fd, int newdirfd, const char *newpath); int linkat_replace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath); + +static inline int at_flags_normalize_nofollow(int flags) { + if (FLAGS_SET(flags, AT_SYMLINK_FOLLOW)) { + assert(!FLAGS_SET(flags, AT_SYMLINK_NOFOLLOW)); + flags &= ~AT_SYMLINK_FOLLOW; + } else + flags |= AT_SYMLINK_NOFOLLOW; + return flags; +} + +static inline int at_flags_normalize_follow(int flags) { + if (FLAGS_SET(flags, AT_SYMLINK_NOFOLLOW)) { + assert(!FLAGS_SET(flags, AT_SYMLINK_FOLLOW)); + flags &= ~AT_SYMLINK_NOFOLLOW; + } else + flags |= AT_SYMLINK_FOLLOW; + return flags; +} |