Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7edc4f94 authored by San Mehat's avatar San Mehat
Browse files

vold: If a filesystem is read/only then restart the fscheck but don't make any changes



Signed-off-by: default avatarSan Mehat <san@google.com>
parent 414ff7d9
Loading
Loading
Loading
Loading
+45 −40
Original line number Diff line number Diff line
@@ -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,28 +51,26 @@ 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
    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]);
#endif
        } 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");
@@ -84,6 +83,10 @@ int vfat_check(blkdev_t *dev)
            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;
@@ -91,6 +94,8 @@ int vfat_check(blkdev_t *dev)
            LOG_VOL("Filesystem check failed (unknown exit code %d)", rc);
            return -EIO;
        }
    } while (0);

    return 0;
}