diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-06-04 21:52:43 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-06-04 21:52:59 +0200 |
commit | ca3b3d90b9b2992c4d8dd607089ef00784d72074 (patch) | |
tree | 067a0422f4f538935f1db1da26c49313d61dd1c8 /hurd/hurd | |
parent | 58695b88a9deaecbcf7794760cc333177edaa2b4 (diff) |
Implement faccessat without AT_EACCESS flag
Diffstat (limited to 'hurd/hurd')
-rw-r--r-- | hurd/hurd/fd.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/hurd/hurd/fd.h b/hurd/hurd/fd.h index adb865a3b6..1f22153fd3 100644 --- a/hurd/hurd/fd.h +++ b/hurd/hurd/fd.h @@ -26,6 +26,7 @@ #include <hurd/hurd_types.h> #include <hurd/port.h> #include <sys/socket.h> +#include <fcntl.h> /* Structure representing a file descriptor. */ @@ -254,6 +255,26 @@ extern int _hurd_select (int nfds, struct pollfd *pollfds, const struct timespec *timeout, const sigset_t *sigmask); +/* Apply AT_FLAGS on FLAGS, in preparation for calling + __hurd_file_name_lookup. */ + +_HURD_FD_H_EXTERN_INLINE error_t +__hurd_at_flags (int *at_flags, int *flags) +{ + if ((*at_flags & AT_SYMLINK_FOLLOW) && (*at_flags & AT_SYMLINK_NOFOLLOW)) + return EINVAL; + + *flags |= (*at_flags & AT_SYMLINK_NOFOLLOW) ? O_NOLINK : 0; + *at_flags &= ~AT_SYMLINK_NOFOLLOW; + if (*at_flags & AT_SYMLINK_FOLLOW) + *flags &= ~O_NOLINK; + *at_flags &= ~AT_SYMLINK_FOLLOW; + if (*at_flags != 0) + return EINVAL; + + return 0; +} + /* Variant of file_name_lookup used in *at function implementations. AT_FLAGS may only contain AT_SYMLINK_FOLLOW or AT_SYMLINK_NOFOLLOW, which will remove and add O_NOLINK from FLAGS respectively. |