Changeset 8851c0a in rtems


Ignore:
Timestamp:
Aug 2, 2010, 6:27:23 PM (9 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
8682da39
Parents:
5114d3f
Message:

2010-08-02 Joel Sherrill <joel.sherrill@…>

  • libfs/src/imfs/imfs_creat.c, libfs/src/imfs/imfs_eval.c, libfs/src/imfs/imfs_mknod.c, libfs/src/imfs/imfs_readlink.c, libfs/src/pipe/fifo.c: Clean up for coverage improvements and formatting.
Location:
cpukit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r5114d3f r8851c0a  
     12010-08-02      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * libfs/src/imfs/imfs_creat.c, libfs/src/imfs/imfs_eval.c,
     4        libfs/src/imfs/imfs_mknod.c, libfs/src/imfs/imfs_readlink.c,
     5        libfs/src/pipe/fifo.c: Clean up for coverage improvements and
     6        formatting.
     7
    182010-08-02      Joel Sherrill <joel.sherrill@oarcorp.com>
    29
  • cpukit/libfs/src/imfs/imfs_creat.c

    r5114d3f r8851c0a  
    6565   *  Set the type specific information
    6666   */
    67   switch (type) {
    68     case IMFS_DIRECTORY:
    69       rtems_chain_initialize_empty(&node->info.directory.Entries);
    70       break;
    71 
    72     case IMFS_HARD_LINK:
    73       node->info.hard_link.link_node = info->hard_link.link_node;
    74       break;
    75 
    76     case IMFS_SYM_LINK:
    77       node->info.sym_link.name = info->sym_link.name;
    78       break;
    79 
    80     case IMFS_DEVICE:
    81       node->info.device.major = info->device.major;
    82       node->info.device.minor = info->device.minor;
    83       break;
    84 
    85     case IMFS_LINEAR_FILE:
    86       node->info.linearfile.size      = 0;
    87       node->info.linearfile.direct    = 0;
    88 
    89     case IMFS_MEMORY_FILE:
     67  if ( type == IMFS_DIRECTORY ) {
     68    rtems_chain_initialize_empty(&node->info.directory.Entries);
     69  } else if ( type == IMFS_HARD_LINK ) {
     70    node->info.hard_link.link_node = info->hard_link.link_node;
     71  } else if ( type == IMFS_SYM_LINK ) {
     72    node->info.sym_link.name = info->sym_link.name;
     73  } else if ( type == IMFS_DEVICE ) {
     74    node->info.device.major = info->device.major;
     75    node->info.device.minor = info->device.minor;
     76  } else if ( type == IMFS_LINEAR_FILE ) {
     77    node->info.linearfile.size      = 0;
     78    node->info.linearfile.direct    = 0;
     79    if ( type == IMFS_MEMORY_FILE ) {
    9080      node->info.file.size            = 0;
    9181      node->info.file.indirect        = 0;
    9282      node->info.file.doubly_indirect = 0;
    9383      node->info.file.triply_indirect = 0;
    94       break;
    95 
    96     case IMFS_FIFO:
    97       node->info.fifo.pipe = NULL;
    98       break;
    99 
    100     default:
    101       IMFS_assert(0);
    102       break;
     84    }
     85  } else if ( type == IMFS_FIFO ) {
     86    node->info.fifo.pipe = NULL;
     87  } else {
     88    IMFS_assert(0);
    10389  }
    10490
  • cpukit/libfs/src/imfs/imfs_eval.c

    r5114d3f r8851c0a  
    7171 *  to do flags on the node.
    7272 */
    73 
    7473int IMFS_evaluate_permission(
    7574  rtems_filesystem_location_info_t  *node,
     
    137136   * Check for things that should never happen.
    138137   */
    139 
    140   if ( jnode->type != IMFS_HARD_LINK )
    141     rtems_fatal_error_occurred (0xABCD0000);
     138  IMFS_assert( jnode->type == IMFS_HARD_LINK );
    142139
    143140  /*
    144141   * Set the hard link value and the handlers.
    145142   */
    146 
    147143  node->node_access = jnode->info.hard_link.link_node;
    148144
     
    178174   * Check for things that should never happen.
    179175   */
    180 
    181   if ( jnode->type != IMFS_SYM_LINK )
    182     rtems_fatal_error_occurred (0xABCD0000);
    183 
    184   if ( !jnode->Parent )
    185     rtems_fatal_error_occurred( 0xBAD00000 );
    186 
     176  IMFS_assert( jnode->type == IMFS_SYM_LINK )
     177  IMFS_assert( jnode->Parent )
    187178
    188179  /*
     
    190181   * root depending on the symbolic links path.
    191182   */
    192 
    193183  node->node_access = jnode->Parent;
    194184
     
    202192   * Use eval path to evaluate the path of the symbolic link.
    203193   */
    204 
    205194  result = IMFS_eval_path(
    206195    &jnode->info.sym_link.name[i],
     
    215204   * Verify we have the correct permissions for this node.
    216205   */
    217 
    218206  if ( !IMFS_evaluate_permission( node, flags ) )
    219207    rtems_set_errno_and_return_minus_one( EACCES );
     
    227215 *  The following routine returns the real node pointed to by a link.
    228216 */
    229 
    230217int IMFS_evaluate_link(
    231218  rtems_filesystem_location_info_t  *node,   /* IN/OUT */
     
    579566         *  If we are at a link follow it.
    580567         */
    581 
    582568        if ( node->type == IMFS_HARD_LINK ) {
    583 
    584569          IMFS_evaluate_hard_link( pathloc, 0 );
    585 
    586570          node = pathloc->node_access;
    587           if ( !node )
    588             rtems_set_errno_and_return_minus_one( ENOTDIR );
     571       
     572          /*
     573           * It would be a design error if we evaluated the link and
     574           * was broken.
     575           */
     576          IMFS_assert( node );
    589577
    590578        } else if ( node->type == IMFS_SYM_LINK ) {
    591 
    592579          result = IMFS_evaluate_sym_link( pathloc, 0 );
    593580
     581          /*
     582           *  In contrast to a hard link, it is possible to have a broken
     583           *  symbolic link.
     584           */
    594585          node = pathloc->node_access;
    595586          if ( result == -1 )
     
    600591         *  Only a directory can be decended into.
    601592         */
    602 
    603593        if ( node->type != IMFS_DIRECTORY )
    604594          rtems_set_errno_and_return_minus_one( ENOTDIR );
     
    608598         *  new fs root node and let them finish evaluating the path.
    609599         */
    610 
    611600        if ( node->info.directory.mt_fs != NULL ) {
    612601          newloc   = node->info.directory.mt_fs->mt_fs_root;
     
    620609         *  Otherwise find the token name in the present location.
    621610         */
    622 
    623611        node = IMFS_find_match_in_dir( node, token );
    624612        if ( !node )
  • cpukit/libfs/src/imfs/imfs_mknod.c

    r5114d3f r8851c0a  
    5454    type = IMFS_DEVICE;
    5555    rtems_filesystem_split_dev_t( dev, info.device.major, info.device.minor );
    56   }
    57   else if (S_ISFIFO(mode))
     56  } else if (S_ISFIFO(mode))
    5857    type = IMFS_FIFO;
    59   else  {
    60     rtems_set_errno_and_return_minus_one( EINVAL );
    61   }
     58  else
     59    IMFS_assert( 0 );
    6260
    6361  /*
     
    7169   *        this path.
    7270   */
    73   new_node = IMFS_create_node(
    74     pathloc,
    75     type,
    76     new_name,
    77     mode,
    78     &info
    79   );
    80 
     71  new_node = IMFS_create_node( pathloc, type, new_name, mode, &info );
    8172  if ( !new_node )
    8273    rtems_set_errno_and_return_minus_one( ENOMEM );
  • cpukit/libfs/src/imfs/imfs_readlink.c

    r5114d3f r8851c0a  
    3535  node = loc->node_access;
    3636
    37   if ( node->type != IMFS_SYM_LINK )
    38     rtems_set_errno_and_return_minus_one( EINVAL );
     37  IMFS_assert( node->type == IMFS_SYM_LINK );
    3938
    4039  for( i=0; ((i<bufsize) && (node->info.sym_link.name[i] != '\0')); i++ )
  • cpukit/libfs/src/pipe/fifo.c

    r5114d3f r8851c0a  
    191191
    192192  sc = rtems_semaphore_release(pipe_semaphore);
    193   if (sc != RTEMS_SUCCESSFUL) {
    194     /* FIXME */
    195     rtems_fatal_error_occurred(0xdeadbeef);
    196   }
     193  #ifdef RTEMS_DEBUG
     194    if (sc != RTEMS_SUCCESSFUL) {
     195      rtems_fatal_error_occurred(0xdeadbeef);
     196    }
     197  #endif
    197198}
    198199
     
    249250  uint32_t mode;
    250251
    251   if (pipe_lock())
     252  #if defined(RTEMS_DEBUG)
    252253    /* WARN pipe not freed and pipep not set to NULL! */
    253     /* FIXME */
    254     rtems_fatal_error_occurred(0xdeadbeef);
    255 
    256   if (!PIPE_LOCK(pipe))
     254    if (pipe_lock())
     255      rtems_fatal_error_occurred(0xdeadbeef);
     256
    257257    /* WARN pipe not released! */
    258     /* FIXME */
    259     rtems_fatal_error_occurred(0xdeadbeef);
     258    if (!PIPE_LOCK(pipe))
     259      rtems_fatal_error_occurred(0xdeadbeef);
     260  #endif
    260261
    261262  mode = LIBIO_ACCMODE(iop);
Note: See TracChangeset for help on using the changeset viewer.