diff options
author | Vignesh Raman <Vignesh_Raman@mentor.com> | 2016-10-07 12:29:47 +0530 |
---|---|---|
committer | Cosmin Cernat <cosmin.cernat@continental-corporation.com> | 2017-01-26 15:41:45 +0200 |
commit | 624d40261a94313356259155959ea07ecaf51d5a (patch) | |
tree | 0c7652116e2a8255a1ac8a378705a4a418b7210f | |
parent | 47e5a424c8ef6e33565737f20d3bd81f69c8efc9 (diff) | |
download | persistence-administrator-624d40261a94313356259155959ea07ecaf51d5a.tar.gz |
PAS: Add support to handle symbolic links when creating backup
Change-Id: I165d00e86e204d033e7e94d98e614fce5b375ad4
Signed-off-by: Vignesh Raman <Vignesh_Raman@mentor.com>
-rw-r--r-- | Administrator/src/ssw_pers_admin_files_helper.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Administrator/src/ssw_pers_admin_files_helper.c b/Administrator/src/ssw_pers_admin_files_helper.c index 83e95db..e4a50dd 100644 --- a/Administrator/src/ssw_pers_admin_files_helper.c +++ b/Administrator/src/ssw_pers_admin_files_helper.c @@ -579,6 +579,47 @@ static sint_t persadmin_copy_subfolders(pstr_t absPathSource, sint_t posInSource } } } + else if(S_ISLNK(sb.st_mode)) + { + char symlinkName[PERSADMIN_MAX_PATH_LENGHT]; + ssize_t numBytes; + + numBytes = readlink(absPathSource, symlinkName, PERSADMIN_MAX_PATH_LENGHT-1); + if(numBytes == -1) + { + bEverythingOK = false ; + (void)snprintf(g_msg, sizeof(g_msg), "persadmin_copy_subfolders: readlink error: errno=<%s>", strerror(errno)) ; + DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING(g_msg)); + break ; + } + + symlinkName[numBytes] = '\0'; + + (void)snprintf(g_msg, sizeof(g_msg), "persadmin_copy_subfolders: SymlinkName = %s, absPathDestination = %s)", absPathSource, absPathDestination) ; + DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING(g_msg)); + + if(0 <= persadmin_check_if_file_exists(absPathDestination, false)) + { + if(-1 == unlink(absPathDestination)) + { + bEverythingOK = false ; + (void)snprintf(g_msg, sizeof(g_msg), "persadmin_copy_subfolders: unlink(%s) failed", absPathSource, absPathDestination) ; + DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING(g_msg)); + break ; + } + } + + if(bEverythingOK) + { + if(symlink(symlinkName, absPathDestination) == -1) + { + bEverythingOK = false ; + (void)snprintf(g_msg, sizeof(g_msg), "persadmin_copy_subfolders: creating symlink failed: errno=<%s>", strerror(errno)) ; + DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING(g_msg)); + break ; + } + } + } else { if(bFilterPassed) |