diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-03-19 21:51:58 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-03-19 21:51:58 +0000 |
commit | af0200363e8d0a69648bd78fd5ee2d0ee5f40624 (patch) | |
tree | 5134c59a5e4afdf27dec4559ad764a099a66c5e1 /c/src/lib/libnetworking | |
parent | Patch from Ralf Corsepius <corsepiu@faw.uni-ulm.de>: (diff) | |
download | rtems-af0200363e8d0a69648bd78fd5ee2d0ee5f40624.tar.bz2 |
Patch from Eric Norum <eric@skatter.usask.ca> that adds external
fcntl support and an external fcntl handler for sockets.
Diffstat (limited to 'c/src/lib/libnetworking')
-rw-r--r-- | c/src/lib/libnetworking/rtems/rtems_syscall.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/c/src/lib/libnetworking/rtems/rtems_syscall.c b/c/src/lib/libnetworking/rtems/rtems_syscall.c index 141b7ceeba..7797e46a2a 100644 --- a/c/src/lib/libnetworking/rtems/rtems_syscall.c +++ b/c/src/lib/libnetworking/rtems/rtems_syscall.c @@ -20,6 +20,7 @@ #include <sys/socketvar.h> #include <sys/protosw.h> #include <sys/proc.h> +#include <sys/fcntl.h> #include <sys/filio.h> #include <net/if.h> @@ -644,14 +645,18 @@ rtems_bsdnet_write (rtems_libio_t *iop, const void *buffer, unsigned32 count) } static int -so_ioctl (struct socket *so, unsigned32 command, void *buffer) +so_ioctl (rtems_libio_t *iop, struct socket *so, unsigned32 command, void *buffer) { switch (command) { case FIONBIO: - if (*(int *)buffer) + if (*(int *)buffer) { + iop->flags |= O_NONBLOCK; so->so_state |= SS_NBIO; - else + } + else { + iop->flags &= ~O_NONBLOCK; so->so_state &= ~SS_NBIO; + } return 0; case FIONREAD: @@ -678,7 +683,7 @@ rtems_bsdnet_ioctl (rtems_libio_t *iop, unsigned32 command, void *buffer) rtems_bsdnet_semaphore_release (); return -1; } - error = so_ioctl (so, command, buffer); + error = so_ioctl (iop, so, command, buffer); rtems_bsdnet_semaphore_release (); if (error) { errno = error; @@ -688,6 +693,26 @@ rtems_bsdnet_ioctl (rtems_libio_t *iop, unsigned32 command, void *buffer) } static int +rtems_bsdnet_fcntl (int cmd, rtems_libio_t *iop) +{ + struct socket *so; + + if (cmd == F_SETFL) { + rtems_bsdnet_semaphore_obtain (); + if ((so = iop->data1) == NULL) { + rtems_bsdnet_semaphore_release (); + return EBADF; + } + if (iop->flags & O_NONBLOCK) + so->so_state |= SS_NBIO; + else + so->so_state &= ~SS_NBIO; + rtems_bsdnet_semaphore_release (); + } + return 0; +} + +static int rtems_bsdnet_fstat (rtems_filesystem_location_info_t *loc, struct stat *sp) { sp->st_mode = S_IFSOCK; @@ -707,4 +732,5 @@ static const rtems_filesystem_file_handlers_r socket_handlers = { NULL, /* fpathconf */ NULL, /* fsync */ NULL, /* fdatasync */ + rtems_bsdnet_fcntl, /* fcntl */ }; |