summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/imfs
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libfs/src/imfs')
-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
10 files changed, 227 insertions, 128 deletions
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, */