Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #399, Deprecate decompress #638

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 4 additions & 162 deletions fsw/cfe-core/src/es/cfe_es_apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,6 @@ int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr,
bool AppSlotFound;
uint32 TaskId;
uint32 ModuleId;
char FileNameOnly[OS_MAX_PATH_LEN];
char RamDiskPath[OS_MAX_PATH_LEN];
size_t StringLength;
bool IsRamDiskFile = false;


/*
* The FileName must not be NULL
Expand Down Expand Up @@ -408,96 +403,10 @@ int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr,
if ( AppSlotFound == true)
{
/*
** Check to see if the code is a Gzip file
** Load the module
*/
if ( CFE_FS_IsGzFile(FileName) == true )
{
/*
** Build up the destination path in the RAM disk
*/
(void) CFE_SB_MessageStringGet(RamDiskPath,
CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING"/",
NULL,
sizeof(RamDiskPath),
sizeof(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING"/"));

/*
** Extract the filename from the path
*/
ReturnCode = CFE_FS_ExtractFilenameFromPath(FileName, FileNameOnly);

if ( ReturnCode == CFE_SUCCESS )
{
if ((strlen(RamDiskPath) + strlen(FileNameOnly)) < OS_MAX_PATH_LEN)
{

/*
** Cat the Filename to the RamDiskPath
*/
strcat(RamDiskPath, FileNameOnly);

/*
** Remove the ".gz" prefix from the filename
** Already Determined that the filename ends in ".gz"
*/
StringLength = strlen(RamDiskPath);
RamDiskPath[StringLength - 3] = '\0';

/*
** Decompress the file:
*/
ReturnCode = CFE_FS_Decompress( FileName, RamDiskPath);

if ( ReturnCode != OS_SUCCESS )
{
CFE_ES_WriteToSysLog("ES Startup: Unable to decompress Application File: %s\n",FileName);

CFE_ES_LockSharedData(__func__,__LINE__);
CFE_ES_Global.AppTable[i].AppState = CFE_ES_AppState_UNDEFINED; /* Release slot */
CFE_ES_UnlockSharedData(__func__,__LINE__);

return(CFE_ES_ERR_APP_CREATE);
}
else
{
/*
** All ready to use unzipped RAM disk file
*/
IsRamDiskFile = true;
ReturnCode = OS_ModuleLoad( &ModuleId, AppName, RamDiskPath);
}
}
else
{
/* Can't include the name string since it could be too long for the message */
CFE_ES_WriteToSysLog("ES Startup: Application path plus file name length (%d) exceeds max allowed (%d)\n",
(int)(strlen(RamDiskPath) + strlen(FileNameOnly)), OS_MAX_PATH_LEN);

CFE_ES_LockSharedData(__func__,__LINE__);
CFE_ES_Global.AppTable[i].AppState = CFE_ES_AppState_UNDEFINED; /* Release slot */
CFE_ES_UnlockSharedData(__func__,__LINE__);

return(CFE_ES_ERR_APP_CREATE);
}

}
else
{
CFE_ES_WriteToSysLog("ES Startup: Unable to extract filename from path: %s.\n",FileName);
CFE_ES_LockSharedData(__func__,__LINE__);
CFE_ES_Global.AppTable[i].AppState = CFE_ES_AppState_UNDEFINED; /* Release slot */
CFE_ES_UnlockSharedData(__func__,__LINE__);
return(CFE_ES_ERR_APP_CREATE);
}
ReturnCode = OS_ModuleLoad ( &ModuleId, AppName, FileName );

}
else
{
/*
** Load the module directly
*/
ReturnCode = OS_ModuleLoad ( &ModuleId, AppName, FileName );
}
/*
** If the Load was OK, then lookup the address of the entry point
*/
Expand Down Expand Up @@ -630,20 +539,6 @@ int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr,

CFE_ES_UnlockSharedData(__func__,__LINE__);

/*
** Remove the temporary RAM disk file
*/
if ( IsRamDiskFile == true )
{
ReturnCode = OS_remove(RamDiskPath);

if (ReturnCode != OS_SUCCESS)
{
CFE_ES_WriteToSysLog("ES Startup: Error removing temp RAM disk file, EC = 0x%08X\n",
(unsigned int) ReturnCode);
}
}

return(CFE_SUCCESS);

} /* End If OS_TaskCreate */
Expand All @@ -670,14 +565,11 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr,
{
CFE_ES_LibraryEntryFuncPtr_t FunctionPointer;
CFE_ES_LibRecord_t * LibSlotPtr;
const char * ActualLoadFile;
size_t StringLength;
int32 Status;
uint32 CheckSlot;
uint32 ModuleId;
bool IsModuleLoaded;
bool IsRamDiskFile;
char RamDiskPath[OS_MAX_PATH_LEN];

/*
* First, should verify that the supplied "LibName" fits within the internal limit
Expand All @@ -692,10 +584,7 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr,
/*
** Allocate an ES_LibTable entry
*/
RamDiskPath[0] = 0;
IsModuleLoaded = false;
IsRamDiskFile = false;
ActualLoadFile = NULL;
LibSlotPtr = NULL;
FunctionPointer = NULL;
ModuleId = 0;
Expand Down Expand Up @@ -771,42 +660,13 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr,
* -------------------
*/

/*
* STAGE 1:
* Figure out what filename to actually load, if a filename was given
* If the file is compressed, it must be uncompressed to a temp location first and that will be loaded
*
* (Note CFE_FS_IsGzFile() handles a NULL filename and properly returns false if NULL)
*/
if ( ! CFE_FS_IsGzFile(FileName) )
{
/*
** Not compressed - Load the library module directly
*/
ActualLoadFile = FileName;
}
else
{
/*
* Decompress to a temp file, and get that file name.
* Implemented in a helper function in the File Services subsystem which avoids clutter here.
*/
Status = CFE_FS_GetUncompressedFile(RamDiskPath, sizeof(RamDiskPath),
FileName, CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING);
if (Status == CFE_SUCCESS)
{
IsRamDiskFile = true;
ActualLoadFile = RamDiskPath;
}
}

/*
* STAGE 2:
* Do the OS_ModuleLoad() if is called for (i.e. ModuleLoadFile is NOT null)
*/
if (Status == CFE_SUCCESS && ActualLoadFile != NULL)
if (Status == CFE_SUCCESS && FileName != NULL)
{
Status = OS_ModuleLoad( &ModuleId, LibName, ActualLoadFile );
Status = OS_ModuleLoad( &ModuleId, LibName, FileName );
if (Status == OS_SUCCESS)
{
Status = CFE_SUCCESS; /* just in case CFE_SUCCESS is different than OS_SUCCESS */
Expand Down Expand Up @@ -901,24 +761,6 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr,
OS_ModuleUnload( ModuleId );
}

/*
* If the above code had used a temp file, then remove it
*/
if ( IsRamDiskFile == true )
{
/*
* Note: do not overwrite "Status" variable here;
* this contains a return code that needs to be
* sent back to the caller.
*/

if (OS_remove(RamDiskPath) != OS_SUCCESS)
{
CFE_ES_WriteToSysLog("ES Startup: Error removing temp lib RAM disk file, EC = 0x%08X\n",
(unsigned int) Status);
}
}

/* Release Slot - No need to lock as it is resetting just a single bool value */
LibSlotPtr->RecordUsed = false;
}
Expand Down
3 changes: 2 additions & 1 deletion fsw/cfe-core/src/fs/cfe_fs_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ int32 CFE_FS_ExtractFilenameFromPath(const char *OriginalPath, char *FileNameOnl
return(ReturnCode);
}


#ifndef CFE_OMIT_DEPRECATED_6_7
/*
** Function: CFE_FS_IsGzFile - See API and header file for details
*/
Expand Down Expand Up @@ -439,6 +439,7 @@ int32 CFE_FS_GetUncompressedFile(char *OutputNameBuffer, uint32 OutputNameBuffer

return Status;
}
#endif /* CFE_OMIT_DEPRECATED_6_7 */

/************************/
/* End of File Comment */
Expand Down
4 changes: 3 additions & 1 deletion fsw/cfe-core/src/fs/cfe_fs_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
*/
#include "cfe_fs_decompress.h"

#ifndef CFE_OMIT_DEPRECATED_6_7 /* Entire file will be removed in major release */

/*
** Global data -- Note: The following Global Data should be removed. The CFE_FS_Decompress API is not
** re-entrant! In order to make sure that two apps will not corrupt the data
Expand Down Expand Up @@ -1225,4 +1227,4 @@ uint32 FS_gz_updcrc( uint8 * s, uint32 n )

}


#endif /* CFE_OMIT_DEPRECATED_6_7 */
39 changes: 27 additions & 12 deletions fsw/cfe-core/src/inc/cfe_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,62 +674,71 @@
*/
#define CFE_FS_FNAME_TOO_LONG ((int32)0xc6000003)

#ifndef CFE_OMIT_DEPRECATED_6_7
/**
* @brief GZIP File Bad Data
* @brief DEPRECATED: GZIP File Bad Data
* @deprecated
*
* The GZIP file contains invalid data and cannot be read
*/
#define CFE_FS_GZIP_BAD_DATA ((int32)0xc6000004)

/**
* @brief GZIP File Bad Code Block
* @brief DEPRECATED: GZIP File Bad Code Block
* @deprecated
*
* The GZIP file codeblock is bad, which means the file is
* most likely corrupted
*/
#define CFE_FS_GZIP_BAD_CODE_BLOCK ((int32)0xc6000005)

/**
* @brief GZIP Memory Buffer Exhausted
* @brief DEPRECATED: GZIP Memory Buffer Exhausted
* @deprecated
*
* The memory buffer used by the decompression routine is
* exhausted.
*/
#define CFE_FS_GZIP_NO_MEMORY ((int32)0xc6000006)

/**
* @brief GZIP CRC Error
* @brief DEPRECATED: GZIP CRC Error
* @deprecated
*
* There is a CRC error in the GZIP file, which means the
* file is most likely corrupted.
*/
#define CFE_FS_GZIP_CRC_ERROR ((int32)0xc6000007)

/**
* @brief GZIP Length Error
* @brief DEPRECATED: GZIP Length Error
* @deprecated
*
* There is a length error in the GZIP internal data
* structures, which means the file is most likely corrupted.
*/
#define CFE_FS_GZIP_LENGTH_ERROR ((int32)0xc6000008)

/**
* @brief GZIP Write Error
* @brief DEPRECATED: GZIP Write Error
* @deprecated
*
* An error occurred trying to write the uncompressed
* file.
*/
#define CFE_FS_GZIP_WRITE_ERROR ((int32)0xc6000009)

/**
* @brief GZIP Read Error
* @brief DEPRECATED: GZIP Read Error
* @deprecated
*
* An error occurred trying to read the GZIP file
*/
#define CFE_FS_GZIP_READ_ERROR ((int32)0xc600000A)

/**
* @brief GZIP Open Output Error
* @brief DEPRECATED: GZIP Open Output Error
* @deprecated
*
* An error occurred trying to open the DestinationFile
* where the GZIP file will be uncompressed. The
Expand All @@ -739,7 +748,8 @@
#define CFE_FS_GZIP_OPEN_OUTPUT ((int32)0xc600000B)

/**
* @brief GZIP Open Input Error
* @brief DEPRECATED: GZIP Open Input Error
* @deprecated
*
* An error occurred trying to open the GZIP file
* to be decompressed. The function must be able to open
Expand All @@ -749,7 +759,8 @@
#define CFE_FS_GZIP_OPEN_INPUT ((int32)0xc600000C)

/**
* @brief GZIP Read Header Error
* @brief DEPRECATED: GZIP Read Header Error
* @deprecated
*
* An error occured trying to read the GZIP file header,
* which means the file is most likely corrupted or
Expand All @@ -758,20 +769,24 @@
#define CFE_FS_GZIP_READ_ERROR_HEADER ((int32)0xc600000D)

/**
* @brief GZIP Index Error
* @brief DEPRECATED: GZIP Index Error
* @deprecated
*
* An error occurred trying to read the GZIP index,
* which means the file is most likely corrupted.
*/
#define CFE_FS_GZIP_INDEX_ERROR ((int32)0xc600000E)

/**
* @brief GZIP Not Zip File
* @brief DEPRECATED: GZIP Not Zip File
* @deprecated
*
* The file to be decompressed is not a valid GZIP file
*/
#define CFE_FS_GZIP_NON_ZIP_FILE ((int32)0xc600000F)

#endif /* CFE_OMIT_DEPRECATED_6_7 */

/**
* @brief Not Implemented
*
Expand Down
Loading