コード例 #1
0
ファイル: memfile.c プロジェクト: epicsdeb/rtems
int  memfile_check_rmnod( IMFS_jnode_t *the_jnode ){

  /*
   * The file cannot be open and the link must be less than 1 to free.
   */

  if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {

    /*
     * Is the rtems_filesystem_current is this node?
     */

    if ( rtems_filesystem_current.node_access == the_jnode )
       rtems_filesystem_current.node_access = NULL;

    /*
     * Free memory associated with a memory file.
     */
    if (the_jnode->type != IMFS_LINEAR_FILE)
      IMFS_memfile_remove( the_jnode );

    free( the_jnode );
  }

  return 0;
}
コード例 #2
0
ファイル: imfs_rmnod.c プロジェクト: rtemss/rtems
void IMFS_check_node_remove( IMFS_jnode_t *jnode )
{
  if ( !rtems_libio_is_file_open( jnode ) && jnode->st_nlink < 1 ) {
    if ( rtems_filesystem_current.node_access == jnode )
       rtems_filesystem_current.node_access = NULL;

    switch ( jnode->type ) {
      case IMFS_MEMORY_FILE:
        IMFS_memfile_remove( jnode );
        break;
      case IMFS_SYM_LINK:
        free( jnode->info.sym_link.name );
        break;
      default:
        break;
    }

    free( jnode );
  }
}
コード例 #3
0
ファイル: imfs_directory.c プロジェクト: epicsdeb/rtems
int imfs_dir_rmnod(
  rtems_filesystem_location_info_t  *parent_pathloc, /* IN */
  rtems_filesystem_location_info_t  *pathloc         /* IN */
)
{
  IMFS_jnode_t *the_jnode;

  the_jnode = (IMFS_jnode_t *) pathloc->node_access;

  /*
   * You cannot remove a node that still has children
   */

  if ( ! rtems_chain_is_empty( &the_jnode->info.directory.Entries ) )
     rtems_set_errno_and_return_minus_one( ENOTEMPTY );

  /*
   * You cannot remove the file system root node.
   */

  if ( pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access )
     rtems_set_errno_and_return_minus_one( EBUSY );

  /*
   * You cannot remove a mountpoint.
   */

   if ( the_jnode->info.directory.mt_fs != NULL )
     rtems_set_errno_and_return_minus_one( EBUSY );

  /*
   * Take the node out of the parent's chain that contains this node
   */

  if ( the_jnode->Parent != NULL ) {
    rtems_chain_extract( (rtems_chain_node *) the_jnode );
    the_jnode->Parent = NULL;
  }

  /*
   * Decrement the link counter and see if we can free the space.
   */

  the_jnode->st_nlink--;
  IMFS_update_ctime( the_jnode );

  /*
   * The file cannot be open and the link must be less than 1 to free.
   */

  if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {

    /*
     * Is the rtems_filesystem_current is this node?
     */

    if ( rtems_filesystem_current.node_access == pathloc->node_access )
       rtems_filesystem_current.node_access = NULL;

    /*
     * Free memory associated with a memory file.
     */

    free( the_jnode );
  }

  return 0;

}