blob: 8216547c122b76074c8795e4a401762f091843a9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/*
* Free IMFS Node Support Routines
*
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <errno.h>
#include "libio_.h"
#include "imfs.h"
/*
* IMFS_freenodinfo
*
* This routine is the IMFS free node handler for the file system
* operations table.
*
* The In Memory File System keeps its nodes in memory. This routine
* is for file sytems that do not.
*/
int IMFS_freenodinfo(
rtems_filesystem_location_info_t *pathloc /* IN */
)
{
return 0;
}
/*
* IMFS_freenod
*
* The following routine frees a node if possible.
*
* The routine returns 0 if the node was not freed and 1 if it was.
*
* NOTE: This routine is for INTERNAL IMFS use only.
*/
int IMFS_freenod(
rtems_filesystem_location_info_t *pathloc
)
{
IMFS_jnode_t *the_jnode;
the_jnode = pathloc->node_access;
if ( the_jnode->type == IMFS_DIRECTORY ) {
/*
* You cannot remove a node that still has children
*/
if ( ! Chain_Is_empty( &the_jnode->info.directory.Entries ) )
return ENOTEMPTY;
/*
* You cannot remove the file system root node.
*/
if ( pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access )
return EBUSY;
/*
* You cannot remove a mountpoint.
*/
if ( the_jnode->info.directory.mt_fs != NULL )
return EBUSY;
}
if ( !rtems_libio_is_file_open( the_jnode ) &&
(the_jnode->st_nlink < 1) ) {
/*
* Is the rtems_filesystem_current is this node?
*/
if ( rtems_filesystem_current.node_access == pathloc->node_access ) {
rtems_filesystem_current.node_access = NULL;
}
/*
* Free memory associated with a memory file.
*/
if ( the_jnode->type == IMFS_MEMORY_FILE )
IMFS_memfile_remove( the_jnode );
free( the_jnode );
}
return 0;
}
|