vold2: Manually bootstrap the ums switch since switch kernel uevents are broken

Signed-off-by: San Mehat <san@google.com>
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 4a24ff7..462029c 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -79,9 +79,15 @@
 }
 
 void VolumeManager::handleSwitchEvent(NetlinkEvent *evt) {
+    const char *devpath = evt->findParam("DEVPATH");
     const char *name = evt->findParam("SWITCH_NAME");
     const char *state = evt->findParam("SWITCH_STATE");
 
+    if (!name || !state) {
+        LOGW("Switch %s event missing name/state info", devpath);
+        return;
+    }
+
     if (!strcmp(name, "usb_mass_storage")) {
 
         if (!strcmp(state, "online"))  {
@@ -228,7 +234,8 @@
              sizeof(nodepath), "/dev/block/vold/%d:%d",
              MAJOR(d), MINOR(d));
 
-    if ((fd = open("/sys/devices/platform/usb_mass_storage/lun0", O_WRONLY)) < 0) {
+    if ((fd = open("/sys/devices/platform/usb_mass_storage/lun0/file",
+                   O_WRONLY)) < 0) {
         LOGE("Unable to open ums lunfile (%s)", strerror(errno));
         return -1;
     }
@@ -270,7 +277,7 @@
              sizeof(nodepath), "/dev/block/vold/%d:%d",
              MAJOR(d), MINOR(d));
 
-    if ((fd = open("/sys/devices/platform/usb_mass_storage/lun0", O_WRONLY)) < 0) {
+    if ((fd = open("/sys/devices/platform/usb_mass_storage/lun0/file", O_WRONLY)) < 0) {
         LOGE("Unable to open ums lunfile (%s)", strerror(errno));
         return -1;
     }