Changeset 241f4c96 in rtems


Ignore:
Timestamp:
Jun 8, 2010, 10:25:46 AM (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
eaee27b
Parents:
5b5772a
Message:

2010-06-08 Sebastian Huber <sebastian.huber@…>

  • libfs/src/imfs/fifoimfs_init.c: New file.
  • libfs/Makefile.am: Reflect change above.
  • libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_eval.c, libfs/src/imfs/imfs_init.c, libfs/src/imfs/imfs_initsupp.c, libfs/src/imfs/miniimfs_init.c, libfs/src/pipe/fifo.c, libfs/src/pipe/pipe.c, libfs/src/pipe/pipe.h: Pipe support is now link-time optional.
  • sapi/include/confdefs.h: Reflect changes above.
Location:
cpukit
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r5b5772a r241f4c96  
     12010-06-08      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * libfs/src/imfs/fifoimfs_init.c: New file.
     4        * libfs/Makefile.am: Reflect change above.
     5        * libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_eval.c,
     6        libfs/src/imfs/imfs_init.c, libfs/src/imfs/imfs_initsupp.c,
     7        libfs/src/imfs/miniimfs_init.c, libfs/src/pipe/fifo.c,
     8        libfs/src/pipe/pipe.c, libfs/src/pipe/pipe.h: Pipe support is now
     9        link-time optional.
     10        * sapi/include/confdefs.h: Reflect changes above.
     11
    1122010-06-08      Sebastian Huber <sebastian.huber@embedded-brains.de>
    213
  • cpukit/libfs/Makefile.am

    r5b5772a r241f4c96  
    3232    src/imfs/imfs_readlink.c src/imfs/imfs_fdatasync.c src/imfs/imfs_fcntl.c \
    3333    src/imfs/ioman.c src/imfs/miniimfs_init.c src/imfs/imfs_load_tar.c \
    34     src/imfs/imfs_rename.c src/imfs/imfs.h \
     34    src/imfs/imfs_rename.c src/imfs/fifoimfs_init.c src/imfs/imfs.h \
    3535    src/imfs/deviceerrno.c \
    3636    src/devfs/devfs_init.c src/devfs/devfs_eval.c src/devfs/devfs_mknod.c \
  • cpukit/libfs/src/imfs/imfs.h

    r5b5772a r241f4c96  
    224224  const rtems_filesystem_file_handlers_r *memfile_handlers;
    225225  const rtems_filesystem_file_handlers_r *directory_handlers;
     226  const rtems_filesystem_file_handlers_r *fifo_handlers;
    226227} IMFS_fs_info_t;
    227228
     
    248249extern const rtems_filesystem_file_handlers_r       IMFS_fifo_handlers;
    249250extern const rtems_filesystem_operations_table      IMFS_ops;
    250 extern const rtems_filesystem_operations_table      miniIMFS_ops;
    251251extern const rtems_filesystem_limits_and_options_t  IMFS_LIMITS_AND_OPTIONS;
    252252
     
    258258   rtems_filesystem_mount_table_entry_t *mt_entry,
    259259   const void                           *data
     260);
     261
     262extern int fifoIMFS_initialize(
     263  rtems_filesystem_mount_table_entry_t  *mt_entry,
     264  const void                            *data
    260265);
    261266
     
    269274   const rtems_filesystem_operations_table    *op_table,
    270275   const rtems_filesystem_file_handlers_r     *memfile_handlers,
    271    const rtems_filesystem_file_handlers_r     *directory_handlers
     276   const rtems_filesystem_file_handlers_r     *directory_handlers,
     277   const rtems_filesystem_file_handlers_r     *fifo_handlers
    272278);
    273279
  • cpukit/libfs/src/imfs/imfs_eval.c

    r5b5772a r241f4c96  
    5959      break;
    6060    case IMFS_FIFO:
    61       loc->handlers = &IMFS_fifo_handlers;
     61      loc->handlers = fs_info->fifo_handlers;
    6262      break;
    6363  }
  • cpukit/libfs/src/imfs/imfs_init.c

    r5b5772a r241f4c96  
     1/**
     2 * @file
     3 *
     4 * @ingroup LibFSIMFS
     5 *
     6 * @brief IMFS initialization.
     7 */
     8
    19/*
    2  *  IMFS Initialization
    3  *
    410 *  COPYRIGHT (c) 1989-1999.
    511 *  On-Line Applications Research Corporation (OAR).
     
    1622#endif
    1723
    18 #include <sys/types.h>         /* for mkdir */
    19 #include <fcntl.h>
    20 #include <unistd.h>
    21 #include <stdlib.h>
    22 
    23 #include <assert.h>
     24#include <rtems/libio_.h>
    2425
    2526#include "imfs.h"
    26 #include <rtems/libio_.h>
    2727
    28 #if defined(IMFS_DEBUG)
    29 #include <stdio.h>
    30 #endif
    31 
    32 /*
    33  *  IMFS file system operations table
    34  */
    35 
    36 const rtems_filesystem_operations_table  IMFS_ops = {
    37   IMFS_eval_path,
    38   IMFS_evaluate_for_make,
    39   IMFS_link,
    40   IMFS_unlink,
    41   IMFS_node_type,
    42   IMFS_mknod,
    43   IMFS_chown,
    44   IMFS_freenodinfo,
    45   IMFS_mount,
    46   IMFS_initialize,
    47   IMFS_unmount,
    48   IMFS_fsunmount,
    49   IMFS_utime,
    50   IMFS_evaluate_link,
    51   IMFS_symlink,
    52   IMFS_readlink,
    53   IMFS_rename,
    54   NULL
     28const rtems_filesystem_operations_table IMFS_ops = {
     29  .evalpath_h = IMFS_eval_path,
     30  .evalformake_h = IMFS_evaluate_for_make,
     31  .link_h = IMFS_link,
     32  .unlink_h = IMFS_unlink,
     33  .node_type_h = IMFS_node_type,
     34  .mknod_h = IMFS_mknod,
     35  .chown_h = IMFS_chown,
     36  .freenod_h = IMFS_freenodinfo,
     37  .mount_h = IMFS_mount,
     38  .fsmount_me_h = IMFS_initialize,
     39  .unmount_h = IMFS_unmount,
     40  .fsunmount_me_h = IMFS_fsunmount,
     41  .utime_h = IMFS_utime,
     42  .eval_link_h = IMFS_evaluate_link,
     43  .symlink_h = IMFS_symlink,
     44  .readlink_h = IMFS_readlink,
     45  .rename_h = IMFS_rename,
     46  .statvfs_h = NULL
    5547};
    5648
    57 /*
    58  *  IMFS_initialize
    59  */
    60 
    6149int IMFS_initialize(
    62   rtems_filesystem_mount_table_entry_t *temp_mt_entry,
     50  rtems_filesystem_mount_table_entry_t *mt_entry,
    6351  const void                           *data
    6452)
    6553{
    66    return IMFS_initialize_support(
    67      temp_mt_entry,
    68      &IMFS_ops,
    69      &IMFS_memfile_handlers,
    70      &IMFS_directory_handlers
    71    );
     54  return IMFS_initialize_support(
     55    mt_entry,
     56    &IMFS_ops,
     57    &IMFS_memfile_handlers,
     58    &IMFS_directory_handlers,
     59    &rtems_filesystem_null_handlers  /* for fifos */
     60  );
    7261}
  • cpukit/libfs/src/imfs/imfs_initsupp.c

    r5b5772a r241f4c96  
    6767   const rtems_filesystem_operations_table    *op_table,
    6868   const rtems_filesystem_file_handlers_r     *memfile_handlers,
    69    const rtems_filesystem_file_handlers_r     *directory_handlers
     69   const rtems_filesystem_file_handlers_r     *directory_handlers,
     70   const rtems_filesystem_file_handlers_r     *fifo_handlers
    7071)
    7172{
     
    109110  fs_info->memfile_handlers      = memfile_handlers;
    110111  fs_info->directory_handlers    = directory_handlers;
     112  fs_info->fifo_handlers         = fifo_handlers;
    111113
    112114  jnode = temp_mt_entry->mt_fs_root.node_access;
    113115  jnode->st_ino = fs_info->ino_count;
    114116
    115   /* Initialize POSIX FIFO/pipe module */
    116   rtems_pipe_initialize();
    117 
    118117  return 0;
    119118}
  • cpukit/libfs/src/imfs/miniimfs_init.c

    r5b5772a r241f4c96  
     1/**
     2 * @file
     3 *
     4 * @ingroup LibFSIMFS
     5 *
     6 * @brief Mini-IMFS initialization.
     7 */
     8
    19/*
    2  *  Mini-IMFS Initialization
    3  *
    410 *  COPYRIGHT (c) 1989-1999.
    511 *  On-Line Applications Research Corporation (OAR).
     
    1622#endif
    1723
    18 #include <sys/types.h>         /* for mkdir */
    19 #include <fcntl.h>
    20 #include <unistd.h>
    21 #include <stdlib.h>
    22 
    23 #include <assert.h>
     24#include <rtems/libio_.h>
    2425
    2526#include "imfs.h"
    26 #include <rtems/libio_.h>
    2727
    28 #if defined(IMFS_DEBUG)
    29 #include <stdio.h>
    30 #endif
    31 
    32 /*
    33  *  miniIMFS file system operations table
    34  */
    35 
    36 const rtems_filesystem_operations_table  miniIMFS_ops = {
    37   IMFS_eval_path,
    38   IMFS_evaluate_for_make,
    39   NULL, /* XXX IMFS_link, */
    40   NULL, /* XXX IMFS_unlink, */
    41   IMFS_node_type,
    42   IMFS_mknod,
    43   NULL, /* XXX IMFS_chown, */
    44   NULL, /* XXX IMFS_freenodinfo, */
    45   NULL, /* XXX IMFS_mount, */
    46   miniIMFS_initialize,
    47   NULL, /* XXX IMFS_unmount, */
    48   NULL, /* XXX IMFS_fsunmount, */
    49   NULL, /* XXX IMFS_utime, */
    50   NULL, /* XXX IMFS_evaluate_link, */
    51   NULL, /* XXX IMFS_symlink, */
    52   NULL, /* XXX IMFS_readlink */
    53   NULL, /* XXX IMFS_rename */
    54   NULL  /* XXX IMFS_statvfs */
     28static const rtems_filesystem_operations_table miniIMFS_ops = {
     29  .evalpath_h = IMFS_eval_path,
     30  .evalformake_h = IMFS_evaluate_for_make,
     31  .link_h = NULL,
     32  .unlink_h = NULL,
     33  .node_type_h = IMFS_node_type,
     34  .mknod_h = IMFS_mknod,
     35  .chown_h = NULL,
     36  .freenod_h = NULL,
     37  .mount_h = IMFS_mount,
     38  .fsmount_me_h = miniIMFS_initialize,
     39  .unmount_h = NULL,
     40  .fsunmount_me_h = NULL,
     41  .utime_h = NULL,
     42  .eval_link_h = NULL,
     43  .symlink_h = NULL,
     44  .readlink_h = NULL,
     45  .rename_h = NULL,
     46  .statvfs_h = NULL
    5547};
    5648
    57 /*
    58  *  miniIMFS_initialize
    59  */
    60 
    6149int miniIMFS_initialize(
    62   rtems_filesystem_mount_table_entry_t *temp_mt_entry,
     50  rtems_filesystem_mount_table_entry_t *mt_entry,
    6351  const void                           *data
    6452)
    6553{
    66     return IMFS_initialize_support(
    67       temp_mt_entry,
    68       &miniIMFS_ops,
    69       &rtems_filesystem_null_handlers,  /* for memfiles */
    70       &rtems_filesystem_null_handlers   /* for directories */
    71    );
     54  return IMFS_initialize_support(
     55    mt_entry,
     56    &miniIMFS_ops,
     57    &rtems_filesystem_null_handlers, /* for memfiles */
     58    &rtems_filesystem_null_handlers, /* for directories */
     59    &rtems_filesystem_null_handlers  /* for fifos */
     60  );
    7261}
  • cpukit/libfs/src/pipe/fifo.c

    r5b5772a r241f4c96  
    2222#include <errno.h>
    2323#include <stdlib.h>
     24
     25#include <rtems.h>
     26#include <rtems/libio_.h>
     27
    2428#include "pipe.h"
    2529
     
    3034#define LIBIO_NODELAY(_iop) ((_iop)->flags & LIBIO_FLAGS_NO_DELAY)
    3135
    32 extern uint16_t rtems_pipe_no;
    33 static rtems_id rtems_pipe_semaphore = 0;
    34 extern bool rtems_pipe_configured;
     36static rtems_id pipe_semaphore = RTEMS_ID_NONE;
    3537
    3638
     
    8385/*
    8486 * Alloc pipe control structure, buffer, and resources.
    85  * Called with rtems_pipe_semaphore held.
     87 * Called with pipe_semaphore held.
    8688 */
    8789static int pipe_alloc(
     
    140142}
    141143
    142 /* Called with rtems_pipe_semaphore held. */
     144/* Called with pipe_semaphore held. */
    143145static inline void pipe_free(
    144146  pipe_control_t *pipe
     
    152154}
    153155
     156static rtems_status_code pipe_lock(void)
     157{
     158  rtems_status_code sc = RTEMS_SUCCESSFUL;
     159
     160  if (pipe_semaphore == RTEMS_ID_NONE) {
     161    rtems_libio_lock();
     162
     163    if (pipe_semaphore == RTEMS_ID_NONE) {
     164      sc = rtems_semaphore_create(
     165        rtems_build_name('P', 'I', 'P', 'E'),
     166        1,
     167        RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
     168        RTEMS_NO_PRIORITY,
     169        &pipe_semaphore
     170      );
     171    }
     172
     173    rtems_libio_unlock();
     174  }
     175
     176  if (sc == RTEMS_SUCCESSFUL) {
     177    sc = rtems_semaphore_obtain(pipe_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     178  }
     179
     180  if (sc == RTEMS_SUCCESSFUL) {
     181    return 0;
     182  } else {
     183    return -EINTR;
     184  }
     185}
     186
     187static void pipe_unlock(void)
     188{
     189  rtems_status_code sc = RTEMS_SUCCESSFUL;
     190
     191  sc = rtems_semaphore_release(pipe_semaphore);
     192  if (sc != RTEMS_SUCCESSFUL) {
     193    /* FIXME */
     194    rtems_fatal_error_occurred(0xdeadbeef);
     195  }
     196}
     197
    154198/*
    155199 * If called with *pipep = NULL, pipe_new will call pipe_alloc to allocate a
     
    164208  int err = 0;
    165209
    166   if (rtems_semaphore_obtain(rtems_pipe_semaphore,
    167         RTEMS_WAIT, RTEMS_NO_TIMEOUT) != RTEMS_SUCCESSFUL)
    168     return -EINTR;
     210  err = pipe_lock();
     211  if (err)
     212    return err;
    169213
    170214  pipe = *pipep;
     
    186230
    187231out:
    188   rtems_semaphore_release(rtems_pipe_semaphore);
     232  pipe_unlock();
    189233  return err;
    190234}
     
    205249
    206250  rtems_status_code sc;
    207   sc = rtems_semaphore_obtain(pipe->Semaphore,
    208                               RTEMS_WAIT, RTEMS_NO_TIMEOUT);
    209   /* WARN pipe not released! */
    210   if(sc != RTEMS_SUCCESSFUL)
    211     rtems_fatal_error_occurred(sc);
     251
     252  if (pipe_lock())
     253    /* WARN pipe not freed and pipep not set to NULL! */
     254    /* FIXME */
     255    rtems_fatal_error_occurred(0xdeadbeef);
     256
     257  if (!PIPE_LOCK(pipe))
     258    /* WARN pipe not released! */
     259    /* FIXME */
     260    rtems_fatal_error_occurred(0xdeadbeef);
    212261
    213262  mode = LIBIO_ACCMODE(iop);
     
    217266     pipe->Writers --;
    218267
    219   sc = rtems_semaphore_obtain(rtems_pipe_semaphore,
    220                               RTEMS_WAIT, RTEMS_NO_TIMEOUT);
    221   /* WARN pipe not freed and pipep not set to NULL! */
    222   if(sc != RTEMS_SUCCESSFUL)
    223     rtems_fatal_error_occurred(sc);
    224 
    225268  PIPE_UNLOCK(pipe);
    226269
     
    240283    PIPE_WAKEUPREADERS(pipe);
    241284
    242   rtems_semaphore_release(rtems_pipe_semaphore);
     285  pipe_unlock();
    243286
    244287#if 0
     
    540583  return -ESPIPE;
    541584}
    542 
    543 /*
    544  * Initialization of FIFO/pipe module.
    545  */
    546 void rtems_pipe_initialize (void)
    547 {
    548   if (!rtems_pipe_configured)
    549     return;
    550 
    551   if (rtems_pipe_semaphore)
    552     return;
    553 
    554   rtems_status_code sc;
    555   sc = rtems_semaphore_create(
    556         rtems_build_name ('P', 'I', 'P', 'E'), 1,
    557         RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
    558         RTEMS_NO_PRIORITY, &rtems_pipe_semaphore);
    559   if (sc != RTEMS_SUCCESSFUL)
    560     rtems_fatal_error_occurred (sc);
    561 
    562   rtems_interval now;
    563   now = rtems_clock_get_ticks_since_boot();
    564   rtems_pipe_no = now;
    565 }
  • cpukit/libfs/src/pipe/pipe.c

    r5b5772a r241f4c96  
    2121
    2222/* Incremental number added to names of anonymous pipe files */
    23 uint16_t rtems_pipe_no = 0;
     23/* FIXME: This approach is questionable */
     24static uint16_t rtems_pipe_no = 0;
    2425
    2526/*
     
    3435  int err = 0;
    3536  /* Create /tmp if not exists */
     37  /* FIXME: We should use a general mkdir function for this */
    3638  if (rtems_filesystem_evaluate_path("/tmp", 3, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE)
    3739      != 0) {
  • cpukit/libfs/src/pipe/pipe.h

    r5b5772a r241f4c96  
    110110);
    111111
    112 /*
    113  * Initialization of FIFO/pipe module.
    114  */
    115 extern void rtems_pipe_initialize (void);
    116 
    117112#ifdef __cplusplus
    118113}
  • cpukit/sapi/include/confdefs.h

    r5b5772a r241f4c96  
    294294#if !defined(CONFIGURE_FILESYSTEM_ENTRY_IMFS) && \
    295295    defined(CONFIGURE_FILESYSTEM_IMFS)
    296 #define CONFIGURE_FILESYSTEM_ENTRY_IMFS { "imfs", IMFS_initialize }
     296  #if defined(CONFIGURE_PIPES_ENABLED)
     297    #define CONFIGURE_FILESYSTEM_ENTRY_IMFS { "imfs", fifoIMFS_initialize }
     298  #else
     299    #define CONFIGURE_FILESYSTEM_ENTRY_IMFS { "imfs", IMFS_initialize }
     300  #endif
    297301#endif
    298302
     
    429433  #endif
    430434
    431   /**
    432    *  This disables the inclusion of pipe support in the full IMFS.
    433    *
    434    *  NOTE: When building for coverage, we need this variable all the time.
    435    */
    436   #if !defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) || \
    437       defined(RTEMS_COVERAGE)
    438     #if defined(CONFIGURE_PIPES_ENABLED)
    439       bool rtems_pipe_configured = true;
    440     #else
    441       bool rtems_pipe_configured = false;
    442     #endif
    443   #endif
    444 
    445435  #ifndef CONFIGURE_HAS_OWN_MOUNT_TABLE
    446436    const rtems_filesystem_mount_table_t configuration_mount_table = {
Note: See TracChangeset for help on using the changeset viewer.