source: rtems/c/src/lib/libc/imfs_rmnod.c @ 089ad91d

4.104.114.84.95
Last change on this file since 089ad91d was 089ad91d, checked in by Jennifer Averett <Jennifer.Averett@…>, on 11/05/99 at 22:25:16

Fixed comment

  • 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-1998.
8 *  On-Line Applications Research Corporation (OAR).
9 *  Copyright assigned to U.S. Government, 1994.
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.OARcorp.com/rtems/license.html.
14 *
15 *  $Id$
16 */
17
18#include <rtems.h>
19#include <rtems/libio.h>
20#include "libio_.h"
21
22#include "imfs.h"
23
24/*
25 *  IMFS_rmnod
26 */
27
28int IMFS_rmnod(
29  rtems_filesystem_location_info_t      *pathloc       /* IN */
30)
31{
32  IMFS_jnode_t *the_jnode; 
33
34  the_jnode = (IMFS_jnode_t *) pathloc->node_access;
35
36  /*
37   * Take the node out of the parent's chain that contains this node
38   */
39
40  if ( the_jnode->Parent != NULL ) {
41    Chain_Extract( (Chain_Node *) the_jnode );
42    the_jnode->Parent = NULL;
43  }
44
45  /*
46   * Decrement the link counter and see if we can free the space.
47   */
48
49  the_jnode->st_nlink--;
50  IMFS_update_ctime( the_jnode );
51
52  /*
53   * The file cannot be open and the link must be less than 1 to free.
54   */
55
56  if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
57
58    /*
59     * Is rtems_filesystem_current this node?
60     */
61
62    if ( rtems_filesystem_current.node_access == pathloc->node_access )
63       rtems_filesystem_current.node_access = NULL;
64
65    /*
66     * Free memory associated with a memory file.
67     */
68
69    free( the_jnode );
70  }
71
72  return 0;
73
74}
75
76
77
Note: See TracBrowser for help on using the repository browser.