Changeset 04df848 in rtems


Ignore:
Timestamp:
10/25/99 14:23:03 (24 years ago)
Author:
Jennifer Averett <Jennifer.Averett@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
1e57186
Parents:
72d3f610
Message:

Added code to correctly free any allocated space during the evaluation
process.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/libcsupport/src/mount.c

    r72d3f610 r04df848  
    9696  rtems_filesystem_location_info_t      loc;
    9797  rtems_filesystem_mount_table_entry_t *temp_mt_entry;
     98  rtems_filesystem_location_info_t     *loc_to_free = NULL;
    9899
    99100/* XXX add code to check for required operations */
     
    142143
    143144  if ( mount_point ) {
    144      if ( rtems_filesystem_evaluate_path(
    145        mount_point,
    146        RTEMS_LIBIO_PERMS_RWX,
    147        &loc,
    148        TRUE ) == -1 )
    149        goto cleanup_and_bail;
    150 
    151      /*
    152       * Test to see if it is a directory
    153       */
    154 
    155      if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
    156        errno = ENOTDIR;
    157        goto cleanup_and_bail;
    158      }
    159 
    160      /*
    161       *  You can only mount one file system onto a single mount point.
    162       */
    163 
    164      if ( search_mt_for_mount_point( &loc ) == FOUND ) {
    165        errno = EBUSY;
    166        goto cleanup_and_bail;
    167      }
     145
     146    if ( rtems_filesystem_evaluate_path(
     147            mount_point, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE ) == -1 )
     148      goto cleanup_and_bail;
     149
     150    /*
     151     *  Test to see if it is a directory
     152     */
     153
     154    loc_to_free = &loc;
     155    if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
     156      errno = ENOTDIR;
     157      goto cleanup_and_bail;
     158    }
     159
     160    /*
     161     *  You can only mount one file system onto a single mount point.
     162     */
     163
     164    if ( search_mt_for_mount_point( &loc ) == FOUND ) {
     165      errno = EBUSY;
     166      goto cleanup_and_bail;
     167    }
    168168 
    169      /*
    170       * This must be a good mount point, so move the location information
    171       * into the allocated mount entry
    172       */
    173 
    174      temp_mt_entry->mt_point_node.node_access = loc.node_access;
    175      temp_mt_entry->mt_point_node.handlers = loc.handlers;
    176      temp_mt_entry->mt_point_node.ops = loc.ops;
    177      temp_mt_entry->mt_point_node.mt_entry = loc.mt_entry;
    178 
    179      /*
    180       * This link to the parent is only done when we are dealing with system
    181       * below the base file system
    182       */
    183 
    184      if ( !loc.ops->mount ){
    185        errno = ENOTSUP;
    186        goto cleanup_and_bail;
    187      }
    188 
    189      if ( loc.ops->mount( temp_mt_entry ) ) {
    190         goto cleanup_and_bail;
    191      }
    192   }
    193   else {
    194 
    195      /*
    196       * This is a mount of the base file system --> The
    197       * mt_point_node.node_access will be set to null to indicate that this
    198       * is the root of the entire file system.
    199       */
    200 
    201       temp_mt_entry->mt_fs_root.node_access = NULL;
    202       temp_mt_entry->mt_fs_root.handlers = NULL;
    203       temp_mt_entry->mt_fs_root.ops = NULL;
    204 
    205       temp_mt_entry->mt_point_node.node_access = NULL;
    206       temp_mt_entry->mt_point_node.handlers = NULL;
    207       temp_mt_entry->mt_point_node.ops = NULL;
    208       temp_mt_entry->mt_point_node.mt_entry = NULL;
     169    /*
     170     *  This must be a good mount point, so move the location information
     171     *  into the allocated mount entry.  Note:  the information that
     172     *  may have been allocated in loc should not be sent to freenode
     173     *  until the system is unmounted.  It may be needed to correctly
     174     *  traverse the tree.
     175     */
     176
     177    temp_mt_entry->mt_point_node.node_access = loc.node_access;
     178    temp_mt_entry->mt_point_node.handlers = loc.handlers;
     179    temp_mt_entry->mt_point_node.ops = loc.ops;
     180    temp_mt_entry->mt_point_node.mt_entry = loc.mt_entry;
     181
     182    /*
     183     *  This link to the parent is only done when we are dealing with system
     184     *  below the base file system
     185     */
     186
     187    if ( !loc.ops->mount ){
     188      errno = ENOTSUP;
     189      goto cleanup_and_bail;
     190    }
     191
     192    if ( loc.ops->mount( temp_mt_entry ) ) {
     193      goto cleanup_and_bail;
     194    }
     195  } else {
     196
     197    /*
     198     *  This is a mount of the base file system --> The
     199     *  mt_point_node.node_access will be set to null to indicate that this
     200     *  is the root of the entire file system.
     201     */
     202
     203    temp_mt_entry->mt_fs_root.node_access = NULL;
     204    temp_mt_entry->mt_fs_root.handlers = NULL;
     205    temp_mt_entry->mt_fs_root.ops = NULL;
     206
     207    temp_mt_entry->mt_point_node.node_access = NULL;
     208    temp_mt_entry->mt_point_node.handlers = NULL;
     209    temp_mt_entry->mt_point_node.ops = NULL;
     210    temp_mt_entry->mt_point_node.mt_entry = NULL;
    209211  }
    210212
    211213  if ( !fs_ops->fsmount_me ){
    212       errno = ENOTSUP;
    213       goto cleanup_and_bail;
     214    errno = ENOTSUP;
     215    goto cleanup_and_bail;
    214216  }
    215217
    216218  if ( fs_ops->fsmount_me( temp_mt_entry ) )
    217       goto cleanup_and_bail;
    218 
    219   /*
    220    * Add the mount table entry to the mount table chain
     219    goto cleanup_and_bail;
     220
     221  /*
     222   *  Add the mount table entry to the mount table chain
    221223   */
    222224
     
    225227  *mt_entry = temp_mt_entry;
    226228
    227   rtems_filesystem_freenode( &loc );
     229  return 0;
     230
     231cleanup_and_bail:
     232
     233  free( temp_mt_entry );
    228234 
    229   return 0;
    230 
    231 cleanup_and_bail:
    232 
    233   free( temp_mt_entry );
    234 
    235   rtems_filesystem_freenode( &loc );
    236  
     235  if ( loc_to_free )
     236    rtems_filesystem_freenode( loc_to_free );
     237
    237238  return -1;
    238239}
  • c/src/exec/libcsupport/src/unmount.c

    r72d3f610 r04df848  
    138138   */
    139139
     140  rtems_filesystem_freenode( &temp_loc.mt_entry->mt_point_node );
    140141  free( temp_loc.mt_entry );
    141142  rtems_filesystem_freenode( &temp_loc );
  • c/src/lib/libc/mount.c

    r72d3f610 r04df848  
    9696  rtems_filesystem_location_info_t      loc;
    9797  rtems_filesystem_mount_table_entry_t *temp_mt_entry;
     98  rtems_filesystem_location_info_t     *loc_to_free = NULL;
    9899
    99100/* XXX add code to check for required operations */
     
    142143
    143144  if ( mount_point ) {
    144      if ( rtems_filesystem_evaluate_path(
    145        mount_point,
    146        RTEMS_LIBIO_PERMS_RWX,
    147        &loc,
    148        TRUE ) == -1 )
    149        goto cleanup_and_bail;
    150 
    151      /*
    152       * Test to see if it is a directory
    153       */
    154 
    155      if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
    156        errno = ENOTDIR;
    157        goto cleanup_and_bail;
    158      }
    159 
    160      /*
    161       *  You can only mount one file system onto a single mount point.
    162       */
    163 
    164      if ( search_mt_for_mount_point( &loc ) == FOUND ) {
    165        errno = EBUSY;
    166        goto cleanup_and_bail;
    167      }
     145
     146    if ( rtems_filesystem_evaluate_path(
     147            mount_point, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE ) == -1 )
     148      goto cleanup_and_bail;
     149
     150    /*
     151     *  Test to see if it is a directory
     152     */
     153
     154    loc_to_free = &loc;
     155    if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
     156      errno = ENOTDIR;
     157      goto cleanup_and_bail;
     158    }
     159
     160    /*
     161     *  You can only mount one file system onto a single mount point.
     162     */
     163
     164    if ( search_mt_for_mount_point( &loc ) == FOUND ) {
     165      errno = EBUSY;
     166      goto cleanup_and_bail;
     167    }
    168168 
    169      /*
    170       * This must be a good mount point, so move the location information
    171       * into the allocated mount entry
    172       */
    173 
    174      temp_mt_entry->mt_point_node.node_access = loc.node_access;
    175      temp_mt_entry->mt_point_node.handlers = loc.handlers;
    176      temp_mt_entry->mt_point_node.ops = loc.ops;
    177      temp_mt_entry->mt_point_node.mt_entry = loc.mt_entry;
    178 
    179      /*
    180       * This link to the parent is only done when we are dealing with system
    181       * below the base file system
    182       */
    183 
    184      if ( !loc.ops->mount ){
    185        errno = ENOTSUP;
    186        goto cleanup_and_bail;
    187      }
    188 
    189      if ( loc.ops->mount( temp_mt_entry ) ) {
    190         goto cleanup_and_bail;
    191      }
    192   }
    193   else {
    194 
    195      /*
    196       * This is a mount of the base file system --> The
    197       * mt_point_node.node_access will be set to null to indicate that this
    198       * is the root of the entire file system.
    199       */
    200 
    201       temp_mt_entry->mt_fs_root.node_access = NULL;
    202       temp_mt_entry->mt_fs_root.handlers = NULL;
    203       temp_mt_entry->mt_fs_root.ops = NULL;
    204 
    205       temp_mt_entry->mt_point_node.node_access = NULL;
    206       temp_mt_entry->mt_point_node.handlers = NULL;
    207       temp_mt_entry->mt_point_node.ops = NULL;
    208       temp_mt_entry->mt_point_node.mt_entry = NULL;
     169    /*
     170     *  This must be a good mount point, so move the location information
     171     *  into the allocated mount entry.  Note:  the information that
     172     *  may have been allocated in loc should not be sent to freenode
     173     *  until the system is unmounted.  It may be needed to correctly
     174     *  traverse the tree.
     175     */
     176
     177    temp_mt_entry->mt_point_node.node_access = loc.node_access;
     178    temp_mt_entry->mt_point_node.handlers = loc.handlers;
     179    temp_mt_entry->mt_point_node.ops = loc.ops;
     180    temp_mt_entry->mt_point_node.mt_entry = loc.mt_entry;
     181
     182    /*
     183     *  This link to the parent is only done when we are dealing with system
     184     *  below the base file system
     185     */
     186
     187    if ( !loc.ops->mount ){
     188      errno = ENOTSUP;
     189      goto cleanup_and_bail;
     190    }
     191
     192    if ( loc.ops->mount( temp_mt_entry ) ) {
     193      goto cleanup_and_bail;
     194    }
     195  } else {
     196
     197    /*
     198     *  This is a mount of the base file system --> The
     199     *  mt_point_node.node_access will be set to null to indicate that this
     200     *  is the root of the entire file system.
     201     */
     202
     203    temp_mt_entry->mt_fs_root.node_access = NULL;
     204    temp_mt_entry->mt_fs_root.handlers = NULL;
     205    temp_mt_entry->mt_fs_root.ops = NULL;
     206
     207    temp_mt_entry->mt_point_node.node_access = NULL;
     208    temp_mt_entry->mt_point_node.handlers = NULL;
     209    temp_mt_entry->mt_point_node.ops = NULL;
     210    temp_mt_entry->mt_point_node.mt_entry = NULL;
    209211  }
    210212
    211213  if ( !fs_ops->fsmount_me ){
    212       errno = ENOTSUP;
    213       goto cleanup_and_bail;
     214    errno = ENOTSUP;
     215    goto cleanup_and_bail;
    214216  }
    215217
    216218  if ( fs_ops->fsmount_me( temp_mt_entry ) )
    217       goto cleanup_and_bail;
    218 
    219   /*
    220    * Add the mount table entry to the mount table chain
     219    goto cleanup_and_bail;
     220
     221  /*
     222   *  Add the mount table entry to the mount table chain
    221223   */
    222224
     
    225227  *mt_entry = temp_mt_entry;
    226228
    227   rtems_filesystem_freenode( &loc );
     229  return 0;
     230
     231cleanup_and_bail:
     232
     233  free( temp_mt_entry );
    228234 
    229   return 0;
    230 
    231 cleanup_and_bail:
    232 
    233   free( temp_mt_entry );
    234 
    235   rtems_filesystem_freenode( &loc );
    236  
     235  if ( loc_to_free )
     236    rtems_filesystem_freenode( loc_to_free );
     237
    237238  return -1;
    238239}
  • c/src/lib/libc/unmount.c

    r72d3f610 r04df848  
    138138   */
    139139
     140  rtems_filesystem_freenode( &temp_loc.mt_entry->mt_point_node );
    140141  free( temp_loc.mt_entry );
    141142  rtems_filesystem_freenode( &temp_loc );
  • cpukit/libcsupport/src/mount.c

    r72d3f610 r04df848  
    9696  rtems_filesystem_location_info_t      loc;
    9797  rtems_filesystem_mount_table_entry_t *temp_mt_entry;
     98  rtems_filesystem_location_info_t     *loc_to_free = NULL;
    9899
    99100/* XXX add code to check for required operations */
     
    142143
    143144  if ( mount_point ) {
    144      if ( rtems_filesystem_evaluate_path(
    145        mount_point,
    146        RTEMS_LIBIO_PERMS_RWX,
    147        &loc,
    148        TRUE ) == -1 )
    149        goto cleanup_and_bail;
    150 
    151      /*
    152       * Test to see if it is a directory
    153       */
    154 
    155      if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
    156        errno = ENOTDIR;
    157        goto cleanup_and_bail;
    158      }
    159 
    160      /*
    161       *  You can only mount one file system onto a single mount point.
    162       */
    163 
    164      if ( search_mt_for_mount_point( &loc ) == FOUND ) {
    165        errno = EBUSY;
    166        goto cleanup_and_bail;
    167      }
     145
     146    if ( rtems_filesystem_evaluate_path(
     147            mount_point, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE ) == -1 )
     148      goto cleanup_and_bail;
     149
     150    /*
     151     *  Test to see if it is a directory
     152     */
     153
     154    loc_to_free = &loc;
     155    if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
     156      errno = ENOTDIR;
     157      goto cleanup_and_bail;
     158    }
     159
     160    /*
     161     *  You can only mount one file system onto a single mount point.
     162     */
     163
     164    if ( search_mt_for_mount_point( &loc ) == FOUND ) {
     165      errno = EBUSY;
     166      goto cleanup_and_bail;
     167    }
    168168 
    169      /*
    170       * This must be a good mount point, so move the location information
    171       * into the allocated mount entry
    172       */
    173 
    174      temp_mt_entry->mt_point_node.node_access = loc.node_access;
    175      temp_mt_entry->mt_point_node.handlers = loc.handlers;
    176      temp_mt_entry->mt_point_node.ops = loc.ops;
    177      temp_mt_entry->mt_point_node.mt_entry = loc.mt_entry;
    178 
    179      /*
    180       * This link to the parent is only done when we are dealing with system
    181       * below the base file system
    182       */
    183 
    184      if ( !loc.ops->mount ){
    185        errno = ENOTSUP;
    186        goto cleanup_and_bail;
    187      }
    188 
    189      if ( loc.ops->mount( temp_mt_entry ) ) {
    190         goto cleanup_and_bail;
    191      }
    192   }
    193   else {
    194 
    195      /*
    196       * This is a mount of the base file system --> The
    197       * mt_point_node.node_access will be set to null to indicate that this
    198       * is the root of the entire file system.
    199       */
    200 
    201       temp_mt_entry->mt_fs_root.node_access = NULL;
    202       temp_mt_entry->mt_fs_root.handlers = NULL;
    203       temp_mt_entry->mt_fs_root.ops = NULL;
    204 
    205       temp_mt_entry->mt_point_node.node_access = NULL;
    206       temp_mt_entry->mt_point_node.handlers = NULL;
    207       temp_mt_entry->mt_point_node.ops = NULL;
    208       temp_mt_entry->mt_point_node.mt_entry = NULL;
     169    /*
     170     *  This must be a good mount point, so move the location information
     171     *  into the allocated mount entry.  Note:  the information that
     172     *  may have been allocated in loc should not be sent to freenode
     173     *  until the system is unmounted.  It may be needed to correctly
     174     *  traverse the tree.
     175     */
     176
     177    temp_mt_entry->mt_point_node.node_access = loc.node_access;
     178    temp_mt_entry->mt_point_node.handlers = loc.handlers;
     179    temp_mt_entry->mt_point_node.ops = loc.ops;
     180    temp_mt_entry->mt_point_node.mt_entry = loc.mt_entry;
     181
     182    /*
     183     *  This link to the parent is only done when we are dealing with system
     184     *  below the base file system
     185     */
     186
     187    if ( !loc.ops->mount ){
     188      errno = ENOTSUP;
     189      goto cleanup_and_bail;
     190    }
     191
     192    if ( loc.ops->mount( temp_mt_entry ) ) {
     193      goto cleanup_and_bail;
     194    }
     195  } else {
     196
     197    /*
     198     *  This is a mount of the base file system --> The
     199     *  mt_point_node.node_access will be set to null to indicate that this
     200     *  is the root of the entire file system.
     201     */
     202
     203    temp_mt_entry->mt_fs_root.node_access = NULL;
     204    temp_mt_entry->mt_fs_root.handlers = NULL;
     205    temp_mt_entry->mt_fs_root.ops = NULL;
     206
     207    temp_mt_entry->mt_point_node.node_access = NULL;
     208    temp_mt_entry->mt_point_node.handlers = NULL;
     209    temp_mt_entry->mt_point_node.ops = NULL;
     210    temp_mt_entry->mt_point_node.mt_entry = NULL;
    209211  }
    210212
    211213  if ( !fs_ops->fsmount_me ){
    212       errno = ENOTSUP;
    213       goto cleanup_and_bail;
     214    errno = ENOTSUP;
     215    goto cleanup_and_bail;
    214216  }
    215217
    216218  if ( fs_ops->fsmount_me( temp_mt_entry ) )
    217       goto cleanup_and_bail;
    218 
    219   /*
    220    * Add the mount table entry to the mount table chain
     219    goto cleanup_and_bail;
     220
     221  /*
     222   *  Add the mount table entry to the mount table chain
    221223   */
    222224
     
    225227  *mt_entry = temp_mt_entry;
    226228
    227   rtems_filesystem_freenode( &loc );
     229  return 0;
     230
     231cleanup_and_bail:
     232
     233  free( temp_mt_entry );
    228234 
    229   return 0;
    230 
    231 cleanup_and_bail:
    232 
    233   free( temp_mt_entry );
    234 
    235   rtems_filesystem_freenode( &loc );
    236  
     235  if ( loc_to_free )
     236    rtems_filesystem_freenode( loc_to_free );
     237
    237238  return -1;
    238239}
  • cpukit/libcsupport/src/unmount.c

    r72d3f610 r04df848  
    138138   */
    139139
     140  rtems_filesystem_freenode( &temp_loc.mt_entry->mt_point_node );
    140141  free( temp_loc.mt_entry );
    141142  rtems_filesystem_freenode( &temp_loc );
Note: See TracChangeset for help on using the changeset viewer.