source: rtems/c/src/libfs/src/imfs/imfs_rmnod.c @ d6b1d73

4.104.114.84.95
Last change on this file since d6b1d73 was d6b1d73, checked in by Joel Sherrill <joel.sherrill@…>, on 01/22/01 at 14:05:14

2001-01-22 Ralf Corsepius <corsepiu@…>

  • configure.in: Add src/imfs/config.h
  • src/imfs/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • src/imfs/.cvsignore: Add config.h and stamp-h
  • src/imfs/*.c: Add config.h support.
  • 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.OARcorp.com/rtems/license.html.
13 *
14 *  $Id$
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems.h>
22#include <rtems/libio.h>
23#include <rtems/libio_.h>
24
25#include "imfs.h"
26
27/*
28 *  IMFS_rmnod
29 */
30
31int IMFS_rmnod(
32  rtems_filesystem_location_info_t      *pathloc       /* IN */
33)
34{
35  IMFS_jnode_t *the_jnode; 
36
37  the_jnode = (IMFS_jnode_t *) pathloc->node_access;
38
39  /*
40   * Take the node out of the parent's chain that contains this node
41   */
42
43  if ( the_jnode->Parent != NULL ) {
44    Chain_Extract( (Chain_Node *) the_jnode );
45    the_jnode->Parent = NULL;
46  }
47
48  /*
49   * Decrement the link counter and see if we can free the space.
50   */
51
52  the_jnode->st_nlink--;
53  IMFS_update_ctime( the_jnode );
54
55  /*
56   * The file cannot be open and the link must be less than 1 to free.
57   */
58
59  if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
60
61    /*
62     * Is rtems_filesystem_current this node?
63     */
64
65    if ( rtems_filesystem_current.node_access == pathloc->node_access )
66       rtems_filesystem_current.node_access = NULL;
67
68    /*
69     * Free memory associated with a memory file.
70     */
71
72    free( the_jnode );
73  }
74
75  return 0;
76
77}
78
79
80
Note: See TracBrowser for help on using the repository browser.