OSDN Git Service

Volume: Don't crap out when dealing with unformatted cards
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>
Fri, 7 Mar 2014 02:24:26 +0000 (02:24 +0000)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Sat, 22 Aug 2015 14:44:35 +0000 (22:44 +0800)
Change-Id: I2ab58328d07a343a5ec9e1c4b58f8258f0c9133c

Volume.cpp

index 097626a..a38668b 100644 (file)
@@ -298,6 +298,13 @@ int Volume::formatVol(bool wipe) {
 
     fstype = getFsType((const char*)devicePath);
 
+    /* If the device has no filesystem, let's default to vfat.
+     * A NULL fstype will cause a MAPERR in the format
+     * switch below */
+    if (fstype == NULL) {
+        fstype = strdup("vfat");
+    }
+
     if (mDebug) {
         SLOGI("Formatting volume %s (%s) as %s", getLabel(), devicePath, fstype);
     }