summaryrefslogtreecommitdiffstats
path: root/c/src/exec/libfs/src/imfs/imfs_directory.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-11-02 20:20:13 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-11-02 20:20:13 +0000
commitb568ccb7455fa29df50205d5fc13802598ced1d6 (patch)
tree83690f72a7978f78a2181dddf6b923c8001ee6cf /c/src/exec/libfs/src/imfs/imfs_directory.c
parentSplit object.c into multiple files. (diff)
downloadrtems-b568ccb7455fa29df50205d5fc13802598ced1d6.tar.bz2
The object memfile.o was being included in the miniIMFS even though it
should not have been. This required that IMFS_rmnod be split into three separate (per file type) routines to avoid dependencies. In the end, a miniIMFS application is 6K smaller than one using the full IMFS.
Diffstat (limited to 'c/src/exec/libfs/src/imfs/imfs_directory.c')
-rw-r--r--c/src/exec/libfs/src/imfs/imfs_directory.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/c/src/exec/libfs/src/imfs/imfs_directory.c b/c/src/exec/libfs/src/imfs/imfs_directory.c
index fbf4ba53a3..89672ec9ae 100644
--- a/c/src/exec/libfs/src/imfs/imfs_directory.c
+++ b/c/src/exec/libfs/src/imfs/imfs_directory.c
@@ -269,4 +269,80 @@ int imfs_dir_fstat(
return 0;
}
+/*
+ * IMFS_dir_rmnod
+ *
+ * This routine is available from the optable to remove a node
+ * from the IMFS file system.
+ */
+
+int imfs_dir_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+)
+{
+ IMFS_jnode_t *the_jnode;
+
+ the_jnode = (IMFS_jnode_t *) pathloc->node_access;
+
+ /*
+ * You cannot remove a node that still has children
+ */
+
+ if ( ! Chain_Is_empty( &the_jnode->info.directory.Entries ) )
+ set_errno_and_return_minus_one( ENOTEMPTY );
+
+ /*
+ * You cannot remove the file system root node.
+ */
+
+ if ( pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access )
+ set_errno_and_return_minus_one( EBUSY );
+
+ /*
+ * You cannot remove a mountpoint.
+ */
+
+ if ( the_jnode->info.directory.mt_fs != NULL )
+ set_errno_and_return_minus_one( EBUSY );
+
+ /*
+ * Take the node out of the parent's chain that contains this node
+ */
+
+ if ( the_jnode->Parent != NULL ) {
+ Chain_Extract( (Chain_Node *) the_jnode );
+ the_jnode->Parent = NULL;
+ }
+
+ /*
+ * Decrement the link counter and see if we can free the space.
+ */
+
+ the_jnode->st_nlink--;
+ IMFS_update_ctime( the_jnode );
+
+ /*
+ * The file cannot be open and the link must be less than 1 to free.
+ */
+
+ 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.
+ */
+
+ free( the_jnode );
+ }
+
+ return 0;
+
+}
+