diff --git a/ChangeLog b/ChangeLog index 93575b4c..e6fe77f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -144,8 +144,10 @@ xx/xx/2005 - 2.0.0-WIP permissions that got lost during the move. (Anton) - ntfsresize: fix segfault during filesystem check if NTFS $Bitmap file size was larger than it should have been. (Szaka) - - mkntfs: don't mark NTFS dirty if the backup boot sector could be - successfully created (Szaka) + - mkntfs: Don't mark NTFS dirty if the backup boot sector could be + successfully created. (Szaka) + - mkntfs: Add new option -T which fakes the time to be 00:00:00 UTC, + Jan 1, 1970 instead of the current system time. 04/09/2004 - 1.9.4 - Urgent bug fixes. diff --git a/ntfsprogs/mkntfs.8.in b/ntfsprogs/mkntfs.8.in index e1e84dec..dad6c3f9 100644 --- a/ntfsprogs/mkntfs.8.in +++ b/ntfsprogs/mkntfs.8.in @@ -3,7 +3,7 @@ .\" This file may be copied under the terms of the GNU Public License. .\" Adapted from e2fsprogs-1.19/misc/mke2fs.8.in by Theodore Ts'o. .\" -.TH MKNTFS 8 "March 2002" "ntfsprogs version @VERSION@" +.TH MKNTFS 8 "June 2005" "ntfsprogs version @VERSION@" .SH NAME mkntfs \- create a NTFS 1.2 (Windows NT/2000/XP) file system .SH SYNOPSIS @@ -60,6 +60,9 @@ mkntfs \- create a NTFS 1.2 (Windows NT/2000/XP) file system .B \-F ] [ +.B \-T +] +[ .B \-I ] [ @@ -213,6 +216,10 @@ to run, even if the specified .I device is not a block special device, or appears to be mounted. .TP +.B \-T +Fake the time to be 00:00:00 UTC, Jan 1, 1970 instead of the current system +time. This is only really useful for debugging purposes. +.TP .B \-I Disable content indexing on the volume. (This is only meaningful on Windows 2000 and later. Windows NT 4.0 and earlier ignore this as they do diff --git a/ntfsprogs/mkntfs.c b/ntfsprogs/mkntfs.c index 077d0f45..58203b9b 100644 --- a/ntfsprogs/mkntfs.c +++ b/ntfsprogs/mkntfs.c @@ -207,6 +207,8 @@ struct { char disable_indexing; /* -I, disables indexing of file contents on the volume by default. */ /* -V, print version and exit. */ + char use_epoch_time; /* -T, fake the time to be + 00:00:00 UTC, Jan 1, 1970. */ } opts; /** @@ -315,6 +317,8 @@ static void usage(void) " -n Do not write to disk\n" " -F Force execution despite " "errors\n" + " -T Fake the time to be " + "00:00:00 UTC, Jan 1, 1970\n" " -q Quiet execution\n" " -v Verbose execution\n" " -vv Very verbose execution\n" @@ -343,7 +347,7 @@ static void parse_options(int argc, char *argv[]) if (argc && *argv) EXEC_NAME = *argv; fprintf(stderr, "%s v%s\n", EXEC_NAME, VERSION); - while ((c = getopt(argc, argv, "c:fh?np:qs:vz:CFIL:QVl")) != EOF) + while ((c = getopt(argc, argv, "c:fh?np:qs:vz:CFTIL:QVl")) != EOF) switch (c) { case 'n': opts.no_action = 1; @@ -401,6 +405,9 @@ static void parse_options(int argc, char *argv[]) case 'F': opts.force = 1; break; + case 'T': + opts.use_epoch_time = 1; + break; case 'I': opts.disable_indexing = 1; break; @@ -433,6 +440,16 @@ static void parse_options(int argc, char *argv[]) usage(); } +/** + * mkntfs_time + */ +static time_t mkntfs_time(void) +{ + if (!opts.use_epoch_time) + return time(NULL); + return 0; +} + /** * append_to_bad_blocks * @@ -1652,7 +1669,7 @@ static int add_attr_std_info(MFT_RECORD *m, const FILE_ATTR_FLAGS flags) STANDARD_INFORMATION si; int err; - si.creation_time = utc2ntfs(time(NULL)); + si.creation_time = utc2ntfs(mkntfs_time()); si.last_data_change_time = si.creation_time; si.last_mft_change_time = si.creation_time; si.last_access_time = si.creation_time; @@ -2426,7 +2443,7 @@ static int create_hardlink(INDEX_BLOCK *idx, const MFT_REF ref_parent, fn->parent_directory = ref_parent; // FIXME: Is this correct? Or do we have to copy the creation_time // from the std info? - fn->creation_time = utc2ntfs(time(NULL)); + fn->creation_time = utc2ntfs(mkntfs_time()); fn->last_data_change_time = fn->creation_time; fn->last_mft_change_time = fn->creation_time; fn->last_access_time = fn->creation_time; @@ -3672,7 +3689,7 @@ int main(int argc, char **argv) /* Setup the correct locale for string output and conversion. */ utils_set_locale(); /* Initialize the random number generator with the current time. */ - srandom(time(NULL)); + srandom(mkntfs_time()); /* Allocate and initialize ntfs_volume structure vol. */ vol = ntfs_volume_alloc(); if (!vol)