summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests/devfs02/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/libtests/devfs02/init.c')
-rw-r--r--testsuites/libtests/devfs02/init.c65
1 files changed, 28 insertions, 37 deletions
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 );