Only create android_secure mountpoint on the primary external storage volume.

Change-Id: I4069297a799260b8ecf355e91a1594b4f03126af
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/Volume.cpp b/Volume.cpp
index 746d84f..ce41455 100644
--- a/Volume.cpp
+++ b/Volume.cpp
@@ -282,6 +282,8 @@
     dev_t deviceNodes[4];
     int n, i, rc = 0;
     char errmsg[255];
+    const char* externalStorage = getenv("EXTERNAL_STORAGE");
+    bool primaryStorage = externalStorage && !strcmp(getMountpoint(), externalStorage);
 
     if (getState() == Volume::State_NoMedia) {
         snprintf(errmsg, sizeof(errmsg),
@@ -340,7 +342,7 @@
         errno = 0;
         int gid;
 
-        if (!strcmp(getMountpoint(), "/mnt/sdcard")) {
+        if (primaryStorage) {
             // Special case the primary SD card.
             // For this we grant write access to the SDCARD_RW group.
             gid = AID_SDCARD_RW;
@@ -358,7 +360,8 @@
 
         protectFromAutorunStupidity();
 
-        if (createBindMounts()) {
+        // only create android_secure on primary storage
+        if (primaryStorage && createBindMounts()) {
             SLOGE("Failed to create bindmounts (%s)", strerror(errno));
             umount("/mnt/secure/staging");
             setState(Volume::State_Idle);