Skip to content

Commit

Permalink
Merge pull request #967 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
osal Integration candidate: 2021-04-20
  • Loading branch information
astrogeco authored Apr 22, 2021
2 parents b37da18 + cafded0 commit afb5f7b
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 170 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ The autogenerated OSAL user's guide can be viewed at <https://github.com/nasa/cF

## Version History

### Development Build: v5.1.0-rc1+dev393

- Changes parameter names to avoid collisions. Renames `access` as `access_mode` in `osapi-file.h`. Renames `time` as `TimeSp` in `os-impl-posix-gettime.c`.
- Deletes the broken RTEMS `os-impl-shell.c` file so so OSAL builds with `OSAL_CONFIG_INCLUDE_SHELL=true`. RTEMS will always report `OS_ERR_NOT_IMPLEMENTED`.
- See <https://github.com/nasa/osal/pull/967> and <https://github.com/nasa/cFS/pull/248>

### Development Build: v5.1.0-rc1+dev387

- Replaces the separate "Initialized" and "Shutdown" flags with a single state flag. Creates a global single source of truth for the OSAL state. This enables users to run tests and OS_API_Init() multiple times without a reboot in the middle to reset the state.
Expand Down
16 changes: 8 additions & 8 deletions src/os/inc/osapi-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,16 @@ typedef enum
* of outputting the ID/descriptor separately from the return value, rather
* than relying on the user to convert it back.
*
* @param[out] filedes The handle ID (OS_OBJECT_ID_UNDEFINED on failure)
* @param[in] path File name to create or open
* @param[in] flags The file permissions - see @ref OS_file_flag_t
* @param[in] access Intended access mode - see @ref OSFileAccess
* @param[out] filedes The handle ID (OS_OBJECT_ID_UNDEFINED on failure)
* @param[in] path File name to create or open
* @param[in] flags The file permissions - see @ref OS_file_flag_t
* @param[in] access_mode Intended access mode - see @ref OSFileAccess
*
* @return Execution status, see @ref OSReturnCodes
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
* @retval #OS_ERROR if the command was not executed properly
*/
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access);
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access_mode);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down Expand Up @@ -261,14 +261,14 @@ int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, size_t nbytes, int32
/**
* @brief Changes the permissions of a file
*
* @param[in] path File to change
* @param[in] access Desired access mode - see @ref OSFileAccess
* @param[in] path File to change
* @param[in] access_mode Desired access mode - see @ref OSFileAccess
*
* @note Some file systems do not implement permissions
*
* @return Execution status, see @ref OSReturnCodes
*/
int32 OS_chmod(const char *path, uint32 access);
int32 OS_chmod(const char *path, uint32 access_mode);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down
2 changes: 1 addition & 1 deletion src/os/inc/osapi-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/*
* Development Build Macro Definitions
*/
#define OS_BUILD_NUMBER 387
#define OS_BUILD_NUMBER 393
#define OS_BUILD_BASELINE "v5.1.0-rc1"

/*
Expand Down
10 changes: 5 additions & 5 deletions src/os/portable/os-impl-posix-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
* See prototype for argument/return detail
*
*-----------------------------------------------------------------*/
int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access)
int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access_mode)
{
int os_perm;
int os_mode;
Expand All @@ -79,7 +79,7 @@ int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, i
** Check for a valid access mode
** For creating a file, OS_READ_ONLY does not make sense
*/
switch (access)
switch (access_mode)
{
case OS_WRITE_ONLY:
os_perm = O_WRONLY;
Expand Down Expand Up @@ -223,7 +223,7 @@ int32 OS_FileStat_Impl(const char *local_path, os_fstat_t *FileStats)
* See prototype for argument/return detail
*
*-----------------------------------------------------------------*/
int32 OS_FileChmod_Impl(const char *local_path, uint32 access)
int32 OS_FileChmod_Impl(const char *local_path, uint32 access_mode)
{
mode_t readbits;
mode_t writebits;
Expand Down Expand Up @@ -282,7 +282,7 @@ int32 OS_FileChmod_Impl(const char *local_path, uint32 access)
writebits |= S_IWGRP;
}

if (access == OS_WRITE_ONLY || access == OS_READ_WRITE)
if (access_mode == OS_WRITE_ONLY || access_mode == OS_READ_WRITE)
{
/* set all "write" mode bits */
st.st_mode |= writebits;
Expand All @@ -293,7 +293,7 @@ int32 OS_FileChmod_Impl(const char *local_path, uint32 access)
st.st_mode &= ~writebits;
}

if (access == OS_READ_ONLY || access == OS_READ_WRITE)
if (access_mode == OS_READ_ONLY || access_mode == OS_READ_WRITE)
{
/* set all "read" mode bits */
st.st_mode |= readbits;
Expand Down
14 changes: 7 additions & 7 deletions src/os/portable/os-impl-posix-gettime.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ int32 OS_GetLocalTime_Impl(OS_time_t *time_struct)
{
int Status;
int32 ReturnCode;
struct timespec time;
struct timespec TimeSp;

Status = clock_gettime(OSAL_GETTIME_SOURCE_CLOCK, &time);
Status = clock_gettime(OSAL_GETTIME_SOURCE_CLOCK, &TimeSp);

if (Status == 0)
{
*time_struct = OS_TimeAssembleFromNanoseconds(time.tv_sec, time.tv_nsec);
*time_struct = OS_TimeAssembleFromNanoseconds(TimeSp.tv_sec, TimeSp.tv_nsec);
ReturnCode = OS_SUCCESS;
}
else
Expand All @@ -103,12 +103,12 @@ int32 OS_SetLocalTime_Impl(const OS_time_t *time_struct)
{
int Status;
int32 ReturnCode;
struct timespec time;
struct timespec TimeSp;

time.tv_sec = OS_TimeGetTotalSeconds(*time_struct);
time.tv_nsec = OS_TimeGetNanosecondsPart(*time_struct);
TimeSp.tv_sec = OS_TimeGetTotalSeconds(*time_struct);
TimeSp.tv_nsec = OS_TimeGetNanosecondsPart(*time_struct);

Status = clock_settime(OSAL_GETTIME_SOURCE_CLOCK, &time);
Status = clock_settime(OSAL_GETTIME_SOURCE_CLOCK, &TimeSp);

if (Status == 0)
{
Expand Down
5 changes: 3 additions & 2 deletions src/os/posix/src/os-impl-shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "os-posix.h"
#include "os-impl-io.h"

#include "os-shared-file.h"
#include "os-shared-shell.h"
#include "os-shared-idmap.h"

Expand All @@ -60,7 +61,7 @@
int32 OS_ShellOutputToFile_Impl(const OS_object_token_t *token, const char *Cmd)
{
pid_t cpid;
uint32 local_id;
osal_index_t local_id;
int wstat;
const char * shell = getenv("SHELL");
OS_impl_file_internal_record_t *impl;
Expand Down Expand Up @@ -88,7 +89,7 @@ int32 OS_ShellOutputToFile_Impl(const OS_object_token_t *token, const char *Cmd)
/* close all _other_ filehandles */
for (local_id = 0; local_id < OS_MAX_NUM_OPEN_FILES; ++local_id)
{
if (OS_global_stream_table[local_id].active_id != 0)
if (OS_ObjectIdIsValid(OS_global_stream_table[local_id].active_id))
{
close(OS_impl_filehandle_table[local_id].fd);
}
Expand Down
13 changes: 4 additions & 9 deletions src/os/rtems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,10 @@ set(RTEMS_IMPL_SRCLIST
../portable/os-impl-posix-dirs.c
)

if (OSAL_CONFIG_INCLUDE_SHELL)
list(APPEND RTEMS_IMPL_SRCLIST
src/os-impl-shell.c
)
else ()
list(APPEND RTEMS_IMPL_SRCLIST
../portable/os-impl-no-shell.c
)
endif ()
# Currently the "shell output to file" for RTEMS is not implemented
list(APPEND RTEMS_IMPL_SRCLIST
../portable/os-impl-no-shell.c
)

# If some form of module loading is configured,
# then build the module loader
Expand Down
85 changes: 0 additions & 85 deletions src/os/rtems/src/os-impl-shell.c

This file was deleted.

6 changes: 3 additions & 3 deletions src/os/shared/inc/os-shared-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ int32 OS_GenericClose_Impl(const OS_object_token_t *token);
Function: OS_FileOpen_Impl
Purpose: Opens the file indicated by "local_path" with permission
indicated by "access".
indicated by "access_mode".
Returns: OS_SUCCESS on success, or relevant error code
------------------------------------------------------------------*/
int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access);
int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access_mode);

/*----------------------------------------------------------------
Function: OS_ShellOutputToFile_Impl
Expand Down Expand Up @@ -181,7 +181,7 @@ int32 OS_FileRename_Impl(const char *old_path, const char *new_path);
Returns: OS_SUCCESS on success, or relevant error code
------------------------------------------------------------------*/
int32 OS_FileChmod_Impl(const char *local_path, uint32 access);
int32 OS_FileChmod_Impl(const char *local_path, uint32 access_mode);

/*
* Internal helper function
Expand Down
10 changes: 5 additions & 5 deletions src/os/shared/src/osapi-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int32 OS_FileAPI_Init(void)
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access)
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access_mode)
{
int32 return_code;
char local_path[OS_MAX_LOCAL_PATH_LEN];
Expand All @@ -126,7 +126,7 @@ int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 acc
/*
** Check for a valid access mode
*/
if (access != OS_WRITE_ONLY && access != OS_READ_ONLY && access != OS_READ_WRITE)
if (access_mode != OS_WRITE_ONLY && access_mode != OS_READ_ONLY && access_mode != OS_READ_WRITE)
{
return OS_ERROR;
}
Expand All @@ -148,7 +148,7 @@ int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 acc
OS_OBJECT_INIT(token, stream, stream_name, path);

/* Now call the OS-specific implementation. */
return_code = OS_FileOpen_Impl(&token, local_path, flags, access);
return_code = OS_FileOpen_Impl(&token, local_path, flags, access_mode);

/* Check result, finalize record, and unlock global table. */
return_code = OS_ObjectIdFinalizeNew(return_code, &token, filedes);
Expand Down Expand Up @@ -274,15 +274,15 @@ int32 OS_write(osal_id_t filedes, const void *buffer, size_t nbytes)
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
int32 OS_chmod(const char *path, uint32 access)
int32 OS_chmod(const char *path, uint32 access_mode)
{
char local_path[OS_MAX_LOCAL_PATH_LEN];
int32 return_code;

return_code = OS_TranslatePath(path, local_path);
if (return_code == OS_SUCCESS)
{
return_code = OS_FileChmod_Impl(local_path, access);
return_code = OS_FileChmod_Impl(local_path, access_mode);
}

return return_code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void Test_OS_FileOpen_Impl(void)
{
/*
* Test Case For:
* int32 OS_FileOpen_Impl(uint32 local_id, const char *local_path, int32 flags, int32 access)
* int32 OS_FileOpen_Impl(uint32 local_id, const char *local_path, int32 flags, int32 access_mode)
*/
OS_object_token_t token;

Expand Down Expand Up @@ -101,7 +101,7 @@ void Test_OS_FileChmod_Impl(void)
{
/*
* Test Case For:
* int32 OS_FileChmod_Impl(const char *local_path, uint32 access)
* int32 OS_FileChmod_Impl(const char *local_path, uint32 access_mode)
*/
struct OCS_stat RefStat;

Expand Down
4 changes: 2 additions & 2 deletions src/unit-test-coverage/shared/src/coveragetest-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void Test_OS_OpenCreate(void)
{
/*
* Test Case For:
* int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access)
* int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access_mode)
*/
int32 expected;
int32 actual;
Expand Down Expand Up @@ -179,7 +179,7 @@ void Test_OS_chmod(void)
{
/*
* Test Case For:
* int32 OS_chmod (const char *path, uint32 access)
* int32 OS_chmod (const char *path, uint32 access_mode)
*/
int32 expected = OS_SUCCESS;
int32 actual = OS_chmod("/cf/file", 0);
Expand Down
7 changes: 4 additions & 3 deletions src/unit-test-coverage/ut-stubs/src/osapi-file-impl-stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@
* File API abstraction layer
*/

UT_DEFAULT_STUB(OS_FileOpen_Impl, (const OS_object_token_t *token, const char *local_path, int32 flags, int32 access))
UT_DEFAULT_STUB(OS_FileOpen_Impl,
(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access_mode))
UT_DEFAULT_STUB(OS_FileStat_Impl, (const char *local_path, os_fstat_t *filestat))
UT_DEFAULT_STUB(OS_FileRemove_Impl, (const char *local_path))
UT_DEFAULT_STUB(OS_FileRename_Impl, (const char *old_path, const char *new_path))
UT_DEFAULT_STUB(OS_FileChmod_Impl, (const char *local_path, uint32 access))
UT_DEFAULT_STUB(OS_FileChmod_Impl, (const char *local_path, uint32 access_mode))
UT_DEFAULT_STUB(OS_ShellOutputToFile_Impl, (const OS_object_token_t *token, const char *Cmd))

/*
* Directory API abstraction layer
*/
UT_DEFAULT_STUB(OS_DirCreate_Impl, (const char *local_path, uint32 access))
UT_DEFAULT_STUB(OS_DirCreate_Impl, (const char *local_path, uint32 access_mode))
UT_DEFAULT_STUB(OS_DirOpen_Impl, (const OS_object_token_t *token, const char *local_path))
UT_DEFAULT_STUB(OS_DirClose_Impl, (const OS_object_token_t *token))
UT_DEFAULT_STUB(OS_DirRead_Impl, (const OS_object_token_t *token, os_dirent_t *dirent))
Expand Down
Loading

0 comments on commit afb5f7b

Please sign in to comment.