diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1998-11-23 19:07:58 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1998-11-23 19:07:58 +0000 |
commit | 07a3253de2c3f9bc2d96a351680ec72548dadd2d (patch) | |
tree | b4f85e78927202cffe01b194c708c3dd800d8e57 /c/src/libfs/src/imfs/imfs_free.c | |
parent | Added new tests in support of the file system infrastructure. (diff) | |
download | rtems-07a3253de2c3f9bc2d96a351680ec72548dadd2d.tar.bz2 |
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@OARcorp.com)
+ Jennifer Averett (jennifer@OARcorp.com)
+ Steve "Mr Mount" Salitasc (salitasc@OARcorp.com)
+ Kerwin Wade (wade@OARcorp.com)
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.
Diffstat (limited to '')
-rw-r--r-- | c/src/libfs/src/imfs/imfs_free.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/c/src/libfs/src/imfs/imfs_free.c b/c/src/libfs/src/imfs/imfs_free.c new file mode 100644 index 0000000000..8216547c12 --- /dev/null +++ b/c/src/libfs/src/imfs/imfs_free.c @@ -0,0 +1,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; +} |