summaryrefslogtreecommitdiffstats
path: root/vold
diff options
context:
space:
mode:
authorSan Mehat <san@google.com>2009-07-16 09:34:53 -0700
committerSan Mehat <san@google.com>2009-07-16 09:34:53 -0700
commitd8221d9869f9fe1031219e8f6cbcef0771d767fa (patch)
tree6dc01a8a7a86c1c3a751e70cb131491fa2b8ff9e /vold
parentb6e70d877886bf363c5789456dcc00bb3f271c95 (diff)
downloadcore-d8221d9869f9fe1031219e8f6cbcef0771d767fa.tar.gz
core-d8221d9869f9fe1031219e8f6cbcef0771d767fa.tar.bz2
core-d8221d9869f9fe1031219e8f6cbcef0771d767fa.zip
vold: vfat: Run up to 3 passes of the disk checker when the checker
indicates the FS has been modified. Also create LOST.DIR if it doesn't exist on mount. Signed-off-by: San Mehat <san@google.com>
Diffstat (limited to 'vold')
-rw-r--r--vold/volmgr_vfat.c71
1 files changed, 49 insertions, 22 deletions
diff --git a/vold/volmgr_vfat.c b/vold/volmgr_vfat.c
index 7a4e12f19..22e2dcf91 100644
--- a/vold/volmgr_vfat.c
+++ b/vold/volmgr_vfat.c
@@ -51,28 +51,40 @@ int vfat_check(blkdev_t *dev)
return 0;
}
- char *args[5];
- args[0] = FSCK_MSDOS_PATH;
- args[1] = "-p";
- args[2] = "-f";
- args[3] = blkdev_get_devpath(dev);
- args[4] = NULL;
- rc = logwrap(4, args, 1);
- free(args[3]);
-
- if (rc == 0) {
- LOG_VOL("Filesystem check completed OK");
- return 0;
- } else if (rc == 2) {
- LOG_VOL("Filesystem check failed (not a FAT filesystem)");
- return -ENODATA;
- } else if (rc == -11) {
- LOG_VOL("Filesystem check crashed");
- return -EIO;
- } else {
- LOG_VOL("Filesystem check failed (unknown exit code %d)", rc);
- return -EIO;
- }
+ int pass = 1;
+ do {
+ char *args[5];
+ args[0] = FSCK_MSDOS_PATH;
+ args[1] = "-p";
+ args[2] = "-f";
+ args[3] = blkdev_get_devpath(dev);
+ args[4] = NULL;
+ rc = logwrap(4, args, 1);
+ free(args[3]);
+
+ if (rc == 0) {
+ LOG_VOL("Filesystem check completed OK");
+ return 0;
+ } else if (rc == 2) {
+ LOG_VOL("Filesystem check failed (not a FAT filesystem)");
+ return -ENODATA;
+ } else if (rc == 4) {
+ if (pass++ <= 3) {
+ LOG_VOL("Filesystem modified - rechecking (pass %d)",
+ pass);
+ continue;
+ } else {
+ LOG_VOL("Failing check after too many rechecks");
+ return -EIO;
+ }
+ } else if (rc == -11) {
+ LOG_VOL("Filesystem check crashed");
+ return -EIO;
+ } else {
+ LOG_VOL("Filesystem check failed (unknown exit code %d)", rc);
+ return -EIO;
+ }
+ } while (0);
return 0;
}
@@ -113,6 +125,21 @@ int vfat_mount(blkdev_t *dev, volume_t *vol, boolean safe_mode)
"utf8,uid=1000,gid=1015,fmask=702,dmask=702,shortname=mixed");
}
+ if (rc == 0) {
+ char *lost_path;
+ asprintf(&lost_path, "%s/LOST.DIR", vol->mount_point);
+ if (access(lost_path, F_OK)) {
+ /*
+ * Create a LOST.DIR in the root so we have somewhere to put
+ * lost cluster chains (fsck_msdos doesn't currently do this)
+ */
+ if (mkdir(lost_path, 0755)) {
+ LOGE("Unable to create LOST.DIR (%s)", strerror(errno));
+ }
+ }
+ free(lost_path);
+ }
+
#if VFAT_DEBUG
LOG_VOL("vfat_mount(%s, %d:%d): mount rc = %d", dev->major,k dev->minor,
vol->mount_point, rc);