summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psximfs02
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/psxtests/psximfs02
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/psxtests/psximfs02')
-rw-r--r--testsuites/psxtests/psximfs02/init.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/testsuites/psxtests/psximfs02/init.c b/testsuites/psxtests/psximfs02/init.c
index 7ae97705a5..d170d4ef6f 100644
--- a/testsuites/psxtests/psximfs02/init.c
+++ b/testsuites/psxtests/psximfs02/init.c
@@ -22,6 +22,7 @@
#include <fcntl.h>
#include <errno.h>
#include <rtems/libio.h>
+#include <rtems/malloc.h>
#include <rtems/libcsupport.h>
#if !HAVE_DECL_SETEUID
@@ -34,11 +35,14 @@ rtems_task Init(
)
{
int status = 0;
- void *alloc_ptr = (void *)0;
+ void *opaque;
char linkname_n[20] = {0};
char linkname_p[20] = {0};
int i;
struct stat stat_buf;
+ static const char mount_point [] = "dir01";
+ static const char fs_type [] = RTEMS_FILESYSTEM_TYPE_IMFS;
+ static const char slink_2_name [] = "node-slink-2";
puts( "\n\n*** TEST IMFS 02 ***" );
@@ -92,27 +96,31 @@ rtems_task Init(
rtems_test_assert( errno == EACCES );
puts( "Allocate most of heap" );
- alloc_ptr = malloc( malloc_free_space() - 150 );
+ opaque = rtems_heap_greedy_allocate(
+ sizeof( rtems_filesystem_mount_table_entry_t )
+ + sizeof( fs_type )
+ + sizeof( rtems_filesystem_global_location_t )
+ );
- puts( "Attempt to mount a fs at /dir01 -- expect ENOMEM" );
+ printf( "Attempt to mount a fs at %s -- expect ENOMEM", mount_point );
status = mount( NULL,
- "dir01",
- "imfs",
+ mount_point,
+ fs_type,
RTEMS_FILESYSTEM_READ_WRITE,
NULL );
rtems_test_assert( status == -1 );
rtems_test_assert( errno == ENOMEM );
puts( "Freeing allocated memory" );
- free( alloc_ptr );
-
- puts( "Allocate most of heap" );
- alloc_ptr = malloc( malloc_free_space() - 4 );
+ rtems_heap_greedy_free( opaque );
puts( "Changing directory to /" );
status = chdir( "/" );
rtems_test_assert( status == 0 );
+ puts( "Allocate most of heap" );
+ opaque = rtems_heap_greedy_allocate( 0 );
+
puts( "Attempt to create /node-link-2 for /node -- expect ENOMEM" );
status = link( "/node", "/node-link-2" );
rtems_test_assert( status == -1 );
@@ -124,23 +132,22 @@ rtems_task Init(
rtems_test_assert( errno == ENOMEM );
puts( "Freeing allocated memory" );
- free( alloc_ptr );
+ rtems_heap_greedy_free( opaque );
puts( "Allocate most of heap" );
- alloc_ptr = malloc( malloc_free_space() - 40 );
+ opaque = rtems_heap_greedy_allocate( sizeof( slink_2_name ) );
- puts( "Attempt to create /node-slink-2 for /node -- expect ENOMEM" );
- status = symlink( "/node", "node-slink-2" );
+ printf( "Attempt to create %s for /node -- expect ENOMEM", slink_2_name );
+ status = symlink( "/node", slink_2_name );
rtems_test_assert( status == -1 );
rtems_test_assert( errno == ENOMEM );
puts( "Freeing allocated memory" );
- free( alloc_ptr );
+ rtems_heap_greedy_free( opaque );
- puts( "Attempt to stat a hardlink -- expect ENOTSUP" );
+ puts( "Attempt to stat a hardlink" );
status = lstat( "/node-link", &stat_buf );
- rtems_test_assert( status == -1 );
- rtems_test_assert( errno == ENOTSUP );
+ rtems_test_assert( status == 0 );
puts( "Changing euid to 10" );
status = seteuid( 10 );