Skip to content

Commit afb5f7b

Browse files
authored
Merge pull request #967 from nasa/integration-candidate
osal Integration candidate: 2021-04-20
2 parents b37da18 + cafded0 commit afb5f7b

15 files changed

+57
-170
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ The autogenerated OSAL user's guide can be viewed at <https://github.com/nasa/cF
1111

1212
## Version History
1313

14+
### Development Build: v5.1.0-rc1+dev393
15+
16+
- 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`.
17+
- 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`.
18+
- See <https://github.com/nasa/osal/pull/967> and <https://github.com/nasa/cFS/pull/248>
19+
1420
### Development Build: v5.1.0-rc1+dev387
1521

1622
- 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.

src/os/inc/osapi-file.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,16 @@ typedef enum
127127
* of outputting the ID/descriptor separately from the return value, rather
128128
* than relying on the user to convert it back.
129129
*
130-
* @param[out] filedes The handle ID (OS_OBJECT_ID_UNDEFINED on failure)
131-
* @param[in] path File name to create or open
132-
* @param[in] flags The file permissions - see @ref OS_file_flag_t
133-
* @param[in] access Intended access mode - see @ref OSFileAccess
130+
* @param[out] filedes The handle ID (OS_OBJECT_ID_UNDEFINED on failure)
131+
* @param[in] path File name to create or open
132+
* @param[in] flags The file permissions - see @ref OS_file_flag_t
133+
* @param[in] access_mode Intended access mode - see @ref OSFileAccess
134134
*
135135
* @return Execution status, see @ref OSReturnCodes
136136
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
137137
* @retval #OS_ERROR if the command was not executed properly
138138
*/
139-
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access);
139+
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access_mode);
140140

141141
/*-------------------------------------------------------------------------------------*/
142142
/**
@@ -261,14 +261,14 @@ int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, size_t nbytes, int32
261261
/**
262262
* @brief Changes the permissions of a file
263263
*
264-
* @param[in] path File to change
265-
* @param[in] access Desired access mode - see @ref OSFileAccess
264+
* @param[in] path File to change
265+
* @param[in] access_mode Desired access mode - see @ref OSFileAccess
266266
*
267267
* @note Some file systems do not implement permissions
268268
*
269269
* @return Execution status, see @ref OSReturnCodes
270270
*/
271-
int32 OS_chmod(const char *path, uint32 access);
271+
int32 OS_chmod(const char *path, uint32 access_mode);
272272

273273
/*-------------------------------------------------------------------------------------*/
274274
/**

src/os/inc/osapi-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
/*
3535
* Development Build Macro Definitions
3636
*/
37-
#define OS_BUILD_NUMBER 387
37+
#define OS_BUILD_NUMBER 393
3838
#define OS_BUILD_BASELINE "v5.1.0-rc1"
3939

4040
/*

src/os/portable/os-impl-posix-files.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
* See prototype for argument/return detail
6868
*
6969
*-----------------------------------------------------------------*/
70-
int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access)
70+
int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access_mode)
7171
{
7272
int os_perm;
7373
int os_mode;
@@ -79,7 +79,7 @@ int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, i
7979
** Check for a valid access mode
8080
** For creating a file, OS_READ_ONLY does not make sense
8181
*/
82-
switch (access)
82+
switch (access_mode)
8383
{
8484
case OS_WRITE_ONLY:
8585
os_perm = O_WRONLY;
@@ -223,7 +223,7 @@ int32 OS_FileStat_Impl(const char *local_path, os_fstat_t *FileStats)
223223
* See prototype for argument/return detail
224224
*
225225
*-----------------------------------------------------------------*/
226-
int32 OS_FileChmod_Impl(const char *local_path, uint32 access)
226+
int32 OS_FileChmod_Impl(const char *local_path, uint32 access_mode)
227227
{
228228
mode_t readbits;
229229
mode_t writebits;
@@ -282,7 +282,7 @@ int32 OS_FileChmod_Impl(const char *local_path, uint32 access)
282282
writebits |= S_IWGRP;
283283
}
284284

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

296-
if (access == OS_READ_ONLY || access == OS_READ_WRITE)
296+
if (access_mode == OS_READ_ONLY || access_mode == OS_READ_WRITE)
297297
{
298298
/* set all "read" mode bits */
299299
st.st_mode |= readbits;

src/os/portable/os-impl-posix-gettime.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ int32 OS_GetLocalTime_Impl(OS_time_t *time_struct)
7373
{
7474
int Status;
7575
int32 ReturnCode;
76-
struct timespec time;
76+
struct timespec TimeSp;
7777

78-
Status = clock_gettime(OSAL_GETTIME_SOURCE_CLOCK, &time);
78+
Status = clock_gettime(OSAL_GETTIME_SOURCE_CLOCK, &TimeSp);
7979

8080
if (Status == 0)
8181
{
82-
*time_struct = OS_TimeAssembleFromNanoseconds(time.tv_sec, time.tv_nsec);
82+
*time_struct = OS_TimeAssembleFromNanoseconds(TimeSp.tv_sec, TimeSp.tv_nsec);
8383
ReturnCode = OS_SUCCESS;
8484
}
8585
else
@@ -103,12 +103,12 @@ int32 OS_SetLocalTime_Impl(const OS_time_t *time_struct)
103103
{
104104
int Status;
105105
int32 ReturnCode;
106-
struct timespec time;
106+
struct timespec TimeSp;
107107

108-
time.tv_sec = OS_TimeGetTotalSeconds(*time_struct);
109-
time.tv_nsec = OS_TimeGetNanosecondsPart(*time_struct);
108+
TimeSp.tv_sec = OS_TimeGetTotalSeconds(*time_struct);
109+
TimeSp.tv_nsec = OS_TimeGetNanosecondsPart(*time_struct);
110110

111-
Status = clock_settime(OSAL_GETTIME_SOURCE_CLOCK, &time);
111+
Status = clock_settime(OSAL_GETTIME_SOURCE_CLOCK, &TimeSp);
112112

113113
if (Status == 0)
114114
{

src/os/posix/src/os-impl-shell.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "os-posix.h"
3838
#include "os-impl-io.h"
3939

40+
#include "os-shared-file.h"
4041
#include "os-shared-shell.h"
4142
#include "os-shared-idmap.h"
4243

@@ -60,7 +61,7 @@
6061
int32 OS_ShellOutputToFile_Impl(const OS_object_token_t *token, const char *Cmd)
6162
{
6263
pid_t cpid;
63-
uint32 local_id;
64+
osal_index_t local_id;
6465
int wstat;
6566
const char * shell = getenv("SHELL");
6667
OS_impl_file_internal_record_t *impl;
@@ -88,7 +89,7 @@ int32 OS_ShellOutputToFile_Impl(const OS_object_token_t *token, const char *Cmd)
8889
/* close all _other_ filehandles */
8990
for (local_id = 0; local_id < OS_MAX_NUM_OPEN_FILES; ++local_id)
9091
{
91-
if (OS_global_stream_table[local_id].active_id != 0)
92+
if (OS_ObjectIdIsValid(OS_global_stream_table[local_id].active_id))
9293
{
9394
close(OS_impl_filehandle_table[local_id].fd);
9495
}

src/os/rtems/CMakeLists.txt

+4-9
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,10 @@ set(RTEMS_IMPL_SRCLIST
3636
../portable/os-impl-posix-dirs.c
3737
)
3838

39-
if (OSAL_CONFIG_INCLUDE_SHELL)
40-
list(APPEND RTEMS_IMPL_SRCLIST
41-
src/os-impl-shell.c
42-
)
43-
else ()
44-
list(APPEND RTEMS_IMPL_SRCLIST
45-
../portable/os-impl-no-shell.c
46-
)
47-
endif ()
39+
# Currently the "shell output to file" for RTEMS is not implemented
40+
list(APPEND RTEMS_IMPL_SRCLIST
41+
../portable/os-impl-no-shell.c
42+
)
4843

4944
# If some form of module loading is configured,
5045
# then build the module loader

src/os/rtems/src/os-impl-shell.c

-85
This file was deleted.

src/os/shared/inc/os-shared-file.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ int32 OS_GenericClose_Impl(const OS_object_token_t *token);
115115
Function: OS_FileOpen_Impl
116116
117117
Purpose: Opens the file indicated by "local_path" with permission
118-
indicated by "access".
118+
indicated by "access_mode".
119119
120120
Returns: OS_SUCCESS on success, or relevant error code
121121
------------------------------------------------------------------*/
122-
int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access);
122+
int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access_mode);
123123

124124
/*----------------------------------------------------------------
125125
Function: OS_ShellOutputToFile_Impl
@@ -181,7 +181,7 @@ int32 OS_FileRename_Impl(const char *old_path, const char *new_path);
181181
182182
Returns: OS_SUCCESS on success, or relevant error code
183183
------------------------------------------------------------------*/
184-
int32 OS_FileChmod_Impl(const char *local_path, uint32 access);
184+
int32 OS_FileChmod_Impl(const char *local_path, uint32 access_mode);
185185

186186
/*
187187
* Internal helper function

src/os/shared/src/osapi-file.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ int32 OS_FileAPI_Init(void)
110110
* See description in API and header file for detail
111111
*
112112
*-----------------------------------------------------------------*/
113-
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access)
113+
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access_mode)
114114
{
115115
int32 return_code;
116116
char local_path[OS_MAX_LOCAL_PATH_LEN];
@@ -126,7 +126,7 @@ int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 acc
126126
/*
127127
** Check for a valid access mode
128128
*/
129-
if (access != OS_WRITE_ONLY && access != OS_READ_ONLY && access != OS_READ_WRITE)
129+
if (access_mode != OS_WRITE_ONLY && access_mode != OS_READ_ONLY && access_mode != OS_READ_WRITE)
130130
{
131131
return OS_ERROR;
132132
}
@@ -148,7 +148,7 @@ int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 acc
148148
OS_OBJECT_INIT(token, stream, stream_name, path);
149149

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

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

282282
return_code = OS_TranslatePath(path, local_path);
283283
if (return_code == OS_SUCCESS)
284284
{
285-
return_code = OS_FileChmod_Impl(local_path, access);
285+
return_code = OS_FileChmod_Impl(local_path, access_mode);
286286
}
287287

288288
return return_code;

src/unit-test-coverage/portable/src/coveragetest-posix-files.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void Test_OS_FileOpen_Impl(void)
4141
{
4242
/*
4343
* Test Case For:
44-
* int32 OS_FileOpen_Impl(uint32 local_id, const char *local_path, int32 flags, int32 access)
44+
* int32 OS_FileOpen_Impl(uint32 local_id, const char *local_path, int32 flags, int32 access_mode)
4545
*/
4646
OS_object_token_t token;
4747

@@ -101,7 +101,7 @@ void Test_OS_FileChmod_Impl(void)
101101
{
102102
/*
103103
* Test Case For:
104-
* int32 OS_FileChmod_Impl(const char *local_path, uint32 access)
104+
* int32 OS_FileChmod_Impl(const char *local_path, uint32 access_mode)
105105
*/
106106
struct OCS_stat RefStat;
107107

src/unit-test-coverage/shared/src/coveragetest-file.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void Test_OS_OpenCreate(void)
5252
{
5353
/*
5454
* Test Case For:
55-
* int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access)
55+
* int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access_mode)
5656
*/
5757
int32 expected;
5858
int32 actual;
@@ -179,7 +179,7 @@ void Test_OS_chmod(void)
179179
{
180180
/*
181181
* Test Case For:
182-
* int32 OS_chmod (const char *path, uint32 access)
182+
* int32 OS_chmod (const char *path, uint32 access_mode)
183183
*/
184184
int32 expected = OS_SUCCESS;
185185
int32 actual = OS_chmod("/cf/file", 0);

src/unit-test-coverage/ut-stubs/src/osapi-file-impl-stubs.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,18 @@
3939
* File API abstraction layer
4040
*/
4141

42-
UT_DEFAULT_STUB(OS_FileOpen_Impl, (const OS_object_token_t *token, const char *local_path, int32 flags, int32 access))
42+
UT_DEFAULT_STUB(OS_FileOpen_Impl,
43+
(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access_mode))
4344
UT_DEFAULT_STUB(OS_FileStat_Impl, (const char *local_path, os_fstat_t *filestat))
4445
UT_DEFAULT_STUB(OS_FileRemove_Impl, (const char *local_path))
4546
UT_DEFAULT_STUB(OS_FileRename_Impl, (const char *old_path, const char *new_path))
46-
UT_DEFAULT_STUB(OS_FileChmod_Impl, (const char *local_path, uint32 access))
47+
UT_DEFAULT_STUB(OS_FileChmod_Impl, (const char *local_path, uint32 access_mode))
4748
UT_DEFAULT_STUB(OS_ShellOutputToFile_Impl, (const OS_object_token_t *token, const char *Cmd))
4849

4950
/*
5051
* Directory API abstraction layer
5152
*/
52-
UT_DEFAULT_STUB(OS_DirCreate_Impl, (const char *local_path, uint32 access))
53+
UT_DEFAULT_STUB(OS_DirCreate_Impl, (const char *local_path, uint32 access_mode))
5354
UT_DEFAULT_STUB(OS_DirOpen_Impl, (const OS_object_token_t *token, const char *local_path))
5455
UT_DEFAULT_STUB(OS_DirClose_Impl, (const OS_object_token_t *token))
5556
UT_DEFAULT_STUB(OS_DirRead_Impl, (const OS_object_token_t *token, os_dirent_t *dirent))

0 commit comments

Comments
 (0)