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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libc/] [imfs_rmnod.c] - Blame information for rev 596

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: imfs_rmnod.c,v 1.2 2001-09-27 12:01:15 chris Exp $
15
 */
16
 
17
#include <rtems.h>
18
#include <rtems/libio.h>
19
#include "libio_.h"
20
 
21
#include "imfs.h"
22
 
23
/*
24
 *  IMFS_rmnod
25
 */
26
 
27
int IMFS_rmnod(
28
  rtems_filesystem_location_info_t      *pathloc       /* IN */
29
)
30
{
31
  IMFS_jnode_t *the_jnode;
32
 
33
  the_jnode = (IMFS_jnode_t *) pathloc->node_access;
34
 
35
  /*
36
   * Take the node out of the parent's chain that contains this node
37
   */
38
 
39
  if ( the_jnode->Parent != NULL ) {
40
    Chain_Extract( (Chain_Node *) the_jnode );
41
    the_jnode->Parent = NULL;
42
  }
43
 
44
  /*
45
   * Decrement the link counter and see if we can free the space.
46
   */
47
 
48
  the_jnode->st_nlink--;
49
  IMFS_update_ctime( the_jnode );
50
 
51
  /*
52
   * The file cannot be open and the link must be less than 1 to free.
53
   */
54
 
55
  if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
56
 
57
    /*
58
     * Is rtems_filesystem_current this node?
59
     */
60
 
61
    if ( rtems_filesystem_current.node_access == pathloc->node_access )
62
       rtems_filesystem_current.node_access = NULL;
63
 
64
    /*
65
     * Free memory associated with a memory file.
66
     */
67
 
68
    free( the_jnode );
69
  }
70
 
71
  return 0;
72
 
73
}
74
 
75
 
76
 

powered by: WebSVN 2.1.0

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