source: rtems/c/src/lib/libc/imfs_free.c @ 0bf2ff8

4.104.114.84.95
Last change on this file since 0bf2ff8 was 07a3253d, checked in by Joel Sherrill <joel.sherrill@…>, on 11/23/98 at 19:07:58

Added base version of file system infrastructure. This includes a major
overhaul of the RTEMS system call interface. This base file system is
the "In-Memory File System" aka IMFS.

The design and implementation was done by the following people:

+ Joel Sherrill (joel@…)
+ Jennifer Averett (jennifer@…)
+ Steve "Mr Mount" Salitasc (salitasc@…)
+ Kerwin Wade (wade@…)

PROBLEMS
========

+ It is VERY likely that merging this will break the UNIX port. This

can/will be fixed.

+ There is likely some reentrancy/mutual exclusion needed.

+ Eventually, there should be a "mini-IMFS" description table to

eliminate links, symlinks, etc to save memory. All you need to
have "classic RTEMS" functionality is technically directories
and device IO. All the rest could be left out to save memory.

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