OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [libfs/] [src/] [imfs/] [imfs_rmnod.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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
 *  imfs_rmnod.c,v 1.10 2002/01/08 12:05:36 joel Exp
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
 
33
int 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
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.