summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-e2fsck-exit-with-exit-status-0-if-no-errors-were-fix.patch
blob: 44f3888b1c00538e83b54377ab2f32802f78cefb (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
From b9bb77a0dd712f06b262a12766972b99cd801269 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Thu, 16 Feb 2017 22:02:35 -0500
Subject: [PATCH] e2fsck: exit with exit status 0 if no errors were fixed

Previously, e2fsck would exit with a status code of 1 even though the
only changes that it made to the file system were various
optimziations and not fixing file system corruption.  Since the man
page states that an exit status of 1 means "file system errors
corrupted", fix e2fsck to return an exit status of 0.

Upstream-Status: Backport

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Daniel Schultz <d.schultz@phytec.de>

Conflicts:
	e2fsck/e2fsck.conf.5.in
---
 e2fsck/e2fsck.conf.5.in                     | 34 +++++++++++++++++++++++++++++
 e2fsck/journal.c                            |  1 +
 e2fsck/problem.c                            |  8 ++++---
 e2fsck/problemP.h                           |  1 +
 e2fsck/unix.c                               | 20 +++++++++++++----
 tests/f_collapse_extent_tree/expect.1       |  2 +-
 tests/f_compress_extent_tree_level/expect.1 |  2 +-
 tests/f_convert_bmap/expect.1               |  2 +-
 tests/f_convert_bmap_and_extent/expect.1    |  2 +-
 tests/f_extent_htree/expect.1               |  2 +-
 tests/f_jnl_errno/expect.1                  |  2 +-
 tests/f_journal/expect.1                    |  2 +-
 tests/f_orphan/expect.1                     |  2 +-
 tests/f_orphan_extents_inode/expect.1       |  2 +-
 tests/f_rehash_dir/expect.1                 |  2 +-
 tests/f_unsorted_EAs/expect.1               |  2 +-
 16 files changed, 68 insertions(+), 18 deletions(-)

diff --git a/e2fsck/e2fsck.conf.5.in b/e2fsck/e2fsck.conf.5.in
index 1f80a04..6a205ce 100644
--- a/e2fsck/e2fsck.conf.5.in
+++ b/e2fsck/e2fsck.conf.5.in
@@ -326,6 +326,40 @@ defaults to true.
 This relation controls whether or not the scratch file directory is used
 instead of an in-memory data structure when tracking inode counts.  It
 defaults to true.
+.TP
+.I not_a_fix
+This boolean option, it set to true, marks the problem as
+one where if the user gives permission to make the requested change,
+it does not mean that the file system had a problem which has since
+been fixed.  This is used for requests to optimize the file system's
+data structure, such as pruning an extent tree.
+@TDB_MAN_COMMENT@.SH THE [scratch_files] STANZA
+@TDB_MAN_COMMENT@The following relations are defined in the
+@TDB_MAN_COMMENT@.I [scratch_files]
+@TDB_MAN_COMMENT@stanza.
+@TDB_MAN_COMMENT@.TP
+@TDB_MAN_COMMENT@.I directory
+@TDB_MAN_COMMENT@If the directory named by this relation exists and is
+@TDB_MAN_COMMENT@writeable, then e2fsck will attempt to use this
+@TDB_MAN_COMMENT@directory to store scratch files instead of using
+@TDB_MAN_COMMENT@in-memory data structures.
+@TDB_MAN_COMMENT@.TP
+@TDB_MAN_COMMENT@.I numdirs_threshold
+@TDB_MAN_COMMENT@If this relation is set, then in-memory data structures
+@TDB_MAN_COMMENT@be used if the number of directories in the filesystem
+@TDB_MAN_COMMENT@are fewer than amount specified.
+@TDB_MAN_COMMENT@.TP
+@TDB_MAN_COMMENT@.I dirinfo
+@TDB_MAN_COMMENT@This relation controls whether or not the scratch file
+@TDB_MAN_COMMENT@directory is used instead of an in-memory data
+@TDB_MAN_COMMENT@structure for directory information.  It defaults to
+@TDB_MAN_COMMENT@true.
+@TDB_MAN_COMMENT@.TP
+@TDB_MAN_COMMENT@.I icount
+@TDB_MAN_COMMENT@This relation controls whether or not the scratch file
+@TDB_MAN_COMMENT@directory is used instead of an in-memory data
+@TDB_MAN_COMMENT@structure when tracking inode counts.  It defaults to
+@TDB_MAN_COMMENT@true.
 .SH LOGGING
 E2fsck has the facility to save the information from an e2fsck run in a
 directory so that a system administrator can review its output at their
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index c8ac57d..b4cf329 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -572,6 +572,7 @@ static void clear_v2_journal_fields(journal_t *journal)
 	if (!fix_problem(ctx, PR_0_CLEAR_V2_JOURNAL, &pctx))
 		return;
 
+	ctx->flags |= E2F_FLAG_PROBLEMS_FIXED;
 	memset(((char *) journal->j_superblock) + V1_SB_SIZE, 0,
 	       ctx->fs->blocksize-V1_SB_SIZE);
 	mark_buffer_dirty(journal->j_sb_buffer);
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 1e645e4..2b01ffc 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -1261,12 +1261,12 @@ static struct e2fsck_problem problem_table[] = {
 	/* Inode extent tree could be shorter */
 	{ PR_1E_CAN_COLLAPSE_EXTENT_TREE,
 	  N_("@i %i @x tree (at level %b) could be shorter.  "),
-	  PROMPT_FIX, PR_NO_OK | PR_PREEN_NO | PR_PREEN_OK },
+	  PROMPT_FIX, PR_NO_OK | PR_PREEN_NO | PR_PREEN_OK | PR_NOT_A_FIX },
 
 	/* Inode extent tree could be narrower */
 	{ PR_1E_CAN_NARROW_EXTENT_TREE,
 	  N_("@i %i @x tree (at level %b) could be narrower.  "),
-	  PROMPT_FIX, PR_NO_OK | PR_PREEN_NO | PR_PREEN_OK },
+	  PROMPT_FIX, PR_NO_OK | PR_PREEN_NO | PR_PREEN_OK | PR_NOT_A_FIX },
 
 	/* Pass 2 errors */
 
@@ -2146,6 +2146,7 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
 		reconfigure_bool(ctx, ptr, key, PR_NO_NOMSG, "no_nomsg");
 		reconfigure_bool(ctx, ptr, key, PR_PREEN_NOHDR, "preen_noheader");
 		reconfigure_bool(ctx, ptr, key, PR_FORCE_NO, "force_no");
+		reconfigure_bool(ctx, ptr, key, PR_NOT_A_FIX, "not_a_fix");
 		profile_get_integer(ctx->profile, "options",
 				    "max_count_problems", 0, 0,
 				    &ptr->max_count);
@@ -2263,7 +2264,8 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
 	if (ptr->flags & PR_AFTER_CODE)
 		answer = fix_problem(ctx, ptr->second_code, pctx);
 
-	if (answer && (ptr->prompt != PROMPT_NONE))
+	if (answer && (ptr->prompt != PROMPT_NONE) &&
+	    !(ptr->flags & PR_NOT_A_FIX))
 		ctx->flags |= E2F_FLAG_PROBLEMS_FIXED;
 
 	return answer;
diff --git a/e2fsck/problemP.h b/e2fsck/problemP.h
index 7944cd6..63bb8df 100644
--- a/e2fsck/problemP.h
+++ b/e2fsck/problemP.h
@@ -44,3 +44,4 @@ struct latch_descr {
 #define PR_CONFIG	0x080000 /* This problem has been customized
 				    from the config file */
 #define PR_FORCE_NO	0x100000 /* Force the answer to be no */
+#define PR_NOT_A_FIX	0x200000 /* Yes doesn't mean a problem was fixed */
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 004a6e5..d33d7fd 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -1896,11 +1896,23 @@ no_journal:
 		fix_problem(ctx, PR_6_IO_FLUSH, &pctx);
 
 	if (was_changed) {
-		exit_value |= FSCK_NONDESTRUCT;
-		if (!(ctx->options & E2F_OPT_PREEN))
-			log_out(ctx, _("\n%s: ***** FILE SYSTEM WAS "
-				       "MODIFIED *****\n"),
+		int fs_fixed = (ctx->flags & E2F_FLAG_PROBLEMS_FIXED);
+
+		if (fs_fixed)
+			exit_value |= FSCK_NONDESTRUCT;
+		if (!(ctx->options & E2F_OPT_PREEN)) {
+#if 0	/* Do this later; it breaks too many tests' golden outputs */
+			log_out(ctx, fs_fixed ?
+				_("\n%s: ***** FILE SYSTEM ERRORS "
+				  "CORRECTED *****\n") :
+				_("%s: File system was modified.\n"),
 				ctx->device_name);
+#else
+			log_out(ctx,
+				_("\n%s: ***** FILE SYSTEM WAS MODIFIED *****\n"),
+				ctx->device_name);
+#endif
+		}
 		if (ctx->mount_flags & EXT2_MF_ISROOT) {
 			log_out(ctx, _("%s: ***** REBOOT SYSTEM *****\n"),
 				ctx->device_name);
diff --git a/tests/f_collapse_extent_tree/expect.1 b/tests/f_collapse_extent_tree/expect.1
index e2eb65e..8165a58 100644
--- a/tests/f_collapse_extent_tree/expect.1
+++ b/tests/f_collapse_extent_tree/expect.1
@@ -13,4 +13,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 12/128 files (0.0% non-contiguous), 19/512 blocks
-Exit status is 1
+Exit status is 0
diff --git a/tests/f_compress_extent_tree_level/expect.1 b/tests/f_compress_extent_tree_level/expect.1
index a359c99..dd33f63 100644
--- a/tests/f_compress_extent_tree_level/expect.1
+++ b/tests/f_compress_extent_tree_level/expect.1
@@ -20,4 +20,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 12/128 files (8.3% non-contiguous), 26/512 blocks
-Exit status is 1
+Exit status is 0
diff --git a/tests/f_convert_bmap/expect.1 b/tests/f_convert_bmap/expect.1
index 7d2ca86..c387962 100644
--- a/tests/f_convert_bmap/expect.1
+++ b/tests/f_convert_bmap/expect.1
@@ -23,4 +23,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 12/128 files (8.3% non-contiguous), 570/2048 blocks
-Exit status is 1
+Exit status is 0
diff --git a/tests/f_convert_bmap_and_extent/expect.1 b/tests/f_convert_bmap_and_extent/expect.1
index 7af91aa..c86c571 100644
--- a/tests/f_convert_bmap_and_extent/expect.1
+++ b/tests/f_convert_bmap_and_extent/expect.1
@@ -30,4 +30,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 13/128 files (15.4% non-contiguous), 574/2048 blocks
-Exit status is 1
+Exit status is 0
diff --git a/tests/f_extent_htree/expect.1 b/tests/f_extent_htree/expect.1
index 223ca69..ea48405 100644
--- a/tests/f_extent_htree/expect.1
+++ b/tests/f_extent_htree/expect.1
@@ -26,4 +26,4 @@ test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
            0 sockets
 ------------
          343 files
-Exit status is 1
+Exit status is 0
diff --git a/tests/f_jnl_errno/expect.1 b/tests/f_jnl_errno/expect.1
index c572951..4134234 100644
--- a/tests/f_jnl_errno/expect.1
+++ b/tests/f_jnl_errno/expect.1
@@ -6,4 +6,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 11/2048 files (9.1% non-contiguous), 1330/8192 blocks
-Exit status is 1
+Exit status is 0
diff --git a/tests/f_journal/expect.1 b/tests/f_journal/expect.1
index a202c80..0a18654 100644
--- a/tests/f_journal/expect.1
+++ b/tests/f_journal/expect.1
@@ -59,4 +59,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 53/2048 files (1.9% non-contiguous), 1409/8192 blocks
-Exit status is 1
+Exit status is 0
diff --git a/tests/f_orphan/expect.1 b/tests/f_orphan/expect.1
index eddc1f8..087ebee 100644
--- a/tests/f_orphan/expect.1
+++ b/tests/f_orphan/expect.1
@@ -11,4 +11,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 12/2048 files (0.0% non-contiguous), 1303/8192 blocks
-Exit status is 1
+Exit status is 0
diff --git a/tests/f_orphan_extents_inode/expect.1 b/tests/f_orphan_extents_inode/expect.1
index 2eaab78..5d713b3 100644
--- a/tests/f_orphan_extents_inode/expect.1
+++ b/tests/f_orphan_extents_inode/expect.1
@@ -7,4 +7,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 12/16 files (0.0% non-contiguous), 21/100 blocks
-Exit status is 1
+Exit status is 0
diff --git a/tests/f_rehash_dir/expect.1 b/tests/f_rehash_dir/expect.1
index 6076765..c1449ba 100644
--- a/tests/f_rehash_dir/expect.1
+++ b/tests/f_rehash_dir/expect.1
@@ -7,4 +7,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 105/2048 files (2.9% non-contiguous), 336/512 blocks
-Exit status is 1
+Exit status is 0
diff --git a/tests/f_unsorted_EAs/expect.1 b/tests/f_unsorted_EAs/expect.1
index 7d588d7..64b9045 100644
--- a/tests/f_unsorted_EAs/expect.1
+++ b/tests/f_unsorted_EAs/expect.1
@@ -8,4 +8,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 12/2048 files (0.0% non-contiguous), 1294/2048 blocks
-Exit status is 1
+Exit status is 0
-- 
1.9.1