diff options
author | San Mehat <san@google.com> | 2009-05-18 11:17:40 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-05-18 11:17:40 -0700 |
commit | 735b60ebc2c293688d89bd311494ce8f61ba6475 (patch) | |
tree | 386128b882e7c198adb2ed10e0c8b33894b1c137 | |
parent | 34c22c5ba951e4df7cc72d8d10da78064d5cfbe4 (diff) | |
parent | 7edc4f9454f1665b73faf0c02543cf350b741a53 (diff) | |
download | core-735b60ebc2c293688d89bd311494ce8f61ba6475.tar.gz core-735b60ebc2c293688d89bd311494ce8f61ba6475.tar.bz2 core-735b60ebc2c293688d89bd311494ce8f61ba6475.zip |
am 7edc4f94: vold: If a filesystem is read/only then restart the fscheck but don\'t make any changes
Merge commit '7edc4f9454f1665b73faf0c02543cf350b741a53'
* commit '7edc4f9454f1665b73faf0c02543cf350b741a53':
vold: If a filesystem is read/only then restart the fscheck but don't make any changes
-rw-r--r-- | vold/volmgr_vfat.c | 85 |
1 files changed, 45 insertions, 40 deletions
diff --git a/vold/volmgr_vfat.c b/vold/volmgr_vfat.c index 344a16600..3c546b44b 100644 --- a/vold/volmgr_vfat.c +++ b/vold/volmgr_vfat.c @@ -39,6 +39,7 @@ int vfat_identify(blkdev_t *dev) int vfat_check(blkdev_t *dev) { int rc; + boolean rw = true; #if VFAT_DEBUG LOG_VOL("vfat_check(%d:%d):", dev->major, dev->minor); @@ -50,47 +51,51 @@ int vfat_check(blkdev_t *dev) return 0; } -#ifdef VERIFY_PASS - char *args[7]; - args[0] = FSCK_MSDOS_PATH; - args[1] = "-v"; - args[2] = "-V"; - args[3] = "-w"; - args[4] = "-p"; - args[5] = blkdev_get_devpath(dev); - args[6] = NULL; - rc = logwrap(6, args); - free(args[5]); -#else - char *args[6]; - args[0] = FSCK_MSDOS_PATH; - args[1] = "-v"; - args[2] = "-w"; - args[3] = "-p"; - args[4] = blkdev_get_devpath(dev); - args[5] = NULL; - rc = logwrap(5, args); - free(args[4]); -#endif + do { + + char *args[6]; + args[0] = FSCK_MSDOS_PATH; + args[1] = "-v"; + + if (rw) { + args[2] = "-w"; + args[3] = "-p"; + args[4] = blkdev_get_devpath(dev); + args[5] = NULL; + rc = logwrap(5, args); + free(args[4]); + } else { + args[2] = "-n"; + args[3] = blkdev_get_devpath(dev); + args[4] = NULL; + rc = logwrap(4, args); + free(args[3]); + } + + if (rc == 0) { + LOG_VOL("Filesystem check completed OK"); + return 0; + } else if (rc == 1) { + LOG_VOL("Filesystem check failed (general failure)"); + return -EINVAL; + } else if (rc == 2) { + LOG_VOL("Filesystem check failed (invalid usage)"); + return -EIO; + } else if (rc == 4) { + LOG_VOL("Filesystem check completed (errors fixed)"); + } else if (rc == 6) { + LOG_VOL("Filesystem read-only - retrying check RO"); + rw = false; + continue; + } else if (rc == 8) { + LOG_VOL("Filesystem check failed (not a FAT filesystem)"); + return -ENODATA; + } else { + LOG_VOL("Filesystem check failed (unknown exit code %d)", rc); + return -EIO; + } + } while (0); - if (rc == 0) { - LOG_VOL("Filesystem check completed OK"); - return 0; - } else if (rc == 1) { - LOG_VOL("Filesystem check failed (general failure)"); - return -EINVAL; - } else if (rc == 2) { - LOG_VOL("Filesystem check failed (invalid usage)"); - return -EIO; - } else if (rc == 4) { - LOG_VOL("Filesystem check completed (errors fixed)"); - } else if (rc == 8) { - LOG_VOL("Filesystem check failed (not a FAT filesystem)"); - return -ENODATA; - } else { - LOG_VOL("Filesystem check failed (unknown exit code %d)", rc); - return -EIO; - } return 0; } |