clang-format many files.

Test: Format-only changes; treehugger suffices.
Change-Id: I23cde3f0bbcac13bef555d13514e922c79d5ad48
diff --git a/model/Disk.cpp b/model/Disk.cpp
index 781d3e9..13cb1c7 100644
--- a/model/Disk.cpp
+++ b/model/Disk.cpp
@@ -15,36 +15,36 @@
  */
 
 #include "Disk.h"
-#include "PublicVolume.h"
+#include "Ext4Crypt.h"
 #include "PrivateVolume.h"
+#include "PublicVolume.h"
 #include "Utils.h"
 #include "VolumeBase.h"
 #include "VolumeManager.h"
-#include "Ext4Crypt.h"
 
 #include <android-base/file.h>
 #include <android-base/logging.h>
+#include <android-base/parseint.h>
 #include <android-base/properties.h>
 #include <android-base/stringprintf.h>
 #include <android-base/strings.h>
-#include <android-base/parseint.h>
 #include <ext4_utils/ext4_crypt.h>
 
 #include "cryptfs.h"
 
-#include <vector>
 #include <fcntl.h>
 #include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/types.h>
+#include <sys/mount.h>
 #include <sys/stat.h>
 #include <sys/sysmacros.h>
-#include <sys/mount.h>
+#include <sys/types.h>
+#include <vector>
 
 using android::base::ReadFileToString;
-using android::base::WriteStringToFile;
 using android::base::StringPrintf;
+using android::base::WriteStringToFile;
 
 namespace android {
 namespace vold {
@@ -112,20 +112,22 @@
      * "ranchu", the device's sysfs path should end with "/block/vd[d-z]", etc.
      * But just having a) and b) is enough for now.
      */
-    return IsRunningInEmulator() && major >= kMajorBlockExperimentalMin
-            && major <= kMajorBlockExperimentalMax;
+    return IsRunningInEmulator() && major >= kMajorBlockExperimentalMin &&
+           major <= kMajorBlockExperimentalMax;
 }
 
 static bool isNvmeBlkDevice(unsigned int major, const std::string& sysPath) {
-    return sysPath.find("nvme") != std::string::npos
-            && major >= kMajorBlockDynamicMin
-            && major <= kMajorBlockDynamicMax;
+    return sysPath.find("nvme") != std::string::npos && major >= kMajorBlockDynamicMin &&
+           major <= kMajorBlockDynamicMax;
 }
 
-Disk::Disk(const std::string& eventPath, dev_t device,
-        const std::string& nickname, int flags) :
-        mDevice(device), mSize(-1), mNickname(nickname), mFlags(flags), mCreated(
-                false), mJustPartitioned(false) {
+Disk::Disk(const std::string& eventPath, dev_t device, const std::string& nickname, int flags)
+    : mDevice(device),
+      mSize(-1),
+      mNickname(nickname),
+      mFlags(flags),
+      mCreated(false),
+      mJustPartitioned(false) {
     mId = StringPrintf("disk:%u,%u", major(device), minor(device));
     mEventPath = eventPath;
     mSysPath = StringPrintf("/sys/%s", eventPath.c_str());
@@ -251,73 +253,78 @@
 
     unsigned int majorId = major(mDevice);
     switch (majorId) {
-    case kMajorBlockLoop: {
-        mLabel = "Virtual";
-        break;
-    }
-    case kMajorBlockScsiA: case kMajorBlockScsiB: case kMajorBlockScsiC: case kMajorBlockScsiD:
-    case kMajorBlockScsiE: case kMajorBlockScsiF: case kMajorBlockScsiG: case kMajorBlockScsiH:
-    case kMajorBlockScsiI: case kMajorBlockScsiJ: case kMajorBlockScsiK: case kMajorBlockScsiL:
-    case kMajorBlockScsiM: case kMajorBlockScsiN: case kMajorBlockScsiO: case kMajorBlockScsiP: {
-        std::string path(mSysPath + "/device/vendor");
-        std::string tmp;
-        if (!ReadFileToString(path, &tmp)) {
-            PLOG(WARNING) << "Failed to read vendor from " << path;
-            return -errno;
-        }
-        tmp = android::base::Trim(tmp);
-        mLabel = tmp;
-        break;
-    }
-    case kMajorBlockMmc: {
-        std::string path(mSysPath + "/device/manfid");
-        std::string tmp;
-        if (!ReadFileToString(path, &tmp)) {
-            PLOG(WARNING) << "Failed to read manufacturer from " << path;
-            return -errno;
-        }
-        tmp = android::base::Trim(tmp);
-        int64_t manfid;
-        if (!android::base::ParseInt(tmp, &manfid)) {
-            PLOG(WARNING) << "Failed to parse manufacturer " << tmp;
-            return -EINVAL;
-        }
-        // Our goal here is to give the user a meaningful label, ideally
-        // matching whatever is silk-screened on the card.  To reduce
-        // user confusion, this list doesn't contain white-label manfid.
-        switch (manfid) {
-        case 0x000003: mLabel = "SanDisk"; break;
-        case 0x00001b: mLabel = "Samsung"; break;
-        case 0x000028: mLabel = "Lexar"; break;
-        case 0x000074: mLabel = "Transcend"; break;
-        }
-        break;
-    }
-    default: {
-        if (isVirtioBlkDevice(majorId)) {
-            LOG(DEBUG) << "Recognized experimental block major ID " << majorId
-                    << " as virtio-blk (emulator's virtual SD card device)";
+        case kMajorBlockLoop: {
             mLabel = "Virtual";
             break;
         }
-        if (isNvmeBlkDevice(majorId, mSysPath)) {
-            std::string path(mSysPath + "/device/model");
+        // clang-format off
+        case kMajorBlockScsiA: case kMajorBlockScsiB: case kMajorBlockScsiC:
+        case kMajorBlockScsiD: case kMajorBlockScsiE: case kMajorBlockScsiF:
+        case kMajorBlockScsiG: case kMajorBlockScsiH: case kMajorBlockScsiI:
+        case kMajorBlockScsiJ: case kMajorBlockScsiK: case kMajorBlockScsiL:
+        case kMajorBlockScsiM: case kMajorBlockScsiN: case kMajorBlockScsiO:
+        case kMajorBlockScsiP: {
+            // clang-format on
+            std::string path(mSysPath + "/device/vendor");
             std::string tmp;
             if (!ReadFileToString(path, &tmp)) {
                 PLOG(WARNING) << "Failed to read vendor from " << path;
                 return -errno;
             }
+            tmp = android::base::Trim(tmp);
             mLabel = tmp;
             break;
         }
-        LOG(WARNING) << "Unsupported block major type " << majorId;
-        return -ENOTSUP;
-    }
+        case kMajorBlockMmc: {
+            std::string path(mSysPath + "/device/manfid");
+            std::string tmp;
+            if (!ReadFileToString(path, &tmp)) {
+                PLOG(WARNING) << "Failed to read manufacturer from " << path;
+                return -errno;
+            }
+            tmp = android::base::Trim(tmp);
+            int64_t manfid;
+            if (!android::base::ParseInt(tmp, &manfid)) {
+                PLOG(WARNING) << "Failed to parse manufacturer " << tmp;
+                return -EINVAL;
+            }
+            // Our goal here is to give the user a meaningful label, ideally
+            // matching whatever is silk-screened on the card.  To reduce
+            // user confusion, this list doesn't contain white-label manfid.
+            switch (manfid) {
+                // clang-format off
+                case 0x000003: mLabel = "SanDisk"; break;
+                case 0x00001b: mLabel = "Samsung"; break;
+                case 0x000028: mLabel = "Lexar"; break;
+                case 0x000074: mLabel = "Transcend"; break;
+                    // clang-format on
+            }
+            break;
+        }
+        default: {
+            if (isVirtioBlkDevice(majorId)) {
+                LOG(DEBUG) << "Recognized experimental block major ID " << majorId
+                           << " as virtio-blk (emulator's virtual SD card device)";
+                mLabel = "Virtual";
+                break;
+            }
+            if (isNvmeBlkDevice(majorId, mSysPath)) {
+                std::string path(mSysPath + "/device/model");
+                std::string tmp;
+                if (!ReadFileToString(path, &tmp)) {
+                    PLOG(WARNING) << "Failed to read vendor from " << path;
+                    return -errno;
+                }
+                mLabel = tmp;
+                break;
+            }
+            LOG(WARNING) << "Unsupported block major type " << majorId;
+            return -ENOTSUP;
+        }
     }
 
     auto listener = VolumeManager::Instance()->getListener();
-    if (listener) listener->onDiskMetadataChanged(getId(),
-            mSize, mLabel, mSysPath);
+    if (listener) listener->onDiskMetadataChanged(getId(), mSize, mLabel, mSysPath);
 
     return OK;
 }
@@ -563,45 +570,49 @@
     // Figure out maximum partition devices supported
     unsigned int majorId = major(mDevice);
     switch (majorId) {
-    case kMajorBlockLoop: {
-        std::string tmp;
-        if (!ReadFileToString(kSysfsLoopMaxMinors, &tmp)) {
-            LOG(ERROR) << "Failed to read max minors";
-            return -errno;
+        case kMajorBlockLoop: {
+            std::string tmp;
+            if (!ReadFileToString(kSysfsLoopMaxMinors, &tmp)) {
+                LOG(ERROR) << "Failed to read max minors";
+                return -errno;
+            }
+            return std::stoi(tmp);
         }
-        return std::stoi(tmp);
-    }
-    case kMajorBlockScsiA: case kMajorBlockScsiB: case kMajorBlockScsiC: case kMajorBlockScsiD:
-    case kMajorBlockScsiE: case kMajorBlockScsiF: case kMajorBlockScsiG: case kMajorBlockScsiH:
-    case kMajorBlockScsiI: case kMajorBlockScsiJ: case kMajorBlockScsiK: case kMajorBlockScsiL:
-    case kMajorBlockScsiM: case kMajorBlockScsiN: case kMajorBlockScsiO: case kMajorBlockScsiP: {
-        // Per Documentation/devices.txt this is static
-        return 15;
-    }
-    case kMajorBlockMmc: {
-        // Per Documentation/devices.txt this is dynamic
-        std::string tmp;
-        if (!ReadFileToString(kSysfsMmcMaxMinors, &tmp) &&
-                !ReadFileToString(kSysfsMmcMaxMinorsDeprecated, &tmp)) {
-            LOG(ERROR) << "Failed to read max minors";
-            return -errno;
-        }
-        return std::stoi(tmp);
-    }
-    default: {
-        if (isVirtioBlkDevice(majorId)) {
-            // drivers/block/virtio_blk.c has "#define PART_BITS 4", so max is
-            // 2^4 - 1 = 15
+        // clang-format off
+        case kMajorBlockScsiA: case kMajorBlockScsiB: case kMajorBlockScsiC:
+        case kMajorBlockScsiD: case kMajorBlockScsiE: case kMajorBlockScsiF:
+        case kMajorBlockScsiG: case kMajorBlockScsiH: case kMajorBlockScsiI:
+        case kMajorBlockScsiJ: case kMajorBlockScsiK: case kMajorBlockScsiL:
+        case kMajorBlockScsiM: case kMajorBlockScsiN: case kMajorBlockScsiO:
+        case kMajorBlockScsiP: {
+            // clang-format on
+            // Per Documentation/devices.txt this is static
             return 15;
         }
-        if (isNvmeBlkDevice(majorId, mSysPath)) {
-            // despite kernel nvme driver supports up to 1M minors,
-            //     #define NVME_MINORS (1U << MINORBITS)
-            // sgdisk can not support more than 127 partitions, due to
-            //     #define MAX_MBR_PARTS 128
-            return 127;
+        case kMajorBlockMmc: {
+            // Per Documentation/devices.txt this is dynamic
+            std::string tmp;
+            if (!ReadFileToString(kSysfsMmcMaxMinors, &tmp) &&
+                !ReadFileToString(kSysfsMmcMaxMinorsDeprecated, &tmp)) {
+                LOG(ERROR) << "Failed to read max minors";
+                return -errno;
+            }
+            return std::stoi(tmp);
         }
-    }
+        default: {
+            if (isVirtioBlkDevice(majorId)) {
+                // drivers/block/virtio_blk.c has "#define PART_BITS 4", so max is
+                // 2^4 - 1 = 15
+                return 15;
+            }
+            if (isNvmeBlkDevice(majorId, mSysPath)) {
+                // despite kernel nvme driver supports up to 1M minors,
+                //     #define NVME_MINORS (1U << MINORBITS)
+                // sgdisk can not support more than 127 partitions, due to
+                //     #define MAX_MBR_PARTS 128
+                return 127;
+            }
+        }
     }
 
     LOG(ERROR) << "Unsupported block major type " << majorId;
diff --git a/model/Disk.h b/model/Disk.h
index 63acf6a..3140144 100644
--- a/model/Disk.h
+++ b/model/Disk.h
@@ -36,7 +36,7 @@
  * how to repartition itself.
  */
 class Disk {
-public:
+  public:
     Disk(const std::string& eventPath, dev_t device, const std::string& nickname, int flags);
     virtual ~Disk();
 
@@ -79,7 +79,7 @@
     status_t partitionPrivate();
     status_t partitionMixed(int8_t ratio);
 
-private:
+  private:
     /* ID that uniquely references this disk */
     std::string mId;
     /* Original event path */
diff --git a/model/EmulatedVolume.h b/model/EmulatedVolume.h
index 9b0c049..f618c55 100644
--- a/model/EmulatedVolume.h
+++ b/model/EmulatedVolume.h
@@ -36,16 +36,16 @@
  * store data local to their app.
  */
 class EmulatedVolume : public VolumeBase {
-public:
+  public:
     explicit EmulatedVolume(const std::string& rawPath);
     EmulatedVolume(const std::string& rawPath, dev_t device, const std::string& fsUuid);
     virtual ~EmulatedVolume();
 
-protected:
+  protected:
     status_t doMount() override;
     status_t doUnmount() override;
 
-private:
+  private:
     std::string mRawPath;
     std::string mLabel;
 
diff --git a/model/ObbVolume.cpp b/model/ObbVolume.cpp
index 709c7a3..ec3d267 100644
--- a/model/ObbVolume.cpp
+++ b/model/ObbVolume.cpp
@@ -14,12 +14,12 @@
  * limitations under the License.
  */
 
-#include "fs/Vfat.h"
+#include "ObbVolume.h"
 #include "Devmapper.h"
 #include "Loop.h"
-#include "ObbVolume.h"
 #include "Utils.h"
 #include "VoldUtil.h"
+#include "fs/Vfat.h"
 
 #include <android-base/logging.h>
 #include <android-base/stringprintf.h>
@@ -31,8 +31,8 @@
 #include <stdlib.h>
 #include <sys/mount.h>
 #include <sys/stat.h>
-#include <sys/types.h>
 #include <sys/sysmacros.h>
+#include <sys/types.h>
 #include <sys/wait.h>
 
 using android::base::StringPrintf;
@@ -42,15 +42,15 @@
 namespace vold {
 
 ObbVolume::ObbVolume(int id, const std::string& sourcePath, const std::string& sourceKey,
-        gid_t ownerGid) : VolumeBase(Type::kObb) {
+                     gid_t ownerGid)
+    : VolumeBase(Type::kObb) {
     setId(StringPrintf("obb:%d", id));
     mSourcePath = sourcePath;
     mSourceKey = sourceKey;
     mOwnerGid = ownerGid;
 }
 
-ObbVolume::~ObbVolume() {
-}
+ObbVolume::~ObbVolume() {}
 
 status_t ObbVolume::doCreate() {
     if (Loop::create(mSourcePath, mLoopPath)) {
@@ -75,8 +75,8 @@
         }
 
         char tmp[PATH_MAX];
-        if (Devmapper::create(getId().c_str(), mLoopPath.c_str(), mSourceKey.c_str(), nr_sec,
-                tmp, PATH_MAX)) {
+        if (Devmapper::create(getId().c_str(), mLoopPath.c_str(), mSourceKey.c_str(), nr_sec, tmp,
+                              PATH_MAX)) {
             PLOG(ERROR) << getId() << " failed to create dm";
             return -1;
         }
@@ -108,8 +108,10 @@
         PLOG(ERROR) << getId() << " failed to create mount point";
         return -1;
     }
-    if (android::vold::vfat::Mount(mMountPath, path,
-            true, false, true, 0, mOwnerGid, 0227, false)) {
+    // clang-format off
+    if (android::vold::vfat::Mount(mMountPath, path, true, false, true,
+                                   0, mOwnerGid, 0227, false)) {
+        // clang-format on
         PLOG(ERROR) << getId() << " failed to mount";
         return -1;
     }
diff --git a/model/ObbVolume.h b/model/ObbVolume.h
index 5ec0cde..8f7ee94 100644
--- a/model/ObbVolume.h
+++ b/model/ObbVolume.h
@@ -28,18 +28,17 @@
  * OBB container.
  */
 class ObbVolume : public VolumeBase {
-public:
-    ObbVolume(int id, const std::string& sourcePath, const std::string& sourceKey,
-            gid_t ownerGid);
+  public:
+    ObbVolume(int id, const std::string& sourcePath, const std::string& sourceKey, gid_t ownerGid);
     virtual ~ObbVolume();
 
-protected:
+  protected:
     status_t doCreate() override;
     status_t doDestroy() override;
     status_t doMount() override;
     status_t doUnmount() override;
 
-private:
+  private:
     std::string mSourcePath;
     std::string mSourceKey;
     gid_t mOwnerGid;
diff --git a/model/PrivateVolume.cpp b/model/PrivateVolume.cpp
index cf21577..de2a09f 100644
--- a/model/PrivateVolume.cpp
+++ b/model/PrivateVolume.cpp
@@ -14,27 +14,27 @@
  * limitations under the License.
  */
 
-#include "fs/Ext4.h"
-#include "fs/F2fs.h"
 #include "PrivateVolume.h"
 #include "EmulatedVolume.h"
 #include "Utils.h"
 #include "VolumeManager.h"
 #include "cryptfs.h"
+#include "fs/Ext4.h"
+#include "fs/F2fs.h"
 
-#include <android-base/stringprintf.h>
 #include <android-base/logging.h>
+#include <android-base/stringprintf.h>
 #include <cutils/fs.h>
 #include <private/android_filesystem_config.h>
 
 #include <fcntl.h>
 #include <stdlib.h>
 #include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/sysmacros.h>
-#include <sys/wait.h>
 #include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 
 using android::base::StringPrintf;
 
@@ -43,14 +43,13 @@
 
 static const unsigned int kMajorBlockMmc = 179;
 
-PrivateVolume::PrivateVolume(dev_t device, const std::string& keyRaw) :
-        VolumeBase(Type::kPrivate), mRawDevice(device), mKeyRaw(keyRaw) {
+PrivateVolume::PrivateVolume(dev_t device, const std::string& keyRaw)
+    : VolumeBase(Type::kPrivate), mRawDevice(device), mKeyRaw(keyRaw) {
     setId(StringPrintf("private:%u,%u", major(device), minor(device)));
     mRawDevPath = StringPrintf("/dev/block/vold/%s", getId().c_str());
 }
 
-PrivateVolume::~PrivateVolume() {
-}
+PrivateVolume::~PrivateVolume() {}
 
 status_t PrivateVolume::readMetadata() {
     status_t res = ReadMetadata(mDmDevPath, &mFsType, &mFsUuid, &mFsLabel);
@@ -66,9 +65,9 @@
         return -EIO;
     }
     if (mKeyRaw.size() != cryptfs_get_keysize()) {
-      PLOG(ERROR) << getId() << " Raw keysize " << mKeyRaw.size() <<
-          " does not match crypt keysize " << cryptfs_get_keysize();
-      return -EIO;
+        PLOG(ERROR) << getId() << " Raw keysize " << mKeyRaw.size()
+                    << " does not match crypt keysize " << cryptfs_get_keysize();
+        return -EIO;
     }
 
     // Recover from stale vold by tearing down any old mappings
@@ -76,10 +75,9 @@
 
     // TODO: figure out better SELinux labels for private volumes
 
-    unsigned char* key = (unsigned char*) mKeyRaw.data();
+    unsigned char* key = (unsigned char*)mKeyRaw.data();
     char crypto_blkdev[MAXPATHLEN];
-    int res = cryptfs_setup_ext_volume(getId().c_str(), mRawDevPath.c_str(),
-            key, crypto_blkdev);
+    int res = cryptfs_setup_ext_volume(getId().c_str(), mRawDevPath.c_str(), key, crypto_blkdev);
     mDmDevPath = crypto_blkdev;
     if (res != 0) {
         PLOG(ERROR) << getId() << " failed to setup cryptfs";
@@ -147,12 +145,12 @@
 
     // Verify that common directories are ready to roll
     if (PrepareDir(mPath + "/app", 0771, AID_SYSTEM, AID_SYSTEM) ||
-            PrepareDir(mPath + "/user", 0711, AID_SYSTEM, AID_SYSTEM) ||
-            PrepareDir(mPath + "/user_de", 0711, AID_SYSTEM, AID_SYSTEM) ||
-            PrepareDir(mPath + "/media", 0770, AID_MEDIA_RW, AID_MEDIA_RW) ||
-            PrepareDir(mPath + "/media/0", 0770, AID_MEDIA_RW, AID_MEDIA_RW) ||
-            PrepareDir(mPath + "/local", 0751, AID_ROOT, AID_ROOT) ||
-            PrepareDir(mPath + "/local/tmp", 0771, AID_SHELL, AID_SHELL)) {
+        PrepareDir(mPath + "/user", 0711, AID_SYSTEM, AID_SYSTEM) ||
+        PrepareDir(mPath + "/user_de", 0711, AID_SYSTEM, AID_SYSTEM) ||
+        PrepareDir(mPath + "/media", 0770, AID_MEDIA_RW, AID_MEDIA_RW) ||
+        PrepareDir(mPath + "/media/0", 0770, AID_MEDIA_RW, AID_MEDIA_RW) ||
+        PrepareDir(mPath + "/local", 0751, AID_ROOT, AID_ROOT) ||
+        PrepareDir(mPath + "/local/tmp", 0771, AID_SHELL, AID_SHELL)) {
         PLOG(ERROR) << getId() << " failed to prepare";
         return -EIO;
     }
@@ -160,8 +158,7 @@
     // Create a new emulated volume stacked above us, it will automatically
     // be destroyed during unmount
     std::string mediaPath(mPath + "/media");
-    auto vol = std::shared_ptr<VolumeBase>(
-            new EmulatedVolume(mediaPath, mRawDevice, mFsUuid));
+    auto vol = std::shared_ptr<VolumeBase>(new EmulatedVolume(mediaPath, mRawDevice, mFsUuid));
     addVolume(vol);
     vol->create();
 
diff --git a/model/PrivateVolume.h b/model/PrivateVolume.h
index 9a61f8d..85aa4dc 100644
--- a/model/PrivateVolume.h
+++ b/model/PrivateVolume.h
@@ -36,14 +36,14 @@
  * keys are tightly tied to this device.
  */
 class PrivateVolume : public VolumeBase {
-public:
+  public:
     PrivateVolume(dev_t device, const std::string& keyRaw);
     virtual ~PrivateVolume();
     const std::string& getFsType() { return mFsType; };
     const std::string& getRawDevPath() { return mRawDevPath; };
     const std::string& getRawDmDevPath() { return mDmDevPath; };
 
-protected:
+  protected:
     status_t doCreate() override;
     status_t doDestroy() override;
     status_t doMount() override;
@@ -52,7 +52,7 @@
 
     status_t readMetadata();
 
-private:
+  private:
     /* Kernel device of raw, encrypted partition */
     dev_t mRawDevice;
     /* Path to raw, encrypted block device */
diff --git a/model/PublicVolume.h b/model/PublicVolume.h
index 3aa7a73..c918f52 100644
--- a/model/PublicVolume.h
+++ b/model/PublicVolume.h
@@ -38,11 +38,11 @@
  * away the Android directory for secondary users.
  */
 class PublicVolume : public VolumeBase {
-public:
+  public:
     explicit PublicVolume(dev_t device);
     virtual ~PublicVolume();
 
-protected:
+  protected:
     status_t doCreate() override;
     status_t doDestroy() override;
     status_t doMount() override;
@@ -52,7 +52,7 @@
     status_t readMetadata();
     status_t initAsecStage();
 
-private:
+  private:
     /* Kernel device representing partition */
     dev_t mDevice;
     /* Block device path */