summaryrefslogtreecommitdiff
path: root/cpukit/libcsupport/src
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-10-02 15:44:59 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-10-07 17:03:20 +0200
commitc17d0b315baf3f3a3afb862f64d0acf424088442 (patch)
tree4b659a3d629d590525cadec5a32e57fd1ec8ad78 /cpukit/libcsupport/src
parent9b83a6654683d2f1f051533cdc41f39456303147 (diff)
Filesystem: Reject removal of root nodes
Reject the removal of file system instance root nodes in rmdir() and unlink() and return the EBUSY error status. File system instances can be removed with unmount(). Remove root node special cases in IMFS, DOSFS, and RFS.
Diffstat (limited to 'cpukit/libcsupport/src')
-rw-r--r--cpukit/libcsupport/src/rmdir.c7
-rw-r--r--cpukit/libcsupport/src/unlink.c10
2 files changed, 14 insertions, 3 deletions
diff --git a/cpukit/libcsupport/src/rmdir.c b/cpukit/libcsupport/src/rmdir.c
index 4e7baf5e39..f2bc16e516 100644
--- a/cpukit/libcsupport/src/rmdir.c
+++ b/cpukit/libcsupport/src/rmdir.c
@@ -38,7 +38,12 @@ int rmdir( const char *path )
rtems_filesystem_node_types_t type = (*ops->node_type_h)( currentloc );
if ( type == RTEMS_FILESYSTEM_DIRECTORY ) {
- rv = (*ops->rmnod_h)( &parentloc, currentloc );
+ if ( !rtems_filesystem_location_is_root( currentloc ) ) {
+ rv = (*ops->rmnod_h)( &parentloc, currentloc );
+ } else {
+ rtems_filesystem_eval_path_error( &ctx, EBUSY );
+ rv = -1;
+ }
} else {
rtems_filesystem_eval_path_error( &ctx, ENOTDIR );
rv = -1;
diff --git a/cpukit/libcsupport/src/unlink.c b/cpukit/libcsupport/src/unlink.c
index 9817ad9611..2a3b1c75a8 100644
--- a/cpukit/libcsupport/src/unlink.c
+++ b/cpukit/libcsupport/src/unlink.c
@@ -34,9 +34,15 @@ int unlink( const char *path )
&parentloc,
parent_eval_flags
);
- const rtems_filesystem_operations_table *ops = currentloc->mt_entry->ops;
- rv = (*ops->rmnod_h)( &parentloc, currentloc );
+ if ( !rtems_filesystem_location_is_root( currentloc ) ) {
+ const rtems_filesystem_operations_table *ops = currentloc->mt_entry->ops;
+
+ rv = (*ops->rmnod_h)( &parentloc, currentloc );
+ } else {
+ rtems_filesystem_eval_path_error( &ctx, EBUSY );
+ rv = -1;
+ }
rtems_filesystem_eval_path_cleanup_with_parent( &ctx, &parentloc );