summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVignesh Raman <Vignesh_Raman@mentor.com>2016-10-07 12:35:27 +0530
committerCosmin Cernat <cosmin.cernat@continental-corporation.com>2017-01-31 13:00:46 +0200
commit6e783a0cb90357decba0a7559bd0865d00197214 (patch)
treed56dd421820a0db0dfb560b9662b656cbeb84751
parentcca0130f31951b0959eabcd3569d28bb33760167 (diff)
downloadpersistence-administrator-6e783a0cb90357decba0a7559bd0865d00197214.tar.gz
PAS: Add error checking in recovery process
When PCL file API is used to write data to files, the files for different users are located in subfolders <appId>/user/<user_no>/seat/<seat_no>/. If the PCL file API is not called to write data to file, the folder <appId>/user/<user_no>/seat/<seat_no>/ will not exist and backup will not create the folder. In this case recovery will fail as there is no error checking to check if source folder exists during recovery phase. Similar error case is seen if /Data/mnt-c/<appId>/node folder is not created. This commit adds error checking in recovery and backup cases. Change-Id: I2f9a01a89c567cf70a178c8f6142f714244311b0 Signed-off-by: Vignesh Raman <Vignesh_Raman@mentor.com>
-rw-r--r--Administrator/src/ssw_pers_admin_backup.c35
-rw-r--r--Administrator/src/ssw_pers_admin_recovery.c307
2 files changed, 195 insertions, 147 deletions
diff --git a/Administrator/src/ssw_pers_admin_backup.c b/Administrator/src/ssw_pers_admin_backup.c
index aa14c51..cd68f06 100644
--- a/Administrator/src/ssw_pers_admin_backup.c
+++ b/Administrator/src/ssw_pers_admin_backup.c
@@ -174,26 +174,35 @@ static long persadmin_priv_data_backup_create_all(pstr_t backup_name)
/* append root path to backup name -> /backup_name/Data; */
(void)snprintf(pchBckupPathDst, (size_t)s32SizeBckup, "%s%s", backup_name, gRootPath);
- /* TODO: check if folder exists; */
- /* copy content of source (/Data) to destination (/backup); */
- sResult = persadmin_copy_folder(gRootPath, pchBckupPathDst, PersadminFilterAll, true);
- if( 0 > sResult )
+ /* check if folder exists; */
+ if( 0 == persadmin_check_if_file_exists(gRootPath, true) )
{
- bCanContinue = false;
- /* some info; */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR), DLT_STRING("persadmin_priv_data_backup_create_all -"), DLT_STRING("persadmin_copy_folder"),
- DLT_STRING(gRootPath), DLT_STRING("to"), DLT_STRING(pchBckupPathDst), DLT_STRING("ERR"), DLT_INT(sResult));
+ /* copy content of source (/Data) to destination (/backup); */
+ sResult = persadmin_copy_folder(gRootPath, pchBckupPathDst, PersadminFilterAll, true);
+ if( 0 > sResult )
+ {
+ bCanContinue = false;
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR), DLT_STRING("persadmin_priv_data_backup_create_all -"), DLT_STRING("persadmin_copy_folder"),
+ DLT_STRING(gRootPath), DLT_STRING("to"), DLT_STRING(pchBckupPathDst), DLT_STRING("ERR"), DLT_INT(sResult));
+ }
+ else
+ {
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_priv_data_backup_create_all -"), DLT_STRING("backed up"),
+ DLT_STRING(gRootPath), DLT_STRING("to"), DLT_STRING(pchBckupPathDst));
+ }
+
+ /* TODO: filter destination folder of files which do not correspond with the definition in BackupFileList.info; */
+ /* persadmin_priv_filter_folder(); */
}
else
{
/* some info; */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_priv_data_backup_create_all -"), DLT_STRING("backed up"),
- DLT_STRING(gRootPath), DLT_STRING("to"), DLT_STRING(pchBckupPathDst));
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_priv_data_backup_create_all -"),
+ DLT_STRING(gRootPath), DLT_STRING("does not exist"));
}
- /* TODO: filter destination folder of files which do not correspond with the definition in BackupFileList.info; */
- /* persadmin_priv_filter_folder(); */
-
/* return result; */
return sResult;
diff --git a/Administrator/src/ssw_pers_admin_recovery.c b/Administrator/src/ssw_pers_admin_recovery.c
index 3a74544..1458745 100644
--- a/Administrator/src/ssw_pers_admin_recovery.c
+++ b/Administrator/src/ssw_pers_admin_recovery.c
@@ -470,45 +470,54 @@ static long persadmin_restore_appl_node(pstr_t backupDataPath,
/* /Data/mnt-c/<appId>/node */
(void)snprintf(pNodeDestPath, sizeof(pNodeDestPath), gLocalCachePath, appId, gNode);
- /* erase node content */
- retVal = persadmin_delete_folder(pNodeDestPath);
- if(retVal < SUCCESS_CODE)
+ if( 0 == persadmin_check_if_file_exists(pNodeSourcePath, true) )
{
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_delete_folder call failed with error code:"),
- DLT_INT(retVal),
- DLT_STRING("for"),
- DLT_STRING(pNodeDestPath));
- }
+ /* erase node content */
+ retVal = persadmin_delete_folder(pNodeDestPath);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_delete_folder call failed with error code:"),
+ DLT_INT(retVal),
+ DLT_STRING("for"),
+ DLT_STRING(pNodeDestPath));
+ }
- /* copy node content */
- retVal = persadmin_copy_folder( pNodeSourcePath,
- pNodeDestPath,
- PersadminFilterAll,
- true);
+ /* copy node content */
+ retVal = persadmin_copy_folder( pNodeSourcePath,
+ pNodeDestPath,
+ PersadminFilterAll,
+ true);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_copy_folder call failed with error code:"),
- DLT_INT(retVal),
- DLT_STRING("for source:"),
- DLT_STRING(pNodeSourcePath),
- DLT_STRING("and destination:"),
- DLT_STRING(pNodeDestPath));
- return GENERIC_ERROR_CODE;
- }
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_copy_folder call failed with error code:"),
+ DLT_INT(retVal),
+ DLT_STRING("for source:"),
+ DLT_STRING(pNodeSourcePath),
+ DLT_STRING("and destination:"),
+ DLT_STRING(pNodeDestPath));
+ return GENERIC_ERROR_CODE;
+ }
- bytesRestored += retVal;
+ bytesRestored += retVal;
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully node content for:"),
- DLT_STRING(appId),
- DLT_STRING("from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored."));
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully node content for:"),
+ DLT_STRING(appId),
+ DLT_STRING("from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored."));
+ }
+ else
+ {
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_restore_appl_node -"),
+ DLT_STRING(pNodeSourcePath), DLT_STRING("does not exist"));
+ }
return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
@@ -562,48 +571,57 @@ static long persadmin_restore_appl_user( pstr_t backupDataPath,
user_no,
seat_no);
- /* erase user content */
- retVal = persadmin_delete_folder(pUserDestPath);
- if(retVal < SUCCESS_CODE)
+ if( 0 == persadmin_check_if_file_exists(pUserSourcePath, true) )
{
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_delete_folder call failed with error code:"),
- DLT_INT(retVal),
- DLT_STRING("for"),
- DLT_STRING(pUserDestPath));
- }
+ /* erase user content */
+ retVal = persadmin_delete_folder(pUserDestPath);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_delete_folder call failed with error code:"),
+ DLT_INT(retVal),
+ DLT_STRING("for"),
+ DLT_STRING(pUserDestPath));
+ }
- /* copy user content */
- retVal = persadmin_copy_folder( pUserSourcePath,
- pUserDestPath,
- PersadminFilterAll,
- true);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_copy_folder call failed with error code:"),
- DLT_INT(retVal),
- DLT_STRING("from"),
- DLT_STRING(pUserSourcePath),
- DLT_STRING("to"),
- DLT_STRING(pUserDestPath));
- return GENERIC_ERROR_CODE;
- }
+ /* copy user content */
+ retVal = persadmin_copy_folder( pUserSourcePath,
+ pUserDestPath,
+ PersadminFilterAll,
+ true);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_copy_folder call failed with error code:"),
+ DLT_INT(retVal),
+ DLT_STRING("from"),
+ DLT_STRING(pUserSourcePath),
+ DLT_STRING("to"),
+ DLT_STRING(pUserDestPath));
+ return GENERIC_ERROR_CODE;
+ }
- bytesRestored += retVal;
+ bytesRestored += retVal;
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully user content for App:"),
- DLT_STRING(appId),
- DLT_STRING("User:"),
- DLT_UINT8(user_no),
- DLT_STRING("Seat:"),
- DLT_UINT8(seat_no),
- DLT_STRING("from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored."));
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully user content for App:"),
+ DLT_STRING(appId),
+ DLT_STRING("User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("Seat:"),
+ DLT_UINT8(seat_no),
+ DLT_STRING("from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored."));
+ }
+ else
+ {
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_restore_appl_user -"),
+ DLT_STRING(pUserSourcePath), DLT_STRING("does not exist"));
+ }
return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
@@ -798,40 +816,49 @@ static long persadmin_restore_user_public_files(pstr_t backupDataP
user_no,
seat_no);
- /* erase user content */
- retVal = persadmin_delete_folder(pUserDestPath);
- if(retVal < SUCCESS_CODE)
+ if( 0 == persadmin_check_if_file_exists(pUserSourcePath, true) )
{
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_delete_folder call failed with error code:"),
- DLT_INT(retVal));
- }
+ /* erase user content */
+ retVal = persadmin_delete_folder(pUserDestPath);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_delete_folder call failed with error code:"),
+ DLT_INT(retVal));
+ }
- /* copy user content */
- retVal = persadmin_copy_folder( pUserSourcePath,
- pUserDestPath,
- PersadminFilterAll,
- true);
- if(retVal < 0)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_copy_folder call failed with error code:"),
- DLT_INT(retVal));
- return GENERIC_ERROR_CODE;
- }
+ /* copy user content */
+ retVal = persadmin_copy_folder( pUserSourcePath,
+ pUserDestPath,
+ PersadminFilterAll,
+ true);
+ if(retVal < 0)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_copy_folder call failed with error code:"),
+ DLT_INT(retVal));
+ return GENERIC_ERROR_CODE;
+ }
- bytesRestored += retVal;
+ bytesRestored += retVal;
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully user public files from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored"));
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully user public files from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored"));
+ }
+ else
+ {
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_restore_user_public_files -"),
+ DLT_STRING(pUserSourcePath), DLT_STRING("does not exist"));
+ }
return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
@@ -962,33 +989,42 @@ static long persadmin_restore_user_group_files( pstr_t backupDataP
user_no,
seat_no);
- /* erase user content */
- retVal = persadmin_delete_folder(pUserDestPath);
- if(retVal < SUCCESS_CODE)
+ if( 0 == persadmin_check_if_file_exists(pUserSourcePath, true) )
{
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_delete_folder call failed with error code:"),
- DLT_INT(retVal));
+ /* erase user content */
+ retVal = persadmin_delete_folder(pUserDestPath);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_delete_folder call failed with error code:"),
+ DLT_INT(retVal));
+ }
+
+ /* copy user content */
+ retVal = persadmin_copy_folder( pUserSourcePath,
+ pUserDestPath,
+ PersadminFilterAll,
+ true);
+
+ if(retVal < 0)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_copy_folder call failed with error code:"),
+ DLT_INT(retVal));
+ free(pStrList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pStrList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+ bytesRestored += retVal;
}
-
- /* copy user content */
- retVal = persadmin_copy_folder( pUserSourcePath,
- pUserDestPath,
- PersadminFilterAll,
- true);
-
- if(retVal < 0)
+ else
{
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_copy_folder call failed with error code:"),
- DLT_INT(retVal));
- free(pStrList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pStrList = NIL;
- return GENERIC_ERROR_CODE;
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_restore_user_group_files -"),
+ DLT_STRING(pUserSourcePath), DLT_STRING("does not exist"));
}
- bytesRestored += retVal;
-
listBuffSize -= ((sint_t)strlen(pItemName) + 1) * (sint_t)sizeof(*pItemName);
pItemName += (strlen(pItemName) + 1); // MISRA-C:2004 Rule 17.4 Performing pointer arithmetic. - Rule currently not accepted
}
@@ -997,16 +1033,19 @@ static long persadmin_restore_user_group_files( pstr_t backupDataP
pStrList = NIL;
}
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully user group files from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored"));
+ if( bytesRestored != 0)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully user group files from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored"));
+ }
return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/