source: rtems/cpukit/libfs/src/imfs/imfs_rmnod.c @ 72d2ec4d

4.104.114.95
Last change on this file since 72d2ec4d was 72d2ec4d, checked in by Chris Johns <chrisj@…>, on 07/03/08 at 01:37:38

2008-07-03 Chris Johns <chrisj@…>

  • cpukit/libcsupport/include/chain.h: Removed. Use the SAPI interface that is supported.
  • cpukit/libcsupport/Makefile.am, cpukit/libcsupport/preinstall.am: Remove chain.h header references.
  • cpukit/sapi/include/rtems/chain.h, cpukit/sapi/inline/rtems/chain.inl: New. A supported chains interface.
  • cpukit/sapi/Makefile.am, cpukit/sapi/preinstall.am: Updated to include the new chains interface.
  • cpukit/libfs/src/imfs/imfs.h, cpukit/libfs/src/imfs/imfs_creat.c, cpukit/libfs/src/imfs/imfs_debug.c, cpukit/libfs/src/imfs/imfs_directory.c, cpukit/libfs/src/imfs/imfs_fsunmount.c, cpukit/libfs/src/imfs/imfs_getchild.c, cpukit/libfs/src/imfs/imfs_load_tar.c, cpukit/libfs/src/imfs/imfs_rmnod.c, cpukit/libfs/src/imfs/memfile.c, cpukit/libfs/src/nfsclient/src/nfs.c, cpukit/libcsupport/include/rtems/libio.h, cpukit/libcsupport/src/malloc_deferred.c, cpukit/libcsupport/src/mount.c, cpukit/libcsupport/src/privateenv.c, cpukit/libcsupport/src/unmount.c: Change to the new chains interface.
  • cpukit/libcsupport/src/malloc_boundary.c: Remove warning.
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  IMFS Node Removal Handler
3 *
4 *  This file contains the handler used to remove a node when a file type
5 *  does not require special actions.
6 *
7 *  COPYRIGHT (c) 1989-1999.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.com/license/LICENSE.
13 *
14 *  $Id$
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <stdlib.h>
22
23#include <rtems.h>
24#include <rtems/libio.h>
25#include <rtems/libio_.h>
26
27#include "imfs.h"
28
29/*
30 *  IMFS_rmnod
31 */
32
33int IMFS_rmnod(
34  rtems_filesystem_location_info_t      *pathloc       /* IN */
35)
36{
37  IMFS_jnode_t *the_jnode;
38
39  the_jnode = (IMFS_jnode_t *) pathloc->node_access;
40
41  /*
42   * Take the node out of the parent's chain that contains this node
43   */
44
45  if ( the_jnode->Parent != NULL ) {
46    rtems_chain_extract( (rtems_chain_node *) the_jnode );
47    the_jnode->Parent = NULL;
48  }
49
50  /*
51   * Decrement the link counter and see if we can free the space.
52   */
53
54  the_jnode->st_nlink--;
55  IMFS_update_ctime( the_jnode );
56
57  /*
58   * The file cannot be open and the link must be less than 1 to free.
59   */
60
61  if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
62
63    /*
64     * Is rtems_filesystem_current this node?
65     */
66
67    if ( rtems_filesystem_current.node_access == pathloc->node_access )
68       rtems_filesystem_current.node_access = NULL;
69
70    /*
71     * Free memory associated with a memory file.
72     */
73
74    if ( the_jnode->type == IMFS_SYM_LINK ) {
75      if ( the_jnode->info.sym_link.name )
76        free( (void*) the_jnode->info.sym_link.name );
77    }
78    free( the_jnode );
79  }
80
81  return 0;
82
83}
Note: See TracBrowser for help on using the repository browser.