From 31ce5db1420870422cc642fcb81aaebc67ee2edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Tue, 21 Dec 2010 15:51:07 +0100 Subject: [PATCH] Added option for not clearing the timestamps in ntfsclone --- ntfsprogs/ntfsclone.8.in | 5 +++++ ntfsprogs/ntfsclone.c | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ntfsprogs/ntfsclone.8.in b/ntfsprogs/ntfsclone.8.in index 6c60d532..ad33816e 100644 --- a/ntfsprogs/ntfsclone.8.in +++ b/ntfsprogs/ntfsclone.8.in @@ -226,6 +226,11 @@ to be used only with the option, for the safety of user's data. The clusters which cause the inconsistency are saved too. .TP +\fB\-t\fR, \fB\-\-preserve\-timestamps\fR +Do not wipe the timestamps, to be used only with the +.B \-\-metadata +option. +.TP \fB\-f\fR, \fB\-\-force\fR Forces ntfsclone to proceed if the filesystem is marked "dirty" for consistency check. diff --git a/ntfsprogs/ntfsclone.c b/ntfsprogs/ntfsclone.c index 50f146d6..68a038f3 100644 --- a/ntfsprogs/ntfsclone.c +++ b/ntfsprogs/ntfsclone.c @@ -114,6 +114,7 @@ static struct { int ignore_fs_check; int rescue; int save_image; + int preserve_timestamps; int restore_image; char *output; char *volume; @@ -295,6 +296,7 @@ static void usage(void) " --rescue Continue after disk read errors\n" " -m, --metadata Clone *only* metadata (for NTFS experts)\n" " --ignore-fs-check Ignore the filesystem check result\n" + " -t, --preserve-timestamps Do not clear the timestamps\n" " -f, --force Force to progress (DANGEROUS)\n" " -h, --help Display this help\n" #ifdef DEBUG @@ -311,7 +313,7 @@ static void usage(void) static void parse_options(int argc, char **argv) { - static const char *sopt = "-dfhmo:O:rs"; + static const char *sopt = "-dfhmo:O:rst"; static const struct option lopt[] = { #ifdef DEBUG { "debug", no_argument, NULL, 'd' }, @@ -325,6 +327,7 @@ static void parse_options(int argc, char **argv) { "ignore-fs-check", no_argument, NULL, 'C' }, { "rescue", no_argument, NULL, 'R' }, { "save-image", no_argument, NULL, 's' }, + { "preserve-timestamps", no_argument, NULL, 't' }, { NULL, 0, NULL, 0 } }; @@ -370,6 +373,9 @@ static void parse_options(int argc, char **argv) case 's': opt.save_image++; break; + case 't': + opt.preserve_timestamps++; + break; default: err_printf("Unknown option '%s'.\n", argv[optind-1]); usage(); @@ -1020,12 +1026,15 @@ static void walk_runs(struct ntfs_walk_cluster *walk) if (!a->non_resident) { if (wipe) { wipe_resident_data(walk->image); - wipe_timestamps(walk->image); + if (!opt.preserve_timestamps) + wipe_timestamps(walk->image); } return; } - if (wipe && walk->image->ctx->attr->type == AT_INDEX_ALLOCATION) + if (wipe + && !opt.preserve_timestamps + && walk->image->ctx->attr->type == AT_INDEX_ALLOCATION) wipe_index_allocation_timestamps(walk->image->ni, a); if (!(rl = ntfs_mapping_pairs_decompress(vol, a, NULL)))