Permalink
Browse files

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
  • Loading branch information...
1 parent d0087cc commit 3f7120aaebde30375c7115aac0c0f34665697135 @cuviper cuviper committed Mar 8, 2011
Showing with 23 additions and 6 deletions.
  1. +23 −6 Fat.cpp
View
29 Fat.cpp
@@ -61,26 +61,43 @@ int Fat::check(const char *fsPath) {
args[3] = fsPath;
args[4] = NULL;
+ enum { FS_OK, FS_FIXED, FS_MISMATCH, FS_ERROR } status = FS_ERROR;
+
rc = logwrap(4, args, 1);
if (rc == 0) {
// if rc is 0, the check was ok
// That means the FileSystem is FAT
fsType = 1;
- } else {
+ status = FS_OK;
+ } else if (rc == 2)
+ status = FS_MISMATCH;
+ else if (rc == 4)
+ status = FS_FIXED;
+ else
+ status = FS_ERROR;
+
+ if (status == FS_MISMATCH) { // not FAT, let's try EXT
args[0] = FSCK_EXT_PATH;
args[1] = "-p";
args[2] = "-f";
args[3] = fsPath;
args[4] = NULL;
rc = logwrap(4, args, 1);
- if (rc == 0)
+ if (rc == 0) {
// if rc is 0, the check was ok
// That means the FileSystem is EXT
fsType = 2;
+ status = FS_OK;
+ } else if (rc == 1)
+ status = FS_FIXED;
+ else if (rc == 8)
+ status = FS_MISMATCH;
+ else
+ status = FS_ERROR;
}
- switch(rc) {
- case 0:
+ switch(status) {
+ case FS_OK:
SLOGI("Filesystem check completed OK");
// TODO: Remove this print.
const char *fsTypePrint;
@@ -93,12 +110,12 @@ int Fat::check(const char *fsPath) {
SLOGI("Filesystem type is: %s", fsTypePrint);
return 0;
- case 2:
+ case FS_MISMATCH:
SLOGW("Filesystem check failed (not a FAT or EXT filesystem)");
errno = ENODATA;
return -1;
- case 4:
+ case FS_FIXED:
if (pass++ <= 3) {
SLOGW("Filesystem modified - rechecking (pass %d)",
pass);

0 comments on commit 3f7120a

Please sign in to comment.