Provide the user with an option to create an undo file so that they
can roll back a failed tuning operation. Previously, one would be
created if force_undo was set in the configuration file and a bunch of
(undocumented) conditions were met.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
.B \-e
.I errors-behavior
]
.B \-e
.I errors-behavior
]
+[
+.B \-z
+.I undo_file
+]
Print the version number of
.B mke2fs
and exit.
Print the version number of
.B mke2fs
and exit.
+.TP
+.BI \-z " undo_file"
+Before overwriting a file system block, write the old contents of the block to
+an undo file. This undo file can be used with e2undo(8) to restore the old
+contents of the file system should something go wrong. If the empty string is
+passed as the undo_file argument, the undo file will be written to a file named
+mke2fs-\fIdevice\fR.e2undo in the directory specified via the
+\fIE2FSPROGS_UNDO_DIR\fR environment variable or the \fIundo_dir\fR directive
+in the configuration file.
+
+WARNING: The undo file cannot be used to recover from a power or system crash.
.SH ENVIRONMENT
.TP
.BI MKE2FS_SYNC
.SH ENVIRONMENT
.TP
.BI MKE2FS_SYNC
static int sync_kludge; /* Set using the MKE2FS_SYNC env. option */
char **fs_types;
const char *root_dir; /* Copy files from the specified directory */
static int sync_kludge; /* Set using the MKE2FS_SYNC env. option */
char **fs_types;
const char *root_dir; /* Copy files from the specified directory */
static profile_t profile;
static profile_t profile;
"[-M last-mounted-directory]\n\t[-O feature[,...]] "
"[-r fs-revision] [-E extended-option[,...]]\n"
"\t[-t fs-type] [-T usage-type ] [-U UUID] [-e errors_behavior]"
"[-M last-mounted-directory]\n\t[-O feature[,...]] "
"[-r fs-revision] [-E extended-option[,...]]\n"
"\t[-t fs-type] [-T usage-type ] [-U UUID] [-e errors_behavior]"
- "[-jnqvDFKSV] device [blocks-count]\n"),
+ "[-z undo_file]\n"
+ "\t[-jnqvDFKSV] device [blocks-count]\n"),
program_name);
exit(1);
}
program_name);
exit(1);
}
}
while ((c = getopt (argc, argv,
}
while ((c = getopt (argc, argv,
- "b:ce:g:i:jl:m:no:qr:s:t:d:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:V")) != EOF) {
+ "b:ce:g:i:jl:m:no:qr:s:t:d:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:Vz:")) != EOF) {
switch (c) {
case 'b':
blocksize = parse_num_blocks2(optarg, -1);
switch (c) {
case 'b':
blocksize = parse_num_blocks2(optarg, -1);
/* Print version number and exit */
show_version_only++;
break;
/* Print version number and exit */
show_version_only++;
break;
+ case 'z':
+ undo_file = optarg;
+ break;
char *dev_name, *tmp_name;
int free_tdb_dir = 0;
char *dev_name, *tmp_name;
int free_tdb_dir = 0;
+ /* (re)open a specific undo file */
+ if (undo_file && undo_file[0] != 0) {
+ set_undo_io_backing_manager(*io_ptr);
+ *io_ptr = undo_io_manager;
+ retval = set_undo_io_backup_file(undo_file);
+ if (retval)
+ goto err;
+ printf(_("Overwriting existing filesystem; this can be undone "
+ "using the command:\n"
+ " e2undo %s %s\n\n"), undo_file, name);
+ return 0;
+ }
+
/*
* Configuration via a conf file would be
* nice
/*
* Configuration via a conf file would be
* nice
if (free_tdb_dir)
free(tdb_dir);
free(tdb_file);
if (free_tdb_dir)
free(tdb_dir);
free(tdb_file);
com_err(program_name, retval, "%s",
_("while trying to setup undo file\n"));
return retval;
com_err(program_name, retval, "%s",
_("while trying to setup undo file\n"));
return retval;
#endif
io_ptr = unix_io_manager;
#endif
io_ptr = unix_io_manager;
- if (should_do_undo(device_name)) {
+ if (undo_file != NULL || should_do_undo(device_name)) {
retval = mke2fs_setup_tdb(device_name, &io_ptr);
if (retval)
exit(1);
retval = mke2fs_setup_tdb(device_name, &io_ptr);
if (retval)
exit(1);