summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--c/src/exec/libfs/src/imfs/deviceio.c56
-rw-r--r--c/src/exec/libfs/src/imfs/imfs.h35
-rw-r--r--c/src/exec/libfs/src/imfs/imfs_directory.c76
-rw-r--r--c/src/exec/libfs/src/imfs/imfs_handlers_device.c2
-rw-r--r--c/src/exec/libfs/src/imfs/imfs_handlers_directory.c2
-rw-r--r--c/src/exec/libfs/src/imfs/imfs_handlers_memfile.c2
-rw-r--r--c/src/exec/libfs/src/imfs/imfs_rmnod.c98
-rw-r--r--c/src/exec/libfs/src/imfs/imfs_unlink.c4
-rw-r--r--c/src/exec/libfs/src/imfs/memfile.c79
-rw-r--r--c/src/exec/libfs/src/imfs/miniimfs_init.c1
-rw-r--r--c/src/lib/libc/Makefile.in2
-rw-r--r--c/src/lib/libc/deviceio.c56
-rw-r--r--c/src/lib/libc/imfs.h35
-rw-r--r--c/src/lib/libc/imfs_directory.c76
-rw-r--r--c/src/lib/libc/imfs_handlers_device.c2
-rw-r--r--c/src/lib/libc/imfs_handlers_directory.c2
-rw-r--r--c/src/lib/libc/imfs_handlers_memfile.c2
-rw-r--r--c/src/lib/libc/imfs_rmnod.c98
-rw-r--r--c/src/lib/libc/imfs_unlink.c4
-rw-r--r--c/src/lib/libc/memfile.c79
-rw-r--r--c/src/lib/libc/miniimfs_init.c1
-rw-r--r--c/src/libfs/src/imfs/deviceio.c56
-rw-r--r--c/src/libfs/src/imfs/imfs.h35
-rw-r--r--c/src/libfs/src/imfs/imfs_directory.c76
-rw-r--r--c/src/libfs/src/imfs/imfs_handlers_device.c2
-rw-r--r--c/src/libfs/src/imfs/imfs_handlers_directory.c2
-rw-r--r--c/src/libfs/src/imfs/imfs_handlers_memfile.c2
-rw-r--r--c/src/libfs/src/imfs/imfs_rmnod.c98
-rw-r--r--c/src/libfs/src/imfs/imfs_unlink.c4
-rw-r--r--c/src/libfs/src/imfs/memfile.c79
-rw-r--r--c/src/libfs/src/imfs/miniimfs_init.c1
-rw-r--r--cpukit/libfs/src/imfs/deviceio.c56
-rw-r--r--cpukit/libfs/src/imfs/imfs.h35
-rw-r--r--cpukit/libfs/src/imfs/imfs_directory.c76
-rw-r--r--cpukit/libfs/src/imfs/imfs_handlers_device.c2
-rw-r--r--cpukit/libfs/src/imfs/imfs_handlers_directory.c2
-rw-r--r--cpukit/libfs/src/imfs/imfs_handlers_memfile.c2
-rw-r--r--cpukit/libfs/src/imfs/imfs_rmnod.c98
-rw-r--r--cpukit/libfs/src/imfs/imfs_unlink.c4
-rw-r--r--cpukit/libfs/src/imfs/memfile.c79
-rw-r--r--cpukit/libfs/src/imfs/miniimfs_init.c1
41 files changed, 909 insertions, 513 deletions
diff --git a/c/src/exec/libfs/src/imfs/deviceio.c b/c/src/exec/libfs/src/imfs/deviceio.c
index f954decf6e..70b9706ada 100644
--- a/c/src/exec/libfs/src/imfs/deviceio.c
+++ b/c/src/exec/libfs/src/imfs/deviceio.c
@@ -17,6 +17,7 @@
#include <rtems.h>
#include <rtems/libio.h>
+#include "libio_.h"
#include "imfs.h"
@@ -213,3 +214,58 @@ int device_lseek(
*
* This IMFS_stat() is used.
*/
+
+/*
+ * device_rmnod
+ */
+
+int device_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+)
+{
+ IMFS_jnode_t *the_jnode;
+
+ the_jnode = (IMFS_jnode_t *) pathloc->node_access;
+
+ /*
+ * 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;
+
+}
+
+
+
diff --git a/c/src/exec/libfs/src/imfs/imfs.h b/c/src/exec/libfs/src/imfs/imfs.h
index d1be06bbf4..a88672c4b8 100644
--- a/c/src/exec/libfs/src/imfs/imfs.h
+++ b/c/src/exec/libfs/src/imfs/imfs.h
@@ -308,10 +308,6 @@ int IMFS_freenodinfo(
rtems_filesystem_location_info_t *pathloc /* IN */
);
-int IMFS_rmnod(
- rtems_filesystem_location_info_t *pathloc /* IN */
-);
-
int IMFS_mknod(
const char *path, /* IN */
mode_t mode, /* IN */
@@ -353,92 +349,123 @@ int memfile_ftruncate(
rtems_libio_t *iop, /* IN */
off_t length /* IN */
);
+
int imfs_dir_open(
rtems_libio_t *iop, /* IN */
const char *pathname, /* IN */
unsigned32 flag, /* IN */
unsigned32 mode /* IN */
);
+
int imfs_dir_close(
rtems_libio_t *iop /* IN */
);
+
int imfs_dir_read(
rtems_libio_t *iop, /* IN */
void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int imfs_dir_lseek(
rtems_libio_t *iop, /* IN */
off_t offset, /* IN */
int whence /* IN */
);
+
int imfs_dir_fstat(
rtems_filesystem_location_info_t *loc, /* IN */
struct stat *buf /* OUT */
);
+
+int imfs_dir_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+);
+
int memfile_open(
rtems_libio_t *iop, /* IN */
const char *pathname, /* IN */
unsigned32 flag, /* IN */
unsigned32 mode /* IN */
);
+
int memfile_close(
rtems_libio_t *iop /* IN */
);
+
int memfile_read(
rtems_libio_t *iop, /* IN */
void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int memfile_write(
rtems_libio_t *iop, /* IN */
const void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int memfile_ioctl(
rtems_libio_t *iop, /* IN */
unsigned32 command, /* IN */
void *buffer /* IN */
);
+
int memfile_lseek(
rtems_libio_t *iop, /* IN */
off_t offset, /* IN */
int whence /* IN */
);
+
+int memfile_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+);
+
int device_open(
rtems_libio_t *iop, /* IN */
const char *pathname, /* IN */
unsigned32 flag, /* IN */
unsigned32 mode /* IN */
);
+
int device_close(
rtems_libio_t *iop /* IN */
);
+
int device_read(
rtems_libio_t *iop, /* IN */
void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int device_write(
rtems_libio_t *iop, /* IN */
const void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int device_ioctl(
rtems_libio_t *iop, /* IN */
unsigned32 command, /* IN */
void *buffer /* IN */
);
+
int device_lseek(
rtems_libio_t *iop, /* IN */
off_t offset, /* IN */
int whence /* IN */
);
+
+int device_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+);
+
int IMFS_utime(
rtems_filesystem_location_info_t *pathloc, /* IN */
time_t actime, /* IN */
time_t modtime /* IN */
);
+
int IMFS_fchmod(
rtems_filesystem_location_info_t *loc,
mode_t mode
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;
+
+}
+
diff --git a/c/src/exec/libfs/src/imfs/imfs_handlers_device.c b/c/src/exec/libfs/src/imfs/imfs_handlers_device.c
index b6b9c808a0..24b7ffa5bb 100644
--- a/c/src/exec/libfs/src/imfs/imfs_handlers_device.c
+++ b/c/src/exec/libfs/src/imfs/imfs_handlers_device.c
@@ -34,5 +34,5 @@ rtems_filesystem_file_handlers_r IMFS_device_handlers = {
NULL, /* fsync */
NULL, /* fdatasync */
NULL, /* fcntl */
- IMFS_rmnod
+ device_rmnod
};
diff --git a/c/src/exec/libfs/src/imfs/imfs_handlers_directory.c b/c/src/exec/libfs/src/imfs/imfs_handlers_directory.c
index 364f3cdf26..0ee06d8ebf 100644
--- a/c/src/exec/libfs/src/imfs/imfs_handlers_directory.c
+++ b/c/src/exec/libfs/src/imfs/imfs_handlers_directory.c
@@ -34,7 +34,7 @@ rtems_filesystem_file_handlers_r IMFS_directory_handlers = {
NULL, /* fsync */
IMFS_fdatasync,
IMFS_fcntl,
- IMFS_rmnod
+ imfs_dir_rmnod
};
diff --git a/c/src/exec/libfs/src/imfs/imfs_handlers_memfile.c b/c/src/exec/libfs/src/imfs/imfs_handlers_memfile.c
index f622c99558..20ef3c57b3 100644
--- a/c/src/exec/libfs/src/imfs/imfs_handlers_memfile.c
+++ b/c/src/exec/libfs/src/imfs/imfs_handlers_memfile.c
@@ -34,5 +34,5 @@ rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
NULL, /* fsync */
IMFS_fdatasync,
IMFS_fcntl,
- IMFS_rmnod
+ memfile_rmnod
};
diff --git a/c/src/exec/libfs/src/imfs/imfs_rmnod.c b/c/src/exec/libfs/src/imfs/imfs_rmnod.c
deleted file mode 100644
index 3768b9543d..0000000000
--- a/c/src/exec/libfs/src/imfs/imfs_rmnod.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * IMFS_rmnod
- *
- * This routine is available from the optable to remove a node
- * from the IMFS file system.
- *
- * 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"
-
-
-int IMFS_rmnod(
- rtems_filesystem_location_info_t *pathloc /* IN */
-)
-{
- IMFS_jnode_t *the_jnode;
-
- the_jnode = (IMFS_jnode_t *) 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 ) )
- 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.
- */
-
- if ( the_jnode->type == IMFS_MEMORY_FILE )
- IMFS_memfile_remove( the_jnode );
-
- free( the_jnode );
- }
-
- return 0;
-
-}
-
-
diff --git a/c/src/exec/libfs/src/imfs/imfs_unlink.c b/c/src/exec/libfs/src/imfs/imfs_unlink.c
index 4e0ca26b2a..e138064e61 100644
--- a/c/src/exec/libfs/src/imfs/imfs_unlink.c
+++ b/c/src/exec/libfs/src/imfs/imfs_unlink.c
@@ -55,13 +55,13 @@ int IMFS_unlink(
node->info.hard_link.link_node->st_nlink --;
IMFS_update_ctime( node->info.hard_link.link_node );
if ( node->info.hard_link.link_node->st_nlink < 1) {
- result = IMFS_rmnod( &the_link );
+ result = (*loc->handlers->rmnod)( &the_link );
if ( result != 0 )
return -1;
}
}
- result = IMFS_rmnod( loc );
+ result = (*loc->handlers->rmnod)( &the_link );
return result;
}
diff --git a/c/src/exec/libfs/src/imfs/memfile.c b/c/src/exec/libfs/src/imfs/memfile.c
index 3468490c90..0a3b30d38f 100644
--- a/c/src/exec/libfs/src/imfs/memfile.c
+++ b/c/src/exec/libfs/src/imfs/memfile.c
@@ -30,26 +30,6 @@
#define MEMFILE_STATIC
/*
- * Set of operations handlers for operations on memfile entities.
- */
-
-rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
- memfile_open,
- memfile_close,
- memfile_read,
- memfile_write,
- memfile_ioctl,
- memfile_lseek,
- IMFS_stat,
- IMFS_fchmod,
- memfile_ftruncate,
- NULL, /* fpathconf */
- NULL, /* fsync */
- IMFS_fdatasync,
- IMFS_fcntl
-};
-
-/*
* Prototypes of private routines
*/
@@ -1056,3 +1036,62 @@ fflush(stdout);
memfile_blocks_allocated--;
}
+
+/*
+ * memfile_rmnod
+ *
+ * This routine is available from the optable to remove a node
+ * from the IMFS file system.
+ */
+
+int memfile_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+)
+{
+ IMFS_jnode_t *the_jnode;
+
+ the_jnode = (IMFS_jnode_t *) pathloc->node_access;
+
+ /*
+ * 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.
+ */
+
+ IMFS_memfile_remove( the_jnode );
+
+ free( the_jnode );
+ }
+
+ return 0;
+
+}
+
+
diff --git a/c/src/exec/libfs/src/imfs/miniimfs_init.c b/c/src/exec/libfs/src/imfs/miniimfs_init.c
index 983cde9439..865822fbfc 100644
--- a/c/src/exec/libfs/src/imfs/miniimfs_init.c
+++ b/c/src/exec/libfs/src/imfs/miniimfs_init.c
@@ -37,7 +37,6 @@ rtems_filesystem_operations_table miniIMFS_ops = {
NULL, /* XXX IMFS_unlink, */
IMFS_node_type,
IMFS_mknod,
- NULL, /* XXX IMFS_rmnod, */
NULL, /* XXX IMFS_chown, */
NULL, /* XXX IMFS_freenodinfo, */
NULL, /* XXX IMFS_mount, */
diff --git a/c/src/lib/libc/Makefile.in b/c/src/lib/libc/Makefile.in
index 361f73d085..e91e2dd478 100644
--- a/c/src/lib/libc/Makefile.in
+++ b/c/src/lib/libc/Makefile.in
@@ -25,7 +25,7 @@ BASE_FS_C_PIECES = base_fs mount unmount ioman libio libio_sockets eval \
IMFS_C_PIECES = imfs_chown imfs_creat imfs_directory imfs_eval imfs_free \
imfs_fsunmount imfs_gtkn imfs_init imfs_initsupp imfs_link imfs_mknod \
- imfs_mount imfs_fchmod imfs_rmnod imfs_unlink imfs_unmount imfs_utime \
+ imfs_mount imfs_fchmod imfs_unlink imfs_unmount imfs_utime \
imfs_ntype imfs_stat imfs_getchild memfile deviceio imfs_handlers_device \
imfs_handlers_directory imfs_handlers_memfile imfs_debug imfs_symlink \
imfs_readlink imfs_fdatasync imfs_fcntl miniimfs_init
diff --git a/c/src/lib/libc/deviceio.c b/c/src/lib/libc/deviceio.c
index f954decf6e..70b9706ada 100644
--- a/c/src/lib/libc/deviceio.c
+++ b/c/src/lib/libc/deviceio.c
@@ -17,6 +17,7 @@
#include <rtems.h>
#include <rtems/libio.h>
+#include "libio_.h"
#include "imfs.h"
@@ -213,3 +214,58 @@ int device_lseek(
*
* This IMFS_stat() is used.
*/
+
+/*
+ * device_rmnod
+ */
+
+int device_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+)
+{
+ IMFS_jnode_t *the_jnode;
+
+ the_jnode = (IMFS_jnode_t *) pathloc->node_access;
+
+ /*
+ * 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;
+
+}
+
+
+
diff --git a/c/src/lib/libc/imfs.h b/c/src/lib/libc/imfs.h
index d1be06bbf4..a88672c4b8 100644
--- a/c/src/lib/libc/imfs.h
+++ b/c/src/lib/libc/imfs.h
@@ -308,10 +308,6 @@ int IMFS_freenodinfo(
rtems_filesystem_location_info_t *pathloc /* IN */
);
-int IMFS_rmnod(
- rtems_filesystem_location_info_t *pathloc /* IN */
-);
-
int IMFS_mknod(
const char *path, /* IN */
mode_t mode, /* IN */
@@ -353,92 +349,123 @@ int memfile_ftruncate(
rtems_libio_t *iop, /* IN */
off_t length /* IN */
);
+
int imfs_dir_open(
rtems_libio_t *iop, /* IN */
const char *pathname, /* IN */
unsigned32 flag, /* IN */
unsigned32 mode /* IN */
);
+
int imfs_dir_close(
rtems_libio_t *iop /* IN */
);
+
int imfs_dir_read(
rtems_libio_t *iop, /* IN */
void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int imfs_dir_lseek(
rtems_libio_t *iop, /* IN */
off_t offset, /* IN */
int whence /* IN */
);
+
int imfs_dir_fstat(
rtems_filesystem_location_info_t *loc, /* IN */
struct stat *buf /* OUT */
);
+
+int imfs_dir_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+);
+
int memfile_open(
rtems_libio_t *iop, /* IN */
const char *pathname, /* IN */
unsigned32 flag, /* IN */
unsigned32 mode /* IN */
);
+
int memfile_close(
rtems_libio_t *iop /* IN */
);
+
int memfile_read(
rtems_libio_t *iop, /* IN */
void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int memfile_write(
rtems_libio_t *iop, /* IN */
const void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int memfile_ioctl(
rtems_libio_t *iop, /* IN */
unsigned32 command, /* IN */
void *buffer /* IN */
);
+
int memfile_lseek(
rtems_libio_t *iop, /* IN */
off_t offset, /* IN */
int whence /* IN */
);
+
+int memfile_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+);
+
int device_open(
rtems_libio_t *iop, /* IN */
const char *pathname, /* IN */
unsigned32 flag, /* IN */
unsigned32 mode /* IN */
);
+
int device_close(
rtems_libio_t *iop /* IN */
);
+
int device_read(
rtems_libio_t *iop, /* IN */
void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int device_write(
rtems_libio_t *iop, /* IN */
const void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int device_ioctl(
rtems_libio_t *iop, /* IN */
unsigned32 command, /* IN */
void *buffer /* IN */
);
+
int device_lseek(
rtems_libio_t *iop, /* IN */
off_t offset, /* IN */
int whence /* IN */
);
+
+int device_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+);
+
int IMFS_utime(
rtems_filesystem_location_info_t *pathloc, /* IN */
time_t actime, /* IN */
time_t modtime /* IN */
);
+
int IMFS_fchmod(
rtems_filesystem_location_info_t *loc,
mode_t mode
diff --git a/c/src/lib/libc/imfs_directory.c b/c/src/lib/libc/imfs_directory.c
index fbf4ba53a3..89672ec9ae 100644
--- a/c/src/lib/libc/imfs_directory.c
+++ b/c/src/lib/libc/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;
+
+}
+
diff --git a/c/src/lib/libc/imfs_handlers_device.c b/c/src/lib/libc/imfs_handlers_device.c
index b6b9c808a0..24b7ffa5bb 100644
--- a/c/src/lib/libc/imfs_handlers_device.c
+++ b/c/src/lib/libc/imfs_handlers_device.c
@@ -34,5 +34,5 @@ rtems_filesystem_file_handlers_r IMFS_device_handlers = {
NULL, /* fsync */
NULL, /* fdatasync */
NULL, /* fcntl */
- IMFS_rmnod
+ device_rmnod
};
diff --git a/c/src/lib/libc/imfs_handlers_directory.c b/c/src/lib/libc/imfs_handlers_directory.c
index 364f3cdf26..0ee06d8ebf 100644
--- a/c/src/lib/libc/imfs_handlers_directory.c
+++ b/c/src/lib/libc/imfs_handlers_directory.c
@@ -34,7 +34,7 @@ rtems_filesystem_file_handlers_r IMFS_directory_handlers = {
NULL, /* fsync */
IMFS_fdatasync,
IMFS_fcntl,
- IMFS_rmnod
+ imfs_dir_rmnod
};
diff --git a/c/src/lib/libc/imfs_handlers_memfile.c b/c/src/lib/libc/imfs_handlers_memfile.c
index f622c99558..20ef3c57b3 100644
--- a/c/src/lib/libc/imfs_handlers_memfile.c
+++ b/c/src/lib/libc/imfs_handlers_memfile.c
@@ -34,5 +34,5 @@ rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
NULL, /* fsync */
IMFS_fdatasync,
IMFS_fcntl,
- IMFS_rmnod
+ memfile_rmnod
};
diff --git a/c/src/lib/libc/imfs_rmnod.c b/c/src/lib/libc/imfs_rmnod.c
deleted file mode 100644
index 3768b9543d..0000000000
--- a/c/src/lib/libc/imfs_rmnod.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * IMFS_rmnod
- *
- * This routine is available from the optable to remove a node
- * from the IMFS file system.
- *
- * 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"
-
-
-int IMFS_rmnod(
- rtems_filesystem_location_info_t *pathloc /* IN */
-)
-{
- IMFS_jnode_t *the_jnode;
-
- the_jnode = (IMFS_jnode_t *) 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 ) )
- 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.
- */
-
- if ( the_jnode->type == IMFS_MEMORY_FILE )
- IMFS_memfile_remove( the_jnode );
-
- free( the_jnode );
- }
-
- return 0;
-
-}
-
-
diff --git a/c/src/lib/libc/imfs_unlink.c b/c/src/lib/libc/imfs_unlink.c
index 4e0ca26b2a..e138064e61 100644
--- a/c/src/lib/libc/imfs_unlink.c
+++ b/c/src/lib/libc/imfs_unlink.c
@@ -55,13 +55,13 @@ int IMFS_unlink(
node->info.hard_link.link_node->st_nlink --;
IMFS_update_ctime( node->info.hard_link.link_node );
if ( node->info.hard_link.link_node->st_nlink < 1) {
- result = IMFS_rmnod( &the_link );
+ result = (*loc->handlers->rmnod)( &the_link );
if ( result != 0 )
return -1;
}
}
- result = IMFS_rmnod( loc );
+ result = (*loc->handlers->rmnod)( &the_link );
return result;
}
diff --git a/c/src/lib/libc/memfile.c b/c/src/lib/libc/memfile.c
index 3468490c90..0a3b30d38f 100644
--- a/c/src/lib/libc/memfile.c
+++ b/c/src/lib/libc/memfile.c
@@ -30,26 +30,6 @@
#define MEMFILE_STATIC
/*
- * Set of operations handlers for operations on memfile entities.
- */
-
-rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
- memfile_open,
- memfile_close,
- memfile_read,
- memfile_write,
- memfile_ioctl,
- memfile_lseek,
- IMFS_stat,
- IMFS_fchmod,
- memfile_ftruncate,
- NULL, /* fpathconf */
- NULL, /* fsync */
- IMFS_fdatasync,
- IMFS_fcntl
-};
-
-/*
* Prototypes of private routines
*/
@@ -1056,3 +1036,62 @@ fflush(stdout);
memfile_blocks_allocated--;
}
+
+/*
+ * memfile_rmnod
+ *
+ * This routine is available from the optable to remove a node
+ * from the IMFS file system.
+ */
+
+int memfile_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+)
+{
+ IMFS_jnode_t *the_jnode;
+
+ the_jnode = (IMFS_jnode_t *) pathloc->node_access;
+
+ /*
+ * 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.
+ */
+
+ IMFS_memfile_remove( the_jnode );
+
+ free( the_jnode );
+ }
+
+ return 0;
+
+}
+
+
diff --git a/c/src/lib/libc/miniimfs_init.c b/c/src/lib/libc/miniimfs_init.c
index 983cde9439..865822fbfc 100644
--- a/c/src/lib/libc/miniimfs_init.c
+++ b/c/src/lib/libc/miniimfs_init.c
@@ -37,7 +37,6 @@ rtems_filesystem_operations_table miniIMFS_ops = {
NULL, /* XXX IMFS_unlink, */
IMFS_node_type,
IMFS_mknod,
- NULL, /* XXX IMFS_rmnod, */
NULL, /* XXX IMFS_chown, */
NULL, /* XXX IMFS_freenodinfo, */
NULL, /* XXX IMFS_mount, */
diff --git a/c/src/libfs/src/imfs/deviceio.c b/c/src/libfs/src/imfs/deviceio.c
index f954decf6e..70b9706ada 100644
--- a/c/src/libfs/src/imfs/deviceio.c
+++ b/c/src/libfs/src/imfs/deviceio.c
@@ -17,6 +17,7 @@
#include <rtems.h>
#include <rtems/libio.h>
+#include "libio_.h"
#include "imfs.h"
@@ -213,3 +214,58 @@ int device_lseek(
*
* This IMFS_stat() is used.
*/
+
+/*
+ * device_rmnod
+ */
+
+int device_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+)
+{
+ IMFS_jnode_t *the_jnode;
+
+ the_jnode = (IMFS_jnode_t *) pathloc->node_access;
+
+ /*
+ * 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;
+
+}
+
+
+
diff --git a/c/src/libfs/src/imfs/imfs.h b/c/src/libfs/src/imfs/imfs.h
index d1be06bbf4..a88672c4b8 100644
--- a/c/src/libfs/src/imfs/imfs.h
+++ b/c/src/libfs/src/imfs/imfs.h
@@ -308,10 +308,6 @@ int IMFS_freenodinfo(
rtems_filesystem_location_info_t *pathloc /* IN */
);
-int IMFS_rmnod(
- rtems_filesystem_location_info_t *pathloc /* IN */
-);
-
int IMFS_mknod(
const char *path, /* IN */
mode_t mode, /* IN */
@@ -353,92 +349,123 @@ int memfile_ftruncate(
rtems_libio_t *iop, /* IN */
off_t length /* IN */
);
+
int imfs_dir_open(
rtems_libio_t *iop, /* IN */
const char *pathname, /* IN */
unsigned32 flag, /* IN */
unsigned32 mode /* IN */
);
+
int imfs_dir_close(
rtems_libio_t *iop /* IN */
);
+
int imfs_dir_read(
rtems_libio_t *iop, /* IN */
void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int imfs_dir_lseek(
rtems_libio_t *iop, /* IN */
off_t offset, /* IN */
int whence /* IN */
);
+
int imfs_dir_fstat(
rtems_filesystem_location_info_t *loc, /* IN */
struct stat *buf /* OUT */
);
+
+int imfs_dir_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+);
+
int memfile_open(
rtems_libio_t *iop, /* IN */
const char *pathname, /* IN */
unsigned32 flag, /* IN */
unsigned32 mode /* IN */
);
+
int memfile_close(
rtems_libio_t *iop /* IN */
);
+
int memfile_read(
rtems_libio_t *iop, /* IN */
void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int memfile_write(
rtems_libio_t *iop, /* IN */
const void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int memfile_ioctl(
rtems_libio_t *iop, /* IN */
unsigned32 command, /* IN */
void *buffer /* IN */
);
+
int memfile_lseek(
rtems_libio_t *iop, /* IN */
off_t offset, /* IN */
int whence /* IN */
);
+
+int memfile_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+);
+
int device_open(
rtems_libio_t *iop, /* IN */
const char *pathname, /* IN */
unsigned32 flag, /* IN */
unsigned32 mode /* IN */
);
+
int device_close(
rtems_libio_t *iop /* IN */
);
+
int device_read(
rtems_libio_t *iop, /* IN */
void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int device_write(
rtems_libio_t *iop, /* IN */
const void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int device_ioctl(
rtems_libio_t *iop, /* IN */
unsigned32 command, /* IN */
void *buffer /* IN */
);
+
int device_lseek(
rtems_libio_t *iop, /* IN */
off_t offset, /* IN */
int whence /* IN */
);
+
+int device_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+);
+
int IMFS_utime(
rtems_filesystem_location_info_t *pathloc, /* IN */
time_t actime, /* IN */
time_t modtime /* IN */
);
+
int IMFS_fchmod(
rtems_filesystem_location_info_t *loc,
mode_t mode
diff --git a/c/src/libfs/src/imfs/imfs_directory.c b/c/src/libfs/src/imfs/imfs_directory.c
index fbf4ba53a3..89672ec9ae 100644
--- a/c/src/libfs/src/imfs/imfs_directory.c
+++ b/c/src/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;
+
+}
+
diff --git a/c/src/libfs/src/imfs/imfs_handlers_device.c b/c/src/libfs/src/imfs/imfs_handlers_device.c
index b6b9c808a0..24b7ffa5bb 100644
--- a/c/src/libfs/src/imfs/imfs_handlers_device.c
+++ b/c/src/libfs/src/imfs/imfs_handlers_device.c
@@ -34,5 +34,5 @@ rtems_filesystem_file_handlers_r IMFS_device_handlers = {
NULL, /* fsync */
NULL, /* fdatasync */
NULL, /* fcntl */
- IMFS_rmnod
+ device_rmnod
};
diff --git a/c/src/libfs/src/imfs/imfs_handlers_directory.c b/c/src/libfs/src/imfs/imfs_handlers_directory.c
index 364f3cdf26..0ee06d8ebf 100644
--- a/c/src/libfs/src/imfs/imfs_handlers_directory.c
+++ b/c/src/libfs/src/imfs/imfs_handlers_directory.c
@@ -34,7 +34,7 @@ rtems_filesystem_file_handlers_r IMFS_directory_handlers = {
NULL, /* fsync */
IMFS_fdatasync,
IMFS_fcntl,
- IMFS_rmnod
+ imfs_dir_rmnod
};
diff --git a/c/src/libfs/src/imfs/imfs_handlers_memfile.c b/c/src/libfs/src/imfs/imfs_handlers_memfile.c
index f622c99558..20ef3c57b3 100644
--- a/c/src/libfs/src/imfs/imfs_handlers_memfile.c
+++ b/c/src/libfs/src/imfs/imfs_handlers_memfile.c
@@ -34,5 +34,5 @@ rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
NULL, /* fsync */
IMFS_fdatasync,
IMFS_fcntl,
- IMFS_rmnod
+ memfile_rmnod
};
diff --git a/c/src/libfs/src/imfs/imfs_rmnod.c b/c/src/libfs/src/imfs/imfs_rmnod.c
deleted file mode 100644
index 3768b9543d..0000000000
--- a/c/src/libfs/src/imfs/imfs_rmnod.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * IMFS_rmnod
- *
- * This routine is available from the optable to remove a node
- * from the IMFS file system.
- *
- * 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"
-
-
-int IMFS_rmnod(
- rtems_filesystem_location_info_t *pathloc /* IN */
-)
-{
- IMFS_jnode_t *the_jnode;
-
- the_jnode = (IMFS_jnode_t *) 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 ) )
- 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.
- */
-
- if ( the_jnode->type == IMFS_MEMORY_FILE )
- IMFS_memfile_remove( the_jnode );
-
- free( the_jnode );
- }
-
- return 0;
-
-}
-
-
diff --git a/c/src/libfs/src/imfs/imfs_unlink.c b/c/src/libfs/src/imfs/imfs_unlink.c
index 4e0ca26b2a..e138064e61 100644
--- a/c/src/libfs/src/imfs/imfs_unlink.c
+++ b/c/src/libfs/src/imfs/imfs_unlink.c
@@ -55,13 +55,13 @@ int IMFS_unlink(
node->info.hard_link.link_node->st_nlink --;
IMFS_update_ctime( node->info.hard_link.link_node );
if ( node->info.hard_link.link_node->st_nlink < 1) {
- result = IMFS_rmnod( &the_link );
+ result = (*loc->handlers->rmnod)( &the_link );
if ( result != 0 )
return -1;
}
}
- result = IMFS_rmnod( loc );
+ result = (*loc->handlers->rmnod)( &the_link );
return result;
}
diff --git a/c/src/libfs/src/imfs/memfile.c b/c/src/libfs/src/imfs/memfile.c
index 3468490c90..0a3b30d38f 100644
--- a/c/src/libfs/src/imfs/memfile.c
+++ b/c/src/libfs/src/imfs/memfile.c
@@ -30,26 +30,6 @@
#define MEMFILE_STATIC
/*
- * Set of operations handlers for operations on memfile entities.
- */
-
-rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
- memfile_open,
- memfile_close,
- memfile_read,
- memfile_write,
- memfile_ioctl,
- memfile_lseek,
- IMFS_stat,
- IMFS_fchmod,
- memfile_ftruncate,
- NULL, /* fpathconf */
- NULL, /* fsync */
- IMFS_fdatasync,
- IMFS_fcntl
-};
-
-/*
* Prototypes of private routines
*/
@@ -1056,3 +1036,62 @@ fflush(stdout);
memfile_blocks_allocated--;
}
+
+/*
+ * memfile_rmnod
+ *
+ * This routine is available from the optable to remove a node
+ * from the IMFS file system.
+ */
+
+int memfile_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+)
+{
+ IMFS_jnode_t *the_jnode;
+
+ the_jnode = (IMFS_jnode_t *) pathloc->node_access;
+
+ /*
+ * 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.
+ */
+
+ IMFS_memfile_remove( the_jnode );
+
+ free( the_jnode );
+ }
+
+ return 0;
+
+}
+
+
diff --git a/c/src/libfs/src/imfs/miniimfs_init.c b/c/src/libfs/src/imfs/miniimfs_init.c
index 983cde9439..865822fbfc 100644
--- a/c/src/libfs/src/imfs/miniimfs_init.c
+++ b/c/src/libfs/src/imfs/miniimfs_init.c
@@ -37,7 +37,6 @@ rtems_filesystem_operations_table miniIMFS_ops = {
NULL, /* XXX IMFS_unlink, */
IMFS_node_type,
IMFS_mknod,
- NULL, /* XXX IMFS_rmnod, */
NULL, /* XXX IMFS_chown, */
NULL, /* XXX IMFS_freenodinfo, */
NULL, /* XXX IMFS_mount, */
diff --git a/cpukit/libfs/src/imfs/deviceio.c b/cpukit/libfs/src/imfs/deviceio.c
index f954decf6e..70b9706ada 100644
--- a/cpukit/libfs/src/imfs/deviceio.c
+++ b/cpukit/libfs/src/imfs/deviceio.c
@@ -17,6 +17,7 @@
#include <rtems.h>
#include <rtems/libio.h>
+#include "libio_.h"
#include "imfs.h"
@@ -213,3 +214,58 @@ int device_lseek(
*
* This IMFS_stat() is used.
*/
+
+/*
+ * device_rmnod
+ */
+
+int device_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+)
+{
+ IMFS_jnode_t *the_jnode;
+
+ the_jnode = (IMFS_jnode_t *) pathloc->node_access;
+
+ /*
+ * 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;
+
+}
+
+
+
diff --git a/cpukit/libfs/src/imfs/imfs.h b/cpukit/libfs/src/imfs/imfs.h
index d1be06bbf4..a88672c4b8 100644
--- a/cpukit/libfs/src/imfs/imfs.h
+++ b/cpukit/libfs/src/imfs/imfs.h
@@ -308,10 +308,6 @@ int IMFS_freenodinfo(
rtems_filesystem_location_info_t *pathloc /* IN */
);
-int IMFS_rmnod(
- rtems_filesystem_location_info_t *pathloc /* IN */
-);
-
int IMFS_mknod(
const char *path, /* IN */
mode_t mode, /* IN */
@@ -353,92 +349,123 @@ int memfile_ftruncate(
rtems_libio_t *iop, /* IN */
off_t length /* IN */
);
+
int imfs_dir_open(
rtems_libio_t *iop, /* IN */
const char *pathname, /* IN */
unsigned32 flag, /* IN */
unsigned32 mode /* IN */
);
+
int imfs_dir_close(
rtems_libio_t *iop /* IN */
);
+
int imfs_dir_read(
rtems_libio_t *iop, /* IN */
void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int imfs_dir_lseek(
rtems_libio_t *iop, /* IN */
off_t offset, /* IN */
int whence /* IN */
);
+
int imfs_dir_fstat(
rtems_filesystem_location_info_t *loc, /* IN */
struct stat *buf /* OUT */
);
+
+int imfs_dir_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+);
+
int memfile_open(
rtems_libio_t *iop, /* IN */
const char *pathname, /* IN */
unsigned32 flag, /* IN */
unsigned32 mode /* IN */
);
+
int memfile_close(
rtems_libio_t *iop /* IN */
);
+
int memfile_read(
rtems_libio_t *iop, /* IN */
void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int memfile_write(
rtems_libio_t *iop, /* IN */
const void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int memfile_ioctl(
rtems_libio_t *iop, /* IN */
unsigned32 command, /* IN */
void *buffer /* IN */
);
+
int memfile_lseek(
rtems_libio_t *iop, /* IN */
off_t offset, /* IN */
int whence /* IN */
);
+
+int memfile_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+);
+
int device_open(
rtems_libio_t *iop, /* IN */
const char *pathname, /* IN */
unsigned32 flag, /* IN */
unsigned32 mode /* IN */
);
+
int device_close(
rtems_libio_t *iop /* IN */
);
+
int device_read(
rtems_libio_t *iop, /* IN */
void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int device_write(
rtems_libio_t *iop, /* IN */
const void *buffer, /* IN */
unsigned32 count /* IN */
);
+
int device_ioctl(
rtems_libio_t *iop, /* IN */
unsigned32 command, /* IN */
void *buffer /* IN */
);
+
int device_lseek(
rtems_libio_t *iop, /* IN */
off_t offset, /* IN */
int whence /* IN */
);
+
+int device_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+);
+
int IMFS_utime(
rtems_filesystem_location_info_t *pathloc, /* IN */
time_t actime, /* IN */
time_t modtime /* IN */
);
+
int IMFS_fchmod(
rtems_filesystem_location_info_t *loc,
mode_t mode
diff --git a/cpukit/libfs/src/imfs/imfs_directory.c b/cpukit/libfs/src/imfs/imfs_directory.c
index fbf4ba53a3..89672ec9ae 100644
--- a/cpukit/libfs/src/imfs/imfs_directory.c
+++ b/cpukit/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;
+
+}
+
diff --git a/cpukit/libfs/src/imfs/imfs_handlers_device.c b/cpukit/libfs/src/imfs/imfs_handlers_device.c
index b6b9c808a0..24b7ffa5bb 100644
--- a/cpukit/libfs/src/imfs/imfs_handlers_device.c
+++ b/cpukit/libfs/src/imfs/imfs_handlers_device.c
@@ -34,5 +34,5 @@ rtems_filesystem_file_handlers_r IMFS_device_handlers = {
NULL, /* fsync */
NULL, /* fdatasync */
NULL, /* fcntl */
- IMFS_rmnod
+ device_rmnod
};
diff --git a/cpukit/libfs/src/imfs/imfs_handlers_directory.c b/cpukit/libfs/src/imfs/imfs_handlers_directory.c
index 364f3cdf26..0ee06d8ebf 100644
--- a/cpukit/libfs/src/imfs/imfs_handlers_directory.c
+++ b/cpukit/libfs/src/imfs/imfs_handlers_directory.c
@@ -34,7 +34,7 @@ rtems_filesystem_file_handlers_r IMFS_directory_handlers = {
NULL, /* fsync */
IMFS_fdatasync,
IMFS_fcntl,
- IMFS_rmnod
+ imfs_dir_rmnod
};
diff --git a/cpukit/libfs/src/imfs/imfs_handlers_memfile.c b/cpukit/libfs/src/imfs/imfs_handlers_memfile.c
index f622c99558..20ef3c57b3 100644
--- a/cpukit/libfs/src/imfs/imfs_handlers_memfile.c
+++ b/cpukit/libfs/src/imfs/imfs_handlers_memfile.c
@@ -34,5 +34,5 @@ rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
NULL, /* fsync */
IMFS_fdatasync,
IMFS_fcntl,
- IMFS_rmnod
+ memfile_rmnod
};
diff --git a/cpukit/libfs/src/imfs/imfs_rmnod.c b/cpukit/libfs/src/imfs/imfs_rmnod.c
deleted file mode 100644
index 3768b9543d..0000000000
--- a/cpukit/libfs/src/imfs/imfs_rmnod.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * IMFS_rmnod
- *
- * This routine is available from the optable to remove a node
- * from the IMFS file system.
- *
- * 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"
-
-
-int IMFS_rmnod(
- rtems_filesystem_location_info_t *pathloc /* IN */
-)
-{
- IMFS_jnode_t *the_jnode;
-
- the_jnode = (IMFS_jnode_t *) 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 ) )
- 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.
- */
-
- if ( the_jnode->type == IMFS_MEMORY_FILE )
- IMFS_memfile_remove( the_jnode );
-
- free( the_jnode );
- }
-
- return 0;
-
-}
-
-
diff --git a/cpukit/libfs/src/imfs/imfs_unlink.c b/cpukit/libfs/src/imfs/imfs_unlink.c
index 4e0ca26b2a..e138064e61 100644
--- a/cpukit/libfs/src/imfs/imfs_unlink.c
+++ b/cpukit/libfs/src/imfs/imfs_unlink.c
@@ -55,13 +55,13 @@ int IMFS_unlink(
node->info.hard_link.link_node->st_nlink --;
IMFS_update_ctime( node->info.hard_link.link_node );
if ( node->info.hard_link.link_node->st_nlink < 1) {
- result = IMFS_rmnod( &the_link );
+ result = (*loc->handlers->rmnod)( &the_link );
if ( result != 0 )
return -1;
}
}
- result = IMFS_rmnod( loc );
+ result = (*loc->handlers->rmnod)( &the_link );
return result;
}
diff --git a/cpukit/libfs/src/imfs/memfile.c b/cpukit/libfs/src/imfs/memfile.c
index 3468490c90..0a3b30d38f 100644
--- a/cpukit/libfs/src/imfs/memfile.c
+++ b/cpukit/libfs/src/imfs/memfile.c
@@ -30,26 +30,6 @@
#define MEMFILE_STATIC
/*
- * Set of operations handlers for operations on memfile entities.
- */
-
-rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
- memfile_open,
- memfile_close,
- memfile_read,
- memfile_write,
- memfile_ioctl,
- memfile_lseek,
- IMFS_stat,
- IMFS_fchmod,
- memfile_ftruncate,
- NULL, /* fpathconf */
- NULL, /* fsync */
- IMFS_fdatasync,
- IMFS_fcntl
-};
-
-/*
* Prototypes of private routines
*/
@@ -1056,3 +1036,62 @@ fflush(stdout);
memfile_blocks_allocated--;
}
+
+/*
+ * memfile_rmnod
+ *
+ * This routine is available from the optable to remove a node
+ * from the IMFS file system.
+ */
+
+int memfile_rmnod(
+ rtems_filesystem_location_info_t *pathloc /* IN */
+)
+{
+ IMFS_jnode_t *the_jnode;
+
+ the_jnode = (IMFS_jnode_t *) pathloc->node_access;
+
+ /*
+ * 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.
+ */
+
+ IMFS_memfile_remove( the_jnode );
+
+ free( the_jnode );
+ }
+
+ return 0;
+
+}
+
+
diff --git a/cpukit/libfs/src/imfs/miniimfs_init.c b/cpukit/libfs/src/imfs/miniimfs_init.c
index 983cde9439..865822fbfc 100644
--- a/cpukit/libfs/src/imfs/miniimfs_init.c
+++ b/cpukit/libfs/src/imfs/miniimfs_init.c
@@ -37,7 +37,6 @@ rtems_filesystem_operations_table miniIMFS_ops = {
NULL, /* XXX IMFS_unlink, */
IMFS_node_type,
IMFS_mknod,
- NULL, /* XXX IMFS_rmnod, */
NULL, /* XXX IMFS_chown, */
NULL, /* XXX IMFS_freenodinfo, */
NULL, /* XXX IMFS_mount, */