From 0161b93d50d6915116c4ca9d1cad42ef89a4ad9e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 3 Mar 2020 19:23:53 +0100 Subject: imfs: Replace devfs with an IMFS specialization Add a simplified path evaluation function IMFS_eval_path_devfs() for a device only IMFS configuration. The code size can be further reduced by the application if it disables the support for legacy IO drivers via: #define CONFIGURE_IMFS_DISABLE_MKNOD #define CONFIGURE_IMFS_DISABLE_MKNOD_DEVICE Obsolete CONFIGURE_MAXIMUM_DEVICES. Remove BSP_MAXIMUM_DEVICES. Update #3894. Update #3898. --- testsuites/libtests/Makefile.am | 18 ------ testsuites/libtests/configure.ac | 2 - testsuites/libtests/devfs01/init.c | 49 ++++++++------- testsuites/libtests/devfs02/devfs02.doc | 22 ------- testsuites/libtests/devfs02/devfs02.scn | 13 ---- testsuites/libtests/devfs02/init.c | 108 -------------------------------- testsuites/libtests/devfs03/devfs03.doc | 21 ------- testsuites/libtests/devfs03/devfs03.scn | 6 -- testsuites/libtests/devfs03/init.c | 99 ----------------------------- testsuites/libtests/devfs04/init.c | 11 +--- testsuites/libtests/deviceio01/init.c | 7 +-- 11 files changed, 32 insertions(+), 324 deletions(-) delete mode 100644 testsuites/libtests/devfs02/devfs02.doc delete mode 100644 testsuites/libtests/devfs02/devfs02.scn delete mode 100644 testsuites/libtests/devfs02/init.c delete mode 100644 testsuites/libtests/devfs03/devfs03.doc delete mode 100644 testsuites/libtests/devfs03/devfs03.scn delete mode 100644 testsuites/libtests/devfs03/init.c (limited to 'testsuites') diff --git a/testsuites/libtests/Makefile.am b/testsuites/libtests/Makefile.am index f3bcde998d..7917c98656 100644 --- a/testsuites/libtests/Makefile.am +++ b/testsuites/libtests/Makefile.am @@ -271,24 +271,6 @@ devfs01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_devfs01) \ $(support_includes) endif -if TEST_devfs02 -lib_tests += devfs02 -lib_screens += devfs02/devfs02.scn -lib_docs += devfs02/devfs02.doc -devfs02_SOURCES = devfs02/init.c -devfs02_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_devfs02) \ - $(support_includes) -endif - -if TEST_devfs03 -lib_tests += devfs03 -lib_screens += devfs03/devfs03.scn -lib_docs += devfs03/devfs03.doc -devfs03_SOURCES = devfs03/init.c -devfs03_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_devfs03) \ - $(support_includes) -endif - if TEST_devfs04 lib_tests += devfs04 lib_screens += devfs04/devfs04.scn diff --git a/testsuites/libtests/configure.ac b/testsuites/libtests/configure.ac index b6177e08e3..710d100405 100644 --- a/testsuites/libtests/configure.ac +++ b/testsuites/libtests/configure.ac @@ -119,8 +119,6 @@ RTEMS_TEST_CHECK([crypt01]) RTEMS_TEST_CHECK([debugger01]) RTEMS_TEST_CHECK([defaultconfig01]) RTEMS_TEST_CHECK([devfs01]) -RTEMS_TEST_CHECK([devfs02]) -RTEMS_TEST_CHECK([devfs03]) RTEMS_TEST_CHECK([devfs04]) RTEMS_TEST_CHECK([deviceio01]) RTEMS_TEST_CHECK([devnullfatal01]) diff --git a/testsuites/libtests/devfs01/init.c b/testsuites/libtests/devfs01/init.c index 44b55e171c..193c7641db 100644 --- a/testsuites/libtests/devfs01/init.c +++ b/testsuites/libtests/devfs01/init.c @@ -1,10 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * COPYRIGHT (c) 1989-2012. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H @@ -12,34 +30,24 @@ #endif #include -#include "test_support.h" -#include #include const char rtems_test_name[] = "DEVFS 1"; -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument argument); - -rtems_task Init( - rtems_task_argument argument -) +static void Init(rtems_task_argument argument) { TEST_BEGIN(); - puts( "devFS_Show" ); - devFS_Show(); - TEST_END(); - rtems_test_exit(0); } -/* configuration information */ +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER + +#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER -#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_MAXIMUM_TASKS 1 -#define CONFIGURE_MAXIMUM_TASKS 1 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION #define CONFIGURE_RTEMS_INIT_TASKS_TABLE @@ -49,4 +57,3 @@ rtems_task Init( #define CONFIGURE_INIT #include -/* end of file */ diff --git a/testsuites/libtests/devfs02/devfs02.doc b/testsuites/libtests/devfs02/devfs02.doc deleted file mode 100644 index 6b594fd055..0000000000 --- a/testsuites/libtests/devfs02/devfs02.doc +++ /dev/null @@ -1,22 +0,0 @@ -# COPYRIGHT (c) 1989-2010. -# On-Line Applications Research Corporation (OAR). -# -# The license and distribution terms for this file may be -# found in the file LICENSE in this distribution or at -# http://www.rtems.org/license/LICENSE. -# - -This file describes the directives and concepts tested by this test set. - -test set name: devfs02 - -directives: - -+ devFS_mknod -+ devFS_evaluate_path - -concepts: - -+ System calls open, mknod, mkfifo are used to exercise the above -mentioned routines. This test exercise mostly the error paths. - diff --git a/testsuites/libtests/devfs02/devfs02.scn b/testsuites/libtests/devfs02/devfs02.scn deleted file mode 100644 index 188207dc77..0000000000 --- a/testsuites/libtests/devfs02/devfs02.scn +++ /dev/null @@ -1,13 +0,0 @@ -*** TEST DEVFS02 *** -Init - attempt to create a fifo - expect EINVAL -Init - set the device name table to NULL - Init - attempt to create a node - expect EFAULT -Init - attempt to stat a node - expect EFAULT -Init - attempt to open a node -Init - restore the device name table -Init - set device table size to zero -Init - attempt to create a node - expect ENOMEM -Init - restore device table size -Init - attempt to create /node -- OK -Init - attempt to create /node - expect EEXIST -*** END OF TEST DEVFS02 *** diff --git a/testsuites/libtests/devfs02/init.c b/testsuites/libtests/devfs02/init.c deleted file mode 100644 index 3e136972b3..0000000000 --- a/testsuites/libtests/devfs02/init.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * COPYRIGHT (c) 1989-2012. - * 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.org/license/LICENSE. - */ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "test_support.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -const char rtems_test_name[] = "DEVFS 2"; - -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument argument); - -rtems_task Init( - rtems_task_argument argument -) -{ - int status; - 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; - - TEST_BEGIN(); - - puts( "Init - attempt to create a fifo - expect ENOTSUP" ); - status = mkfifo( "/fifo01", 0 ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == ENOTSUP ); - - /* 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 create a node - expect ENOSPC" ); - status = mknod( "/node", S_IFBLK, 0LL ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == ENOSPC ); - - /* Now restore */ - puts( "Init - restore device table size" ); - rootloc->mt_entry->immutable_fs_info = data; - - opaque = rtems_heap_greedy_allocate( NULL, 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 ); - - rtems_heap_greedy_free( opaque ); - - puts( "Init - attempt to create /node -- OK" ); - status = mknod( "/node", S_IFBLK, 0LL ); - rtems_test_assert( status == 0 ); - - puts( "Init - attempt to create /node - expect EEXIST" ); - status = mknod( "/node", S_IFBLK, 0LL ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EEXIST ); - - TEST_END(); - - rtems_test_exit(0); -} - -/* configuration information */ - -#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER - -#define CONFIGURE_MAXIMUM_TASKS 1 -#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION - -#define CONFIGURE_RTEMS_INIT_TASKS_TABLE - -#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 2 - -/* Make sure that we have enough devices for all BSPs */ -#define CONFIGURE_MAXIMUM_DEVICES 64 - -#define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM - -#define CONFIGURE_INIT -#include -/* end of file */ diff --git a/testsuites/libtests/devfs03/devfs03.doc b/testsuites/libtests/devfs03/devfs03.doc deleted file mode 100644 index 3cbb71facc..0000000000 --- a/testsuites/libtests/devfs03/devfs03.doc +++ /dev/null @@ -1,21 +0,0 @@ -# COPYRIGHT (c) 1989-2010. -# On-Line Applications Research Corporation (OAR). -# -# The license and distribution terms for this file may be -# found in the file LICENSE in this distribution or at -# http://www.rtems.org/license/LICENSE. -# - -This file describes the directives and concepts tested by this test set. - -test set name: devfs03 - -directives: - -+ devFS_initialize - -concepts: - -+ A call to mount, after consuming much of the workspace memory leads -to an ENOMEM which initializing the filesystem. - diff --git a/testsuites/libtests/devfs03/devfs03.scn b/testsuites/libtests/devfs03/devfs03.scn deleted file mode 100644 index 06f283eba2..0000000000 --- a/testsuites/libtests/devfs03/devfs03.scn +++ /dev/null @@ -1,6 +0,0 @@ -*** TEST DEVFS03 *** -Init - attempt to create /dir01 -- OK -Init - allocating most of workspace memory -Init - mount a new fs at /dir01 - expect ENOMEM -Init - freeing the workspace memory -*** END OF TEST DEVFS03 *** diff --git a/testsuites/libtests/devfs03/init.c b/testsuites/libtests/devfs03/init.c deleted file mode 100644 index 24940832f0..0000000000 --- a/testsuites/libtests/devfs03/init.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * COPYRIGHT (c) 1989-2012. - * 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.org/license/LICENSE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include "test_support.h" -#include -#include -#include -#include -#include -#include - -const char rtems_test_name[] = "DEVFS 3"; - -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument argument); - -rtems_task Init( - rtems_task_argument argument -) -{ - int status; - devFS_node nodes [1]; - devFS_data data = { - .nodes = nodes, - .count = 1 - }; - - TEST_BEGIN(); - - memset(nodes, 0, sizeof(nodes)); - - puts( "Init - attempt to create /dir01 -- OK" ); - status = mkdir( "/dir01", S_IRWXU ); - rtems_test_assert( status == 0 ); - - 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 == EINVAL ); - - 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 ); - - TEST_END(); - - rtems_test_exit(0); -} - -/* configuration information */ - -#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER -#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER - -#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 4 -#define CONFIGURE_MAXIMUM_TASKS 1 -#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION - -#define CONFIGURE_RTEMS_INIT_TASKS_TABLE - -#define CONFIGURE_FILESYSTEM_DEVFS - -#define CONFIGURE_INIT -#include -/* end of file */ diff --git a/testsuites/libtests/devfs04/init.c b/testsuites/libtests/devfs04/init.c index bc747a8e07..a7549abdad 100644 --- a/testsuites/libtests/devfs04/init.c +++ b/testsuites/libtests/devfs04/init.c @@ -13,21 +13,17 @@ #include #include "test_support.h" -#include #include #include #include #include +#include #include #include "test_driver.h" -#include const char rtems_test_name[] = "DEVFS 4"; -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument argument); - -rtems_task Init( +static rtems_task Init( rtems_task_argument argument ) { @@ -88,9 +84,6 @@ rtems_task Init( #define CONFIGURE_RTEMS_INIT_TASKS_TABLE -/* Make sure that we have enough devices for all BSPs */ -#define CONFIGURE_MAXIMUM_DEVICES 64 - #define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM #define CONFIGURE_INIT diff --git a/testsuites/libtests/deviceio01/init.c b/testsuites/libtests/deviceio01/init.c index ff6223234f..c27e345be5 100644 --- a/testsuites/libtests/deviceio01/init.c +++ b/testsuites/libtests/deviceio01/init.c @@ -13,21 +13,18 @@ #include #include "test_support.h" -#include #include #include #include #include +#include #include #include "test_driver.h" #include const char rtems_test_name[] = "DEVICEIO 1"; -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument argument); - -rtems_task Init( +static rtems_task Init( rtems_task_argument argument ) { -- cgit v1.2.3