Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6538c2d2 authored by Jaegeuk Kim's avatar Jaegeuk Kim Committed by Automerger Merge Worker
Browse files

Merge changes from topic "fscklog_f2fs" am: 65e07d31

parents 6f663556 65e07d31
Loading
Loading
Loading
Loading
+14 −11
Original line number Original line Diff line number Diff line
@@ -98,11 +98,13 @@ public class BootReceiver extends BroadcastReceiver {


    // example: fs_stat,/dev/block/platform/soc/by-name/userdata,0x5
    // example: fs_stat,/dev/block/platform/soc/by-name/userdata,0x5
    private static final String FS_STAT_PATTERN = "fs_stat,[^,]*/([^/,]+),(0x[0-9a-fA-F]+)";
    private static final String FS_STAT_PATTERN = "fs_stat,[^,]*/([^/,]+),(0x[0-9a-fA-F]+)";
    private static final int FS_STAT_FS_FIXED = 0x400; // should match with fs_mgr.cpp:FsStatFlags
    private static final int FS_STAT_FSCK_FS_FIXED =
            0x400; // should match with fs_mgr.cpp:FsStatFlags
    private static final String FSCK_PASS_PATTERN = "Pass ([1-9]E?):";
    private static final String FSCK_PASS_PATTERN = "Pass ([1-9]E?):";
    private static final String FSCK_TREE_OPTIMIZATION_PATTERN =
    private static final String FSCK_TREE_OPTIMIZATION_PATTERN =
            "Inode [0-9]+ extent tree.*could be shorter";
            "Inode [0-9]+ extent tree.*could be shorter";
    private static final String FSCK_FS_MODIFIED = "FILE SYSTEM WAS MODIFIED";
    private static final String E2FSCK_FS_MODIFIED = "FILE SYSTEM WAS MODIFIED";
    private static final String F2FS_FSCK_FS_MODIFIED = "[FSCK] Unreachable";
    // ro.boottime.init.mount_all. + postfix for mount_all duration
    // ro.boottime.init.mount_all. + postfix for mount_all duration
    private static final String[] MOUNT_DURATION_PROPS_POSTFIX =
    private static final String[] MOUNT_DURATION_PROPS_POSTFIX =
            new String[] { "early", "default", "late" };
            new String[] { "early", "default", "late" };
@@ -460,7 +462,7 @@ public class BootReceiver extends BroadcastReceiver {
        int lineNumber = 0;
        int lineNumber = 0;
        int lastFsStatLineNumber = 0;
        int lastFsStatLineNumber = 0;
        for (String line : lines) { // should check all lines
        for (String line : lines) { // should check all lines
            if (line.contains(FSCK_FS_MODIFIED)) {
            if (line.contains(E2FSCK_FS_MODIFIED) || line.contains(F2FS_FSCK_FS_MODIFIED)) {
                uploadNeeded = true;
                uploadNeeded = true;
            } else if (line.contains("fs_stat")) {
            } else if (line.contains("fs_stat")) {
                Matcher matcher = pattern.matcher(line);
                Matcher matcher = pattern.matcher(line);
@@ -674,7 +676,7 @@ public class BootReceiver extends BroadcastReceiver {
    public static int fixFsckFsStat(String partition, int statOrg, String[] lines,
    public static int fixFsckFsStat(String partition, int statOrg, String[] lines,
            int startLineNumber, int endLineNumber) {
            int startLineNumber, int endLineNumber) {
        int stat = statOrg;
        int stat = statOrg;
        if ((stat & FS_STAT_FS_FIXED) != 0) {
        if ((stat & FS_STAT_FSCK_FS_FIXED) != 0) {
            // fs was fixed. should check if quota warning was caused by tree optimization.
            // fs was fixed. should check if quota warning was caused by tree optimization.
            // This is not a real fix but optimization, so should not be counted as a fs fix.
            // This is not a real fix but optimization, so should not be counted as a fs fix.
            Pattern passPattern = Pattern.compile(FSCK_PASS_PATTERN);
            Pattern passPattern = Pattern.compile(FSCK_PASS_PATTERN);
@@ -687,7 +689,8 @@ public class BootReceiver extends BroadcastReceiver {
            String otherFixLine = null;
            String otherFixLine = null;
            for (int i = startLineNumber; i < endLineNumber; i++) {
            for (int i = startLineNumber; i < endLineNumber; i++) {
                String line = lines[i];
                String line = lines[i];
                if (line.contains(FSCK_FS_MODIFIED)) { // no need to parse above this
                if (line.contains(E2FSCK_FS_MODIFIED)
                        || line.contains(F2FS_FSCK_FS_MODIFIED)) { // no need to parse above this
                    break;
                    break;
                } else if (line.startsWith("Pass ")) {
                } else if (line.startsWith("Pass ")) {
                    Matcher matcher = passPattern.matcher(line);
                    Matcher matcher = passPattern.matcher(line);
@@ -715,9 +718,9 @@ public class BootReceiver extends BroadcastReceiver {
                    }
                    }
                } else if (line.startsWith("Update quota info") && currentPass.equals("5")) {
                } else if (line.startsWith("Update quota info") && currentPass.equals("5")) {
                    // follows "[QUOTA WARNING]", ignore
                    // follows "[QUOTA WARNING]", ignore
                } else if (line.startsWith("Timestamp(s) on inode") &&
                } else if (line.startsWith("Timestamp(s) on inode")
                        line.contains("beyond 2310-04-04 are likely pre-1970") &&
                        && line.contains("beyond 2310-04-04 are likely pre-1970")
                        currentPass.equals("1")) {
                        && currentPass.equals("1")) {
                    Slog.i(TAG, "fs_stat, partition:" + partition + " found timestamp adjustment:"
                    Slog.i(TAG, "fs_stat, partition:" + partition + " found timestamp adjustment:"
                            + line);
                            + line);
                    // followed by next line, "Fix? yes"
                    // followed by next line, "Fix? yes"
@@ -745,7 +748,7 @@ public class BootReceiver extends BroadcastReceiver {
            } else if ((foundTreeOptimization && foundQuotaFix) || foundTimestampAdjustment) {
            } else if ((foundTreeOptimization && foundQuotaFix) || foundTimestampAdjustment) {
                // not a real fix, so clear it.
                // not a real fix, so clear it.
                Slog.i(TAG, "fs_stat, partition:" + partition + " fix ignored");
                Slog.i(TAG, "fs_stat, partition:" + partition + " fix ignored");
                stat &= ~FS_STAT_FS_FIXED;
                stat &= ~FS_STAT_FSCK_FS_FIXED;
            }
            }
        }
        }
        return stat;
        return stat;