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

4.104.114.84.95
Last change on this file since cf0539b1 was cf0539b1, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:54:17

2003-09-04 Joel Sherrill <joel@…>

  • src/dosfs/dosfs.h, src/dosfs/fat.h, src/dosfs/fat_fat_operations.h, src/dosfs/fat_file.h, src/dosfs/msdos.h, src/dosfs/msdos_create.c, src/dosfs/msdos_dir.c, src/dosfs/msdos_eval.c, src/dosfs/msdos_file.c, src/dosfs/msdos_free.c, src/dosfs/msdos_fsunmount.c, src/dosfs/msdos_handlers_dir.c, src/dosfs/msdos_handlers_file.c, src/dosfs/msdos_init.c, src/dosfs/msdos_initsupp.c, src/dosfs/msdos_misc.c, src/dosfs/msdos_mknod.c, src/dosfs/msdos_node_type.c, src/imfs/deviceio.c, src/imfs/imfs.h, src/imfs/imfs_chown.c, src/imfs/imfs_config.c, src/imfs/imfs_creat.c, src/imfs/imfs_debug.c, src/imfs/imfs_directory.c, src/imfs/imfs_eval.c, src/imfs/imfs_fchmod.c, src/imfs/imfs_fcntl.c, src/imfs/imfs_fdatasync.c, src/imfs/imfs_free.c, src/imfs/imfs_fsunmount.c, src/imfs/imfs_getchild.c, src/imfs/imfs_gtkn.c, src/imfs/imfs_handlers_device.c, src/imfs/imfs_handlers_directory.c, src/imfs/imfs_handlers_link.c, src/imfs/imfs_handlers_memfile.c, src/imfs/imfs_init.c, src/imfs/imfs_initsupp.c, src/imfs/imfs_link.c, src/imfs/imfs_mknod.c, src/imfs/imfs_mount.c, src/imfs/imfs_ntype.c, src/imfs/imfs_readlink.c, src/imfs/imfs_rmnod.c, src/imfs/imfs_stat.c, src/imfs/imfs_symlink.c, src/imfs/imfs_unixstub.c, src/imfs/imfs_unlink.c, src/imfs/imfs_unmount.c, src/imfs/imfs_utime.c, src/imfs/ioman.c, src/imfs/linearfile.c, src/imfs/memfile.c, src/imfs/miniimfs_init.c: URL for license changed.
  • Property mode set to 100644
File size: 1.5 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    Chain_Extract( (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    free( the_jnode );
75  }
76
77  return 0;
78
79}
80
81
82
Note: See TracBrowser for help on using the repository browser.