vold: Bugfixes & cleanups

  - Fix issue where container-names > 64 bytes were getting truncated in the
    kernel. lo_name is only 64 bytes in length, so we now hash the container
    id via md5
  - Add 'dump' command to dump loop and devicemapper status
  - Add 'debug' command to enable more detailed logging at runtime
  - Log vold IPC arguments (minus encryption keys)
  - Fix premature return from Loop::lookupActive() and friends

Change-Id: I0e833261a445ce9dc1a8187e5501d27daba1ca76
Signed-off-by: San Mehat <san@google.com>
diff --git a/Volume.cpp b/Volume.cpp
index d592c5f..80a8bf1 100644
--- a/Volume.cpp
+++ b/Volume.cpp
@@ -100,6 +100,7 @@
 
 Volume::Volume(VolumeManager *vm, const char *label, const char *mount_point) {
     mVm = vm;
+    mDebug = false;
     mLabel = strdup(label);
     mMountpoint = strdup(mount_point);
     mState = Volume::State_Init;
@@ -111,6 +112,10 @@
     free(mMountpoint);
 }
 
+void Volume::setDebug(bool enable) {
+    mDebug = enable;
+}
+
 dev_t Volume::getDiskDevice() {
     return MKDEV(0, 0);
 };
@@ -184,7 +189,9 @@
     sprintf(devicePath, "/dev/block/vold/%d:%d",
             MAJOR(diskNode), MINOR(diskNode));
 
-    LOGI("Formatting volume %s (%s)", getLabel(), devicePath);
+    if (mDebug) {
+        LOGI("Formatting volume %s (%s)", getLabel(), devicePath);
+    }
     setState(Volume::State_Formatting);
 
     if (initializeMbr(devicePath)) {
@@ -396,7 +403,9 @@
 
     while(retries--) {
         if (!mount(src, dst, "", flags, NULL)) {
-            LOGD("Moved mount %s -> %s sucessfully", src, dst);
+            if (mDebug) {
+                LOGD("Moved mount %s -> %s sucessfully", src, dst);
+            }
             return 0;
         } else if (errno != EBUSY) {
             LOGE("Failed to move mount %s -> %s (%s)", src, dst, strerror(errno));
@@ -425,7 +434,10 @@
 int Volume::doUnmount(const char *path, bool force) {
     int retries = 10;
 
-    LOGD("Unmounting {%s}, force = %d", path, force);
+    if (mDebug) {
+        LOGD("Unmounting {%s}, force = %d", path, force);
+    }
+
     while (retries--) {
         if (!umount(path) || errno == EINVAL || errno == ENOENT) {
             LOGI("%s sucessfully unmounted", path);