Changeset 98244bf4 in rtems


Ignore:
Timestamp:
Apr 3, 2012, 2:33:11 PM (8 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Children:
350127a2
Parents:
02c3f4d7 (diff), 58f6655 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'upstream'

Files:
4 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/Makefile.am

    r02c3f4d7 r98244bf4  
    6060    src/privateenv.c \
    6161    src/open_dev_console.c src/__usrenv.c src/rtems_mkdir.c
    62 
    63 if LIBNETWORKING
    64 BASE_FS_C_FILES += src/libio_sockets.c
    65 endif
    6662
    6763TERMIOS_C_FILES = src/cfgetispeed.c src/cfgetospeed.c src/cfsetispeed.c \
  • cpukit/libnetworking/rtems/rtems_bsdnet_internal.h

    r02c3f4d7 r98244bf4  
    200200#endif
    201201
    202 int rtems_bsdnet_makeFdForSocket(
    203     void *so, const rtems_filesystem_file_handlers_r *h);
    204202struct socket *rtems_bsdnet_fdToSocket(int fd);
    205203
  • cpukit/libnetworking/rtems/rtems_syscall.c

    r02c3f4d7 r98244bf4  
    1414
    1515#include <rtems.h>
    16 #include <rtems/libio.h>
     16#include <rtems/libio_.h>
    1717#include <rtems/error.h>
    1818#include <rtems/rtems_bsdnet.h>
     
    4343 */
    4444static const rtems_filesystem_file_handlers_r socket_handlers;
     45
     46/*
     47 * Convert an RTEMS file descriptor to a BSD socket pointer.
     48 */
     49struct socket *
     50rtems_bsdnet_fdToSocket (int fd)
     51{
     52  rtems_libio_t *iop;
     53
     54  /* same as rtems_libio_check_fd(_fd) but different return */
     55  if ((uint32_t)fd >= rtems_libio_number_iops) {
     56    errno = EBADF;
     57    return NULL;
     58  }
     59  iop = &rtems_libio_iops[fd];
     60
     61  /* same as rtems_libio_check_is_open(iop) but different return */
     62  if ((iop->flags & LIBIO_FLAGS_OPEN) == 0) {
     63    errno = EBADF;
     64    return NULL;
     65  }
     66
     67  if (iop->pathinfo.handlers != &socket_handlers) {
     68    errno = ENOTSOCK;
     69    return NULL;
     70  }
     71
     72  if (iop->data1 == NULL)
     73    errno = EBADF;
     74  return iop->data1;
     75}
     76
     77/*
     78 * Create an RTEMS file descriptor for a socket
     79 */
     80static int
     81rtems_bsdnet_makeFdForSocket (void *so)
     82{
     83  rtems_libio_t *iop;
     84  int fd;
     85
     86  iop = rtems_libio_allocate();
     87  if (iop == 0)
     88      rtems_set_errno_and_return_minus_one( ENFILE );
     89
     90  fd = iop - rtems_libio_iops;
     91  iop->flags |= LIBIO_FLAGS_WRITE | LIBIO_FLAGS_READ;
     92  iop->data0 = fd;
     93  iop->data1 = so;
     94  iop->pathinfo.handlers = &socket_handlers;
     95  iop->pathinfo.ops = &rtems_filesystem_operations_default;
     96  iop->pathinfo.mt_entry = &rtems_filesystem_null_mt_entry;
     97  rtems_filesystem_location_add_to_mt_entry(&iop->pathinfo);
     98  return fd;
     99}
    45100
    46101/*
     
    83138        error = socreate(domain, &so, type, protocol, NULL);
    84139        if (error == 0) {
    85                 fd = rtems_bsdnet_makeFdForSocket (so, &socket_handlers);
     140                fd = rtems_bsdnet_makeFdForSocket (so);
    86141                if (fd < 0)
    87142                        soclose (so);
     
    234289        head->so_qlen--;
    235290
    236         fd = rtems_bsdnet_makeFdForSocket (so, &socket_handlers);
     291        fd = rtems_bsdnet_makeFdForSocket (so);
    237292        if (fd < 0) {
    238293                TAILQ_INSERT_HEAD(&head->so_comp, so, so_list);
  • testsuites/libtests/Makefile.am

    r02c3f4d7 r98244bf4  
    2222if NETTESTS
    2323SUBDIRS += ftp01
     24SUBDIRS += syscall01
    2425endif
    2526
  • testsuites/libtests/configure.ac

    r02c3f4d7 r98244bf4  
    4444# Explicitly list all Makefiles here
    4545AC_CONFIG_FILES([Makefile
     46syscall01/Makefile
    4647flashdisk01/Makefile
    4748block01/Makefile
Note: See TracChangeset for help on using the changeset viewer.