summaryrefslogtreecommitdiffstats
path: root/e2fsprogs-1.42.12-resize2fs-fsck.patch
blob: 40f34e6b1eed32bd98ba4603f68697daefd2bd25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
commit 0462fd6db55de28d7e087d8d06ab20339acd8f67
Author: Eric Sandeen <sandeen@sandeen.net>
Date:   Sun Dec 14 19:08:59 2014 -0500

    resize2fs: don't require fsck to print min size
    
    My previous change ended up requiring that the filesystem
    be fsck'd after the last mount, even if we are only querying
    the minimum size.  This is a bit draconian, and it burned
    the Fedora installer, which wants to calculate minimum size
    for every filesystem in the box at install time, which in turn
    requires a full fsck of every filesystem.
    
    Try this one more time, and separate out the tests to make things
    a bit more clear.  If we're only printing the min size, don't
    require the fsck, as this is a bit less dangerous/critical.
    
    Signed-off-by: Eric Sandeen <sandeen@redhat.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>

diff --git a/resize/main.c b/resize/main.c
index 983d8c2..9a35af0 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -321,10 +321,30 @@ int main (int argc, char ** argv)
 	}
 	fs->default_bitmap_type = EXT2FS_BMAP64_RBTREE;
 
-	if (!(mount_flags & EXT2_MF_MOUNTED)) {
-		if (!force && ((fs->super->s_lastcheck < fs->super->s_mtime) ||
-			       (fs->super->s_state & EXT2_ERROR_FS) ||
-			       ((fs->super->s_state & EXT2_VALID_FS) == 0))) {
+	/*
+	 * Before acting on an unmounted filesystem, make sure it's ok,
+	 * unless the user is forcing it.
+	 *
+	 * We do ERROR and VALID checks even if we're only printing the
+	 * minimimum size, because traversal of a badly damaged filesystem
+	 * can cause issues as well.  We don't require it to be fscked after
+	 * the last mount time in this case, though, as this is a bit less
+	 * risky.
+	 */
+	if (!force && !(mount_flags & EXT2_MF_MOUNTED)) {
+		int checkit = 0;
+
+		if (fs->super->s_state & EXT2_ERROR_FS)
+			checkit = 1;
+
+		if ((fs->super->s_state & EXT2_VALID_FS) == 0)
+			checkit = 1;
+
+		if ((fs->super->s_lastcheck < fs->super->s_mtime) &&
+		    !print_min_size)
+			checkit = 1;
+
+		if (checkit) {
 			fprintf(stderr,
 				_("Please run 'e2fsck -f %s' first.\n\n"),
 				device_name);