summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-03-13 11:33:51 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-03-13 12:23:37 +0100
commit3b7c123c8d910eb60ab3b38dec6224e2de9847c9 (patch)
treea67335010c15af5efb5e27224ae9204883c2b5b8 /testsuites/libtests
parentAdd missing BSD sections. (diff)
downloadrtems-3b7c123c8d910eb60ab3b38dec6224e2de9847c9.tar.bz2
Filesystem: Reference counting for locations
o A new data structure rtems_filesystem_global_location_t was introduced to be used for o the mount point location in the mount table entry, o the file system root location in the mount table entry, o the root directory location in the user environment, and o the current directory location in the user environment. During the path evaluation global start locations are obtained to ensure that the current file system instance will be not unmounted in the meantime. o The user environment uses now reference counting and is protected from concurrent access. o The path evaluation process was completely rewritten and simplified. The IMFS, RFS, NFS, and DOSFS use now a generic path evaluation method. Recursive calls in the path evaluation have been replaced with iteration to avoid stack overflows. Only the evaluation of symbolic links is recursive. No dynamic memory allocations and intermediate buffers are used in the high level path evaluation. No global locks are held during the file system instance specific path evaluation process. o Recursive symbolic link evaluation is now limited by RTEMS_FILESYSTEM_SYMLOOP_MAX. Applications can retrieve this value via sysconf(). o The device file system (devFS) uses now no global variables and allocation from the workspace. Node names are allocated from the heap. o The upper layer lseek() performs now some parameter checks. o The upper layer ftruncate() performs now some parameter checks. o unmask() is now restricted to the RWX flags and protected from concurrent access. o The fchmod_h and rmnod_h file system node handlers are now a file system operation. o The unlink_h operation has been removed. All nodes are now destroyed with the rmnod_h operation. o New lock_h, unlock_h, clonenod_h, and are_nodes_equal_h file system operations. o The path evaluation and file system operations are now protected by per file system instance lock and unlock operations. o Fix and test file descriptor duplicate in fcntl(). o New test fstests/fsnofs01.
Diffstat (limited to 'testsuites/libtests')
-rw-r--r--testsuites/libtests/devfs01/init.c33
-rw-r--r--testsuites/libtests/devfs02/init.c65
-rw-r--r--testsuites/libtests/devfs03/init.c41
3 files changed, 57 insertions, 82 deletions
diff --git a/testsuites/libtests/devfs01/init.c b/testsuites/libtests/devfs01/init.c
index aa7b146824..27dc8d3f97 100644
--- a/testsuites/libtests/devfs01/init.c
+++ b/testsuites/libtests/devfs01/init.c
@@ -22,39 +22,10 @@ rtems_task Init(
rtems_task_argument argument
)
{
- int sc;
- int size;
- rtems_filesystem_location_info_t *temp_loc;
- rtems_device_name_t *device_name_table;
-
puts( "\n\n*** TEST DEVFS01 ***" );
- puts( "devFS_Show - OK" );
- sc = devFS_Show();
- rtems_test_assert( sc == 0 );
-
- /* save original node access information */
- temp_loc = &rtems_filesystem_root;
- device_name_table = (rtems_device_name_t *)temp_loc->node_access;
- temp_loc->node_access = NULL;
-
- puts( "devFS_Show - no device table - EFAULT" );
- sc = devFS_Show();
- rtems_test_assert( sc == -1 );
- rtems_test_assert( errno == EFAULT );
-
- /* restore node access information */
- temp_loc->node_access = device_name_table;
-
- /* save original device table size information */
- size = rtems_device_table_size;
- rtems_device_table_size = 0;
- puts( "devFS_Show - devices - OK" );
- sc = devFS_Show();
- rtems_test_assert( sc == 0 );
-
- /* restore original device table size information */
- rtems_device_table_size = size;
+ puts( "devFS_Show" );
+ devFS_Show();
puts( "*** END OF TEST DEVFS01 ***" );
diff --git a/testsuites/libtests/devfs02/init.c b/testsuites/libtests/devfs02/init.c
index f648a177cf..96febbf974 100644
--- a/testsuites/libtests/devfs02/init.c
+++ b/testsuites/libtests/devfs02/init.c
@@ -2,6 +2,9 @@
* COPYRIGHT (c) 1989-2010.
* On-Line Applications Research Corporation (OAR).
*
+ * Modifications to support reference counting in the file system are
+ * Copyright (c) 2012 embedded brains GmbH.
+ *
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
@@ -10,74 +13,62 @@
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
-#include <tmacros.h>
#include "test_support.h"
-#include <rtems/devfs.h>
+
+#include <tmacros.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <rtems/devfs.h>
+#include <rtems/malloc.h>
+
rtems_task Init(
rtems_task_argument argument
)
{
int status;
- rtems_filesystem_location_info_t *temp_loc;
- rtems_device_name_t *device_name_table;
- int temp_size = 0;
- struct stat statbuf;
+ rtems_filesystem_location_info_t *rootloc = &rtems_filesystem_root->location;
+ const devFS_data *data = rootloc->mt_entry->immutable_fs_info;
+ devFS_data zero_count_data = {
+ .nodes = data->nodes,
+ .count = 0
+ };
+ void *opaque;
puts( "\n\n*** TEST DEVFS02 ***" );
- puts( "Init - attempt to create a fifo - expect EINVAL" );
+ puts( "Init - attempt to create a fifo - expect ENOTSUP" );
status = mkfifo( "/fifo01", 0 );
rtems_test_assert( status == -1 );
- rtems_test_assert( errno == EINVAL );
-
- /* Manipulate the root */
- puts( "Init - set the device name table to NULL" );
- temp_loc = &rtems_filesystem_root;
- device_name_table = (rtems_device_name_t *)temp_loc->node_access;
- temp_loc->node_access = NULL;
-
- puts(" Init - attempt to create a node - expect EFAULT" );
- status = mknod( "/node", S_IFBLK, 0LL );
- rtems_test_assert( status == -1 );
- rtems_test_assert( errno == EFAULT );
+ rtems_test_assert( errno == ENOTSUP );
- /* This case actually stops at evaluation of path */
- puts( "Init - attempt to stat a node - expect EFAULT" );
- status = stat( "/", &statbuf );
- rtems_test_assert( status == -1 );
- rtems_test_assert( errno == EFAULT );
+ /* Manipulate the device table size */
+ puts( "Init - set device table size to zero" );
+ rootloc->mt_entry->immutable_fs_info = &zero_count_data;
- puts( "Init - attempt to open a node" );
- status = open( "/node", O_RDWR );
+ puts( "Init - attempt to create a node - expect ENOSPC" );
+ status = mknod( "/node", S_IFBLK, 0LL );
rtems_test_assert( status == -1 );
- rtems_test_assert( errno == EFAULT );
+ rtems_test_assert( errno == ENOSPC );
/* Now restore */
- puts( "Init - restore the device name table" );
- temp_loc->node_access = device_name_table;
+ puts( "Init - restore device table size" );
+ rootloc->mt_entry->immutable_fs_info = data;
- /* Manipulate the device table size */
- puts( "Init - set device table size to zero" );
- temp_size = rtems_device_table_size;
- rtems_device_table_size = 0;
+ opaque = rtems_heap_greedy_allocate( 0 );
puts( "Init - attempt to create a node - expect ENOMEM" );
status = mknod( "/node", S_IFBLK, 0LL );
rtems_test_assert( status == -1 );
rtems_test_assert( errno == ENOMEM );
- /* Now restore */
- puts( "Init - restore device table size" );
- rtems_device_table_size = temp_size;
+ rtems_heap_greedy_free( opaque );
puts( "Init - attempt to create /node -- OK" );
status = mknod( "/node", S_IFBLK, 0LL );
diff --git a/testsuites/libtests/devfs03/init.c b/testsuites/libtests/devfs03/init.c
index 07e29263c5..7660227009 100644
--- a/testsuites/libtests/devfs03/init.c
+++ b/testsuites/libtests/devfs03/init.c
@@ -2,6 +2,9 @@
* COPYRIGHT (c) 1989-2010.
* On-Line Applications Research Corporation (OAR).
*
+ * Modifications to support reference counting in the file system are
+ * Copyright (c) 2012 embedded brains GmbH.
+ *
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
@@ -21,15 +24,17 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <rtems/score/heap.h>
rtems_task Init(
rtems_task_argument argument
)
{
int status;
- void *alloc_ptr = (void *)0;
- Heap_Information_block Info;
+ devFS_node nodes [1];
+ devFS_data data = {
+ .nodes = nodes,
+ .count = 1
+ };
puts( "\n\n*** TEST DEVFS03 ***" );
@@ -37,24 +42,31 @@ rtems_task Init(
status = mkdir( "/dir01", S_IRWXU );
rtems_test_assert( status == 0 );
- puts( "Init - allocating most of workspace memory" );
- status = rtems_workspace_get_information( &Info );
- rtems_test_assert( status == true );
- status = rtems_workspace_allocate( Info.Free.largest - 4, &alloc_ptr );
- rtems_test_assert( status == true );
-
- puts( "Init - mount a new fs at /dir01 - expect ENOMEM" );
+ puts( "Init - mount a new fs at /dir01 - expect EINVAL" );
status = mount( NULL,
"/dir01",
"devfs",
RTEMS_FILESYSTEM_READ_WRITE,
NULL );
rtems_test_assert( status == -1 );
- rtems_test_assert( errno == ENOMEM );
+ rtems_test_assert( errno == EINVAL );
- puts( "Init - freeing the workspace memory" );
- status = rtems_workspace_free( alloc_ptr );
- rtems_test_assert( status == true );
+ puts( "Init - mount a new fs at /dir01 - OK" );
+ status = mount( NULL,
+ "/dir01",
+ "devfs",
+ RTEMS_FILESYSTEM_READ_WRITE,
+ &data );
+ rtems_test_assert( status == 0 );
+
+ puts( "Init - make file /dir01/dev -- expect ENOTSUP" );
+ status = creat( "/dir01/dev", S_IRWXU );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == ENOTSUP );
+
+ puts( "Init - unmount fs at /dir01 - OK" );
+ status = unmount( "/dir01" );
+ rtems_test_assert( status == 0 );
status = rmdir( "/dir01" );
rtems_test_assert( status == 0 );
@@ -69,6 +81,7 @@ rtems_task Init(
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE