diff options
author | Amith Yamasani <yamasani@google.com> | 2012-06-18 16:51:41 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-06-18 16:51:41 -0700 |
commit | 39758edbed0be8f3d75427f750db6e9d005cd16a (patch) | |
tree | 3a475ef1a8294bf6492d7e4d904149fe0bcd4720 /cmds | |
parent | 56b3a321e7c6f03d1bc0c5c0915d56bc46b7a33e (diff) | |
parent | 386ce58a21b81390d2831b0f1107d03773af687a (diff) | |
download | frameworks_base-39758edbed0be8f3d75427f750db6e9d005cd16a.zip frameworks_base-39758edbed0be8f3d75427f750db6e9d005cd16a.tar.gz frameworks_base-39758edbed0be8f3d75427f750db6e9d005cd16a.tar.bz2 |
am 386ce58a: Merge "Don\'t backup or delete the backup file, if it\'s in the backup path." into jb-dev
* commit '386ce58a21b81390d2831b0f1107d03773af687a':
Don't backup or delete the backup file, if it's in the backup path.
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/rawbu/backup.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/cmds/rawbu/backup.cpp b/cmds/rawbu/backup.cpp index 9ea046d..70e7b57 100644 --- a/cmds/rawbu/backup.cpp +++ b/cmds/rawbu/backup.cpp @@ -38,6 +38,7 @@ static char nameBuffer[PATH_MAX]; static struct stat statBuffer; static char copyBuffer[8192]; +static char *backupFilePath = NULL; static uint32_t inputFileVersion; @@ -152,6 +153,10 @@ static int wipe (const char *path) strcat(nameBuffer, "/"); } else { + // Don't delete the backup file + if (backupFilePath && strcmp(backupFilePath, nameBuffer) == 0) { + continue; + } ret = unlink(nameBuffer); if (ret != 0) { @@ -279,7 +284,7 @@ static int backup_dir(FILE* fh, const char* srcPath) continue; } - if (fullPath == NULL) { + if (fullPath != NULL) { free(fullPath); } fullPath = (char*)malloc(srcLen + strlen(de->d_name) + 2); @@ -320,8 +325,13 @@ static int backup_dir(FILE* fh, const char* srcPath) goto done; } } else if (S_ISREG(statBuffer.st_mode)) { - printf("Saving file %s...\n", fullPath); - + // Skip the backup file + if (backupFilePath && strcmp(fullPath, backupFilePath) == 0) { + printf("Skipping backup file %s...\n", backupFilePath); + continue; + } else { + printf("Saving file %s...\n", fullPath); + } if (write_header(fh, TYPE_FILE, fullPath, &statBuffer) == 0) { result = 0; goto done; @@ -373,6 +383,9 @@ static int backup_data(const char* destPath) printf("Backing up /data to %s...\n", destPath); + // The path that shouldn't be backed up + backupFilePath = strdup(destPath); + if (!write_int32(fh, FILE_VERSION)) goto done; if (!write_int32(fh, opt_backupAll)) goto done; if (!backup_dir(fh, "/data")) goto done; @@ -509,6 +522,9 @@ static int restore_data(const char* srcPath) } else { opt_backupAll = 0; } + + // The path that shouldn't be deleted + backupFilePath = strdup(srcPath); printf("Wiping contents of /data...\n"); if (!wipe("/data")) { |