errcode_t ext2fs_run_ext3_journal(ext2_filsys *fs);
+static const char *fsck_explain = N_("\nThis operation requires a freshly checked filesystem.\n");
+
static const char *please_fsck = N_("Please run e2fsck -f on the filesystem.\n");
static const char *please_dir_fsck =
N_("Please run e2fsck -fD on the filesystem.\n");
"[-g group]\n"
"\t[-i interval[d|m|w]] [-j] [-J journal_options] [-l]\n"
"\t[-m reserved_blocks_percent] [-o [^]mount_options[,...]]\n"
- "\t[-p mmp_update_interval] [-r reserved_blocks_count] "
- "[-u user]\n"
- "\t[-C mount_count] [-L volume_label] [-M last_mounted_dir]\n"
+ "\t[-r reserved_blocks_count] [-u user] [-C mount_count]\n"
+ "\t[-L volume_label] [-M last_mounted_dir]\n"
"\t[-O [^]feature[,...]] [-Q quota_options]\n"
"\t[-E extended-option[,...]] [-T last_check_time] "
"[-U UUID]\n\t[-I new_inode_size] [-z undo_file] device\n"),
EXT4_FEATURE_RO_COMPAT_QUOTA |
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM |
EXT4_FEATURE_RO_COMPAT_READONLY |
- EXT4_FEATURE_RO_COMPAT_PROJECT
+ EXT4_FEATURE_RO_COMPAT_PROJECT |
+ EXT4_FEATURE_RO_COMPAT_VERITY
};
static __u32 clear_ok_features[3] = {
if (!(fs->super->s_state & EXT2_VALID_FS) ||
(fs->super->s_state & EXT2_ERROR_FS) ||
(fs->super->s_lastcheck < fs->super->s_mtime)) {
- printf("\n%s\n", _(please_fsck));
+ puts(_(fsck_explain));
+ puts(_(please_fsck));
if (mount_flags & EXT2_MF_READONLY)
printf("%s", _("(and reboot afterwards!)\n"));
exit(1);
return;
fsck_requested++;
fs->super->s_state &= ~EXT2_VALID_FS;
- printf("\n%s\n", _(please_dir_fsck));
+ puts(_(fsck_explain));
+ puts(_(please_dir_fsck));
if (mount_flags & EXT2_MF_READONLY)
printf("%s", _("(and reboot afterwards!)\n"));
}
static void convert_64bit(ext2_filsys fs, int direction)
{
- if (!direction)
- return;
-
/*
* Is resize2fs going to demand a fsck run? Might as well tell the
* user now.
if (retval)
fatal_err(retval, "close ea_inode");
- hash = ext2fs_crc32c_le(ctx->fs->csum_seed, ctx->ea_buf, inode->i_size);
+ hash = ext2fs_crc32c_le(ctx->fs->csum_seed,
+ (unsigned char *) ctx->ea_buf, inode->i_size);
ext2fs_set_ea_inode_hash(inode, hash);
}
}
static void update_block_xattr_hashes(struct rewrite_context *ctx,
- void *block_buf)
+ char *block_buf)
{
struct ext2_ext_attr_header *header;
struct ext2_ext_attr_entry *start, *end;
if (!ino)
break;
- if (pass == 1 && (inode->i_flags & EXT4_EA_INODE_FL) ||
- pass == 2 && !(inode->i_flags & EXT4_EA_INODE_FL))
+ if (((pass == 1) &&
+ (inode->i_flags & EXT4_EA_INODE_FL)) ||
+ ((pass == 2) &&
+ !(inode->i_flags & EXT4_EA_INODE_FL)))
rewrite_one_inode(&ctx, ino, inode);
} while (ino);
if (FEATURE_ON(E2P_FEATURE_RO_INCOMPAT,
EXT4_FEATURE_RO_COMPAT_PROJECT)) {
+ if (fs->super->s_inode_size == EXT2_GOOD_OLD_INODE_SIZE) {
+ fprintf(stderr, _("Cannot enable project feature; "
+ "inode size too small.\n"));
+ exit(1);
+ }
Q_flag = 1;
quota_enable[PRJQUOTA] = QOPT_ENABLE;
}
uuid_seed = ext2fs_crc32c_le(~0, fs->super->s_uuid,
sizeof(fs->super->s_uuid));
- if (fs->super->s_checksum_seed != uuid_seed &&
- (mount_flags & EXT2_MF_MOUNTED)) {
- fputs(_("UUID has changed since enabling "
- "metadata_csum. Filesystem must be unmounted "
- "\nto safely rewrite all metadata to "
- "match the new UUID.\n"), stderr);
- return 1;
+ if (fs->super->s_checksum_seed != uuid_seed) {
+ if (mount_flags & (EXT2_MF_BUSY|EXT2_MF_MOUNTED)) {
+ fputs(_("UUID has changed since enabling "
+ "metadata_csum. Filesystem must be unmounted "
+ "\nto safely rewrite all metadata to match the new UUID.\n"),
+ stderr);
+ return 1;
+ }
+ check_fsck_needed(fs, _("Recalculating checksums "
+ "could take some time."));
+ rewrite_checksums = 1;
}
-
- rewrite_checksums = 1;
}
if (sb->s_rev_level == EXT2_GOOD_OLD_REV &&
/* Nothing to do. */
return;
+ if (quota_enable[PRJQUOTA] == QOPT_ENABLE &&
+ fs->super->s_inode_size == EXT2_GOOD_OLD_INODE_SIZE) {
+ fprintf(stderr, _("Cannot enable project quota; "
+ "inode size too small.\n"));
+ exit(1);
+ }
+
for (qtype = 0; qtype < MAXQUOTAS; qtype++) {
if (quota_enable[qtype] == QOPT_ENABLE)
qtype_bits |= 1 << qtype;
intv);
fs->super->s_mmp_update_interval = intv;
ext2fs_mark_super_dirty(fs);
+ } else if (!strcmp(token, "force_fsck")) {
+ fs->super->s_state |= EXT2_ERROR_FS;
+ printf(_("Setting filesystem error flag to force fsck.\n"));
+ ext2fs_mark_super_dirty(fs);
} else if (!strcmp(token, "test_fs")) {
fs->super->s_flags |= EXT2_FLAGS_TEST_FILESYS;
printf("Setting test filesystem flag\n");
"\tclear_mmp\n"
"\thash_alg=<hash algorithm>\n"
"\tmount_opts=<extended default mount options>\n"
+ "\tmmp_update_interval=<mmp update interval in seconds>\n"
"\tstride=<RAID per-disk chunk size in blocks>\n"
"\tstripe_width=<RAID stride*data disks in blocks>\n"
+ "\tforce_fsck\n"
"\ttest_fs\n"
"\t^test_fs\n"));
free(buf);
rc = 1;
goto closefs;
}
+
+#ifdef NO_RECOVERY
+ /* Warn if file system needs recovery and it is opened for writing. */
+ if ((open_flag & EXT2_FLAG_RW) && !(mount_flags & EXT2_MF_MOUNTED) &&
+ (sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
+ (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER)) {
+ fprintf(stderr,
+_("Warning: The journal is dirty. You may wish to replay the journal like:\n\n"
+ "\te2fsck -E journal_only %s\n\n"
+ "then rerun this command. Otherwise, any changes made may be overwritten\n"
+ "by journal recovery.\n"), device_name);
+ }
+#else
+ /* Recover the journal if possible. */
+ if ((open_flag & EXT2_FLAG_RW) && !(mount_flags & (EXT2_MF_BUSY | EXT2_MF_MOUNTED)) &&
+ ext2fs_has_feature_journal_needs_recovery(fs->super)) {
+ errcode_t err;
+
+ printf(_("Recovering journal.\n"));
+ err = ext2fs_run_ext3_journal(&fs);
+ if (err) {
+ com_err("tune2fs", err, "while recovering journal.\n");
+ printf(_("Please run e2fsck -fy %s.\n"), argv[1]);
+ if (fs)
+ ext2fs_close_free(&fs);
+ exit(1);
+ }
+ }
+#endif
+
/* Normally we only need to write out the superblock */
fs->flags |= EXT2_FLAG_SUPER_ONLY;
free(ext_mount_opts);
}
-#ifdef NO_RECOVERY
- /* Warn if file system needs recovery and it is opened for writing. */
- if ((open_flag & EXT2_FLAG_RW) && !(mount_flags & EXT2_MF_MOUNTED) &&
- (sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
- (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER)) {
- fprintf(stderr,
-_("Warning: The journal is dirty. You may wish to replay the journal like:\n\n"
- "\te2fsck -E journal_only %s\n\n"
- "then rerun this command. Otherwise, any changes made may be overwritten\n"
- "by journal recovery.\n"), device_name);
- }
-#else
- /* Recover the journal if possible. */
- if ((open_flag & EXT2_FLAG_RW) && !(mount_flags & EXT2_MF_MOUNTED) &&
- ext2fs_has_feature_journal_needs_recovery(fs->super)) {
- errcode_t err;
-
- printf(_("Recovering journal.\n"));
- err = ext2fs_run_ext3_journal(&fs);
- if (err) {
- com_err("tune2fs", err, "while recovering journal.\n");
- printf(_("Please run e2fsck -fy %s.\n"), argv[1]);
- goto closefs;
- }
- ext2fs_clear_feature_journal_needs_recovery(fs->super);
- ext2fs_mark_super_dirty(fs);
- }
-#endif
-
free(device_name);
remove_error_table(&et_ext2_error_table);
#endif
}
- convert_64bit(fs, feature_64bit);
+ if (feature_64bit)
+ convert_64bit(fs, feature_64bit);
return (ext2fs_close_free(&fs) ? 1 : 0);
}