diff options
Diffstat (limited to 'vold/volmgr_vfat.c')
-rw-r--r-- | vold/volmgr_vfat.c | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/vold/volmgr_vfat.c b/vold/volmgr_vfat.c index 661f714..344a166 100644 --- a/vold/volmgr_vfat.c +++ b/vold/volmgr_vfat.c @@ -31,7 +31,7 @@ static char FSCK_MSDOS_PATH[] = "/system/bin/dosfsck"; int vfat_identify(blkdev_t *dev) { #if VFAT_DEBUG - LOG_VOL("vfat_identify(%s):\n", dev->dev_fspath); + LOG_VOL("vfat_identify(%d:%d):", dev->major, dev->minor); #endif return 0; // XXX: Implement } @@ -41,12 +41,12 @@ int vfat_check(blkdev_t *dev) int rc; #if VFAT_DEBUG - LOG_VOL("vfat_check(%s):\n", dev->dev_fspath); + LOG_VOL("vfat_check(%d:%d):", dev->major, dev->minor); #endif if (access(FSCK_MSDOS_PATH, X_OK)) { - LOGE("vfat_check(%s): %s not found (skipping checks)\n", - FSCK_MSDOS_PATH, dev->dev_fspath); + LOGE("vfat_check(%d:%d): %s not found (skipping checks)", + dev->major, dev->minor, FSCK_MSDOS_PATH); return 0; } @@ -57,61 +57,77 @@ int vfat_check(blkdev_t *dev) args[2] = "-V"; args[3] = "-w"; args[4] = "-p"; - args[5] = dev->dev_fspath; + 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] = dev->dev_fspath; + args[4] = blkdev_get_devpath(dev); args[5] = NULL; rc = logwrap(5, args); + free(args[4]); #endif if (rc == 0) { - LOG_VOL("Filesystem check completed OK\n"); + LOG_VOL("Filesystem check completed OK"); return 0; } else if (rc == 1) { - LOG_VOL("Filesystem check failed (general failure)\n"); + LOG_VOL("Filesystem check failed (general failure)"); return -EINVAL; } else if (rc == 2) { - LOG_VOL("Filesystem check failed (invalid usage)\n"); + LOG_VOL("Filesystem check failed (invalid usage)"); return -EIO; } else if (rc == 4) { - LOG_VOL("Filesystem check completed (errors fixed)\n"); + 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)\n", rc); + LOG_VOL("Filesystem check failed (unknown exit code %d)", rc); return -EIO; } return 0; } -int vfat_mount(blkdev_t *dev, volume_t *vol) +int vfat_mount(blkdev_t *dev, volume_t *vol, boolean safe_mode) { int flags, rc; + char *devpath; + + devpath = blkdev_get_devpath(dev); #if VFAT_DEBUG - LOG_VOL("vfat_mount(%s, %s):\n", dev->dev_fspath, vol->mount_point); + LOG_VOL("vfat_mount(%d:%d, %s, %d):", dev->major, dev->minor, vol->mount_point, safe_mode); #endif flags = MS_NODEV | MS_NOEXEC | MS_NOSUID | MS_DIRSYNC; - rc = mount(dev->dev_fspath, vol->mount_point, "vfat", flags, - "utf8,uid=1000,gid=1000,fmask=711,dmask=700"); + + if (vol->state == volstate_mounted) { + LOG_VOL("Remounting %d:%d on %s, safe mode %d", dev->major, + dev->minor, vol->mount_point, safe_mode); + flags |= MS_REMOUNT; + } + + rc = mount(devpath, vol->mount_point, "vfat", flags, + "utf8,uid=1000,gid=1000,fmask=711,dmask=700,shortname=mixed"); if (rc && errno == EROFS) { - LOGE("vfat_mount(%s, %s): Read only filesystem - retrying mount RO\n", - dev->dev_fspath, vol->mount_point); + LOGE("vfat_mount(%d:%d, %s): Read only filesystem - retrying mount RO", + dev->major, dev->minor, vol->mount_point); flags |= MS_RDONLY; - rc = mount(dev->dev_fspath, vol->mount_point, "vfat", flags, - "utf8,uid=1000,gid=1000,fmask=711,dmask=700"); + rc = mount(devpath, vol->mount_point, "vfat", flags, + "utf8,uid=1000,gid=1000,fmask=711,dmask=700,shortname=mixed"); } #if VFAT_DEBUG - LOG_VOL("vfat_mount(%s, %s): mount rc = %d\n", dev->dev_fspath, + LOG_VOL("vfat_mount(%s, %d:%d): mount rc = %d", dev->major,k dev->minor, vol->mount_point, rc); #endif + free (devpath); return rc; } |