OSDN Git Service

vold: add support for ext4 media
[android-x86/system-vold.git] / Volume.cpp
index 4af1fc1..9e1c8a7 100644 (file)
@@ -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,