From 1c36569232264983974320b9c6335477929707e5 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 14 May 2020 14:41:22 -0400 Subject: [PATCH] Fix #367, Deprecate OS_VolumeTable objects Remove the OS_VolumeTable definition from all BSPs, but provide a default (empty) one to support linking when OMIT_DEPRECATED is not set. --- CMakeLists.txt | 26 ++++---- src/bsp/mcp750-vxworks/CMakeLists.txt | 1 - src/bsp/mcp750-vxworks/build_options.cmake | 3 - src/bsp/mcp750-vxworks/src/bsp_voltab.c | 60 ----------------- src/bsp/pc-linux/CMakeLists.txt | 1 - src/bsp/pc-linux/build_options.cmake | 5 -- src/bsp/pc-linux/src/bsp_start.c | 32 --------- src/bsp/pc-linux/src/bsp_voltab.c | 49 -------------- src/bsp/pc-rtems/CMakeLists.txt | 1 - src/bsp/pc-rtems/build_options.cmake | 5 -- src/bsp/pc-rtems/src/bsp_start.c | 66 +++++++------------ src/bsp/pc-rtems/src/bsp_voltab.c | 52 --------------- src/bsp/pc-rtems/src/pcrtems_bsp_internal.h | 5 ++ src/bsp/shared/inc/bsp-impl.h | 5 +- src/bsp/shared/src/bsp_default_voltab.c | 62 +++++++++++++++++ src/os/inc/osapi-os-filesys.h | 20 ++++-- src/os/shared/inc/os-shared-filesys.h | 4 +- src/os/shared/src/osapi-filesys.c | 49 +++++++------- .../shared/src/coveragetest-filesys.c | 46 ------------- .../osfile-test/ut_osfile_dirio_test.h | 2 +- .../osfilesys-test/ut_osfilesys_diskio_test.c | 8 +-- .../osfilesys-test/ut_osfilesys_diskio_test.h | 2 +- src/ut-stubs/utstub-helpers.c | 2 +- 23 files changed, 160 insertions(+), 346 deletions(-) delete mode 100644 src/bsp/mcp750-vxworks/src/bsp_voltab.c delete mode 100644 src/bsp/pc-linux/src/bsp_voltab.c delete mode 100644 src/bsp/pc-rtems/src/bsp_voltab.c create mode 100644 src/bsp/shared/src/bsp_default_voltab.c diff --git a/CMakeLists.txt b/CMakeLists.txt index e378f56ce..2a34d257b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,11 +30,6 @@ # # This also exports the following variables: # -# OSAL_BSP_STAGING_INSTALL_DIR : the location of the staging directory -# for the selected OSAL BSP. This can be used in -# post-build rules or "install()" commands to stage -# binary or data files for execution. -# # UT_COVERAGE_COMPILE_FLAGS : Compiler flags that must be used to # instrument code for coverage testing # UT_COVERAGE_LINK_FLAGS : Linker flags that must be used to @@ -161,13 +156,22 @@ if (OSAL_BSP_INCLUDE_DIRECTORIES) include_directories(${OSAL_BSP_INCLUDE_DIRECTORIES}) endif (OSAL_BSP_INCLUDE_DIRECTORIES) +set(BSP_SRCLIST + src/bsp/shared/src/osapi-bsp.c + src/bsp/shared/src/bsp_default_app_run.c + src/bsp/shared/src/bsp_default_app_startup.c + src/bsp/shared/src/bsp_default_symtab.c +) + +if (NOT OMIT_DEPRECATED) + list(APPEND BSP_SRCLIST + src/bsp/shared/src/bsp_default_voltab.c + ) +endif (NOT OMIT_DEPRECATED) # Define the external "osal_bsp" static library target add_library(osal_bsp STATIC - src/bsp/shared/src/osapi-bsp.c - src/bsp/shared/src/bsp_default_app_run.c - src/bsp/shared/src/bsp_default_app_startup.c - src/bsp/shared/src/bsp_default_symtab.c + ${BSP_SRCLIST} $ ) @@ -337,10 +341,6 @@ endif (ENABLE_UNIT_TESTS) # This is conditional to avoid warnings in a standalone build. get_directory_property(HAS_PARENT PARENT_DIRECTORY) if (HAS_PARENT) - # export the "OSAL_BSP_STAGING_INSTALL_DIR" to the parent build, so this can be - # used in "install" commands as necessary for the files needed at runtime - set(OSAL_BSP_STAGING_INSTALL_DIR "${OSAL_BSP_STAGING_INSTALL_DIR}" PARENT_SCOPE) - # Export the UT coverage compiler/linker flags to the parent build. # These flags are based on the target system type and should be used # when building code intended for coverage analysis. diff --git a/src/bsp/mcp750-vxworks/CMakeLists.txt b/src/bsp/mcp750-vxworks/CMakeLists.txt index 37e906696..a73a2d25d 100644 --- a/src/bsp/mcp750-vxworks/CMakeLists.txt +++ b/src/bsp/mcp750-vxworks/CMakeLists.txt @@ -6,7 +6,6 @@ add_library(osal_mcp750-vxworks_impl OBJECT src/bsp_start.c - src/bsp_voltab.c src/bsp_console.c ) diff --git a/src/bsp/mcp750-vxworks/build_options.cmake b/src/bsp/mcp750-vxworks/build_options.cmake index d9b097934..3e3c71751 100644 --- a/src/bsp/mcp750-vxworks/build_options.cmake +++ b/src/bsp/mcp750-vxworks/build_options.cmake @@ -4,8 +4,5 @@ # ########################################################################## -# This indicates where to stage target binaries created during the build -set(OSAL_BSP_STAGING_INSTALL_DIR "CF:0") - # The "-u" switch is required to ensure that "ldppc" pulls in the OS_BSPMain entry point target_link_libraries(osal_bsp -uOS_BSPMain) diff --git a/src/bsp/mcp750-vxworks/src/bsp_voltab.c b/src/bsp/mcp750-vxworks/src/bsp_voltab.c deleted file mode 100644 index bb25283b9..000000000 --- a/src/bsp/mcp750-vxworks/src/bsp_voltab.c +++ /dev/null @@ -1,60 +0,0 @@ -/* -** File : bsp_voltab.c -** Author : Nicholas Yanchik / GSFC Code 582 -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. -** -** -** BSP Volume table for file systems -*/ - -/**************************************************************************************** - INCLUDE FILES -****************************************************************************************/ -#include "common_types.h" -#include "osapi.h" - - -/* -** volume table. -*/ -OS_VolumeInfo_t OS_VolumeTable [NUM_TABLE_ENTRIES] = -{ -/* Dev Name Phys Dev Vol Type Volatile? Free? IsMounted? Volname MountPt BlockSz */ - -/* RAM Disk */ -{"/ramdev0", " ", RAM_DISK, true, true, false, " ", " ", 0 }, - -/* non-volatile Disk -- Auto-Mapped to an existing CF disk */ -{"/eedev0", "CF:0", FS_BASED, false, false, true, "CF", "/cf", 512 }, - -/* -** Spare RAM disks to be used for SSR and other RAM disks -*/ -{"/ramdev1", " ", RAM_DISK, true, true, false, " ", " ", 0 }, -{"/ramdev2", " ", RAM_DISK, true, true, false, " ", " ", 0 }, -{"/ramdev3", " ", RAM_DISK, true, true, false, " ", " ", 0 }, -{"/ramdev4", " ", RAM_DISK, true, true, false, " ", " ", 0 }, -{"/ramdev5", " ", RAM_DISK, true, true, false, " ", " ", 0 }, - -/* -** Hard disk mappings -*/ -{"/ssrdev0", "/hd:0/SSR1", FS_BASED, true, true, false, " ", " ", 0 }, -{"/ssrdev1", "/hd:0/SSR2", FS_BASED, true, true, false, " ", " ", 0 }, -{"/ssrdev2", "/hd:0/SSR3", FS_BASED, true, true, false, " ", " ", 0 }, - -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 } - -}; - - - diff --git a/src/bsp/pc-linux/CMakeLists.txt b/src/bsp/pc-linux/CMakeLists.txt index ba7d3ecb4..40b0aaca7 100644 --- a/src/bsp/pc-linux/CMakeLists.txt +++ b/src/bsp/pc-linux/CMakeLists.txt @@ -10,7 +10,6 @@ add_library(osal_pc-linux_impl OBJECT src/bsp_start.c - src/bsp_voltab.c src/bsp_console.c ) diff --git a/src/bsp/pc-linux/build_options.cmake b/src/bsp/pc-linux/build_options.cmake index c0a7a5c07..bf1d3c356 100644 --- a/src/bsp/pc-linux/build_options.cmake +++ b/src/bsp/pc-linux/build_options.cmake @@ -21,8 +21,3 @@ if (NOT CMAKE_CROSSCOMPILING) set(UT_COVERAGE_COMPILE_FLAGS -pg --coverage) set(UT_COVERAGE_LINK_FLAGS -pg --coverage) endif() - -# This indicates where to stage target binaries created during the build -# It should reflect the _real_ location of the persistent storage path used by -# the BSP which is intended to be used for runtime modules or files. -set(OSAL_BSP_STAGING_INSTALL_DIR "eeprom1") diff --git a/src/bsp/pc-linux/src/bsp_start.c b/src/bsp/pc-linux/src/bsp_start.c index 50d080fcb..964e0aba2 100644 --- a/src/bsp/pc-linux/src/bsp_start.c +++ b/src/bsp/pc-linux/src/bsp_start.c @@ -38,41 +38,9 @@ OS_BSP_PcLinuxGlobalData_t OS_BSP_PcLinuxGlobal; --------------------------------------------------------- */ void OS_BSP_Initialize(void) { - mode_t mode; - uint32 i; - struct stat statbuf; FILE *fp; char buffer[32]; - /* - ** Create local directories for "disk" mount points - ** See bsp_voltab for the values - ** - ** NOTE - the voltab table is poorly designed here; values of "0" are valid - ** and will translate into an entry that is actually used. In particular the - ** "free" flag has to be actually initialized to TRUE to say its NOT valid. - ** So in the case of an entry that has been zeroed out (i.e. bss section) it - ** will be treated as a valid entry. - ** - ** Checking that the DeviceName starts with a leading slash '/' is a workaround - ** for this, and may be the only way to detect an entry that is uninitialized. - */ - mode = S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO; - for (i = 0; i < NUM_TABLE_ENTRIES; ++i) - { - if (OS_VolumeTable[i].VolumeType == FS_BASED && - OS_VolumeTable[i].PhysDevName[0] != 0 && - OS_VolumeTable[i].DeviceName[0] == '/') - - { - if (stat(OS_VolumeTable[i].PhysDevName, &statbuf) < 0) - { - BSP_DEBUG("Creating mount point: %s\n", OS_VolumeTable[i].PhysDevName); - mkdir(OS_VolumeTable[i].PhysDevName, mode); - } - } - } - /* * If not running as root, check /proc/sys/fs/mqueue/msg_max * diff --git a/src/bsp/pc-linux/src/bsp_voltab.c b/src/bsp/pc-linux/src/bsp_voltab.c deleted file mode 100644 index ca881b265..000000000 --- a/src/bsp/pc-linux/src/bsp_voltab.c +++ /dev/null @@ -1,49 +0,0 @@ -/* -** File : bsp_voltab.c -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. -** -** -** Author : Nicholas Yanchik / GSFC Code 582 -** -** BSP Volume table for file systems -*/ - -/**************************************************************************************** - INCLUDE FILES -****************************************************************************************/ - -#include "pclinux_bsp_internal.h" - -/* -** volume table. -*/ -OS_VolumeInfo_t OS_VolumeTable [NUM_TABLE_ENTRIES] = -{ -/* Dev Name Phys Dev Vol Type Volatile? Free? IsMounted? Volname MountPt BlockSz */ -{"/ramdev0", "./ram0", FS_BASED, true, true, false, " ", " ", 0 }, -{"/ramdev1", "./ram1", FS_BASED, true, true, false, " ", " ", 0 }, -{"/ramdev2", "./ram2", FS_BASED, true, true, false, " ", " ", 0 }, -{"/ramdev3", "./ram3", FS_BASED, true, true, false, " ", " ", 0 }, -{"/ramdev4", "./ram4", FS_BASED, true, true, false, " ", " ", 0 }, -{"/ramdev5", "./ram5", FS_BASED, true, true, false, " ", " ", 0 }, - -/* -** The following entry is a "pre-mounted" path to a non-volatile device -*/ -{"/eedev0", "./eeprom1", FS_BASED, false, false, true, "CF", "/cf", 512 }, - -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 } -}; - diff --git a/src/bsp/pc-rtems/CMakeLists.txt b/src/bsp/pc-rtems/CMakeLists.txt index b5df36a6c..9b5a0af99 100644 --- a/src/bsp/pc-rtems/CMakeLists.txt +++ b/src/bsp/pc-rtems/CMakeLists.txt @@ -6,7 +6,6 @@ add_library(osal_pc-rtems_impl OBJECT src/bsp_start.c - src/bsp_voltab.c src/bsp_console.c ) diff --git a/src/bsp/pc-rtems/build_options.cmake b/src/bsp/pc-rtems/build_options.cmake index 1690376ff..d32e9245a 100644 --- a/src/bsp/pc-rtems/build_options.cmake +++ b/src/bsp/pc-rtems/build_options.cmake @@ -8,8 +8,3 @@ target_link_libraries(osal_bsp rtemscpu ) - -# This indicates where to stage target binaries created during the build -# It should reflect the _real_ location of the persistent storage path used by -# the BSP which is intended to be used for runtime modules or files. -set(OSAL_BSP_STAGING_INSTALL_DIR "eeprom") diff --git a/src/bsp/pc-rtems/src/bsp_start.c b/src/bsp/pc-rtems/src/bsp_start.c index bcce3f6e2..f9dbe2f3e 100644 --- a/src/bsp/pc-rtems/src/bsp_start.c +++ b/src/bsp/pc-rtems/src/bsp_start.c @@ -101,9 +101,7 @@ OS_BSP_PcRtemsGlobalData_t OS_BSP_PcRtemsGlobal; void OS_BSP_Setup(void) { int status; - unsigned int i; struct stat statbuf; - const char * cfpart; const char * cmdlinestr; const char * cmdp; char * cmdi, *cmdo; @@ -206,6 +204,19 @@ void OS_BSP_Setup(void) printf("Creating Root file system failed: %s\n", rtems_status_text(status)); } + /* + * Create the mountpoint for the general purpose file system + */ + if (stat(RTEMS_USER_FS_MOUNTPOINT, &statbuf) < 0) + { + status = mkdir(RTEMS_USER_FS_MOUNTPOINT, + S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO); /* For nonvol filesystem mountpoint */ + if (status < 0) + { + printf("mkdir failed: %s\n", strerror(errno)); + } + } + /* * Register the IDE partition table. */ @@ -217,52 +228,25 @@ void OS_BSP_Setup(void) * is still available. */ BSP_DEBUG("warning: /dev/hda partition table not found: %s / %s\n", rtems_status_text(status), strerror(errno)); BSP_DEBUG("Persistent storage will NOT be mounted\n"); - cfpart = NULL; } else { - cfpart = "/dev/hda1"; + status = mount("/dev/hda1", RTEMS_USER_FS_MOUNTPOINT, RTEMS_FILESYSTEM_TYPE_DOSFS, + RTEMS_FILESYSTEM_READ_WRITE, NULL); + if (status < 0) + { + BSP_DEBUG("mount failed: %s\n", strerror(errno)); + } } /* - ** Create local directories for "disk" mount points - ** See bsp_voltab for the values - ** - ** NOTE - the voltab table is poorly designed here; values of "0" are valid - ** and will translate into an entry that is actually used. In particular the - ** "free" flag has to be actually initialized to TRUE to say its NOT valid. - ** So in the case of an entry that has been zeroed out (i.e. bss section) it - ** will be treated as a valid entry. - ** - ** Checking that the DeviceName starts with a leading slash '/' is a workaround - ** for this, and may be the only way to detect an entry that is uninitialized. - */ - for (i = 0; i < NUM_TABLE_ENTRIES; ++i) - { - if (OS_VolumeTable[i].VolumeType == FS_BASED && OS_VolumeTable[i].PhysDevName[0] != 0 && - OS_VolumeTable[i].DeviceName[0] == '/') + * Change to the user storage mountpoint dir, which + * will be the basis of relative directory refs. + * If mounted, it will be persistent, otherwise + * it will be an IMFS dir, but should generally work. + */ + chdir(RTEMS_USER_FS_MOUNTPOINT); - { - if (stat(OS_VolumeTable[i].PhysDevName, &statbuf) < 0) - { - status = mkdir(OS_VolumeTable[i].PhysDevName, - S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO); /* For ramdisk mountpoint */ - if (status < 0) - { - printf("mkdir failed: %s\n", strerror(errno)); - } - } - if (cfpart != NULL && strcmp(OS_VolumeTable[i].MountPoint, "/cf") == 0) - { - status = mount(cfpart, OS_VolumeTable[i].PhysDevName, RTEMS_FILESYSTEM_TYPE_DOSFS, - RTEMS_FILESYSTEM_READ_WRITE, NULL); - if (status < 0) - { - printf("mount failed: %s\n", strerror(errno)); - } - } - } - } /* * Start the shell now, before any application starts. diff --git a/src/bsp/pc-rtems/src/bsp_voltab.c b/src/bsp/pc-rtems/src/bsp_voltab.c deleted file mode 100644 index f927d7abc..000000000 --- a/src/bsp/pc-rtems/src/bsp_voltab.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -** File : bsp_voltab.c -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. -** -** -** BSP Volume table for file systems -*/ - -/**************************************************************************************** - INCLUDE FILES -****************************************************************************************/ -#include "common_types.h" -#include "osapi.h" - -/* -** volume table. This table has the OS_ name, since it belongs to the OSAL, not the CFE_PSP -*/ -OS_VolumeInfo_t OS_VolumeTable [NUM_TABLE_ENTRIES] = -{ -/* Dev Name Phys Dev Vol Type Volatile? Free? IsMounted? Volname MountPt BlockSz */ - -/* cFE RAM Disk */ -{ "/ramdev0", "/ram0", FS_BASED, true, true, false, " ", " ", 512 }, - -/* cFE non-volatile Disk -- Auto-Mapped to an existing CF disk */ -{"/eedev0", "/eeprom", FS_BASED, false, false, true, "CF", "/cf", 512 }, - -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, - -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, - -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, -{"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 } - -}; - - - diff --git a/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h b/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h index 89656d2c7..0903dc945 100644 --- a/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h +++ b/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h @@ -31,6 +31,11 @@ #define RTEMS_NUMBER_OF_RAMDISKS 1 #define RTEMS_MAX_CMDLINE 256 +/* + * The location which the general purpose file system will be mounted + */ +#define RTEMS_USER_FS_MOUNTPOINT "/mnt" + /* * By default put the shell at the same priority * as the utility task which handles OS_printf() diff --git a/src/bsp/shared/inc/bsp-impl.h b/src/bsp/shared/inc/bsp-impl.h index bce51a9bb..3534fbad5 100644 --- a/src/bsp/shared/inc/bsp-impl.h +++ b/src/bsp/shared/inc/bsp-impl.h @@ -91,10 +91,13 @@ typedef struct */ extern OS_BSP_GlobalData_t OS_BSP_Global; +#ifndef OSAL_OMIT_DEPRECATED /* * Volume Table declaration (supplied by BSP; typically defined in bsp_voltab.c) + * @deprecated Use OS File System API to register volumes. */ -extern OS_VolumeInfo_t OS_VolumeTable[NUM_TABLE_ENTRIES]; +extern OS_VolumeInfo_t OS_VolumeTable[OS_MAX_FILE_SYSTEMS]; +#endif /********************************************************************/ /* INTERNAL BSP IMPLEMENTATION FUNCTIONS */ diff --git a/src/bsp/shared/src/bsp_default_voltab.c b/src/bsp/shared/src/bsp_default_voltab.c new file mode 100644 index 000000000..4786585b4 --- /dev/null +++ b/src/bsp/shared/src/bsp_default_voltab.c @@ -0,0 +1,62 @@ +/* +** File : bsp_voltab.c +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. +** +** +** BSP Volume table for file systems +** +** Define a default OS volume table, which has no valid entries in it. +** This is a deprecated structure in the process of being phased out. +** +** This source file should only be compiled and included in "osal_bsp" when +** OSAL_OMIT_DEPRECATED is false/unset. +** +** This serves to decouple the PSP changes and the OSAL_OMIT_DEPRECATED setting - +** allowing a PSP to be updated to use only the recommended API and remove the +** OS_VolumeTable, while still allowing code to build and link when OSAL_OMIT_DEPRECATED +** is not set. +** +** If a classic PSP is still providing this symbol, then the PSP-provided symbol will +** be used, and this one will be ignored, preserving old behavior. +** +** If an updated PSP has removed this symbol, then this will be used to satisfy linking +** requirements when building without OSAL_OMIT_DEPRECATED. +** +*/ + +/**************************************************************************************** + INCLUDE FILES +****************************************************************************************/ +#include "common_types.h" +#include "osapi.h" + +OS_VolumeInfo_t OS_VolumeTable [OS_MAX_FILE_SYSTEMS] = +{ + /* Dev Name Phys Dev Vol Type Volatile? Free? IsMounted? Volname MountPt BlockSz */ + {"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, + {"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, + {"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, + {"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, + {"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, + {"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, + {"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, + + {"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, + {"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, + {"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, + + {"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, + {"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, + {"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 }, + {"unused", "unused", FS_BASED, true, true, false, " ", " ", 0 } + +}; + + + diff --git a/src/os/inc/osapi-os-filesys.h b/src/os/inc/osapi-os-filesys.h index 5739a66f1..d928c1cf3 100644 --- a/src/os/inc/osapi-os-filesys.h +++ b/src/os/inc/osapi-os-filesys.h @@ -38,20 +38,24 @@ #define OS_CHK_ONLY 0 /**< Unused, API takes bool */ #define OS_REPAIR 1 /**< Unused, API takes bool */ +#ifndef OSAL_OMIT_DEPRECATED + /** @defgroup OSVolType OSAL Volume Type Defines * @{ */ -#define FS_BASED 0 /**< Volume type FS based */ -#define RAM_DISK 1 /**< Volume type RAM disk */ -#define EEPROM_DISK 2 /**< Volume type EEPROM disk */ -#define ATA_DISK 3 /**< Volume type ATA disk */ +#define FS_BASED 0 /**< @deprecated Volume type FS based */ +#define RAM_DISK 1 /**< @deprecated Volume type RAM disk */ +#define EEPROM_DISK 2 /**< @deprecated Volume type EEPROM disk */ +#define ATA_DISK 3 /**< @deprecated Volume type ATA disk */ /**@}*/ /** * @brief Number of entries in the internal volume table + * @deprecated */ -#define NUM_TABLE_ENTRIES 14 +#define NUM_FILE_SYSTEMS OS_MAX_FILE_SYSTEMS +#endif /* ** Length of a Device and Volume name */ @@ -113,11 +117,12 @@ * os_err_name_t. */ typedef os_err_name_t os_fs_err_name_t; -#endif /** * @brief Internal structure of the OS volume table for * mounted file systems and path translation + * + * @deprecated Use the OSAL file system API to register volumes */ typedef struct { @@ -133,6 +138,9 @@ typedef struct } OS_VolumeInfo_t; +#endif + + /** @brief OSAL file system info */ typedef struct { diff --git a/src/os/shared/inc/os-shared-filesys.h b/src/os/shared/inc/os-shared-filesys.h index d578e57bf..2175316fd 100644 --- a/src/os/shared/inc/os-shared-filesys.h +++ b/src/os/shared/inc/os-shared-filesys.h @@ -199,11 +199,13 @@ int32 OS_FileSysUnmountVolume_Impl (uint32 filesys_id); */ bool OS_FileSys_FindVirtMountPoint(void *ref, uint32 local_id, const OS_common_record_t *obj); -int32 OS_FileSys_InitLocalFromVolTable(OS_filesys_internal_record_t *local, const OS_VolumeInfo_t *Vol); int32 OS_FileSys_SetupInitialParamsForDevice(const char *devname, OS_filesys_internal_record_t *local); int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char * fsvolname, uint32 blocksize, uint32 numblocks, bool should_format); +#ifndef OSAL_OMIT_DEPRECATED +int32 OS_FileSys_InitLocalFromVolTable(OS_filesys_internal_record_t *local, const OS_VolumeInfo_t *Vol); +#endif #endif /* INCLUDE_OS_SHARED_FILESYS_H_ */ diff --git a/src/os/shared/src/osapi-filesys.c b/src/os/shared/src/osapi-filesys.c index c2638ad70..ac98076f5 100644 --- a/src/os/shared/src/osapi-filesys.c +++ b/src/os/shared/src/osapi-filesys.c @@ -48,24 +48,18 @@ enum */ OS_filesys_internal_record_t OS_filesys_table[LOCAL_NUM_OBJECTS]; +#ifndef OSAL_OMIT_DEPRECATED -#ifndef OS_DISABLE_VOLUME_TABLE /* * This is the volume table reference. It is defined in the BSP/startup code for the board * In this implementation it is treated as a "const" -- any dynamic updates such as runtime * mount points are handled with an internal table. + * + * Use of the static volume table is deprecated. New applications should register the file + * system mappings via runtime API calls instead (e.g. OS_FileSysAddFixedMap). */ extern const OS_VolumeInfo_t OS_VolumeTable[]; -#define OS_COMPAT_VOLTAB OS_VolumeTable -#define OS_COMPAT_VOLTAB_SIZE NUM_TABLE_ENTRIES -#else -/* - * Alternatively, this module can work without an OS_VolumeTable at all. - * In this mode, the PSP/BSP can explicitly instantiate any filesystem mappings - * using the runtime API call(s) prior to starting the app. - */ -#define OS_COMPAT_VOLTAB NULL -#define OS_COMPAT_VOLTAB_SIZE 0 + #endif @@ -104,10 +98,14 @@ bool OS_FileSys_FindVirtMountPoint(void *ref, uint32 local_id, const OS_common_r * Purpose: Local helper routine, not part of OSAL API. * Pre-populates a local filesys table entry from the classic OS_VolumeTable * This provides backward compatibility with existing PSP/BSP implementations. + * + * This helper is not necessary when not using the OS_VolumeTable and therefore + * can be compiled-out when OSAL_OMIT_DEPRECATED is set. * * Returns: OS_SUCCESS on success or appropriate error code. * *-----------------------------------------------------------------*/ +#ifndef OSAL_OMIT_DEPRECATED int32 OS_FileSys_InitLocalFromVolTable(OS_filesys_internal_record_t *local, const OS_VolumeInfo_t *Vol) { int32 return_code = OS_SUCCESS; @@ -198,7 +196,7 @@ int32 OS_FileSys_InitLocalFromVolTable(OS_filesys_internal_record_t *local, cons return return_code; } /* end OS_FileSys_InitLocalFromVolTable */ - +#endif /* OSAL_OMIT_DEPRECATED */ /*---------------------------------------------------------------- * @@ -208,18 +206,21 @@ int32 OS_FileSys_InitLocalFromVolTable(OS_filesys_internal_record_t *local, cons * Pre-populates a local filesys table entry from the classic OS_VolumeTable * This provides backward compatibility with existing PSP/BSP implementations. * + * This function is a no-op when OSAL_OMIT_DEPRECATED is set. + * * Returns: OS_SUCCESS on success or appropriate error code. * *-----------------------------------------------------------------*/ int32 OS_FileSys_SetupInitialParamsForDevice(const char *devname, OS_filesys_internal_record_t *local) { + int32 return_code = OS_ERR_NAME_NOT_FOUND; + +#ifndef OSAL_OMIT_DEPRECATED const OS_VolumeInfo_t *Vol; - int32 return_code; uint32 i; - return_code = OS_ERR_NAME_NOT_FOUND; - Vol = OS_COMPAT_VOLTAB; - for (i = 0; i < OS_COMPAT_VOLTAB_SIZE; i++) + Vol = OS_VolumeTable; + for (i = 0; i < OS_MAX_FILE_SYSTEMS; i++) { if (strcmp(Vol->DeviceName, devname) == 0) { @@ -229,6 +230,7 @@ int32 OS_FileSys_SetupInitialParamsForDevice(const char *devname, OS_filesys_int ++Vol; } +#endif /* OSAL_OMIT_DEPRECATED */ return return_code; } /* end OS_FileSys_SetupInitialParamsForDevice */ @@ -360,15 +362,17 @@ int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char * f *-----------------------------------------------------------------*/ int32 OS_FileSysAPI_Init(void) { + int32 return_code = OS_SUCCESS; + + memset(OS_filesys_table, 0, sizeof(OS_filesys_table)); + +#ifndef OSAL_OMIT_DEPRECATED uint32 i; uint32 local_id; - int32 return_code = OS_SUCCESS; OS_common_record_t *global; OS_filesys_internal_record_t *local; const OS_VolumeInfo_t *Vol; - memset(OS_filesys_table, 0, sizeof(OS_filesys_table)); - /* * For compatibility, migrate active entries of the BSP-provided OS_VolumeTable * into the local filesystem table. In this implementation, the OS_VolumeTable @@ -392,8 +396,8 @@ int32 OS_FileSysAPI_Init(void) * Most existing PSP packages seem to set the device name in unused entries * to the special string "unused", whereas a valid entry starts with a slash (/). */ - Vol = OS_COMPAT_VOLTAB; - for (i = 0; i < OS_COMPAT_VOLTAB_SIZE && return_code == OS_SUCCESS; i++) + Vol = OS_VolumeTable; + for (i = 0; i < OS_MAX_FILE_SYSTEMS && return_code == OS_SUCCESS; i++) { if (Vol->DeviceName[0] == '/' && Vol->FreeFlag == false) { @@ -413,6 +417,7 @@ int32 OS_FileSysAPI_Init(void) } ++Vol; } +#endif return return_code; } /* end OS_FileSysAPI_Init */ @@ -1026,7 +1031,7 @@ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) OS_Lock_Global_Impl(OS_OBJECT_TYPE_OS_FILESYS); - for ( i = 0; i < NUM_TABLE_ENTRIES; i++ ) + for ( i = 0; i < OS_MAX_FILE_SYSTEMS; i++ ) { if ( OS_global_filesys_table[i].active_id == 0) { diff --git a/src/unit-test-coverage/shared/src/coveragetest-filesys.c b/src/unit-test-coverage/shared/src/coveragetest-filesys.c index e84d14ec7..aa6d64de4 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-filesys.c +++ b/src/unit-test-coverage/shared/src/coveragetest-filesys.c @@ -551,51 +551,6 @@ void Test_OS_FileSys_FindVirtMountPoint(void) UtAssert_True(result, "OS_FileSys_FindVirtMountPoint(%s) (nominal) == true", refstr); } -/* - * Specific volume table entries to exercise translation cases in OS_FileSys_InitLocalFromVolTable() - */ -static const OS_VolumeInfo_t UT_VOLTAB_TESTCASES[] = -{ - { .DeviceName = "/UT1", .VolumeType = ATA_DISK, .FreeFlag = false, .IsMounted = true }, - { .DeviceName = "/UT2", .VolumeType = EEPROM_DISK, .FreeFlag = true, .IsMounted = false }, - { .DeviceName = "/UT3", .VolumeType = RAM_DISK, .FreeFlag = true, .IsMounted = false } -}; - -void Test_OS_FileSys_InitLocalFromVolTable(void) -{ - /* - * Test Case For: - * static int32 OS_FileSys_InitLocalFromVolTable(OS_filesys_internal_record_t *local, const OS_VolumeInfo_t *Vol) - * - * This is a static internal function and must be invoked through a UT-specific wrapper in - * order to get coverage on it. - */ - OS_filesys_internal_record_t temprec; - int32 actual; - int32 expected; - - - /* this should return OS_ERROR because the mount point was not valid */ - memset(&temprec,0,sizeof(temprec)); - expected = OS_ERROR; - actual = OS_FileSys_InitLocalFromVolTable(&temprec, &UT_VOLTAB_TESTCASES[0]); - UtAssert_True(actual == expected, "OS_FileSys_InitLocalFromVolTable(0) (%ld) == OS_ERROR", (long)actual); - - memset(&temprec,0,sizeof(temprec)); - expected = OS_SUCCESS; - actual = OS_FileSys_InitLocalFromVolTable(&temprec, &UT_VOLTAB_TESTCASES[1]); - UtAssert_True(actual == expected, "OS_FileSys_InitLocalFromVolTable(1) (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(temprec.fstype == OS_FILESYS_TYPE_MTD, "OS_FileSys_InitLocalFromVolTable(1) fstype(%u) == OS_FILESYS_TYPE_MTD", - (unsigned int)temprec.fstype); - - memset(&temprec,0,sizeof(temprec)); - expected = OS_SUCCESS; - actual = OS_FileSys_InitLocalFromVolTable(&temprec, &UT_VOLTAB_TESTCASES[2]); - UtAssert_True(actual == expected, "OS_FileSys_InitLocalFromVolTable(1) (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(temprec.fstype == OS_FILESYS_TYPE_VOLATILE_DISK, "OS_FileSys_InitLocalFromVolTable(2) fstype(%u) == OS_FILESYS_TYPE_MTD", - (unsigned int)temprec.fstype); -} - /* Osapi_Test_Setup * * Purpose: @@ -637,7 +592,6 @@ void UtTest_Setup(void) ADD_TEST(OS_GetFsInfo); ADD_TEST(OS_TranslatePath); ADD_TEST(OS_FileSys_FindVirtMountPoint); - ADD_TEST(OS_FileSys_InitLocalFromVolTable); } diff --git a/src/unit-tests/osfile-test/ut_osfile_dirio_test.h b/src/unit-tests/osfile-test/ut_osfile_dirio_test.h index 8d689b909..d843f7cbb 100644 --- a/src/unit-tests/osfile-test/ut_osfile_dirio_test.h +++ b/src/unit-tests/osfile-test/ut_osfile_dirio_test.h @@ -17,7 +17,7 @@ ** Macros **--------------------------------------------------------------------------------*/ -#define UT_OS_FILE_LIST_LEN (NUM_TABLE_ENTRIES + 10) +#define UT_OS_FILE_LIST_LEN (OS_MAX_FILE_SYSTEMS + 10) /*--------------------------------------------------------------------------------* ** Data types diff --git a/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.c b/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.c index 7e804156a..3cd6f97ad 100644 --- a/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.c +++ b/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.c @@ -88,7 +88,7 @@ extern char g_mntNames[UT_OS_FILESYS_LIST_LEN][UT_OS_FILE_BUFF_SIZE]; ** (a) OS_FS_ERR_DRIVE_NOT_CREATED ** ----------------------------------------------------- ** Test #4: Disk-full condition -** 1) Call this routine (NUM_TABLE_ENTRIES+1) of times +** 1) Call this routine (OS_MAX_FILE_SYSTEMS+1) of times ** 2) Expect the returned value to be (except the last call) ** (a) OS_SUCCESS ** 3) Expect the returned value of the last call to be @@ -148,7 +148,7 @@ void UT_os_initfs_test() /*-----------------------------------------------------*/ testDesc = "#4 Disk-full"; - for (i=0; i <= NUM_TABLE_ENTRIES; i++) + for (i=0; i <= OS_MAX_FILE_SYSTEMS; i++) { memset(g_devNames[i], '\0', sizeof(g_devNames[i])); UT_os_sprintf(g_devNames[i], "/ramdev%d", (int)i); @@ -226,7 +226,7 @@ void UT_os_initfs_test() ** (a) OS_FS_ERR_DRIVE_NOT_CREATED ** ----------------------------------------------------- ** Test #4: Disk-full condition -** 1) Call this routine (NUM_TABLE_ENTRIES+1) of times +** 1) Call this routine (OS_MAX_FILE_SYSTEMS+1) of times ** 2) Expect the returned value to be (except the last call) ** (a) OS_SUCCESS ** 3) Expect the returned value of the last call to be @@ -284,7 +284,7 @@ void UT_os_makefs_test() /*-----------------------------------------------------*/ testDesc = "#4 Disk-full"; - for (i=0; i <= NUM_TABLE_ENTRIES; i++) + for (i=0; i <= OS_MAX_FILE_SYSTEMS; i++) { memset(g_devNames[i], '\0', sizeof(g_devNames[i])); UT_os_sprintf(g_devNames[i], "/ramdev%d", (int)i); diff --git a/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.h b/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.h index 4e190c075..b08228c65 100644 --- a/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.h +++ b/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.h @@ -17,7 +17,7 @@ ** Macros **--------------------------------------------------------------------------------*/ -#define UT_OS_FILESYS_LIST_LEN (NUM_TABLE_ENTRIES + 10) +#define UT_OS_FILESYS_LIST_LEN (OS_MAX_FILE_SYSTEMS + 10) /*--------------------------------------------------------------------------------* ** Data types diff --git a/src/ut-stubs/utstub-helpers.c b/src/ut-stubs/utstub-helpers.c index 11147cc53..3561c995a 100644 --- a/src/ut-stubs/utstub-helpers.c +++ b/src/ut-stubs/utstub-helpers.c @@ -36,7 +36,7 @@ const uint32 UT_MAXOBJS[UT_OBJTYPE_MAX] = [UT_OBJTYPE_MODULE] = OS_MAX_MODULES, [UT_OBJTYPE_FILESTREAM] = OS_MAX_NUM_OPEN_FILES, [UT_OBJTYPE_TIMEBASE] = OS_MAX_TIMEBASES, - [UT_OBJTYPE_FILESYS] = NUM_TABLE_ENTRIES, + [UT_OBJTYPE_FILESYS] = OS_MAX_FILE_SYSTEMS, [UT_OBJTYPE_DIR] = OS_MAX_NUM_OPEN_DIRS };