diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-11-01 13:37:31 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-11-01 13:37:31 +0100 |
commit | bc7ec3a7fb632b685d9fe2dbd12be4be4d4fde82 (patch) | |
tree | 6296ee3440a467012133e2d974e586f5b70f4c89 /hurd/hurd | |
parent | 12bdb857648466973b2695622b72cbc3d5ac1430 (diff) | |
parent | 258b100bf44ec5255ef594d6560ca3da03004577 (diff) |
Merge commit 'refs/top-bases/t/extern_inline' into t/extern_inline
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 ac253fe7df..40b965c036 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. */ @@ -276,6 +277,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. |