.RI [^] feature [,...]
]
[
+.B \-T
+.I time-last-checked
+]
+[
.B \-U
.I UUID
]
on the filesystem after changing this feature in order to have a valid
filesystem.
.TP
+.BI \-T " time-last-checked"
+Set the time the filesystem was last checked using
+.BR e2fsck .
+This can be useful in scripts which use a Logical Volume Manager to make
+a consistent snapshot of a filesystem, and then check the filesystem
+during off hours to make sure it hasn't been corrupted due to
+hardware problems, etc. If the filesystem was clean, then this option can
+be used to set the last checked time on the original filesystem. The format
+of
+.I time-last-checked
+is the international date format, with an optional time specifier, i.e.
+YYYYMMDD[[HHMM]SS]. The keyword
+.B now
+is also accepted, in which case the last checked time will be set to the
+current time.
+.TP
.BI \-u " user"
Set the user who can use the reserved filesystem blocks.
.I user
char * device_name;
char * new_label, *new_last_mounted, *new_UUID;
static int c_flag, C_flag, e_flag, f_flag, g_flag, i_flag, l_flag, L_flag;
-static int m_flag, M_flag, r_flag, s_flag = -1, u_flag, U_flag;
+static int m_flag, M_flag, r_flag, s_flag = -1, u_flag, U_flag, T_flag;
+static time_t last_check_time;
static int print_label;
static int max_mount_count, mount_count, mount_flags;
static unsigned long interval, reserved_ratio, reserved_blocks;
"\t[-i interval[d|m|w]] [-j] [-J journal-options]\n"
"\t[-l] [-s sparse-flag] [-m reserved-blocks-percent]\n"
"\t[-r reserved-blocks-count] [-u user] [-C mount-count]\n"
- "\t[-L volume-label] [-M last-mounted-dir] [-U UUID]\n"
- "\t[-O [^]feature[,...]] device\n"), program_name);
+ "\t[-L volume-label] [-M last-mounted-dir]\n"
+ "\t[-O [^]feature[,...]] [-T last-check-time] [-U UUID]"
+ " device\n"), program_name);
exit (1);
}
print_label++;
}
+static time_t parse_time(char *str)
+{
+ struct tm ts;
+
+ if (strcmp(str, "now") == 0) {
+ return (time(0));
+ }
+ memset(&ts, 0, sizeof(ts));
+ strptime(optarg, "%Y%m%d%H%M%S", &ts);
+ if (ts.tm_mday == 0) {
+ com_err(program_name, 0,
+ _("Couldn't parse date/time specifier: %s"),
+ str);
+ usage();
+ }
+ return (mktime(&ts));
+}
static void parse_tune2fs_options(int argc, char **argv)
{
struct passwd * pw;
printf("tune2fs %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE);
- while ((c = getopt (argc, argv, "c:e:fg:i:jlm:r:s:u:C:J:L:M:O:U:")) != EOF)
+ while ((c = getopt(argc, argv, "c:e:fg:i:jlm:r:s:u:C:J:L:M:O:T:U:")) != EOF)
switch (c)
{
case 'c':
s_flag = atoi(optarg);
open_flag = EXT2_FLAG_RW;
break;
+ case 'T':
+ T_flag = 1;
+ last_check_time = parse_time(optarg);
+ open_flag = EXT2_FLAG_RW;
+ break;
case 'u':
resuid = strtoul (optarg, &tmp, 0);
if (*tmp) {
_(please_fsck));
}
}
+ if (T_flag) {
+ sb->s_lastcheck = last_check_time;
+ ext2fs_mark_super_dirty(fs);
+ printf(_("Setting time filesystem last checked to %s\n"),
+ ctime(&last_check_time));
+ }
if (u_flag) {
sb->s_def_resuid = resuid;
ext2fs_mark_super_dirty(fs);