vold2: Wire up more of the mount function

Signed-off-by: San Mehat <san@android.com>
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index a724a8d..024645d 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -89,6 +89,48 @@
         cli->sendMsg(ErrorCode::VolumeListResult, buffer, false);
         free(buffer);
     }
-    cli->sendMsg(ErrorCode::CommandOkay, "Volumes Listed", false);
+    cli->sendMsg(ErrorCode::CommandOkay, "Volumes listed.", false);
     return 0;
 }
+
+int VolumeManager::mountVolume(const char *label) {
+    Volume *v = lookupVolume(label);
+
+    if (!v) {
+        errno = ENOENT;
+        return -1;
+    }
+
+    if (v->getState() != Volume::State_Idle) {
+        errno = EBUSY;
+        return -1;
+    }
+
+    return v->mount();
+}
+
+int VolumeManager::unmountVolume(const char *label) {
+    Volume *v = lookupVolume(label);
+
+    if (!v) {
+        errno = ENOENT;
+        return -1;
+    }
+
+    if (v->getState() != Volume::State_Mounted) {
+        errno = EBUSY;
+        return -1;
+    }
+
+    return v->unmount();
+}
+
+Volume *VolumeManager::lookupVolume(const char *label) {
+    VolumeCollection::iterator i;
+
+    for (i = mVolumes->begin(); i != mVolumes->end(); ++i) {
+        if (!strcmp(label, (*i)->getLabel()))
+            return (*i);
+    }
+    return NULL;
+}