Skip to content

Commit f55cc82

Browse files
authored
Merge pull request #1156 from jphickey/fix-981-better-filename-parser
Fix #981, implement better filename parser
2 parents b50ae63 + 361eb65 commit f55cc82

File tree

11 files changed

+893
-57
lines changed

11 files changed

+893
-57
lines changed

cmake/sample_defs/cpu1_cfe_es_startup.scr

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
CFE_LIB, /cf/sample_lib.so, SAMPLE_LIB_Init, SAMPLE_LIB, 0, 0, 0x0, 0;
2-
CFE_APP, /cf/sample_app.so, SAMPLE_APP_Main, SAMPLE_APP, 50, 16384, 0x0, 0;
3-
CFE_APP, /cf/ci_lab.so, CI_Lab_AppMain, CI_LAB_APP, 60, 16384, 0x0, 0;
4-
CFE_APP, /cf/to_lab.so, TO_Lab_AppMain, TO_LAB_APP, 70, 16384, 0x0, 0;
5-
CFE_APP, /cf/sch_lab.so, SCH_Lab_AppMain, SCH_LAB_APP, 80, 16384, 0x0, 0;
1+
CFE_LIB, sample_lib, SAMPLE_LIB_Init, SAMPLE_LIB, 0, 0, 0x0, 0;
2+
CFE_APP, sample_app, SAMPLE_APP_Main, SAMPLE_APP, 50, 16384, 0x0, 0;
3+
CFE_APP, ci_lab, CI_Lab_AppMain, CI_LAB_APP, 60, 16384, 0x0, 0;
4+
CFE_APP, to_lab, TO_Lab_AppMain, TO_LAB_APP, 70, 16384, 0x0, 0;
5+
CFE_APP, sch_lab, SCH_Lab_AppMain, SCH_LAB_APP, 80, 16384, 0x0, 0;
66
!
77
! Startup script fields:
88
! 1. Object Type -- CFE_APP for an Application, or CFE_LIB for a library.
@@ -27,4 +27,7 @@ CFE_APP, /cf/sch_lab.so, SCH_Lab_AppMain, SCH_LAB_APP, 80, 16384, 0x0, 0;
2727
! vxWorks = .o ( ci.o )
2828
! RTEMS with S-record Loader = .s3r ( ci.s3r )
2929
! RTEMS with CEXP Loader = .o ( ci.o )
30+
! 3. The filename field (2) no longer requires a fully-qualified filename; the path and extension
31+
! may be omitted. If omitted, the standard virtual path (/cf) and a platform-specific default
32+
! extension will be used, which is derived from the build system.
3033

cmake/sample_defs/cpu1_platform_cfg.h

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,35 @@
3636
#ifndef _cfe_platform_cfg_
3737
#define _cfe_platform_cfg_
3838

39+
40+
/**
41+
** \cfeescfg Default virtual path for persistent storage
42+
**
43+
** \par Description:
44+
** This configures the default location in the virtual file system
45+
** for persistent/non-volatile storage. Files such as the startup
46+
** script, app/library dynamic modules, and configuration tables are
47+
** expected to be stored in this directory.
48+
**
49+
*/
50+
#define CFE_PLATFORM_ES_NONVOL_DISK_MOUNT_STRING "/cf"
51+
52+
/**
53+
** \cfeescfg Default virtual path for volatile storage
54+
**
55+
** \par Description:
56+
** The #CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING parameter is used to set the cFE mount path
57+
** for the CFE RAM disk. This is a parameter for missions that do not want to
58+
** use the default value of "/ram", or for missions that need to have a different
59+
** value for different CPUs or Spacecraft.
60+
** Note that the vxWorks OSAL cannot currently handle names that have more than one
61+
** path separator in it. The names "/ram", "/ramdisk", "/disk123" will all work, but
62+
** "/disks/ram" will not.
63+
** Multiple separators can be used with the posix or RTEMS ports.
64+
**
65+
*/
66+
#define CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING "/ram"
67+
3968
/**
4069
** \cfesbcfg Maximum Number of Unique Message IDs SB Routing Table can hold
4170
**
@@ -682,23 +711,6 @@
682711
#define CFE_PLATFORM_ES_RAM_DISK_PERCENT_RESERVED 30
683712

684713

685-
/**
686-
** \cfeescfg RAM Disk Mount string
687-
**
688-
** \par Description:
689-
** The #CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING parameter is used to set the cFE mount path
690-
** for the CFE RAM disk. This is a parameter for missions that do not want to
691-
** use the default value of "/ram", or for missions that need to have a different
692-
** value for different CPUs or Spacecraft.
693-
** Note that the vxWorks OSAL cannot currently handle names that have more than one
694-
** path separator in it. The names "/ram", "/ramdisk", "/disk123" will all work, but
695-
** "/disks/ram" will not.
696-
** Multiple separators can be used with the posix or RTEMS ports.
697-
**
698-
*/
699-
#define CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING "/ram"
700-
701-
702714
/**
703715
** \cfeescfg Define Critical Data Store Size
704716
**

cmake/target/inc/target_config.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,17 @@ typedef const struct
106106
uint32 RamDiskTotalSectors; /***< RAM disk number of sectors */
107107

108108
/**
109-
* Default value for start up file
109+
* Default value for nonvolatile file system mount point
110+
*/
111+
const char *NonvolMountPoint;
112+
113+
/**
114+
* Default value for volatile file system mount point
115+
*/
116+
const char *RamdiskMountPoint;
117+
118+
/**
119+
* File name of startup script
110120
*/
111121
const char *NonvolStartupFile;
112122

cmake/target/src/target_config.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ Target_CfeConfigData GLOBAL_CFE_CONFIGDATA =
7272
.SystemNotify = CFE_ES_ProcessAsyncEvent,
7373

7474
/*
75-
* Default values for Startup file.
76-
* This is a suggested value, but the PSP may provide a different file
75+
* Default values for various file paths
7776
*/
77+
.NonvolMountPoint = CFE_PLATFORM_ES_NONVOL_DISK_MOUNT_STRING,
78+
.RamdiskMountPoint = CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING,
7879
.NonvolStartupFile = CFE_PLATFORM_ES_NONVOL_STARTUP_FILE,
7980

8081
/*

fsw/cfe-core/src/es/cfe_es_apps.c

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
*/
7777
void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath )
7878
{
79-
char ES_AppLoadBuffer[ES_START_BUFF_SIZE]; /* A buffer of for a line in a file */
79+
char ES_AppLoadBuffer[ES_START_BUFF_SIZE]; /* A buffer of for a line in a file */
80+
char ScriptFileName[OS_MAX_PATH_LEN];
8081
const char *TokenList[CFE_ES_STARTSCRIPT_MAX_TOKENS_PER_LINE];
8182
uint32 NumTokens;
8283
uint32 BuffLen; /* Length of the current buffer */
@@ -93,14 +94,20 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath )
9394
if ( ResetType == CFE_PSP_RST_TYPE_PROCESSOR )
9495
{
9596
/*
96-
** Open the file in the volatile disk.
97+
** First Attempt to parse as file in the volatile disk (temp area).
9798
*/
98-
Status = OS_OpenCreate(&AppFile, CFE_PLATFORM_ES_VOLATILE_STARTUP_FILE, OS_FILE_FLAG_NONE, OS_READ_ONLY);
99+
Status = CFE_FS_ParseInputFileName(ScriptFileName, CFE_PLATFORM_ES_VOLATILE_STARTUP_FILE,
100+
sizeof(ScriptFileName), CFE_FS_FileCategory_TEMP);
101+
102+
if (Status == CFE_SUCCESS)
103+
{
104+
Status = OS_OpenCreate(&AppFile, ScriptFileName, OS_FILE_FLAG_NONE, OS_READ_ONLY);
105+
}
99106

100107
if ( Status >= 0 )
101108
{
102109
CFE_ES_WriteToSysLog ("ES Startup: Opened ES App Startup file: %s\n",
103-
CFE_PLATFORM_ES_VOLATILE_STARTUP_FILE);
110+
ScriptFileName);
104111
FileOpened = true;
105112
}
106113
else
@@ -120,11 +127,17 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath )
120127
/*
121128
** Try to Open the file passed in to the cFE start.
122129
*/
123-
Status = OS_OpenCreate(&AppFile, StartFilePath, OS_FILE_FLAG_NONE, OS_READ_ONLY);
130+
Status = CFE_FS_ParseInputFileName(ScriptFileName, StartFilePath,
131+
sizeof(ScriptFileName), CFE_FS_FileCategory_SCRIPT);
132+
133+
if (Status == CFE_SUCCESS)
134+
{
135+
Status = OS_OpenCreate(&AppFile, ScriptFileName, OS_FILE_FLAG_NONE, OS_READ_ONLY);
136+
}
124137

125138
if ( Status >= 0 )
126139
{
127-
CFE_ES_WriteToSysLog ("ES Startup: Opened ES App Startup file: %s\n",StartFilePath);
140+
CFE_ES_WriteToSysLog ("ES Startup: Opened ES App Startup file: %s\n",ScriptFileName);
128141
FileOpened = true;
129142
}
130143
else
@@ -271,7 +284,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens)
271284
CFE_ES_AppId_t AppId;
272285
CFE_ES_LibId_t LibId;
273286
} IdBuf;
274-
int32 CreateStatus = CFE_ES_ERR_APP_CREATE;
287+
int32 Status;
275288
CFE_ES_AppStartParams_t ParamBuf;
276289

277290
/*
@@ -280,7 +293,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens)
280293
if (NumTokens < 8)
281294
{
282295
CFE_ES_WriteToSysLog("ES Startup: Invalid ES Startup file entry: %u\n", (unsigned int)NumTokens);
283-
return (CreateStatus);
296+
return CFE_ES_BAD_ARGUMENT;
284297
}
285298

286299
/* Get pointers to specific tokens that are simple strings used as-is */
@@ -292,7 +305,14 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens)
292305
* Both Libraries and Apps use File Name (1) and Symbol Name (2) fields so copy those now
293306
*/
294307
memset(&ParamBuf, 0, sizeof(ParamBuf));
295-
strncpy(ParamBuf.BasicInfo.FileName, TokenList[1], sizeof(ParamBuf.BasicInfo.FileName) - 1);
308+
Status = CFE_FS_ParseInputFileName(ParamBuf.BasicInfo.FileName, TokenList[1],
309+
sizeof(ParamBuf.BasicInfo.FileName), CFE_FS_FileCategory_DYNAMIC_MODULE);
310+
if (Status != CFE_SUCCESS)
311+
{
312+
CFE_ES_WriteToSysLog("ES Startup: Invalid ES Startup script file name: %s\n", TokenList[1]);
313+
return Status;
314+
}
315+
296316
strncpy(ParamBuf.BasicInfo.InitSymbolName, TokenList[2], sizeof(ParamBuf.BasicInfo.InitSymbolName) - 1);
297317

298318
if (strcmp(EntryType, "CFE_APP") == 0)
@@ -338,7 +358,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens)
338358
/*
339359
** Now create the application
340360
*/
341-
CreateStatus = CFE_ES_AppCreate(&IdBuf.AppId, ModuleName, &ParamBuf);
361+
Status = CFE_ES_AppCreate(&IdBuf.AppId, ModuleName, &ParamBuf);
342362
}
343363
else if (strcmp(EntryType, "CFE_LIB") == 0)
344364
{
@@ -347,14 +367,15 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens)
347367
/*
348368
** Now load the library
349369
*/
350-
CreateStatus = CFE_ES_LoadLibrary(&IdBuf.LibId, ModuleName, &ParamBuf.BasicInfo);
370+
Status = CFE_ES_LoadLibrary(&IdBuf.LibId, ModuleName, &ParamBuf.BasicInfo);
351371
}
352372
else
353373
{
354374
CFE_ES_WriteToSysLog("ES Startup: Unexpected EntryType %s in startup file.\n", EntryType);
375+
Status = CFE_ES_ERR_APP_CREATE;
355376
}
356377

357-
return (CreateStatus);
378+
return (Status);
358379
}
359380

360381
/*

0 commit comments

Comments
 (0)