Changeset ca90c6c in rtems


Ignore:
Timestamp:
Sep 13, 2017, 12:00:50 PM (22 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
e2b1db23
Parents:
856ede4f
git-author:
Sebastian Huber <sebastian.huber@…> (09/13/17 12:00:50)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/15/17 08:27:08)
Message:

libio: Add rtems_libio_iop_flags_initialize()

Update #3132.

Location:
cpukit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/include/rtems/libio_.h

    r856ede4f rca90c6c  
    8989 */
    9090extern rtems_filesystem_global_location_t rtems_filesystem_global_location_null;
     91
     92/**
     93 * @brief Sets the iop flags to the specified flags together with
     94 * LIBIO_FLAGS_OPEN.
     95 *
     96 * Use this once a file descriptor allocated via rtems_libio_allocate() is
     97 * fully initialized.
     98 *
     99 * @param[in] iop The iop.
     100 * @param[in] flags The flags.
     101 */
     102static inline void rtems_libio_iop_flags_initialize(
     103  rtems_libio_t *iop,
     104  uint32_t       flags
     105)
     106{
     107  iop->flags = LIBIO_FLAGS_OPEN | flags;
     108}
    91109
    92110/**
  • cpukit/libcsupport/src/fcntl.c

    r856ede4f rca90c6c  
    2727static int duplicate_iop( rtems_libio_t *iop )
    2828{
    29   int rv = 0;
    30 
    31   rtems_libio_t *diop = rtems_libio_allocate();
     29  int            rv;
     30  int            oflag;
     31  rtems_libio_t *diop;
     32
     33  oflag = rtems_libio_to_fcntl_flags( iop->flags );
     34  diop = rtems_libio_allocate();
    3235
    3336  if (diop != NULL) {
    34     int oflag = rtems_libio_to_fcntl_flags( iop->flags );
    35 
    36     rtems_libio_iop_flags_set( diop, rtems_libio_fcntl_flags( oflag ) );
    37 
    3837    rtems_filesystem_instance_lock( &iop->pathinfo );
    3938    rtems_filesystem_location_clone( &diop->pathinfo, &iop->pathinfo );
     
    4746    rv = (*diop->pathinfo.handlers->open_h)( diop, NULL, oflag, 0 );
    4847    if ( rv == 0 ) {
     48      rtems_libio_iop_flags_initialize(
     49        diop,
     50        rtems_libio_fcntl_flags( oflag )
     51      );
    4952      rv = rtems_libio_iop_to_descriptor( diop );
    5053    } else {
  • cpukit/libcsupport/src/libio.c

    r856ede4f rca90c6c  
    117117    rtems_libio_iop_freelist = iop->data1;
    118118    memset( iop, 0, sizeof(*iop) );
    119     iop->flags = LIBIO_FLAGS_OPEN;
    120119  }
    121120
  • cpukit/libcsupport/src/open.c

    r856ede4f rca90c6c  
    9797  }
    9898
    99   rtems_libio_iop_flags_set( iop, rtems_libio_fcntl_flags( oflag ) );
    10099  rtems_filesystem_eval_path_extract_currentloc( &ctx, &iop->pathinfo );
    101100  rtems_filesystem_eval_path_cleanup( &ctx );
     101
     102  iop->flags = rtems_libio_fcntl_flags( oflag );
    102103
    103104  rv = (*iop->pathinfo.handlers->open_h)( iop, path, oflag, mode );
    104105
    105106  if ( rv == 0 ) {
     107    rtems_libio_iop_flags_set( iop, LIBIO_FLAGS_OPEN );
     108
    106109    if ( truncate ) {
    107110      rv = ftruncate( fd, 0 );
  • cpukit/libnetworking/rtems/rtems_syscall.c

    r856ede4f rca90c6c  
    8282
    8383  fd = rtems_libio_iop_to_descriptor(iop);
    84   rtems_libio_iop_flags_set(iop, LIBIO_FLAGS_READ_WRITE);
    8584  iop->data0 = fd;
    8685  iop->data1 = so;
     
    8887  iop->pathinfo.mt_entry = &rtems_filesystem_null_mt_entry;
    8988  rtems_filesystem_location_add_to_mt_entry(&iop->pathinfo);
     89  rtems_libio_iop_flags_initialize(iop, LIBIO_FLAGS_READ_WRITE);
    9090  return fd;
    9191}
  • cpukit/posix/src/shmopen.c

    r856ede4f rca90c6c  
    226226  size_t len;
    227227  Objects_Get_by_name_error obj_err;
     228  uint32_t flags;
    228229
    229230  if ( shm_check_oflag( oflag ) != 0 ) {
     
    276277
    277278  fd = rtems_libio_iop_to_descriptor( iop );
    278   rtems_libio_iop_flags_set( iop, LIBIO_FLAGS_CLOSE_ON_EXEC );
    279   if ( oflag & O_RDONLY ) {
    280     rtems_libio_iop_flags_set( iop, LIBIO_FLAGS_READ );
    281   } else {
    282     rtems_libio_iop_flags_set( iop, LIBIO_FLAGS_READ_WRITE );
    283   }
    284279  iop->data0 = fd;
    285280  iop->data1 = shm;
     
    288283  iop->pathinfo.mt_entry = &rtems_filesystem_null_mt_entry;
    289284  rtems_filesystem_location_add_to_mt_entry( &iop->pathinfo );
     285
     286  flags = LIBIO_FLAGS_CLOSE_ON_EXEC;
     287  if ( oflag & O_RDONLY ) {
     288    flags |= LIBIO_FLAGS_READ;
     289  } else {
     290    flags |= LIBIO_FLAGS_READ_WRITE;
     291  }
     292
     293  rtems_libio_iop_flags_initialize( iop, flags );
    290294
    291295  return fd;
Note: See TracChangeset for help on using the changeset viewer.