Merge "blkid: add support to recognize exfat to blkid."
diff --git a/contrib/Android.bp b/contrib/Android.bp
index 585a8f1..c2d5cd9 100644
--- a/contrib/Android.bp
+++ b/contrib/Android.bp
@@ -10,7 +10,7 @@
     host_supported: true,
 
     srcs: ["fsstress.c"],
-    cflags: ["-W", "-Wall"],
+    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
     system_shared_libs: ["libc"],
 
     target: {
@@ -28,7 +28,7 @@
     host_supported: true,
 
     srcs: ["add_ext4_encrypt.c"],
-    cflags: ["-W", "-Wall"],
+    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
     shared_libs: [
         "libext2fs",
         "libext2_com_err",
diff --git a/debugfs/Android.bp b/debugfs/Android.bp
index b60b453..013a421 100644
--- a/debugfs/Android.bp
+++ b/debugfs/Android.bp
@@ -34,6 +34,7 @@
     cflags: [
         "-W",
         "-Wall",
+        "-Wno-macro-redefined",
         "-fno-strict-aliasing",
         "-DDEBUGFS",
     ],
diff --git a/e2fsck/Android.bp b/e2fsck/Android.bp
index 0e1f9b8..1cabe86 100644
--- a/e2fsck/Android.bp
+++ b/e2fsck/Android.bp
@@ -34,7 +34,7 @@
         "readahead.c",
         "extents.c",
     ],
-    cflags: ["-W", "-Wall", "-fno-strict-aliasing"],
+    cflags: ["-W", "-Wall", "-Wno-macro-redefined", "-fno-strict-aliasing"],
 }
 
 e2fsck_libs = [
diff --git a/e2fsck/e2fsck.conf.5.in b/e2fsck/e2fsck.conf.5.in
index 1848bdb..0bfc76a 100644
--- a/e2fsck/e2fsck.conf.5.in
+++ b/e2fsck/e2fsck.conf.5.in
@@ -303,6 +303,13 @@
 option even overrides the
 .B -y
 option given on the command-line (just for the specific problem, of course).
+.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]
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index 46fe7b4..c4f58f1 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -572,6 +572,7 @@
 	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 34a671e..4b25069 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -1276,12 +1276,12 @@
 	/* 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 */
 
@@ -2166,6 +2166,7 @@
 		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);
@@ -2283,7 +2284,8 @@
 	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 @@
 #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 e00fa16..6029cc3 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -1908,11 +1908,23 @@
 		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/lib/blkid/Android.bp b/lib/blkid/Android.bp
index 9a3f276..9b385f9 100644
--- a/lib/blkid/Android.bp
+++ b/lib/blkid/Android.bp
@@ -24,6 +24,7 @@
         "-W",
         "-Wall",
         "-fno-strict-aliasing",
+        "-Wno-macro-redefined",
     ],
 
     header_libs: ["libext2-headers"],
diff --git a/lib/e2p/Android.bp b/lib/e2p/Android.bp
index 9c344df..db51670 100644
--- a/lib/e2p/Android.bp
+++ b/lib/e2p/Android.bp
@@ -32,6 +32,7 @@
     cflags: [
         "-W",
         "-Wall",
+        "-Wno-macro-redefined",
     ],
 
     header_libs: ["libext2-headers"],
diff --git a/lib/ext2fs/Android.bp b/lib/ext2fs/Android.bp
index 73b11a3..df07a9b 100644
--- a/lib/ext2fs/Android.bp
+++ b/lib/ext2fs/Android.bp
@@ -97,6 +97,7 @@
         "-W",
         "-Wall",
         "-Wno-unused-parameter",
+        "-Wno-macro-redefined",
     ],
     target: {
         host: {
diff --git a/lib/support/Android.bp b/lib/support/Android.bp
index 11248b4..24414a4 100644
--- a/lib/support/Android.bp
+++ b/lib/support/Android.bp
@@ -25,6 +25,7 @@
     cflags: [
         "-W",
         "-Wall",
+        "-Wno-macro-redefined",
     ],
 
     header_libs: ["libext2-headers"],
diff --git a/misc/Android.bp b/misc/Android.bp
index f75c9d1..e36bf93 100644
--- a/misc/Android.bp
+++ b/misc/Android.bp
@@ -9,7 +9,7 @@
     srcs: [
         "create_inode.c",
     ],
-    cflags: ["-W", "-Wall"],
+    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
     shared_libs: [
         "libext2_quota",
         "libext2fs",
@@ -32,7 +32,7 @@
         "default_profile.c",
         "create_inode.c",
     ],
-    cflags: ["-W", "-Wall"],
+    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
     shared_libs: [
         "libext2fs",
         "libext2_blkid",
@@ -58,6 +58,7 @@
         "-W",
         "-Wall",
         "-DNO_RECOVERY",
+        "-Wno-macro-redefined",
     ],
     include_dirs: ["external/e2fsprogs/e2fsck"],
 }
@@ -104,7 +105,7 @@
     host_supported: true,
 
     srcs: ["badblocks.c"],
-    cflags: ["-W", "-Wall"],
+    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
     shared_libs: [
         "libext2fs",
         "libext2_com_err",
@@ -123,7 +124,7 @@
     host_supported: true,
 
     srcs: ["chattr.c"],
-    cflags: ["-W", "-Wall"],
+    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
     shared_libs: [
         "libext2_com_err",
         "libext2_e2p",
@@ -137,7 +138,7 @@
 cc_defaults {
     name: "lsattr-defaults",
     srcs: ["lsattr.c"],
-    cflags: ["-W", "-Wall"],
+    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
 }
 
 lsattr_libs = [
@@ -169,7 +170,7 @@
     name: "blkid",
 
     srcs: ["blkid.c"],
-    cflags: ["-W", "-Wall"],
+    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
     shared_libs: [
         "libext2fs",
         "libext2_blkid",
@@ -187,7 +188,7 @@
     host_supported: true,
 
     srcs: ["e4crypt.c"],
-    cflags: ["-W", "-Wall"],
+    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
     shared_libs: [
         "libext2fs",
         "libext2_uuid",
@@ -209,7 +210,7 @@
     host_supported: true,
 
     srcs: ["e2image.c"],
-    cflags: ["-W", "-Wall"],
+    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
     shared_libs: [
         "libext2fs",
         "libext2_blkid",
diff --git a/resize/Android.bp b/resize/Android.bp
index 5d8f0e8..6d3d321 100644
--- a/resize/Android.bp
+++ b/resize/Android.bp
@@ -12,7 +12,7 @@
         "sim_progress.c",
         "resource_track.c",
     ],
-    cflags: ["-W", "-Wall"],
+    cflags: ["-W", "-Wall", "-Wno-macro-redefined"],
     shared_libs: [
         "libext2fs",
         "libext2_com_err",
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 @@
 
 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 @@
 
 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 @@
 
 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 @@
 
 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 @@
            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 @@
 
 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 @@
 
 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 @@
 
 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 @@
 
 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 @@
 
 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 @@
 
 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