diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-12-27 19:30:36 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-12-27 19:30:36 +0000 |
commit | 704e05ff173885df6d1d27f381604429f27fd4de (patch) | |
tree | fc67caec36bc5ed0c4190cafd38f69850a10ca0a /hurd/hurd/fd.h | |
parent | ecfe3e291f848cf598309d746619de62ea88fabb (diff) | |
parent | 3fcbb67b7949a8b362de5558bf1c6dd7ec5d21cf (diff) |
Merge branch 't/tls-threadvar' into refs/top-bases/t/ONSTACK
Diffstat (limited to 'hurd/hurd/fd.h')
-rw-r--r-- | hurd/hurd/fd.h | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/hurd/hurd/fd.h b/hurd/hurd/fd.h index a56b71ca5d..af5fdcf759 100644 --- a/hurd/hurd/fd.h +++ b/hurd/hurd/fd.h @@ -1,5 +1,5 @@ /* File descriptors. - Copyright (C) 1993-2016 Free Software Foundation, Inc. + Copyright (C) 1993-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -26,6 +26,9 @@ #include <hurd/hurd_types.h> #include <hurd/port.h> #include <sys/socket.h> +#include <sys/select.h> +#include <fcntl.h> +#include <bits/types/sigset_t.h> /* Structure representing a file descriptor. */ @@ -58,9 +61,10 @@ extern struct mutex _hurd_dtable_lock; /* Locks those two variables. */ NULL. The cell is unlocked; when ready to use it, lock it and check for it being unused. */ -struct hurd_fd *_hurd_fd_get (int fd); +extern struct hurd_fd *_hurd_fd_get (int fd); -#if defined __USE_EXTERN_INLINES && defined _LIBC && !defined NOT_IN_libc +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) _HURD_FD_H_EXTERN_INLINE struct hurd_fd * _hurd_fd_get (int fd) { @@ -93,6 +97,7 @@ _hurd_fd_get (int fd) return descriptor; } +# endif #endif @@ -137,11 +142,12 @@ _hurd_fd_get (int fd) __result; }) #include <errno.h> +#include <bits/types/error_t.h> /* Check if ERR should generate a signal. Returns the signal to take, or zero if none. */ -int _hurd_fd_error_signal (error_t err); +extern int _hurd_fd_error_signal (error_t err); #ifdef __USE_EXTERN_INLINES _HURD_FD_H_EXTERN_INLINE int @@ -166,7 +172,7 @@ _hurd_fd_error_signal (error_t err) always use this function to handle errors from RPCs made on file descriptor ports. Some errors are translated into signals. */ -error_t _hurd_fd_error (int fd, error_t err); +extern error_t _hurd_fd_error (int fd, error_t err); #ifdef __USE_EXTERN_INLINES _HURD_FD_H_EXTERN_INLINE error_t @@ -176,7 +182,7 @@ _hurd_fd_error (int fd, error_t err) if (signo) { const struct hurd_signal_detail detail - = { code: fd, error: err, exc: 0 }; + = { exc: 0, exc_code: 0, exc_subcode: 0, code: fd, error: err }; _hurd_raise_signal (NULL, signo, &detail); } return err; @@ -186,7 +192,7 @@ _hurd_fd_error (int fd, error_t err) /* Handle error code ERR from an RPC on file descriptor FD's port. Set `errno' to the appropriate error code, and always return -1. */ -int __hurd_dfail (int fd, error_t err); +extern int __hurd_dfail (int fd, error_t err); #ifdef __USE_EXTERN_INLINES _HURD_FD_H_EXTERN_INLINE int @@ -200,7 +206,7 @@ __hurd_dfail (int fd, error_t err) /* Likewise, but do not raise SIGPIPE on EPIPE if flags contain MSG_NOSIGNAL. */ -int __hurd_sockfail (int fd, int flags, error_t err); +extern int __hurd_sockfail (int fd, int flags, error_t err); #ifdef __USE_EXTERN_INLINES _HURD_FD_H_EXTERN_INLINE int @@ -249,9 +255,9 @@ extern error_t _hurd_fd_close (struct hurd_fd *fd); If successful, stores the amount actually read or written in *NBYTES. */ extern error_t _hurd_fd_read (struct hurd_fd *fd, - void *buf, size_t *nbytes, loff_t offset); + void *buf, size_t *nbytes, __loff_t offset); extern error_t _hurd_fd_write (struct hurd_fd *fd, - const void *buf, size_t *nbytes, loff_t offset); + const void *buf, size_t *nbytes, __loff_t offset); /* Call *RPC on PORT and/or CTTY; if a call on CTTY returns EBACKGROUND, @@ -274,6 +280,30 @@ 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. */ + +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) +_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; +} +# endif +#endif + /* 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. |