Changeset 5b5772a in rtems


Ignore:
Timestamp:
Jun 8, 2010, 8:50:57 AM (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
241f4c96
Parents:
78f4d6d7
Message:

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

  • libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_rmnod.c: Added and use IMFS_create_orphan() and IMFS_check_node_remove().
  • libfs/src/imfs/deviceio.c, libfs/src/imfs/imfs_directory.c, libfs/src/imfs/imfs_fifo.c: Use IMFS_create_orphan() and IMFS_check_node_remove().
  • libfs/src/imfs/imfs_handlers_memfile.c, libfs/src/imfs/memfile.c: Use IMFS_rmnod() and IMFS_check_node_remove() instead of memfile_rmnod() and memfile_check_rmnod().
Location:
cpukit
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r78f4d6d7 r5b5772a  
     12010-06-08      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_rmnod.c: Added and use
     4        IMFS_create_orphan() and IMFS_check_node_remove().
     5        * libfs/src/imfs/deviceio.c, libfs/src/imfs/imfs_directory.c,
     6        libfs/src/imfs/imfs_fifo.c: Use IMFS_create_orphan() and
     7        IMFS_check_node_remove().
     8        * libfs/src/imfs/imfs_handlers_memfile.c, libfs/src/imfs/memfile.c:
     9        Use IMFS_rmnod() and IMFS_check_node_remove() instead of
     10        memfile_rmnod() and memfile_check_rmnod().
     11
    1122010-06-08      Sebastian Huber <sebastian.huber@embedded-brains.de>
    213
  • cpukit/libfs/src/imfs/deviceio.c

    r78f4d6d7 r5b5772a  
    8282    (void *) &args
    8383  );
     84
     85  IMFS_check_node_remove( the_jnode );
    8486
    8587  return rtems_deviceio_errno( status );
  • cpukit/libfs/src/imfs/imfs.h

    r78f4d6d7 r5b5772a  
    471471);
    472472
    473 extern int memfile_rmnod(
    474   rtems_filesystem_location_info_t  *parent_pathloc, /* IN */
    475   rtems_filesystem_location_info_t  *pathloc         /* IN */
    476 );
    477 
    478473extern int device_open(
    479474  rtems_libio_t *iop,            /* IN  */
     
    555550);
    556551
     552extern void IMFS_create_orphan(
     553  IMFS_jnode_t *jnode
     554);
     555
     556extern void IMFS_check_node_remove(
     557  IMFS_jnode_t *jnode
     558);
     559
    557560extern int IMFS_rmnod(
    558561  rtems_filesystem_location_info_t  *parent_pathloc, /* IN */
  • cpukit/libfs/src/imfs/imfs_directory.c

    r78f4d6d7 r5b5772a  
    312312     rtems_set_errno_and_return_minus_one( EBUSY );
    313313
    314   /*
    315    * Take the node out of the parent's chain that contains this node
    316    */
    317 
    318   if ( the_jnode->Parent != NULL ) {
    319     rtems_chain_extract( (rtems_chain_node *) the_jnode );
    320     the_jnode->Parent = NULL;
    321   }
    322 
    323   /*
    324    * Decrement the link counter and see if we can free the space.
    325    */
    326 
    327   the_jnode->st_nlink--;
    328   IMFS_update_ctime( the_jnode );
    329 
    330   /*
    331    * The file cannot be open and the link must be less than 1 to free.
    332    */
    333 
    334   if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
    335 
    336     /*
    337      * Is the rtems_filesystem_current is this node?
    338      */
    339 
    340     if ( rtems_filesystem_current.node_access == pathloc->node_access )
    341        rtems_filesystem_current.node_access = NULL;
    342 
    343     /*
    344      * Free memory associated with a memory file.
    345      */
    346 
    347     free( the_jnode );
    348   }
     314  IMFS_create_orphan( the_jnode );
     315  IMFS_check_node_remove( the_jnode );
    349316
    350317  return 0;
    351 
    352 }
     318}
  • cpukit/libfs/src/imfs/imfs_fifo.c

    r78f4d6d7 r5b5772a  
    5454  int err = pipe_release(&JNODE2PIPE(jnode), iop);
    5555
    56   if (! err) {
     56  if (err == 0) {
    5757    iop->flags &= ~LIBIO_FLAGS_OPEN;
    58     /* Free jnode if file is already unlinked and no one opens it */
    59     if (! rtems_libio_is_file_open(jnode) && jnode->st_nlink < 1)
    60       free(jnode);
     58    IMFS_check_node_remove(jnode);
    6159  }
    6260
  • cpukit/libfs/src/imfs/imfs_handlers_memfile.c

    r78f4d6d7 r5b5772a  
    3838  IMFS_fdatasync,
    3939  IMFS_fcntl,
    40   memfile_rmnod
     40  IMFS_rmnod
    4141};
  • cpukit/libfs/src/imfs/imfs_rmnod.c

    r78f4d6d7 r5b5772a  
    2727#include "imfs.h"
    2828
     29void IMFS_create_orphan( IMFS_jnode_t *jnode )
     30{
     31  if ( jnode->Parent != NULL ) {
     32    rtems_chain_extract( &jnode->Node );
     33    jnode->Parent = NULL;
     34  }
     35
     36  --jnode->st_nlink;
     37
     38  IMFS_update_ctime( jnode );
     39}
     40
     41void IMFS_check_node_remove( IMFS_jnode_t *jnode )
     42{
     43  if ( !rtems_libio_is_file_open( jnode ) && jnode->st_nlink < 1 ) {
     44    if ( rtems_filesystem_current.node_access == jnode )
     45       rtems_filesystem_current.node_access = NULL;
     46
     47    switch ( jnode->type ) {
     48      case IMFS_MEMORY_FILE:
     49        IMFS_memfile_remove( jnode );
     50        break;
     51      case IMFS_SYM_LINK:
     52        free( jnode->info.sym_link.name );
     53        break;
     54      default:
     55        break;
     56    }
     57
     58    free( jnode );
     59  }
     60}
     61
    2962/*
    3063 *  IMFS_rmnod
     
    3669)
    3770{
    38   IMFS_jnode_t *the_jnode;
     71  IMFS_jnode_t *jnode = (IMFS_jnode_t *) pathloc->node_access;
    3972
    40   the_jnode = (IMFS_jnode_t *) pathloc->node_access;
    41 
    42   /*
    43    * Take the node out of the parent's chain that contains this node
    44    */
    45 
    46   if ( the_jnode->Parent != NULL ) {
    47     rtems_chain_extract( (rtems_chain_node *) the_jnode );
    48     the_jnode->Parent = NULL;
    49   }
    50 
    51   /*
    52    * Decrement the link counter and see if we can free the space.
    53    */
    54 
    55   the_jnode->st_nlink--;
    56   IMFS_update_ctime( the_jnode );
    57 
    58   /*
    59    * The file cannot be open and the link must be less than 1 to free.
    60    */
    61 
    62   if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
    63 
    64     /*
    65      * Is rtems_filesystem_current this node?
    66      */
    67 
    68     if ( rtems_filesystem_current.node_access == pathloc->node_access )
    69        rtems_filesystem_current.node_access = NULL;
    70 
    71     /*
    72      * Free memory associated with a memory file.
    73      */
    74 
    75     if ( the_jnode->type == IMFS_SYM_LINK ) {
    76       if ( the_jnode->info.sym_link.name )
    77         free( (void*) the_jnode->info.sym_link.name );
    78     }
    79     free( the_jnode );
    80   }
     73  IMFS_create_orphan( jnode );
     74  IMFS_check_node_remove( jnode );
    8175
    8276  return 0;
    83 
    8477}
  • cpukit/libfs/src/imfs/memfile.c

    r78f4d6d7 r5b5772a  
    7373   unsigned int           length
    7474);
    75 
    76 int  memfile_check_rmnod( IMFS_jnode_t *the_jnode );
    7775
    7876void *memfile_alloc_block(void);
     
    142140    iop->offset = the_jnode->info.file.size;
    143141
    144   memfile_check_rmnod( the_jnode );
     142  IMFS_check_node_remove( the_jnode );
     143
    145144  return 0;
    146145}
     
    10981097  memfile_blocks_allocated--;
    10991098}
    1100 
    1101 
    1102 /*
    1103  *  memfile_rmnod
    1104  *
    1105  *  This routine is available from the optable to remove a node
    1106  *  from the IMFS file system.
    1107  */
    1108 
    1109 int memfile_rmnod(
    1110   rtems_filesystem_location_info_t  *parent_pathloc,  /* IN */
    1111   rtems_filesystem_location_info_t  *pathloc          /* IN */
    1112 )
    1113 {
    1114   IMFS_jnode_t *the_jnode;
    1115 
    1116   the_jnode = (IMFS_jnode_t *) pathloc->node_access;
    1117 
    1118   /*
    1119    * Take the node out of the parent's chain that contains this node
    1120    */
    1121 
    1122   if ( the_jnode->Parent != NULL ) {
    1123     rtems_chain_extract( (rtems_chain_node *) the_jnode );
    1124     the_jnode->Parent = NULL;
    1125   }
    1126 
    1127   /*
    1128    * Decrement the link counter and see if we can free the space.
    1129    */
    1130 
    1131   the_jnode->st_nlink--;
    1132   IMFS_update_ctime( the_jnode );
    1133 
    1134   return memfile_check_rmnod( the_jnode );
    1135 }
    1136 
    1137 
    1138 int  memfile_check_rmnod( IMFS_jnode_t *the_jnode ){
    1139 
    1140   /*
    1141    * The file cannot be open and the link must be less than 1 to free.
    1142    */
    1143 
    1144   if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
    1145 
    1146     /*
    1147      * Is the rtems_filesystem_current is this node?
    1148      */
    1149 
    1150     if ( rtems_filesystem_current.node_access == the_jnode )
    1151        rtems_filesystem_current.node_access = NULL;
    1152 
    1153     /*
    1154      * Free memory associated with a memory file.
    1155      */
    1156     if (the_jnode->type != IMFS_LINEAR_FILE)
    1157       IMFS_memfile_remove( the_jnode );
    1158 
    1159     free( the_jnode );
    1160   }
    1161 
    1162   return 0;
    1163 }
Note: See TracChangeset for help on using the changeset viewer.