Changeset 94b357c2 in rtems


Ignore:
Timestamp:
Nov 5, 1999, 9:10:54 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
378fe02
Parents:
6c85bdd
Message:

Unmount was failing as a side-effect of splitting the rmnod handler
and not handling every case properly.

Files:
4 added
25 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/libfs/src/imfs/deviceio.c

    r6c85bdd r94b357c2  
    213213 *  device_stat
    214214 *
    215  *  This IMFS_stat() is used.
     215 *  The IMFS_stat() is used.
    216216 */
    217217
    218218/*
    219219 *  device_rmnod
    220  */
    221 
    222 int device_rmnod(
    223   rtems_filesystem_location_info_t      *pathloc       /* IN */
    224 )
    225 {
    226   IMFS_jnode_t *the_jnode; 
    227 
    228   the_jnode = (IMFS_jnode_t *) pathloc->node_access;
    229 
    230   /*
    231    * Take the node out of the parent's chain that contains this node
    232    */
    233 
    234   if ( the_jnode->Parent != NULL ) {
    235     Chain_Extract( (Chain_Node *) the_jnode );
    236     the_jnode->Parent = NULL;
    237   }
    238 
    239   /*
    240    * Decrement the link counter and see if we can free the space.
    241    */
    242 
    243   the_jnode->st_nlink--;
    244   IMFS_update_ctime( the_jnode );
    245 
    246   /*
    247    * The file cannot be open and the link must be less than 1 to free.
    248    */
    249 
    250   if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
    251 
    252     /*
    253      * Is the rtems_filesystem_current is this node?
    254      */
    255 
    256     if ( rtems_filesystem_current.node_access == pathloc->node_access )
    257        rtems_filesystem_current.node_access = NULL;
    258 
    259     /*
    260      * Free memory associated with a memory file.
    261      */
    262 
    263     free( the_jnode );
    264   }
    265 
    266   return 0;
    267 
    268 }
    269 
    270 
    271 
     220 *
     221 *  The IMFS_rmnod() is used.
     222 */
  • c/src/exec/libfs/src/imfs/imfs.h

    r6c85bdd r94b357c2  
    213213 */
    214214
     215extern rtems_filesystem_file_handlers_r       IMFS_directory_handlers;
    215216extern rtems_filesystem_file_handlers_r       IMFS_device_handlers;
     217extern rtems_filesystem_file_handlers_r       IMFS_link_handlers;
    216218extern rtems_filesystem_file_handlers_r       IMFS_memfile_handlers;
    217 extern rtems_filesystem_file_handlers_r       IMFS_directory_handlers;
    218219extern rtems_filesystem_operations_table      IMFS_ops;
    219220extern rtems_filesystem_operations_table      miniIMFS_ops;
     
    457458);
    458459
    459 int device_rmnod(
    460   rtems_filesystem_location_info_t      *pathloc       /* IN */
    461 );
    462 
    463460int IMFS_utime(
    464461  rtems_filesystem_location_info_t  *pathloc,       /* IN */
     
    493490);
    494491
     492int IMFS_rmnod(
     493  rtems_filesystem_location_info_t      *pathloc       /* IN */
     494);
     495
    495496#ifdef __cplusplus
    496497}
  • c/src/exec/libfs/src/imfs/imfs_eval.c

    r6c85bdd r94b357c2  
    4646    case IMFS_SYM_LINK:
    4747    case IMFS_HARD_LINK:
    48       loc->handlers = &rtems_filesystem_null_handlers;
     48      loc->handlers = &IMFS_link_handlers;
    4949      break;
    5050    case IMFS_MEMORY_FILE:
  • c/src/exec/libfs/src/imfs/imfs_fsunmount.c

    r6c85bdd r94b357c2  
    4343    ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next))
    4444
     45/* XXX should be in a more public place */
     46
     47extern int IMFS_Set_handlers( 
     48  rtems_filesystem_location_info_t   *loc
     49);
    4550
    4651int IMFS_fsunmount(
     
    6065   jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
    6166   loc = temp_mt_entry->mt_fs_root;
    62 
    6367   
    6468   /*
     
    7175     next = jnode->Parent;
    7276     loc.node_access = (void *)jnode;
     77     IMFS_Set_handlers( &loc );
    7378
    7479     if ( jnode->type != IMFS_DIRECTORY ) {
  • c/src/exec/libfs/src/imfs/imfs_handlers_device.c

    r6c85bdd r94b357c2  
    3535  NULL,   /* fdatasync */
    3636  NULL,   /* fcntl */
    37   device_rmnod
     37  IMFS_rmnod
    3838};
  • c/src/exec/libfs/src/imfs/imfs_unlink.c

    r6c85bdd r94b357c2  
    5050
    5151    /*
    52      * If this is the last referance to the node
    53      * Free the node that the link points to.
     52     *  If removing the last hard link to a node, then we need
     53     *  to remove the node that is a link and the node itself.
    5454     */
     55
    5556    node->info.hard_link.link_node->st_nlink --;
    5657    IMFS_update_ctime( node->info.hard_link.link_node );
     
    6263  }
    6364
    64   result = (*loc->handlers->rmnod)( &the_link );
     65  /*
     66   *  Now actually free the node we were asked to free.
     67   */
     68
     69  result = (*loc->handlers->rmnod)( loc );
    6570
    6671  return result;
  • c/src/lib/libc/Makefile.in

    r6c85bdd r94b357c2  
    2828    imfs_mount imfs_fchmod imfs_unlink imfs_unmount imfs_utime \
    2929    imfs_ntype imfs_stat imfs_getchild memfile deviceio imfs_handlers_device \
    30     imfs_handlers_directory imfs_handlers_memfile imfs_debug imfs_symlink \
    31     imfs_readlink imfs_fdatasync imfs_fcntl miniimfs_init
     30    imfs_handlers_directory imfs_handlers_link imfs_handlers_memfile \
     31    imfs_debug imfs_rmnod imfs_symlink imfs_readlink imfs_fdatasync \
     32    imfs_fcntl miniimfs_init
    3233
    3334TERMIOS_C_PIECES = cfgetispeed cfgetospeed cfsetispeed cfsetospeed tcgetattr \
  • c/src/lib/libc/deviceio.c

    r6c85bdd r94b357c2  
    213213 *  device_stat
    214214 *
    215  *  This IMFS_stat() is used.
     215 *  The IMFS_stat() is used.
    216216 */
    217217
    218218/*
    219219 *  device_rmnod
    220  */
    221 
    222 int device_rmnod(
    223   rtems_filesystem_location_info_t      *pathloc       /* IN */
    224 )
    225 {
    226   IMFS_jnode_t *the_jnode; 
    227 
    228   the_jnode = (IMFS_jnode_t *) pathloc->node_access;
    229 
    230   /*
    231    * Take the node out of the parent's chain that contains this node
    232    */
    233 
    234   if ( the_jnode->Parent != NULL ) {
    235     Chain_Extract( (Chain_Node *) the_jnode );
    236     the_jnode->Parent = NULL;
    237   }
    238 
    239   /*
    240    * Decrement the link counter and see if we can free the space.
    241    */
    242 
    243   the_jnode->st_nlink--;
    244   IMFS_update_ctime( the_jnode );
    245 
    246   /*
    247    * The file cannot be open and the link must be less than 1 to free.
    248    */
    249 
    250   if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
    251 
    252     /*
    253      * Is the rtems_filesystem_current is this node?
    254      */
    255 
    256     if ( rtems_filesystem_current.node_access == pathloc->node_access )
    257        rtems_filesystem_current.node_access = NULL;
    258 
    259     /*
    260      * Free memory associated with a memory file.
    261      */
    262 
    263     free( the_jnode );
    264   }
    265 
    266   return 0;
    267 
    268 }
    269 
    270 
    271 
     220 *
     221 *  The IMFS_rmnod() is used.
     222 */
  • c/src/lib/libc/imfs.h

    r6c85bdd r94b357c2  
    213213 */
    214214
     215extern rtems_filesystem_file_handlers_r       IMFS_directory_handlers;
    215216extern rtems_filesystem_file_handlers_r       IMFS_device_handlers;
     217extern rtems_filesystem_file_handlers_r       IMFS_link_handlers;
    216218extern rtems_filesystem_file_handlers_r       IMFS_memfile_handlers;
    217 extern rtems_filesystem_file_handlers_r       IMFS_directory_handlers;
    218219extern rtems_filesystem_operations_table      IMFS_ops;
    219220extern rtems_filesystem_operations_table      miniIMFS_ops;
     
    457458);
    458459
    459 int device_rmnod(
    460   rtems_filesystem_location_info_t      *pathloc       /* IN */
    461 );
    462 
    463460int IMFS_utime(
    464461  rtems_filesystem_location_info_t  *pathloc,       /* IN */
     
    493490);
    494491
     492int IMFS_rmnod(
     493  rtems_filesystem_location_info_t      *pathloc       /* IN */
     494);
     495
    495496#ifdef __cplusplus
    496497}
  • c/src/lib/libc/imfs_eval.c

    r6c85bdd r94b357c2  
    4646    case IMFS_SYM_LINK:
    4747    case IMFS_HARD_LINK:
    48       loc->handlers = &rtems_filesystem_null_handlers;
     48      loc->handlers = &IMFS_link_handlers;
    4949      break;
    5050    case IMFS_MEMORY_FILE:
  • c/src/lib/libc/imfs_fsunmount.c

    r6c85bdd r94b357c2  
    4343    ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next))
    4444
     45/* XXX should be in a more public place */
     46
     47extern int IMFS_Set_handlers( 
     48  rtems_filesystem_location_info_t   *loc
     49);
    4550
    4651int IMFS_fsunmount(
     
    6065   jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
    6166   loc = temp_mt_entry->mt_fs_root;
    62 
    6367   
    6468   /*
     
    7175     next = jnode->Parent;
    7276     loc.node_access = (void *)jnode;
     77     IMFS_Set_handlers( &loc );
    7378
    7479     if ( jnode->type != IMFS_DIRECTORY ) {
  • c/src/lib/libc/imfs_handlers_device.c

    r6c85bdd r94b357c2  
    3535  NULL,   /* fdatasync */
    3636  NULL,   /* fcntl */
    37   device_rmnod
     37  IMFS_rmnod
    3838};
  • c/src/lib/libc/imfs_unlink.c

    r6c85bdd r94b357c2  
    5050
    5151    /*
    52      * If this is the last referance to the node
    53      * Free the node that the link points to.
     52     *  If removing the last hard link to a node, then we need
     53     *  to remove the node that is a link and the node itself.
    5454     */
     55
    5556    node->info.hard_link.link_node->st_nlink --;
    5657    IMFS_update_ctime( node->info.hard_link.link_node );
     
    6263  }
    6364
    64   result = (*loc->handlers->rmnod)( &the_link );
     65  /*
     66   *  Now actually free the node we were asked to free.
     67   */
     68
     69  result = (*loc->handlers->rmnod)( loc );
    6570
    6671  return result;
  • c/src/libfs/src/imfs/deviceio.c

    r6c85bdd r94b357c2  
    213213 *  device_stat
    214214 *
    215  *  This IMFS_stat() is used.
     215 *  The IMFS_stat() is used.
    216216 */
    217217
    218218/*
    219219 *  device_rmnod
    220  */
    221 
    222 int device_rmnod(
    223   rtems_filesystem_location_info_t      *pathloc       /* IN */
    224 )
    225 {
    226   IMFS_jnode_t *the_jnode; 
    227 
    228   the_jnode = (IMFS_jnode_t *) pathloc->node_access;
    229 
    230   /*
    231    * Take the node out of the parent's chain that contains this node
    232    */
    233 
    234   if ( the_jnode->Parent != NULL ) {
    235     Chain_Extract( (Chain_Node *) the_jnode );
    236     the_jnode->Parent = NULL;
    237   }
    238 
    239   /*
    240    * Decrement the link counter and see if we can free the space.
    241    */
    242 
    243   the_jnode->st_nlink--;
    244   IMFS_update_ctime( the_jnode );
    245 
    246   /*
    247    * The file cannot be open and the link must be less than 1 to free.
    248    */
    249 
    250   if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
    251 
    252     /*
    253      * Is the rtems_filesystem_current is this node?
    254      */
    255 
    256     if ( rtems_filesystem_current.node_access == pathloc->node_access )
    257        rtems_filesystem_current.node_access = NULL;
    258 
    259     /*
    260      * Free memory associated with a memory file.
    261      */
    262 
    263     free( the_jnode );
    264   }
    265 
    266   return 0;
    267 
    268 }
    269 
    270 
    271 
     220 *
     221 *  The IMFS_rmnod() is used.
     222 */
  • c/src/libfs/src/imfs/imfs.h

    r6c85bdd r94b357c2  
    213213 */
    214214
     215extern rtems_filesystem_file_handlers_r       IMFS_directory_handlers;
    215216extern rtems_filesystem_file_handlers_r       IMFS_device_handlers;
     217extern rtems_filesystem_file_handlers_r       IMFS_link_handlers;
    216218extern rtems_filesystem_file_handlers_r       IMFS_memfile_handlers;
    217 extern rtems_filesystem_file_handlers_r       IMFS_directory_handlers;
    218219extern rtems_filesystem_operations_table      IMFS_ops;
    219220extern rtems_filesystem_operations_table      miniIMFS_ops;
     
    457458);
    458459
    459 int device_rmnod(
    460   rtems_filesystem_location_info_t      *pathloc       /* IN */
    461 );
    462 
    463460int IMFS_utime(
    464461  rtems_filesystem_location_info_t  *pathloc,       /* IN */
     
    493490);
    494491
     492int IMFS_rmnod(
     493  rtems_filesystem_location_info_t      *pathloc       /* IN */
     494);
     495
    495496#ifdef __cplusplus
    496497}
  • c/src/libfs/src/imfs/imfs_eval.c

    r6c85bdd r94b357c2  
    4646    case IMFS_SYM_LINK:
    4747    case IMFS_HARD_LINK:
    48       loc->handlers = &rtems_filesystem_null_handlers;
     48      loc->handlers = &IMFS_link_handlers;
    4949      break;
    5050    case IMFS_MEMORY_FILE:
  • c/src/libfs/src/imfs/imfs_fsunmount.c

    r6c85bdd r94b357c2  
    4343    ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next))
    4444
     45/* XXX should be in a more public place */
     46
     47extern int IMFS_Set_handlers( 
     48  rtems_filesystem_location_info_t   *loc
     49);
    4550
    4651int IMFS_fsunmount(
     
    6065   jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
    6166   loc = temp_mt_entry->mt_fs_root;
    62 
    6367   
    6468   /*
     
    7175     next = jnode->Parent;
    7276     loc.node_access = (void *)jnode;
     77     IMFS_Set_handlers( &loc );
    7378
    7479     if ( jnode->type != IMFS_DIRECTORY ) {
  • c/src/libfs/src/imfs/imfs_handlers_device.c

    r6c85bdd r94b357c2  
    3535  NULL,   /* fdatasync */
    3636  NULL,   /* fcntl */
    37   device_rmnod
     37  IMFS_rmnod
    3838};
  • c/src/libfs/src/imfs/imfs_unlink.c

    r6c85bdd r94b357c2  
    5050
    5151    /*
    52      * If this is the last referance to the node
    53      * Free the node that the link points to.
     52     *  If removing the last hard link to a node, then we need
     53     *  to remove the node that is a link and the node itself.
    5454     */
     55
    5556    node->info.hard_link.link_node->st_nlink --;
    5657    IMFS_update_ctime( node->info.hard_link.link_node );
     
    6263  }
    6364
    64   result = (*loc->handlers->rmnod)( &the_link );
     65  /*
     66   *  Now actually free the node we were asked to free.
     67   */
     68
     69  result = (*loc->handlers->rmnod)( loc );
    6570
    6671  return result;
  • cpukit/libfs/src/imfs/deviceio.c

    r6c85bdd r94b357c2  
    213213 *  device_stat
    214214 *
    215  *  This IMFS_stat() is used.
     215 *  The IMFS_stat() is used.
    216216 */
    217217
    218218/*
    219219 *  device_rmnod
    220  */
    221 
    222 int device_rmnod(
    223   rtems_filesystem_location_info_t      *pathloc       /* IN */
    224 )
    225 {
    226   IMFS_jnode_t *the_jnode; 
    227 
    228   the_jnode = (IMFS_jnode_t *) pathloc->node_access;
    229 
    230   /*
    231    * Take the node out of the parent's chain that contains this node
    232    */
    233 
    234   if ( the_jnode->Parent != NULL ) {
    235     Chain_Extract( (Chain_Node *) the_jnode );
    236     the_jnode->Parent = NULL;
    237   }
    238 
    239   /*
    240    * Decrement the link counter and see if we can free the space.
    241    */
    242 
    243   the_jnode->st_nlink--;
    244   IMFS_update_ctime( the_jnode );
    245 
    246   /*
    247    * The file cannot be open and the link must be less than 1 to free.
    248    */
    249 
    250   if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
    251 
    252     /*
    253      * Is the rtems_filesystem_current is this node?
    254      */
    255 
    256     if ( rtems_filesystem_current.node_access == pathloc->node_access )
    257        rtems_filesystem_current.node_access = NULL;
    258 
    259     /*
    260      * Free memory associated with a memory file.
    261      */
    262 
    263     free( the_jnode );
    264   }
    265 
    266   return 0;
    267 
    268 }
    269 
    270 
    271 
     220 *
     221 *  The IMFS_rmnod() is used.
     222 */
  • cpukit/libfs/src/imfs/imfs.h

    r6c85bdd r94b357c2  
    213213 */
    214214
     215extern rtems_filesystem_file_handlers_r       IMFS_directory_handlers;
    215216extern rtems_filesystem_file_handlers_r       IMFS_device_handlers;
     217extern rtems_filesystem_file_handlers_r       IMFS_link_handlers;
    216218extern rtems_filesystem_file_handlers_r       IMFS_memfile_handlers;
    217 extern rtems_filesystem_file_handlers_r       IMFS_directory_handlers;
    218219extern rtems_filesystem_operations_table      IMFS_ops;
    219220extern rtems_filesystem_operations_table      miniIMFS_ops;
     
    457458);
    458459
    459 int device_rmnod(
    460   rtems_filesystem_location_info_t      *pathloc       /* IN */
    461 );
    462 
    463460int IMFS_utime(
    464461  rtems_filesystem_location_info_t  *pathloc,       /* IN */
     
    493490);
    494491
     492int IMFS_rmnod(
     493  rtems_filesystem_location_info_t      *pathloc       /* IN */
     494);
     495
    495496#ifdef __cplusplus
    496497}
  • cpukit/libfs/src/imfs/imfs_eval.c

    r6c85bdd r94b357c2  
    4646    case IMFS_SYM_LINK:
    4747    case IMFS_HARD_LINK:
    48       loc->handlers = &rtems_filesystem_null_handlers;
     48      loc->handlers = &IMFS_link_handlers;
    4949      break;
    5050    case IMFS_MEMORY_FILE:
  • cpukit/libfs/src/imfs/imfs_fsunmount.c

    r6c85bdd r94b357c2  
    4343    ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next))
    4444
     45/* XXX should be in a more public place */
     46
     47extern int IMFS_Set_handlers( 
     48  rtems_filesystem_location_info_t   *loc
     49);
    4550
    4651int IMFS_fsunmount(
     
    6065   jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
    6166   loc = temp_mt_entry->mt_fs_root;
    62 
    6367   
    6468   /*
     
    7175     next = jnode->Parent;
    7276     loc.node_access = (void *)jnode;
     77     IMFS_Set_handlers( &loc );
    7378
    7479     if ( jnode->type != IMFS_DIRECTORY ) {
  • cpukit/libfs/src/imfs/imfs_handlers_device.c

    r6c85bdd r94b357c2  
    3535  NULL,   /* fdatasync */
    3636  NULL,   /* fcntl */
    37   device_rmnod
     37  IMFS_rmnod
    3838};
  • cpukit/libfs/src/imfs/imfs_unlink.c

    r6c85bdd r94b357c2  
    5050
    5151    /*
    52      * If this is the last referance to the node
    53      * Free the node that the link points to.
     52     *  If removing the last hard link to a node, then we need
     53     *  to remove the node that is a link and the node itself.
    5454     */
     55
    5556    node->info.hard_link.link_node->st_nlink --;
    5657    IMFS_update_ctime( node->info.hard_link.link_node );
     
    6263  }
    6364
    64   result = (*loc->handlers->rmnod)( &the_link );
     65  /*
     66   *  Now actually free the node we were asked to free.
     67   */
     68
     69  result = (*loc->handlers->rmnod)( loc );
    6570
    6671  return result;
Note: See TracChangeset for help on using the changeset viewer.