am 92736efa: Another fix for encryption

* commit '92736efab068bdbfeb1177544907b84511fb04e0':
  Another fix for encryption
diff --git a/DirectVolume.h b/DirectVolume.h
index de1ed8b..c0139d4 100644
--- a/DirectVolume.h
+++ b/DirectVolume.h
@@ -27,7 +27,7 @@
 
 class DirectVolume : public Volume {
 public:
-    static const int MAX_PARTITIONS = 4;
+    static const int MAX_PARTITIONS = 32;
 protected:
     PathCollection *mPaths;
     int            mDiskMajor;
@@ -37,7 +37,7 @@
     int            mOrigDiskMinor;
     int            mOrigPartMinors[MAX_PARTITIONS];
     int            mDiskNumParts;
-    unsigned char  mPendingPartMap;
+    unsigned int   mPendingPartMap;
     int            mIsDecrypted;
     int            mFlags;
 
diff --git a/Ext4.cpp b/Ext4.cpp
index 290489e..4ec0616 100644
--- a/Ext4.cpp
+++ b/Ext4.cpp
@@ -67,16 +67,18 @@
     return rc;
 }
 
-int Ext4::format(const char *fsPath) {
+int Ext4::format(const char *fsPath, const char *mountpoint) {
     int fd;
-    const char *args[4];
+    const char *args[6];
     int rc;
 
     args[0] = MKEXT4FS_PATH;
     args[1] = "-J";
-    args[2] = fsPath;
-    args[3] = NULL;
-    rc = logwrap(3, args, 1);
+    args[2] = "-a";
+    args[3] = mountpoint;
+    args[4] = fsPath;
+    args[5] = NULL;
+    rc = logwrap(5, args, 1);
 
     if (rc == 0) {
         SLOGI("Filesystem (ext4) formatted OK");
diff --git a/Ext4.h b/Ext4.h
index a09b576..c5ab78a 100644
--- a/Ext4.h
+++ b/Ext4.h
@@ -23,7 +23,7 @@
 public:
     static int doMount(const char *fsPath, const char *mountPoint, bool ro, bool remount,
             bool executable);
-    static int format(const char *fsPath);
+    static int format(const char *fsPath, const char *mountpoint);
 };
 
 #endif
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index ca5ec84..2bc1fe9 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -379,8 +379,12 @@
 
     if (wantFilesystem) {
         int formatStatus;
+        char mountPoint[255];
+
+        snprintf(mountPoint, sizeof(mountPoint), "%s/%s", Volume::ASECDIR, id);
+
         if (usingExt4) {
-            formatStatus = Ext4::format(dmDevice);
+            formatStatus = Ext4::format(dmDevice, mountPoint);
         } else {
             formatStatus = Fat::format(dmDevice, numImgSectors);
         }
@@ -395,9 +399,6 @@
             return -1;
         }
 
-        char mountPoint[255];
-
-        snprintf(mountPoint, sizeof(mountPoint), "%s/%s", Volume::ASECDIR, id);
         if (mkdir(mountPoint, 0000)) {
             if (errno != EEXIST) {
                 SLOGE("Mountpoint creation failed (%s)", strerror(errno));