OSDN Git Service

vold2: Don't bail out if the UMS switch isn't there
authorSan Mehat <san@google.com>
Mon, 4 Jan 2010 16:30:00 +0000 (08:30 -0800)
committerSan Mehat <san@google.com>
Mon, 4 Jan 2010 16:30:00 +0000 (08:30 -0800)
Signed-off-by: San Mehat <san@google.com>
main.cpp

index 1ffbc7b..2412612 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -87,24 +87,24 @@ int main() {
         FILE *fp;
         char state[255];
 
-        if (!(fp = fopen("/sys/devices/virtual/switch/usb_mass_storage/state",
+        if ((fp = fopen("/sys/devices/virtual/switch/usb_mass_storage/state",
                          "r"))) {
-            LOGE("Failed to open ums switch (%s)", strerror(errno));
-            exit(1);
-        }
-        if (!fgets(state, sizeof(state), fp)) {
-            LOGE("Failed to read switch state (%s)", strerror(errno));
+            if (!fgets(state, sizeof(state), fp)) {
+                LOGE("Failed to read switch state (%s)", strerror(errno));
+                fclose(fp);
+                exit(1);
+            }
+            if (!strncmp(state, "online", 6)) {
+                LOGD("Bootstrapped ums is connected");
+                vm->notifyUmsConnected(true);
+            } else {
+                LOGD("Bootstrapped ums is disconnected");
+                vm->notifyUmsConnected(false);
+            }
             fclose(fp);
-            exit(1);
-        }
-        if (!strncmp(state, "online", 6)) {
-            LOGD("Bootstrapped ums is connected");
-            vm->notifyUmsConnected(true);
         } else {
-            LOGD("Bootstrapped ums is disconnected");
-            vm->notifyUmsConnected(false);
+            LOGW("No UMS switch available");
         }
-        fclose(fp);
     }
 //    coldboot("/sys/class/switch");