#include "ext2fs/ext2fsP.h"
#include "uuid/uuid.h"
#include "util.h"
-#include "plausible.h"
-#include "profile.h"
-#include "prof_err.h"
+#include "support/nls-enable.h"
+#include "support/plausible.h"
+#include "support/profile.h"
+#include "support/prof_err.h"
#include "../version.h"
-#include "quota/quotaio.h"
+#include "support/quotaio.h"
#include "mke2fs.h"
#include "create_inode.h"
-#include "nls-enable.h"
#define STRIDE_LENGTH 8
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 char *undo_file;
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]"
- "[-jnqvDFKSV] device [blocks-count]\n"),
+ "[-z undo_file]\n"
+ "\t[-jnqvDFKSV] device [blocks-count]\n"),
program_name);
exit(1);
}
ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_ZEROED);
ext2fs_group_desc_csum_set(fs, i);
}
- retval = ext2fs_zero_blocks2(fs, blk, num, &blk, &num);
- if (retval) {
- fprintf(stderr, _("\nCould not write %d "
- "blocks in inode table starting at %llu: %s\n"),
- num, blk, error_message(retval));
- exit(1);
+ if (!itable_zeroed) {
+ retval = ext2fs_zero_blocks2(fs, blk, num, &blk, &num);
+ if (retval) {
+ fprintf(stderr, _("\nCould not write %d "
+ "blocks in inode table starting at %llu: %s\n"),
+ num, blk, error_message(retval));
+ exit(1);
+ }
}
if (sync_kludge) {
if (sync_kludge == 1)
EXT4_FEATURE_INCOMPAT_FLEX_BG|
EXT4_FEATURE_INCOMPAT_MMP |
EXT4_FEATURE_INCOMPAT_64BIT|
- EXT4_FEATURE_INCOMPAT_INLINE_DATA,
+ EXT4_FEATURE_INCOMPAT_INLINE_DATA|
+ EXT4_FEATURE_INCOMPAT_ENCRYPT,
/* R/O compat */
EXT2_FEATURE_RO_COMPAT_LARGE_FILE|
EXT4_FEATURE_RO_COMPAT_HUGE_FILE|
EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|
EXT4_FEATURE_RO_COMPAT_GDT_CSUM|
EXT4_FEATURE_RO_COMPAT_BIGALLOC|
-#ifdef CONFIG_QUOTA
EXT4_FEATURE_RO_COMPAT_QUOTA|
-#endif
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM
};
}
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);
/* Print version number and exit */
show_version_only++;
break;
+ case 'z':
+ undo_file = optarg;
+ break;
default:
usage();
}
char *dev_name, *tmp_name;
int free_tdb_dir = 0;
+ /* (re)open a specific undo file */
+ if (undo_file && undo_file[0] != 0) {
+ retval = set_undo_io_backing_manager(*io_ptr);
+ if (retval)
+ goto err;
+ *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 retval;
+ }
+
/*
* Configuration via a conf file would be
* nice
if ((unlink(tdb_file) < 0) && (errno != ENOENT)) {
retval = errno;
+ com_err(program_name, retval,
+ _("while trying to delete %s"), tdb_file);
goto errout;
}
- set_undo_io_backing_manager(*io_ptr);
+ retval = set_undo_io_backing_manager(*io_ptr);
+ if (retval)
+ goto errout;
*io_ptr = undo_io_manager;
retval = set_undo_io_backup_file(tdb_file);
if (retval)
if (free_tdb_dir)
free(tdb_dir);
free(tdb_file);
+err:
com_err(program_name, retval, "%s",
_("while trying to setup undo file\n"));
return retval;
#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);
sizeof(fs->super->s_last_mounted));
}
+ /* Set current default encryption algorithms for data and
+ * filename encryption */
+ if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_ENCRYPT) {
+ fs->super->s_encrypt_algos[0] =
+ EXT4_ENCRYPTION_MODE_AES_256_XTS;
+ fs->super->s_encrypt_algos[1] =
+ EXT4_ENCRYPTION_MODE_AES_256_CTS;
+ }
+
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
fs->super->s_checksum_type = EXT2_CRC32C_CHKSUM;
}
if (super_only) {
+ check_plausibility(device_name, CHECK_FS_EXIST, NULL);
+ printf(_("%s may be further corrupted by superblock rewrite\n"),
+ device_name);
+ if (!force)
+ proceed_question(proceed_delay);
fs->super->s_state |= EXT2_ERROR_FS;
fs->flags &= ~(EXT2_FLAG_IB_DIRTY|EXT2_FLAG_BB_DIRTY);
- /*
+ /*
* The command "mke2fs -S" is used to recover
* corrupted file systems, so do not mark any of the
* inodes as unused; we want e2fsck to consider all
EXT2_ROOT_INO);
if (retval) {
com_err(program_name, retval, "%s",
- _("\nError while populating file system\n"));
+ _("while populating file system"));
exit(1);
} else if (!quiet)
printf("%s", _("done\n"));