vold: Add 'force' option to anything that can cause an unmount

Signed-off-by: San Mehat <san@google.com>
diff --git a/Volume.cpp b/Volume.cpp
index 529975a..cce2fc1 100644
--- a/Volume.cpp
+++ b/Volume.cpp
@@ -275,7 +275,7 @@
     return -1;
 }
 
-int Volume::unmountVol() {
+int Volume::unmountVol(bool force) {
     int i, rc;
 
     if (getState() != Volume::State_Mounted) {
@@ -285,7 +285,7 @@
     }
 
     setState(Volume::State_Unmounting);
-    usleep(1000 * 200); // Give the framework some time to react
+    usleep(1000 * 1000); // Give the framework some time to react
     for (i = 1; i <= 10; i++) {
         rc = umount(getMountpoint());
         if (!rc)
@@ -299,17 +299,18 @@
         LOGW("Volume %s unmount attempt %d failed (%s)",
              getLabel(), i, strerror(errno));
 
-        int action;
+        int action = 0;
 
-        if (i > 8) {
-            action = 2; // SIGKILL
-        } else if (i > 7) {
-            action = 1; // SIGHUP
-        } else
-            action = 0; // just complain
+        if (force) {
+            if (i > 8) {
+                action = 2; // SIGKILL
+            } else if (i > 7) {
+                action = 1; // SIGHUP
+            }
+        }
 
         Process::killProcessesWithOpenFiles(getMountpoint(), action);
-        usleep(1000*250);
+        usleep(1000*1000);
     }
 
     if (!rc) {
@@ -319,6 +320,7 @@
         return 0;
     }
 
+    errno = EBUSY;
     LOGE("Volume %s failed to unmount (%s)\n", getLabel(), strerror(errno));
     setState(Volume::State_Mounted);
     return -1;