summaryrefslogtreecommitdiff
path: root/hurd/hurd
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2016-06-04 21:53:28 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2016-06-04 21:53:28 +0200
commit792f37ecfbd2cde23c07a45a3e15f5a7e37c1d19 (patch)
tree32408b4b29430e1f5419e4fbe5dc8f50ecdb7771 /hurd/hurd
parent68c5a582545cbb54d7f2130360eb2cbf423b2662 (diff)
parentca3b3d90b9b2992c4d8dd607089ef00784d72074 (diff)
Merge branch 't/faccessat' into refs/top-bases/tschwinge/Roger_Whittaker
Diffstat (limited to 'hurd/hurd')
-rw-r--r--hurd/hurd/fd.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/hurd/hurd/fd.h b/hurd/hurd/fd.h
index 6d4b637582..a8b00e7085 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. */
@@ -274,6 +275,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.