From: Eric Sandeen Date: Fri, 21 Feb 2014 01:18:41 +0000 (-0500) Subject: tune2fs: allow removal of dirty journal with two "-f" options X-Git-Tag: v1.42.10~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fe2bd60844cfe5d805e62a4316afaa5cd9d7c83;p=thirdparty%2Fe2fsprogs.git tune2fs: allow removal of dirty journal with two "-f" options Jim pointed out that "tune2fs -f -O ^has_journal" won't remove the journal if the needs_recovery flag is set; the manpage seems to indicate that it should. And if you've lost an external journal and can no longer replay it, how should one proceed? Change tune2fs so that two "-f" options will allow removal of a dirty journal from a filesystem, even if the filesystem needs recovery. e2fsck can then do its best to pick up the pieces. Addresses-Debian-Bug: #559301 Reported-by: Jim Faulkner Signed-off-by: Eric Sandeen Signed-off-by: "Theodore Ts'o" --- diff --git a/misc/tune2fs.8.in b/misc/tune2fs.8.in index 94557076c..c50d47505 100644 --- a/misc/tune2fs.8.in +++ b/misc/tune2fs.8.in @@ -248,7 +248,10 @@ option is useful when removing the filesystem feature from a filesystem which has an external journal (or is corrupted such that it appears to have an external journal), but that -external journal is not available. +external journal is not available. If the filesystem appears to require +journal replay, the +.B \-f +flag must be specified twice to proceed. .sp .B WARNING: Removing an external journal from a filesystem which was not cleanly unmounted diff --git a/misc/tune2fs.c b/misc/tune2fs.c index e56055242..d35d54bc3 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -437,8 +437,9 @@ static int update_feature_set(ext2_filsys fs, char *features) "read-only.\n"), stderr); return 1; } - if (sb->s_feature_incompat & - EXT3_FEATURE_INCOMPAT_RECOVER) { + if ((sb->s_feature_incompat & + EXT3_FEATURE_INCOMPAT_RECOVER) && + f_flag < 2) { fputs(_("The needs_recovery flag is set. " "Please run e2fsck before clearing\n" "the has_journal flag.\n"), stderr); @@ -948,7 +949,7 @@ static void parse_tune2fs_options(int argc, char **argv) open_flag |= EXT2_FLAG_RW; break; case 'f': /* Force */ - f_flag = 1; + f_flag++; break; case 'g': resgid = strtoul(optarg, &tmp, 0);