From: Andreas Dilger Date: Thu, 12 Apr 2012 23:38:13 +0000 (-0600) Subject: tune2fs: warn if the filesystem journal is dirty X-Git-Tag: v1.45.2.wc1~24 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=27269dc9040100072c88865d70b4cc75394a0553;p=tools%2Fe2fsprogs.git tune2fs: warn if the filesystem journal is dirty Running tune2fs on a filesystem with an unrecovered journal can cause the tune2fs settings to be reverted when the journal is replayed. Print a warning if this is detected so that the user isn't surprised if it happens. Signed-off-by: Jim Garlick Signed-off-by: Andreas Dilger --- diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 7d2d38d..2782094 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -3314,6 +3314,7 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n" ext2fs_mark_super_dirty(fs); printf(_("Setting stripe width to %d\n"), stripe_width); } + if (ext_mount_opts) { strncpy((char *)(fs->super->s_mount_opts), ext_mount_opts, sizeof(fs->super->s_mount_opts)); @@ -3324,6 +3325,16 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n" free(ext_mount_opts); } + /* 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: needs_recovery flag is set. You may wish\n" + "replay the journal then rerun this command, or any\n" + "changes may be overwritten by journal recovery.\n")); + } + free(device_name); remove_error_table(&et_ext2_error_table);