/* File descriptors.
-Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ Copyright (C) 1993,94,95,96,97,98,99,2000,01,02
+ 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
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#ifndef _HURD_FD_H
#define _HURD_FD_H 1
#include <features.h>
+#include <cthreads.h>
+
#include <hurd/hurd_types.h>
#include <hurd/port.h>
extern struct mutex _hurd_dtable_lock; /* Locks those two variables. */
\f
#include <hurd/signal.h>
-#include <lock-intern.h>
-#ifndef _EXTERN_INLINE
-#define _EXTERN_INLINE extern __inline
+#ifndef _HURD_FD_H_EXTERN_INLINE
+#define _HURD_FD_H_EXTERN_INLINE extern __inline
#endif
/* Returns the descriptor cell for FD. If FD is invalid or unused, return
NULL. The cell is unlocked; when ready to use it, lock it and check for
it being unused. */
-_EXTERN_INLINE struct hurd_fd *
+_HURD_FD_H_EXTERN_INLINE struct hurd_fd *
_hurd_fd_get (int fd)
{
struct hurd_fd *descriptor;
/* Check if ERR should generate a signal.
Returns the signal to take, or zero if none. */
-_EXTERN_INLINE error_t
+_HURD_FD_H_EXTERN_INLINE int
_hurd_fd_error_signal (error_t err)
{
switch (err)
always use this function to handle errors from RPCs made on file
descriptor ports. Some errors are translated into signals. */
-_EXTERN_INLINE error_t
+_HURD_FD_H_EXTERN_INLINE error_t
_hurd_fd_error (int fd, error_t err)
{
int signo = _hurd_fd_error_signal (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. */
-_EXTERN_INLINE int
+_HURD_FD_H_EXTERN_INLINE int
__hurd_dfail (int fd, error_t err)
{
errno = _hurd_fd_error (fd, err);
extern error_t _hurd_fd_close (struct hurd_fd *fd);
-/* Read and write data from a file descriptor; just like `read' and `write'.
+/* Read and write data from a file descriptor; just like `read' and `write'
+ if OFFSET is -1, or like `pread' and `pwrite' if OFFSET is not -1.
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);
+extern error_t _hurd_fd_read (struct hurd_fd *fd,
+ void *buf, size_t *nbytes, loff_t offset);
extern error_t _hurd_fd_write (struct hurd_fd *fd,
- const void *buf, size_t *nbytes);
+ const void *buf, size_t *nbytes, loff_t offset);
/* Call *RPC on PORT and/or CTTY; if a call on CTTY returns EBACKGROUND,
extern error_t _hurd_ctty_output (io_t port, io_t ctty, error_t (*rpc) (io_t));
+/* The guts of `select' and `poll'. Check the first NFDS descriptors
+ either in POLLFDS (if nonnull) or in each of READFDS, WRITEFDS,
+ EXCEPTFDS that is nonnull. If TIMEOUT is not NULL, time out after
+ waiting the interval specified therein. If SIGMASK is nonnull,
+ the set of blocked signals is temporarily set to that during this call.
+ Returns the number of ready descriptors, or -1 for errors. */
+struct pollfd;
+struct timespec;
+extern int _hurd_select (int nfds, struct pollfd *pollfds,
+ fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ const struct timespec *timeout,
+ const sigset_t *sigmask);
+
+
#endif /* hurd/fd.h */