diff options
author | codeworkx <codeworkx@cyanogenmod.org> | 2013-01-31 17:49:46 +0000 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-03-22 03:32:47 -0700 |
commit | 9939d4c788687bd680d822992e19720aa75f2836 (patch) | |
tree | d675fc7c34564278b9cc73a0e94c6a69d4d5e352 | |
parent | 45da364af584d02c28f7c53ba63d98aff6940160 (diff) | |
download | android_system_vold-9939d4c788687bd680d822992e19720aa75f2836.tar.gz android_system_vold-9939d4c788687bd680d822992e19720aa75f2836.tar.bz2 android_system_vold-9939d4c788687bd680d822992e19720aa75f2836.zip |
vold: add support for ext4 media
Squashed commit of the following:
Author: codeworkx <codeworkx@cyanogenmod.org>
vold: add support for ext4 media
Depends on:
http://review.cyanogenmod.org/31202
http://review.cyanogenmod.org/31211
Result:
http://pastebin.com/nzUbvW7K
Change-Id: I5bd227e637f2a1ed4d13a2eb81390c56c953f482
Author: Ricardo Cerqueira <cyanogenmod@cerqueira.org>
vold: Replace usage of discontinued logwrap()
Change-Id: Ia76bf8998064beee5e0ea4451c4dd8418c2193c4
Author: Ricardo Cerqueira <cyanogenmod@cerqueira.org>
Apply the mounts to the SDCARD /storage path instead of /mnt/media_rw
Change-Id: I6c8d73a00c6ffa64875f3c4c718d8a416d08d5c1
Author: Pawit Pornkitprasan <p.pawit@gmail.com>
vold: restore 4.4 sdcard logic
Mount points in 4.4 are always fuse-wrapped to provide granular
permission. Unix file systems no longer need to be manually
fuse-wrapped by us.
Change-Id: I6885b0baeaae7c380ec32d410a70a4f53801157b
Change-Id: I5bd227e637f2a1ed4d13a2eb81390c56c953f482
-rw-r--r-- | Ext4.cpp | 52 | ||||
-rw-r--r-- | Ext4.h | 1 | ||||
-rw-r--r-- | Volume.cpp | 19 |
3 files changed, 70 insertions, 2 deletions
@@ -43,8 +43,9 @@ #include "Ext4.h" #include "VoldUtil.h" -#define MKEXT4FS_PATH "/system/bin/make_ext4fs" -#define RESIZE2FS_PATH "/system/bin/resize2fs" +static char E2FSCK_PATH[] = "/system/bin/e2fsck"; +static char RESIZE2FS_PATH[] = "/system/bin/resize2fs"; +static char MKEXT4FS_PATH[] = "/system/bin/make_ext4fs"; int Ext4::doMount(const char *fsPath, const char *mountPoint, bool ro, bool remount, bool executable) { @@ -68,6 +69,53 @@ int Ext4::doMount(const char *fsPath, const char *mountPoint, bool ro, bool remo return rc; } +int Ext4::check(const char *fsPath) { + bool rw = true; + if (access(E2FSCK_PATH, X_OK)) { + SLOGW("Skipping fs checks.\n"); + return 0; + } + + int rc = -1; + int status; + do { + const char *args[5]; + args[0] = E2FSCK_PATH; + args[1] = "-p"; + args[2] = "-f"; + args[3] = fsPath; + args[4] = NULL; + + rc = android_fork_execvp(ARRAY_SIZE(args), (char **)args, &status, false, + true); + + switch(rc) { + case 0: + SLOGI("EXT4 Filesystem check completed OK.\n"); + return 0; + case 1: + SLOGI("EXT4 Filesystem check completed, errors corrected OK.\n"); + return 0; + case 2: + SLOGE("EXT4 Filesystem check completed, errors corrected, need reboot.\n"); + return 0; + case 4: + SLOGE("EXT4 Filesystem errors left uncorrected.\n"); + return 0; + case 8: + SLOGE("E2FSCK Operational error.\n"); + errno = EIO; + return -1; + default: + SLOGE("EXT4 Filesystem check failed (unknown exit code %d).\n", rc); + errno = EIO; + return -1; + } + } while (0); + + return 0; +} + int Ext4::resize(const char *fspath, unsigned int numSectors) { const char *args[4]; char* size_str; @@ -23,6 +23,7 @@ class Ext4 { public: static int doMount(const char *fsPath, const char *mountPoint, bool ro, bool remount, bool executable); + static int check(const char *fsPath); static int format(const char *fsPath, unsigned int numSectors, const char *mountpoint); static int resize(const char *fsPath, unsigned int numSectors); }; @@ -47,6 +47,7 @@ #include "Volume.h" #include "VolumeManager.h" #include "ResponseCode.h" +#include "Ext4.h" #include "Fat.h" #include "Ntfs.h" #include "Exfat.h" @@ -301,6 +302,8 @@ int Volume::formatVol(bool wipe) { if (strcmp(fstype, "exfat") == 0) { ret = Exfat::format(devicePath); + } else if (strcmp(fstype, "ext4") == 0) { + ret = Ext4::format(devicePath, 0, NULL); } else if (strcmp(fstype, "ntfs") == 0) { ret = Ntfs::format(devicePath, wipe); } else { @@ -478,6 +481,22 @@ int Volume::mountVol() { continue; } + } else if (strcmp(fstype, "ext4") == 0) { + + if (Ext4::check(devicePath)) { + errno = EIO; + /* Badness - abort the mount */ + SLOGE("%s failed FS checks (%s)", devicePath, strerror(errno)); + setState(Volume::State_Idle); + free(fstype); + return -1; + } + + if (Ext4::doMount(devicePath, getMountpoint(), false, false, false)) { + SLOGE("%s failed to mount via EXT4 (%s)\n", devicePath, strerror(errno)); + continue; + } + } else if (strcmp(fstype, "ntfs") == 0) { if (Ntfs::doMount(devicePath, getMountpoint(), false, false, false, |