Skip to content

Commit 3f7120a

Browse files
committed
vold: Don't mess with EXT when a FAT partition was just dirty
When fsck_msdos returns 4, that means it fixed things on the partition, so it should be allowed to loop and try again. So we shouldn't be gobbling all non-zero returns as a sign to try EXT instead. This patch tries to better reconcile the return codes between fsck_msdos and e2fsck with a common enum status. The original rc is still kept so that unknown codes can still be reported in the default case of the switch. Change-Id: Ibb749948780759e41ffc25d77c5c69cc562dc0d1
1 parent d0087cc commit 3f7120a

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

Fat.cpp

+23-6
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,43 @@ int Fat::check(const char *fsPath) {
6161
args[3] = fsPath;
6262
args[4] = NULL;
6363

64+
enum { FS_OK, FS_FIXED, FS_MISMATCH, FS_ERROR } status = FS_ERROR;
65+
6466
rc = logwrap(4, args, 1);
6567
if (rc == 0) {
6668
// if rc is 0, the check was ok
6769
// That means the FileSystem is FAT
6870
fsType = 1;
69-
} else {
71+
status = FS_OK;
72+
} else if (rc == 2)
73+
status = FS_MISMATCH;
74+
else if (rc == 4)
75+
status = FS_FIXED;
76+
else
77+
status = FS_ERROR;
78+
79+
if (status == FS_MISMATCH) { // not FAT, let's try EXT
7080
args[0] = FSCK_EXT_PATH;
7181
args[1] = "-p";
7282
args[2] = "-f";
7383
args[3] = fsPath;
7484
args[4] = NULL;
7585
rc = logwrap(4, args, 1);
76-
if (rc == 0)
86+
if (rc == 0) {
7787
// if rc is 0, the check was ok
7888
// That means the FileSystem is EXT
7989
fsType = 2;
90+
status = FS_OK;
91+
} else if (rc == 1)
92+
status = FS_FIXED;
93+
else if (rc == 8)
94+
status = FS_MISMATCH;
95+
else
96+
status = FS_ERROR;
8097
}
8198

82-
switch(rc) {
83-
case 0:
99+
switch(status) {
100+
case FS_OK:
84101
SLOGI("Filesystem check completed OK");
85102
// TODO: Remove this print.
86103
const char *fsTypePrint;
@@ -93,12 +110,12 @@ int Fat::check(const char *fsPath) {
93110
SLOGI("Filesystem type is: %s", fsTypePrint);
94111
return 0;
95112

96-
case 2:
113+
case FS_MISMATCH:
97114
SLOGW("Filesystem check failed (not a FAT or EXT filesystem)");
98115
errno = ENODATA;
99116
return -1;
100117

101-
case 4:
118+
case FS_FIXED:
102119
if (pass++ <= 3) {
103120
SLOGW("Filesystem modified - rechecking (pass %d)",
104121
pass);

0 commit comments

Comments
 (0)