Loading core/java/com/android/server/BootReceiver.java +19 −6 Original line number Diff line number Diff line Loading @@ -438,6 +438,7 @@ public class BootReceiver extends BroadcastReceiver { String currentPass = ""; boolean foundTreeOptimization = false; boolean foundQuotaFix = false; boolean foundTimestampAdjustment = false; boolean foundOtherFix = false; String otherFixLine = null; for (int i = startLineNumber; i < endLineNumber; i++) { Loading Loading @@ -470,6 +471,16 @@ public class BootReceiver extends BroadcastReceiver { } } else if (line.startsWith("Update quota info") && currentPass.equals("5")) { // follows "[QUOTA WARNING]", ignore } else if (line.startsWith("Timestamp(s) on inode") && line.contains("beyond 2310-04-04 are likely pre-1970") && currentPass.equals("1")) { Slog.i(TAG, "fs_stat, partition:" + partition + " found timestamp adjustment:" + line); // followed by next line, "Fix? yes" if (lines[i + 1].contains("Fix? yes")) { i++; } foundTimestampAdjustment = true; } else { line = line.trim(); // ignore empty msg or any msg before Pass 1 Loading @@ -480,15 +491,17 @@ public class BootReceiver extends BroadcastReceiver { } } } if (!foundOtherFix && foundTreeOptimization && foundQuotaFix) { // not a real fix, so clear it. Slog.i(TAG, "fs_stat, partition:" + partition + " quota fix due to tree optimization"); stat &= ~FS_STAT_FS_FIXED; } else { if (foundOtherFix) { if (otherFixLine != null) { Slog.i(TAG, "fs_stat, partition:" + partition + " fix:" + otherFixLine); } } else if (foundQuotaFix && !foundTreeOptimization) { Slog.i(TAG, "fs_stat, got quota fix without tree optimization, partition:" + partition); } else if ((foundTreeOptimization && foundQuotaFix) || foundTimestampAdjustment) { // not a real fix, so clear it. Slog.i(TAG, "fs_stat, partition:" + partition + " fix ignored"); stat &= ~FS_STAT_FS_FIXED; } } return stat; Loading services/tests/servicestests/src/com/android/server/BootReceiverFixFsckFsStatTest.java +90 −3 Original line number Diff line number Diff line Loading @@ -52,13 +52,13 @@ public class BootReceiverFixFsckFsStatTest { " ", "/dev/block/platform/soc/624000.ufshc/by-name/userdata: ***** FILE SYSTEM WAS MODIFIED *****" }; doTestFsckFsStat(logs, 0x405, 5, 0, logs.length); doTestFsckFsStat(logs, 0x405, 0x5, 0, logs.length); final String[] doubleLogs = new String[logs.length * 2]; System.arraycopy(logs, 0, doubleLogs, 0, logs.length); System.arraycopy(logs, 0, doubleLogs, logs.length, logs.length); doTestFsckFsStat(doubleLogs, 0x401, 1, 0, logs.length); doTestFsckFsStat(doubleLogs, 0x402, 2, logs.length, logs.length * 2); doTestFsckFsStat(doubleLogs, 0x401, 0x1, 0, logs.length); doTestFsckFsStat(doubleLogs, 0x402, 0x2, logs.length, logs.length * 2); } @Test Loading @@ -79,6 +79,7 @@ public class BootReceiverFixFsckFsStatTest { " ", "/dev/block/platform/soc/624000.ufshc/by-name/userdata: ***** FILE SYSTEM WAS MODIFIED *****" }; // quota fix without tree optimization is an error. doTestFsckFsStat(logs, 0x405, 0x405, 0, logs.length); } Loading @@ -103,6 +104,92 @@ public class BootReceiverFixFsckFsStatTest { doTestFsckFsStat(logs, 0x405, 0x405, 0, logs.length); } @Test public void testTimestampAdjustment() { final String[] logs = { "e2fsck 1.43.3 (04-Sep-2016)", "Pass 1: Checking inodes, blocks, and sizes", "Timestamp(s) on inode 508580 beyond 2310-04-04 are likely pre-1970.", "Fix? yes", " ", "Pass 1E: Optimizing extent trees", "Pass 2: Checking directory structure", "Pass 3: Checking directory connectivity", "Pass 4: Checking reference counts", "Pass 5: Checking group summary information", " ", "/dev/block/platform/soc/624000.ufshc/by-name/userdata: ***** FILE SYSTEM WAS MODIFIED *****" }; doTestFsckFsStat(logs, 0x405, 0x5, 0, logs.length); } @Test public void testTimestampAdjustmentNoFixLine() { final String[] logs = { "e2fsck 1.43.3 (04-Sep-2016)", "Pass 1: Checking inodes, blocks, and sizes", "Timestamp(s) on inode 508580 beyond 2310-04-04 are likely pre-1970.", " ", "Pass 1E: Optimizing extent trees", "Pass 2: Checking directory structure", "Pass 3: Checking directory connectivity", "Pass 4: Checking reference counts", "Pass 5: Checking group summary information", " ", "/dev/block/platform/soc/624000.ufshc/by-name/userdata: ***** FILE SYSTEM WAS MODIFIED *****" }; doTestFsckFsStat(logs, 0x405, 0x5, 0, logs.length); } @Test public void testTimestampAdjustmentWithQuotaFix() { final String[] logs = { "e2fsck 1.43.3 (04-Sep-2016)", "Pass 1: Checking inodes, blocks, and sizes", "Timestamp(s) on inode 508580 beyond 2310-04-04 are likely pre-1970.", "Fix? yes", " ", "Pass 1E: Optimizing extent trees", "Pass 2: Checking directory structure", "Pass 3: Checking directory connectivity", "Pass 4: Checking reference counts", "Pass 5: Checking group summary information", "[QUOTA WARNING] Usage inconsistent for ID 10038:actual (71667712, 1000) != expected (71671808, 1000)", "Update quota info for quota type 0? yes", " ", "[QUOTA WARNING] Usage inconsistent for ID 10038:actual (59555840, 953) != expected (59559936, 953)", "Update quota info for quota type 1? yes", " ", "/dev/block/platform/soc/624000.ufshc/by-name/userdata: ***** FILE SYSTEM WAS MODIFIED *****" }; doTestFsckFsStat(logs, 0x405, 0x405, 0, logs.length); } @Test public void testAllNonFixes() { final String[] logs = { "e2fsck 1.43.3 (04-Sep-2016)", "Pass 1: Checking inodes, blocks, and sizes", "Timestamp(s) on inode 508580 beyond 2310-04-04 are likely pre-1970.", "Fix? yes", "Inode 877141 extent tree (at level 1) could be shorter. Fix? yes", " ", "Pass 1E: Optimizing extent trees", "Pass 2: Checking directory structure", "Pass 3: Checking directory connectivity", "Pass 4: Checking reference counts", "Pass 5: Checking group summary information", "[QUOTA WARNING] Usage inconsistent for ID 10038:actual (71667712, 1000) != expected (71671808, 1000)", "Update quota info for quota type 0? yes", " ", "[QUOTA WARNING] Usage inconsistent for ID 10038:actual (59555840, 953) != expected (59559936, 953)", "Update quota info for quota type 1? yes", " ", "/dev/block/platform/soc/624000.ufshc/by-name/userdata: ***** FILE SYSTEM WAS MODIFIED *****" }; doTestFsckFsStat(logs, 0x405, 0x5, 0, logs.length); } private void doTestFsckFsStat(String[] lines, int statOrg, int statUpdated, int startLineNumber, int endLineNumber) { assertEquals(statUpdated, BootReceiver.fixFsckFsStat(PARTITION, statOrg, lines, Loading Loading
core/java/com/android/server/BootReceiver.java +19 −6 Original line number Diff line number Diff line Loading @@ -438,6 +438,7 @@ public class BootReceiver extends BroadcastReceiver { String currentPass = ""; boolean foundTreeOptimization = false; boolean foundQuotaFix = false; boolean foundTimestampAdjustment = false; boolean foundOtherFix = false; String otherFixLine = null; for (int i = startLineNumber; i < endLineNumber; i++) { Loading Loading @@ -470,6 +471,16 @@ public class BootReceiver extends BroadcastReceiver { } } else if (line.startsWith("Update quota info") && currentPass.equals("5")) { // follows "[QUOTA WARNING]", ignore } else if (line.startsWith("Timestamp(s) on inode") && line.contains("beyond 2310-04-04 are likely pre-1970") && currentPass.equals("1")) { Slog.i(TAG, "fs_stat, partition:" + partition + " found timestamp adjustment:" + line); // followed by next line, "Fix? yes" if (lines[i + 1].contains("Fix? yes")) { i++; } foundTimestampAdjustment = true; } else { line = line.trim(); // ignore empty msg or any msg before Pass 1 Loading @@ -480,15 +491,17 @@ public class BootReceiver extends BroadcastReceiver { } } } if (!foundOtherFix && foundTreeOptimization && foundQuotaFix) { // not a real fix, so clear it. Slog.i(TAG, "fs_stat, partition:" + partition + " quota fix due to tree optimization"); stat &= ~FS_STAT_FS_FIXED; } else { if (foundOtherFix) { if (otherFixLine != null) { Slog.i(TAG, "fs_stat, partition:" + partition + " fix:" + otherFixLine); } } else if (foundQuotaFix && !foundTreeOptimization) { Slog.i(TAG, "fs_stat, got quota fix without tree optimization, partition:" + partition); } else if ((foundTreeOptimization && foundQuotaFix) || foundTimestampAdjustment) { // not a real fix, so clear it. Slog.i(TAG, "fs_stat, partition:" + partition + " fix ignored"); stat &= ~FS_STAT_FS_FIXED; } } return stat; Loading
services/tests/servicestests/src/com/android/server/BootReceiverFixFsckFsStatTest.java +90 −3 Original line number Diff line number Diff line Loading @@ -52,13 +52,13 @@ public class BootReceiverFixFsckFsStatTest { " ", "/dev/block/platform/soc/624000.ufshc/by-name/userdata: ***** FILE SYSTEM WAS MODIFIED *****" }; doTestFsckFsStat(logs, 0x405, 5, 0, logs.length); doTestFsckFsStat(logs, 0x405, 0x5, 0, logs.length); final String[] doubleLogs = new String[logs.length * 2]; System.arraycopy(logs, 0, doubleLogs, 0, logs.length); System.arraycopy(logs, 0, doubleLogs, logs.length, logs.length); doTestFsckFsStat(doubleLogs, 0x401, 1, 0, logs.length); doTestFsckFsStat(doubleLogs, 0x402, 2, logs.length, logs.length * 2); doTestFsckFsStat(doubleLogs, 0x401, 0x1, 0, logs.length); doTestFsckFsStat(doubleLogs, 0x402, 0x2, logs.length, logs.length * 2); } @Test Loading @@ -79,6 +79,7 @@ public class BootReceiverFixFsckFsStatTest { " ", "/dev/block/platform/soc/624000.ufshc/by-name/userdata: ***** FILE SYSTEM WAS MODIFIED *****" }; // quota fix without tree optimization is an error. doTestFsckFsStat(logs, 0x405, 0x405, 0, logs.length); } Loading @@ -103,6 +104,92 @@ public class BootReceiverFixFsckFsStatTest { doTestFsckFsStat(logs, 0x405, 0x405, 0, logs.length); } @Test public void testTimestampAdjustment() { final String[] logs = { "e2fsck 1.43.3 (04-Sep-2016)", "Pass 1: Checking inodes, blocks, and sizes", "Timestamp(s) on inode 508580 beyond 2310-04-04 are likely pre-1970.", "Fix? yes", " ", "Pass 1E: Optimizing extent trees", "Pass 2: Checking directory structure", "Pass 3: Checking directory connectivity", "Pass 4: Checking reference counts", "Pass 5: Checking group summary information", " ", "/dev/block/platform/soc/624000.ufshc/by-name/userdata: ***** FILE SYSTEM WAS MODIFIED *****" }; doTestFsckFsStat(logs, 0x405, 0x5, 0, logs.length); } @Test public void testTimestampAdjustmentNoFixLine() { final String[] logs = { "e2fsck 1.43.3 (04-Sep-2016)", "Pass 1: Checking inodes, blocks, and sizes", "Timestamp(s) on inode 508580 beyond 2310-04-04 are likely pre-1970.", " ", "Pass 1E: Optimizing extent trees", "Pass 2: Checking directory structure", "Pass 3: Checking directory connectivity", "Pass 4: Checking reference counts", "Pass 5: Checking group summary information", " ", "/dev/block/platform/soc/624000.ufshc/by-name/userdata: ***** FILE SYSTEM WAS MODIFIED *****" }; doTestFsckFsStat(logs, 0x405, 0x5, 0, logs.length); } @Test public void testTimestampAdjustmentWithQuotaFix() { final String[] logs = { "e2fsck 1.43.3 (04-Sep-2016)", "Pass 1: Checking inodes, blocks, and sizes", "Timestamp(s) on inode 508580 beyond 2310-04-04 are likely pre-1970.", "Fix? yes", " ", "Pass 1E: Optimizing extent trees", "Pass 2: Checking directory structure", "Pass 3: Checking directory connectivity", "Pass 4: Checking reference counts", "Pass 5: Checking group summary information", "[QUOTA WARNING] Usage inconsistent for ID 10038:actual (71667712, 1000) != expected (71671808, 1000)", "Update quota info for quota type 0? yes", " ", "[QUOTA WARNING] Usage inconsistent for ID 10038:actual (59555840, 953) != expected (59559936, 953)", "Update quota info for quota type 1? yes", " ", "/dev/block/platform/soc/624000.ufshc/by-name/userdata: ***** FILE SYSTEM WAS MODIFIED *****" }; doTestFsckFsStat(logs, 0x405, 0x405, 0, logs.length); } @Test public void testAllNonFixes() { final String[] logs = { "e2fsck 1.43.3 (04-Sep-2016)", "Pass 1: Checking inodes, blocks, and sizes", "Timestamp(s) on inode 508580 beyond 2310-04-04 are likely pre-1970.", "Fix? yes", "Inode 877141 extent tree (at level 1) could be shorter. Fix? yes", " ", "Pass 1E: Optimizing extent trees", "Pass 2: Checking directory structure", "Pass 3: Checking directory connectivity", "Pass 4: Checking reference counts", "Pass 5: Checking group summary information", "[QUOTA WARNING] Usage inconsistent for ID 10038:actual (71667712, 1000) != expected (71671808, 1000)", "Update quota info for quota type 0? yes", " ", "[QUOTA WARNING] Usage inconsistent for ID 10038:actual (59555840, 953) != expected (59559936, 953)", "Update quota info for quota type 1? yes", " ", "/dev/block/platform/soc/624000.ufshc/by-name/userdata: ***** FILE SYSTEM WAS MODIFIED *****" }; doTestFsckFsStat(logs, 0x405, 0x5, 0, logs.length); } private void doTestFsckFsStat(String[] lines, int statOrg, int statUpdated, int startLineNumber, int endLineNumber) { assertEquals(statUpdated, BootReceiver.fixFsckFsStat(PARTITION, statOrg, lines, Loading