clang-format the rest of the files
Apply clang-format to fix the remaining files not fixed by
change I23cde3f0bbcac13bef555d13514e922c79d5ad48
Test: Format-only changes; treehugger suffices.
Change-Id: I1bfd5c8d68d298596875d5edae26cdfe27c03489
Merged-In: I1bfd5c8d68d298596875d5edae26cdfe27c03489
diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp
index 81523c6..1a15304 100644
--- a/VoldNativeService.cpp
+++ b/VoldNativeService.cpp
@@ -24,9 +24,9 @@
#include "Process.h"
#include "VolumeManager.h"
-#include "cryptfs.h"
#include "Ext4Crypt.h"
#include "MetadataCrypt.h"
+#include "cryptfs.h"
#include <fstream>
#include <thread>
@@ -83,11 +83,11 @@
uid_t uid;
if (checkCallingPermission(String16(permission), reinterpret_cast<int32_t*>(&pid),
- reinterpret_cast<int32_t*>(&uid))) {
+ reinterpret_cast<int32_t*>(&uid))) {
return ok();
} else {
return exception(binder::Status::EX_SECURITY,
- StringPrintf("UID %d / PID %d lacks permission %s", uid, pid, permission));
+ StringPrintf("UID %d / PID %d lacks permission %s", uid, pid, permission));
}
}
@@ -97,7 +97,7 @@
return ok();
} else {
return exception(binder::Status::EX_SECURITY,
- StringPrintf("UID %d is not expected UID %d", uid, expectedUid));
+ StringPrintf("UID %d is not expected UID %d", uid, expectedUid));
}
}
@@ -108,7 +108,7 @@
for (const char& c : id) {
if (!std::isalnum(c) && c != ':' && c != ',') {
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
- StringPrintf("ID %s is malformed", id.c_str()));
+ StringPrintf("ID %s is malformed", id.c_str()));
}
}
return ok();
@@ -120,16 +120,16 @@
}
if (path[0] != '/') {
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
- StringPrintf("Path %s is relative", path.c_str()));
+ StringPrintf("Path %s is relative", path.c_str()));
}
if ((path + '/').find("/../") != std::string::npos) {
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
- StringPrintf("Path %s is shady", path.c_str()));
+ StringPrintf("Path %s is shady", path.c_str()));
}
for (const char& c : path) {
if (c == '\0' || c == '\n') {
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
- StringPrintf("Path %s is malformed", path.c_str()));
+ StringPrintf("Path %s is malformed", path.c_str()));
}
}
return ok();
@@ -140,45 +140,49 @@
for (const char& c : hex) {
if (!std::isxdigit(c) && c != ':' && c != '-') {
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
- StringPrintf("Hex %s is malformed", hex.c_str()));
+ StringPrintf("Hex %s is malformed", hex.c_str()));
}
}
return ok();
}
-#define ENFORCE_UID(uid) { \
- binder::Status status = checkUid((uid)); \
- if (!status.isOk()) { \
- return status; \
- } \
-}
+#define ENFORCE_UID(uid) \
+ { \
+ binder::Status status = checkUid((uid)); \
+ if (!status.isOk()) { \
+ return status; \
+ } \
+ }
-#define CHECK_ARGUMENT_ID(id) { \
- binder::Status status = checkArgumentId((id)); \
- if (!status.isOk()) { \
- return status; \
- } \
-}
+#define CHECK_ARGUMENT_ID(id) \
+ { \
+ binder::Status status = checkArgumentId((id)); \
+ if (!status.isOk()) { \
+ return status; \
+ } \
+ }
-#define CHECK_ARGUMENT_PATH(path) { \
- binder::Status status = checkArgumentPath((path)); \
- if (!status.isOk()) { \
- return status; \
- } \
-}
+#define CHECK_ARGUMENT_PATH(path) \
+ { \
+ binder::Status status = checkArgumentPath((path)); \
+ if (!status.isOk()) { \
+ return status; \
+ } \
+ }
-#define CHECK_ARGUMENT_HEX(hex) { \
- binder::Status status = checkArgumentHex((hex)); \
- if (!status.isOk()) { \
- return status; \
- } \
-}
+#define CHECK_ARGUMENT_HEX(hex) \
+ { \
+ binder::Status status = checkArgumentHex((hex)); \
+ if (!status.isOk()) { \
+ return status; \
+ } \
+ }
-#define ACQUIRE_LOCK \
+#define ACQUIRE_LOCK \
std::lock_guard<std::mutex> lock(VolumeManager::Instance()->getLock()); \
ATRACE_CALL();
-#define ACQUIRE_CRYPT_LOCK \
+#define ACQUIRE_CRYPT_LOCK \
std::lock_guard<std::mutex> lock(VolumeManager::Instance()->getCryptLock()); \
ATRACE_CALL();
@@ -196,7 +200,7 @@
return android::OK;
}
-status_t VoldNativeService::dump(int fd, const Vector<String16> & /* args */) {
+status_t VoldNativeService::dump(int fd, const Vector<String16>& /* args */) {
auto out = std::fstream(StringPrintf("/proc/self/fd/%d", fd));
const binder::Status dump_permission = checkPermission(kDump);
if (!dump_permission.isOk()) {
@@ -211,7 +215,7 @@
}
binder::Status VoldNativeService::setListener(
- const android::sp<android::os::IVoldListener>& listener) {
+ const android::sp<android::os::IVoldListener>& listener) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_LOCK;
@@ -223,12 +227,8 @@
ENFORCE_UID(AID_SYSTEM);
// Simply acquire/release each lock for watchdog
- {
- ACQUIRE_LOCK;
- }
- {
- ACQUIRE_CRYPT_LOCK;
- }
+ { ACQUIRE_LOCK; }
+ { ACQUIRE_CRYPT_LOCK; }
return ok();
}
@@ -283,7 +283,7 @@
}
binder::Status VoldNativeService::partition(const std::string& diskId, int32_t partitionType,
- int32_t ratio) {
+ int32_t ratio) {
ENFORCE_UID(AID_SYSTEM);
CHECK_ARGUMENT_ID(diskId);
ACQUIRE_LOCK;
@@ -293,15 +293,19 @@
return error("Failed to find disk " + diskId);
}
switch (partitionType) {
- case PARTITION_TYPE_PUBLIC: return translate(disk->partitionPublic());
- case PARTITION_TYPE_PRIVATE: return translate(disk->partitionPrivate());
- case PARTITION_TYPE_MIXED: return translate(disk->partitionMixed(ratio));
- default: return error("Unknown type " + std::to_string(partitionType));
+ case PARTITION_TYPE_PUBLIC:
+ return translate(disk->partitionPublic());
+ case PARTITION_TYPE_PRIVATE:
+ return translate(disk->partitionPrivate());
+ case PARTITION_TYPE_MIXED:
+ return translate(disk->partitionMixed(ratio));
+ default:
+ return error("Unknown type " + std::to_string(partitionType));
}
}
binder::Status VoldNativeService::forgetPartition(const std::string& partGuid,
- const std::string& fsUuid) {
+ const std::string& fsUuid) {
ENFORCE_UID(AID_SYSTEM);
CHECK_ARGUMENT_HEX(partGuid);
CHECK_ARGUMENT_HEX(fsUuid);
@@ -311,7 +315,7 @@
}
binder::Status VoldNativeService::mount(const std::string& volId, int32_t mountFlags,
- int32_t mountUserId) {
+ int32_t mountUserId) {
ENFORCE_UID(AID_SYSTEM);
CHECK_ARGUMENT_ID(volId);
ACQUIRE_LOCK;
@@ -387,9 +391,7 @@
auto status = pathForVolId(volId, &path);
if (!status.isOk()) return status;
- std::thread([=]() {
- android::vold::Benchmark(path, listener);
- }).detach();
+ std::thread([=]() { android::vold::Benchmark(path, listener); }).detach();
return ok();
}
@@ -404,8 +406,9 @@
return translate(android::vold::CheckEncryption(path));
}
-binder::Status VoldNativeService::moveStorage(const std::string& fromVolId,
- const std::string& toVolId, const android::sp<android::os::IVoldTaskListener>& listener) {
+binder::Status VoldNativeService::moveStorage(
+ const std::string& fromVolId, const std::string& toVolId,
+ const android::sp<android::os::IVoldTaskListener>& listener) {
ENFORCE_UID(AID_SYSTEM);
CHECK_ARGUMENT_ID(fromVolId);
CHECK_ARGUMENT_ID(toVolId);
@@ -419,9 +422,7 @@
return error("Failed to find volume " + toVolId);
}
- std::thread([=]() {
- android::vold::MoveStorage(fromVol, toVol, listener);
- }).detach();
+ std::thread([=]() { android::vold::MoveStorage(fromVol, toVol, listener); }).detach();
return ok();
}
@@ -431,11 +432,20 @@
std::string tmp;
switch (remountMode) {
- case REMOUNT_MODE_NONE: tmp = "none"; break;
- case REMOUNT_MODE_DEFAULT: tmp = "default"; break;
- case REMOUNT_MODE_READ: tmp = "read"; break;
- case REMOUNT_MODE_WRITE: tmp = "write"; break;
- default: return error("Unknown mode " + std::to_string(remountMode));
+ case REMOUNT_MODE_NONE:
+ tmp = "none";
+ break;
+ case REMOUNT_MODE_DEFAULT:
+ tmp = "default";
+ break;
+ case REMOUNT_MODE_READ:
+ tmp = "read";
+ break;
+ case REMOUNT_MODE_WRITE:
+ tmp = "write";
+ break;
+ default:
+ return error("Unknown mode " + std::to_string(remountMode));
}
return translate(VolumeManager::Instance()->remountUid(uid, tmp));
}
@@ -449,14 +459,15 @@
}
binder::Status VoldNativeService::createObb(const std::string& sourcePath,
- const std::string& sourceKey, int32_t ownerGid, std::string* _aidl_return) {
+ const std::string& sourceKey, int32_t ownerGid,
+ std::string* _aidl_return) {
ENFORCE_UID(AID_SYSTEM);
CHECK_ARGUMENT_PATH(sourcePath);
CHECK_ARGUMENT_HEX(sourceKey);
ACQUIRE_LOCK;
return translate(
- VolumeManager::Instance()->createObb(sourcePath, sourceKey, ownerGid, _aidl_return));
+ VolumeManager::Instance()->createObb(sourcePath, sourceKey, ownerGid, _aidl_return));
}
binder::Status VoldNativeService::destroyObb(const std::string& volId) {
@@ -467,41 +478,35 @@
return translate(VolumeManager::Instance()->destroyObb(volId));
}
-binder::Status VoldNativeService::fstrim(int32_t fstrimFlags,
- const android::sp<android::os::IVoldTaskListener>& listener) {
+binder::Status VoldNativeService::fstrim(
+ int32_t fstrimFlags, const android::sp<android::os::IVoldTaskListener>& listener) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_LOCK;
- std::thread([=]() {
- android::vold::Trim(listener);
- }).detach();
+ std::thread([=]() { android::vold::Trim(listener); }).detach();
return ok();
}
binder::Status VoldNativeService::runIdleMaint(
- const android::sp<android::os::IVoldTaskListener>& listener) {
+ const android::sp<android::os::IVoldTaskListener>& listener) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_LOCK;
- std::thread([=]() {
- android::vold::RunIdleMaint(listener);
- }).detach();
+ std::thread([=]() { android::vold::RunIdleMaint(listener); }).detach();
return ok();
}
binder::Status VoldNativeService::abortIdleMaint(
- const android::sp<android::os::IVoldTaskListener>& listener) {
+ const android::sp<android::os::IVoldTaskListener>& listener) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_LOCK;
- std::thread([=]() {
- android::vold::AbortIdleMaint(listener);
- }).detach();
+ std::thread([=]() { android::vold::AbortIdleMaint(listener); }).detach();
return ok();
}
binder::Status VoldNativeService::mountAppFuse(int32_t uid, int32_t pid, int32_t mountId,
- android::base::unique_fd* _aidl_return) {
+ android::base::unique_fd* _aidl_return) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_LOCK;
@@ -541,7 +546,7 @@
}
static int fdeEnableInternal(int32_t passwordType, const std::string& password,
- int32_t encryptionFlags) {
+ int32_t encryptionFlags) {
bool noUi = (encryptionFlags & VoldNativeService::ENCRYPTION_FLAG_NO_UI) != 0;
for (int tries = 0; tries < 2; ++tries) {
@@ -562,8 +567,8 @@
return -1;
}
-binder::Status VoldNativeService::fdeEnable(int32_t passwordType,
- const std::string& password, int32_t encryptionFlags) {
+binder::Status VoldNativeService::fdeEnable(int32_t passwordType, const std::string& password,
+ int32_t encryptionFlags) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_CRYPT_LOCK;
@@ -581,7 +586,7 @@
}
binder::Status VoldNativeService::fdeChangePassword(int32_t passwordType,
- const std::string& password) {
+ const std::string& password) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_CRYPT_LOCK;
@@ -595,8 +600,7 @@
return translate(cryptfs_verify_passwd(password.c_str()));
}
-binder::Status VoldNativeService::fdeGetField(const std::string& key,
- std::string* _aidl_return) {
+binder::Status VoldNativeService::fdeGetField(const std::string& key, std::string* _aidl_return) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_CRYPT_LOCK;
@@ -609,8 +613,7 @@
}
}
-binder::Status VoldNativeService::fdeSetField(const std::string& key,
- const std::string& value) {
+binder::Status VoldNativeService::fdeSetField(const std::string& key, const std::string& value) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_CRYPT_LOCK;
@@ -692,8 +695,7 @@
return translateBool(e4crypt_mount_metadata_encrypted(mountPoint, true));
}
-binder::Status VoldNativeService::createUserKey(int32_t userId, int32_t userSerial,
- bool ephemeral) {
+binder::Status VoldNativeService::createUserKey(int32_t userId, int32_t userSerial, bool ephemeral) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_CRYPT_LOCK;
@@ -708,7 +710,8 @@
}
binder::Status VoldNativeService::addUserKeyAuth(int32_t userId, int32_t userSerial,
- const std::string& token, const std::string& secret) {
+ const std::string& token,
+ const std::string& secret) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_CRYPT_LOCK;
@@ -723,7 +726,8 @@
}
binder::Status VoldNativeService::unlockUserKey(int32_t userId, int32_t userSerial,
- const std::string& token, const std::string& secret) {
+ const std::string& token,
+ const std::string& secret) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_CRYPT_LOCK;
@@ -738,7 +742,8 @@
}
binder::Status VoldNativeService::prepareUserStorage(const std::unique_ptr<std::string>& uuid,
- int32_t userId, int32_t userSerial, int32_t flags) {
+ int32_t userId, int32_t userSerial,
+ int32_t flags) {
ENFORCE_UID(AID_SYSTEM);
std::string empty_string = "";
auto uuid_ = uuid ? *uuid : empty_string;
@@ -749,7 +754,7 @@
}
binder::Status VoldNativeService::destroyUserStorage(const std::unique_ptr<std::string>& uuid,
- int32_t userId, int32_t flags) {
+ int32_t userId, int32_t flags) {
ENFORCE_UID(AID_SYSTEM);
std::string empty_string = "";
auto uuid_ = uuid ? *uuid : empty_string;
diff --git a/VoldNativeService.h b/VoldNativeService.h
index 2e90101..0a080e1 100644
--- a/VoldNativeService.h
+++ b/VoldNativeService.h
@@ -26,10 +26,10 @@
namespace vold {
class VoldNativeService : public BinderService<VoldNativeService>, public os::BnVold {
-public:
+ public:
static status_t start();
static char const* getServiceName() { return "vold"; }
- virtual status_t dump(int fd, const Vector<String16> &args) override;
+ virtual status_t dump(int fd, const Vector<String16>& args) override;
binder::Status setListener(const android::sp<android::os::IVoldListener>& listener);
@@ -51,38 +51,35 @@
binder::Status unmount(const std::string& volId);
binder::Status format(const std::string& volId, const std::string& fsType);
binder::Status benchmark(const std::string& volId,
- const android::sp<android::os::IVoldTaskListener>& listener);
+ const android::sp<android::os::IVoldTaskListener>& listener);
binder::Status checkEncryption(const std::string& volId);
binder::Status moveStorage(const std::string& fromVolId, const std::string& toVolId,
- const android::sp<android::os::IVoldTaskListener>& listener);
+ const android::sp<android::os::IVoldTaskListener>& listener);
binder::Status remountUid(int32_t uid, int32_t remountMode);
binder::Status mkdirs(const std::string& path);
binder::Status createObb(const std::string& sourcePath, const std::string& sourceKey,
- int32_t ownerGid, std::string* _aidl_return);
+ int32_t ownerGid, std::string* _aidl_return);
binder::Status destroyObb(const std::string& volId);
binder::Status fstrim(int32_t fstrimFlags,
- const android::sp<android::os::IVoldTaskListener>& listener);
- binder::Status runIdleMaint(
- const android::sp<android::os::IVoldTaskListener>& listener);
- binder::Status abortIdleMaint(
- const android::sp<android::os::IVoldTaskListener>& listener);
+ const android::sp<android::os::IVoldTaskListener>& listener);
+ binder::Status runIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener);
+ binder::Status abortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener);
binder::Status mountAppFuse(int32_t uid, int32_t pid, int32_t mountId,
- android::base::unique_fd* _aidl_return);
+ android::base::unique_fd* _aidl_return);
binder::Status unmountAppFuse(int32_t uid, int32_t pid, int32_t mountId);
binder::Status fdeCheckPassword(const std::string& password);
binder::Status fdeRestart();
binder::Status fdeComplete(int32_t* _aidl_return);
- binder::Status fdeEnable(int32_t passwordType,
- const std::string& password, int32_t encryptionFlags);
- binder::Status fdeChangePassword(int32_t passwordType,
- const std::string& password);
+ binder::Status fdeEnable(int32_t passwordType, const std::string& password,
+ int32_t encryptionFlags);
+ binder::Status fdeChangePassword(int32_t passwordType, const std::string& password);
binder::Status fdeVerifyPassword(const std::string& password);
binder::Status fdeGetField(const std::string& key, std::string* _aidl_return);
binder::Status fdeSetField(const std::string& key, const std::string& value);
@@ -101,18 +98,18 @@
binder::Status createUserKey(int32_t userId, int32_t userSerial, bool ephemeral);
binder::Status destroyUserKey(int32_t userId);
- binder::Status addUserKeyAuth(int32_t userId, int32_t userSerial,
- const std::string& token, const std::string& secret);
+ binder::Status addUserKeyAuth(int32_t userId, int32_t userSerial, const std::string& token,
+ const std::string& secret);
binder::Status fixateNewestUserKeyAuth(int32_t userId);
- binder::Status unlockUserKey(int32_t userId, int32_t userSerial,
- const std::string& token, const std::string& secret);
+ binder::Status unlockUserKey(int32_t userId, int32_t userSerial, const std::string& token,
+ const std::string& secret);
binder::Status lockUserKey(int32_t userId);
- binder::Status prepareUserStorage(const std::unique_ptr<std::string>& uuid,
- int32_t userId, int32_t userSerial, int32_t flags);
- binder::Status destroyUserStorage(const std::unique_ptr<std::string>& uuid,
- int32_t userId, int32_t flags);
+ binder::Status prepareUserStorage(const std::unique_ptr<std::string>& uuid, int32_t userId,
+ int32_t userSerial, int32_t flags);
+ binder::Status destroyUserStorage(const std::unique_ptr<std::string>& uuid, int32_t userId,
+ int32_t flags);
};
} // namespace vold
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 21e132a..f0b742e 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -26,8 +26,8 @@
#include <sys/ioctl.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>
#include <unistd.h>
@@ -79,11 +79,10 @@
static const unsigned int kMajorBlockExperimentalMin = 240;
static const unsigned int kMajorBlockExperimentalMax = 254;
-VolumeManager *VolumeManager::sInstance = NULL;
+VolumeManager* VolumeManager::sInstance = NULL;
-VolumeManager *VolumeManager::Instance() {
- if (!sInstance)
- sInstance = new VolumeManager();
+VolumeManager* VolumeManager::Instance() {
+ if (!sInstance) sInstance = new VolumeManager();
return sInstance;
}
@@ -95,8 +94,7 @@
mSecureKeyguardShowing = true;
}
-VolumeManager::~VolumeManager() {
-}
+VolumeManager::~VolumeManager() {}
int VolumeManager::updateVirtualDisk() {
ATRACE_NAME("VolumeManager::updateVirtualDisk");
@@ -117,8 +115,9 @@
return -1;
}
- auto disk = new android::vold::Disk("virtual", buf.st_rdev, "virtual",
- android::vold::Disk::Flags::kAdoptable | android::vold::Disk::Flags::kSd);
+ auto disk = new android::vold::Disk(
+ "virtual", buf.st_rdev, "virtual",
+ android::vold::Disk::Flags::kAdoptable | android::vold::Disk::Flags::kSd);
mVirtualDisk = std::shared_ptr<android::vold::Disk>(disk);
handleDiskAdded(mVirtualDisk);
}
@@ -157,7 +156,7 @@
// storage; the framework will decide if it should be mounted.
CHECK(mInternalEmulated == nullptr);
mInternalEmulated = std::shared_ptr<android::vold::VolumeBase>(
- new android::vold::EmulatedVolume("/data/media"));
+ new android::vold::EmulatedVolume("/data/media"));
mInternalEmulated->create();
// Consider creating a virtual disk
@@ -173,17 +172,17 @@
return 0;
}
-void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {
+void VolumeManager::handleBlockEvent(NetlinkEvent* evt) {
std::lock_guard<std::mutex> lock(mLock);
if (mDebug) {
LOG(VERBOSE) << "----------------";
- LOG(VERBOSE) << "handleBlockEvent with action " << (int) evt->getAction();
+ LOG(VERBOSE) << "handleBlockEvent with action " << (int)evt->getAction();
evt->dump();
}
- std::string eventPath(evt->findParam("DEVPATH")?evt->findParam("DEVPATH"):"");
- std::string devType(evt->findParam("DEVTYPE")?evt->findParam("DEVTYPE"):"");
+ std::string eventPath(evt->findParam("DEVPATH") ? evt->findParam("DEVPATH") : "");
+ std::string devType(evt->findParam("DEVTYPE") ? evt->findParam("DEVTYPE") : "");
if (devType != "disk") return;
@@ -192,43 +191,42 @@
dev_t device = makedev(major, minor);
switch (evt->getAction()) {
- case NetlinkEvent::Action::kAdd: {
- for (const auto& source : mDiskSources) {
- if (source->matches(eventPath)) {
- // For now, assume that MMC and virtio-blk (the latter is
- // emulator-specific; see Disk.cpp for details) devices are SD,
- // and that everything else is USB
- int flags = source->getFlags();
- if (major == kMajorBlockMmc
- || (android::vold::IsRunningInEmulator()
- && major >= (int) kMajorBlockExperimentalMin
- && major <= (int) kMajorBlockExperimentalMax)) {
- flags |= android::vold::Disk::Flags::kSd;
- } else {
- flags |= android::vold::Disk::Flags::kUsb;
- }
+ case NetlinkEvent::Action::kAdd: {
+ for (const auto& source : mDiskSources) {
+ if (source->matches(eventPath)) {
+ // For now, assume that MMC and virtio-blk (the latter is
+ // emulator-specific; see Disk.cpp for details) devices are SD,
+ // and that everything else is USB
+ int flags = source->getFlags();
+ if (major == kMajorBlockMmc || (android::vold::IsRunningInEmulator() &&
+ major >= (int)kMajorBlockExperimentalMin &&
+ major <= (int)kMajorBlockExperimentalMax)) {
+ flags |= android::vold::Disk::Flags::kSd;
+ } else {
+ flags |= android::vold::Disk::Flags::kUsb;
+ }
- auto disk = new android::vold::Disk(eventPath, device,
- source->getNickname(), flags);
- handleDiskAdded(std::shared_ptr<android::vold::Disk>(disk));
- break;
+ auto disk =
+ new android::vold::Disk(eventPath, device, source->getNickname(), flags);
+ handleDiskAdded(std::shared_ptr<android::vold::Disk>(disk));
+ break;
+ }
}
+ break;
}
- break;
- }
- case NetlinkEvent::Action::kChange: {
- LOG(DEBUG) << "Disk at " << major << ":" << minor << " changed";
- handleDiskChanged(device);
- break;
- }
- case NetlinkEvent::Action::kRemove: {
- handleDiskRemoved(device);
- break;
- }
- default: {
- LOG(WARNING) << "Unexpected block event action " << (int) evt->getAction();
- break;
- }
+ case NetlinkEvent::Action::kChange: {
+ LOG(DEBUG) << "Disk at " << major << ":" << minor << " changed";
+ handleDiskChanged(device);
+ break;
+ }
+ case NetlinkEvent::Action::kRemove: {
+ handleDiskRemoved(device);
+ break;
+ }
+ default: {
+ LOG(WARNING) << "Unexpected block event action " << (int)evt->getAction();
+ break;
+ }
}
}
@@ -237,7 +235,7 @@
// until the user unlocks the device to actually touch it
if (mSecureKeyguardShowing) {
LOG(INFO) << "Found disk at " << disk->getEventPath()
- << " but delaying scan due to secure keyguard";
+ << " but delaying scan due to secure keyguard";
mPendingDisks.push_back(disk);
} else {
disk->create();
@@ -312,8 +310,7 @@
return nullptr;
}
-void VolumeManager::listVolumes(android::vold::VolumeBase::Type type,
- std::list<std::string>& list) {
+void VolumeManager::listVolumes(android::vold::VolumeBase::Type type, std::list<std::string>& list) {
list.clear();
for (const auto& disk : mDisks) {
disk->listVolumes(type, list);
@@ -497,7 +494,7 @@
}
// We purposefully leave the namespace open across the fork
- nsFd = openat(pidFd, "ns/mnt", O_RDONLY); // not O_CLOEXEC
+ nsFd = openat(pidFd, "ns/mnt", O_RDONLY); // not O_CLOEXEC
if (nsFd < 0) {
PLOG(WARNING) << "Failed to open namespace for " << de->d_name;
goto next;
@@ -522,26 +519,22 @@
// Sane default of no storage visible
_exit(0);
}
- if (TEMP_FAILURE_RETRY(mount(storageSource.c_str(), "/storage",
- NULL, MS_BIND | MS_REC, NULL)) == -1) {
- PLOG(ERROR) << "Failed to mount " << storageSource << " for "
- << de->d_name;
+ if (TEMP_FAILURE_RETRY(
+ mount(storageSource.c_str(), "/storage", NULL, MS_BIND | MS_REC, NULL)) == -1) {
+ PLOG(ERROR) << "Failed to mount " << storageSource << " for " << de->d_name;
_exit(1);
}
- if (TEMP_FAILURE_RETRY(mount(NULL, "/storage", NULL,
- MS_REC | MS_SLAVE, NULL)) == -1) {
- PLOG(ERROR) << "Failed to set MS_SLAVE to /storage for "
- << de->d_name;
+ if (TEMP_FAILURE_RETRY(mount(NULL, "/storage", NULL, MS_REC | MS_SLAVE, NULL)) == -1) {
+ PLOG(ERROR) << "Failed to set MS_SLAVE to /storage for " << de->d_name;
_exit(1);
}
// Mount user-specific symlink helper into place
userid_t user_id = multiuser_get_user_id(uid);
std::string userSource(StringPrintf("/mnt/user/%d", user_id));
- if (TEMP_FAILURE_RETRY(mount(userSource.c_str(), "/storage/self",
- NULL, MS_BIND, NULL)) == -1) {
- PLOG(ERROR) << "Failed to mount " << userSource << " for "
- << de->d_name;
+ if (TEMP_FAILURE_RETRY(
+ mount(userSource.c_str(), "/storage/self", NULL, MS_BIND, NULL)) == -1) {
+ PLOG(ERROR) << "Failed to mount " << userSource << " for " << de->d_name;
_exit(1);
}
@@ -555,7 +548,7 @@
TEMP_FAILURE_RETRY(waitpid(child, nullptr, 0));
}
-next:
+ next:
close(nsFd);
close(pidFd);
}
@@ -583,7 +576,7 @@
// Can be called twice (sequentially) during shutdown. should be safe for that.
int VolumeManager::shutdown() {
if (mInternalEmulated == nullptr) {
- return 0; // already shutdown
+ return 0; // already shutdown
}
android::vold::sSleepOnUnmount = false;
mInternalEmulated->destroy();
@@ -673,20 +666,18 @@
android::vold::ForceUnmount(path);
const auto opts = android::base::StringPrintf(
- "fd=%i,"
- "rootmode=40000,"
- "default_permissions,"
- "allow_other,"
- "user_id=%d,group_id=%d,"
- "context=\"u:object_r:app_fuse_file:s0\","
- "fscontext=u:object_r:app_fusefs:s0",
- device_fd,
- uid,
- uid);
+ "fd=%i,"
+ "rootmode=40000,"
+ "default_permissions,"
+ "allow_other,"
+ "user_id=%d,group_id=%d,"
+ "context=\"u:object_r:app_fuse_file:s0\","
+ "fscontext=u:object_r:app_fusefs:s0",
+ device_fd, uid, uid);
- const int result = TEMP_FAILURE_RETRY(mount(
- "/dev/fuse", path.c_str(), "fuse",
- MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_NOATIME, opts.c_str()));
+ const int result =
+ TEMP_FAILURE_RETRY(mount("/dev/fuse", path.c_str(), "fuse",
+ MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_NOATIME, opts.c_str()));
if (result != 0) {
PLOG(ERROR) << "Failed to mount " << path;
return -errno;
@@ -695,11 +686,8 @@
return android::OK;
}
-static android::status_t runCommandInNamespace(const std::string& command,
- uid_t uid,
- pid_t pid,
- const std::string& path,
- int device_fd) {
+static android::status_t runCommandInNamespace(const std::string& command, uid_t uid, pid_t pid,
+ const std::string& path, int device_fd) {
if (DEBUG_APPFUSE) {
LOG(DEBUG) << "Run app fuse command " << command << " for the path " << path
<< " in namespace " << uid;
@@ -713,8 +701,7 @@
// Obtains process file descriptor.
const std::string pid_str = android::base::StringPrintf("%d", pid);
- const unique_fd pid_fd(
- openat(dir.get(), pid_str.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC));
+ const unique_fd pid_fd(openat(dir.get(), pid_str.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC));
if (pid_fd.get() == -1) {
PLOG(ERROR) << "Failed to open /proc/" << pid;
return -errno;
@@ -730,7 +717,7 @@
}
if (sb.st_uid != AID_SYSTEM) {
LOG(ERROR) << "Only system can mount appfuse. UID expected=" << AID_SYSTEM
- << ", actual=" << sb.st_uid;
+ << ", actual=" << sb.st_uid;
return -EPERM;
}
}
@@ -739,8 +726,8 @@
{
std::string rootName;
std::string pidName;
- if (!android::vold::Readlinkat(dir.get(), "1/ns/mnt", &rootName)
- || !android::vold::Readlinkat(pid_fd.get(), "ns/mnt", &pidName)) {
+ if (!android::vold::Readlinkat(dir.get(), "1/ns/mnt", &rootName) ||
+ !android::vold::Readlinkat(pid_fd.get(), "ns/mnt", &pidName)) {
PLOG(ERROR) << "Failed to read namespaces";
return -EPERM;
}
@@ -751,7 +738,7 @@
}
// We purposefully leave the namespace open across the fork
- unique_fd ns_fd(openat(pid_fd.get(), "ns/mnt", O_RDONLY)); // not O_CLOEXEC
+ unique_fd ns_fd(openat(pid_fd.get(), "ns/mnt", O_RDONLY)); // not O_CLOEXEC
if (ns_fd.get() < 0) {
PLOG(ERROR) << "Failed to open namespace for /proc/" << pid << "/ns/mnt";
return -errno;
@@ -769,8 +756,8 @@
} else if (command == "unmount") {
// If it's just after all FD opened on mount point are closed, umount2 can fail with
// EBUSY. To avoid the case, specify MNT_DETACH.
- if (umount2(path.c_str(), UMOUNT_NOFOLLOW | MNT_DETACH) != 0 &&
- errno != EINVAL && errno != ENOENT) {
+ if (umount2(path.c_str(), UMOUNT_NOFOLLOW | MNT_DETACH) != 0 && errno != EINVAL &&
+ errno != ENOENT) {
PLOG(ERROR) << "Failed to unmount directory.";
_exit(-errno);
}
@@ -797,11 +784,11 @@
}
int VolumeManager::createObb(const std::string& sourcePath, const std::string& sourceKey,
- int32_t ownerGid, std::string* outVolId) {
+ int32_t ownerGid, std::string* outVolId) {
int id = mNextObbId++;
auto vol = std::shared_ptr<android::vold::VolumeBase>(
- new android::vold::ObbVolume(id, sourcePath, sourceKey, ownerGid));
+ new android::vold::ObbVolume(id, sourcePath, sourceKey, ownerGid));
vol->create();
mObbVolumes.push_back(vol);
@@ -823,7 +810,7 @@
}
int VolumeManager::mountAppFuse(uid_t uid, pid_t pid, int mountId,
- android::base::unique_fd* device_fd) {
+ android::base::unique_fd* device_fd) {
std::string name = std::to_string(mountId);
// Check mount point name.
@@ -841,7 +828,7 @@
}
// Open device FD.
- device_fd->reset(open("/dev/fuse", O_RDWR)); // not O_CLOEXEC
+ device_fd->reset(open("/dev/fuse", O_RDWR)); // not O_CLOEXEC
if (device_fd->get() == -1) {
PLOG(ERROR) << "Failed to open /dev/fuse";
return -1;
diff --git a/VolumeManager.h b/VolumeManager.h
index fb455d8..eedb1cb 100644
--- a/VolumeManager.h
+++ b/VolumeManager.h
@@ -17,8 +17,8 @@
#ifndef ANDROID_VOLD_VOLUME_MANAGER_H
#define ANDROID_VOLD_VOLUME_MANAGER_H
-#include <pthread.h>
#include <fnmatch.h>
+#include <pthread.h>
#include <stdlib.h>
#include <list>
@@ -29,9 +29,9 @@
#include <android-base/unique_fd.h>
#include <cutils/multiuser.h>
+#include <sysutils/NetlinkEvent.h>
#include <utils/List.h>
#include <utils/Timers.h>
-#include <sysutils/NetlinkEvent.h>
#include "android/os/IVoldListener.h"
@@ -41,12 +41,12 @@
#define DEBUG_APPFUSE 0
class VolumeManager {
-private:
- static VolumeManager *sInstance;
+ private:
+ static VolumeManager* sInstance;
- bool mDebug;
+ bool mDebug;
-public:
+ public:
virtual ~VolumeManager();
// TODO: pipe all requests through VM to avoid exposing this lock
@@ -59,13 +59,12 @@
int start();
int stop();
- void handleBlockEvent(NetlinkEvent *evt);
+ void handleBlockEvent(NetlinkEvent* evt);
class DiskSource {
- public:
- DiskSource(const std::string& sysPattern, const std::string& nickname, int flags) :
- mSysPattern(sysPattern), mNickname(nickname), mFlags(flags) {
- }
+ public:
+ DiskSource(const std::string& sysPattern, const std::string& nickname, int flags)
+ : mSysPattern(sysPattern), mNickname(nickname), mFlags(flags) {}
bool matches(const std::string& sysPath) {
return !fnmatch(mSysPattern.c_str(), sysPath.c_str(), 0);
@@ -74,7 +73,7 @@
const std::string& getNickname() { return mNickname; }
int getFlags() { return mFlags; }
- private:
+ private:
std::string mSysPattern;
std::string mNickname;
int mFlags;
@@ -110,7 +109,7 @@
int updateVirtualDisk();
int setDebug(bool enable);
- static VolumeManager *Instance();
+ static VolumeManager* Instance();
/*
* Ensure that all directories along given path exist, creating parent
@@ -122,13 +121,13 @@
int mkdirs(const std::string& path);
int createObb(const std::string& path, const std::string& key, int32_t ownerGid,
- std::string* outVolId);
+ std::string* outVolId);
int destroyObb(const std::string& volId);
int mountAppFuse(uid_t uid, pid_t pid, int mountId, android::base::unique_fd* device_fd);
int unmountAppFuse(uid_t uid, pid_t pid, int mountId);
-private:
+ private:
VolumeManager();
void readInitialState();
diff --git a/binder/android/os/IVold.aidl b/binder/android/os/IVold.aidl
index f386889..567385c 100644
--- a/binder/android/os/IVold.aidl
+++ b/binder/android/os/IVold.aidl
@@ -44,14 +44,14 @@
void checkEncryption(@utf8InCpp String volId);
void moveStorage(@utf8InCpp String fromVolId, @utf8InCpp String toVolId,
- IVoldTaskListener listener);
+ IVoldTaskListener listener);
void remountUid(int uid, int remountMode);
void mkdirs(@utf8InCpp String path);
- @utf8InCpp String createObb(@utf8InCpp String sourcePath,
- @utf8InCpp String sourceKey, int ownerGid);
+ @utf8InCpp String createObb(@utf8InCpp String sourcePath, @utf8InCpp String sourceKey,
+ int ownerGid);
void destroyObb(@utf8InCpp String volId);
void fstrim(int fstrimFlags, IVoldTaskListener listener);
@@ -84,13 +84,16 @@
void createUserKey(int userId, int userSerial, boolean ephemeral);
void destroyUserKey(int userId);
- void addUserKeyAuth(int userId, int userSerial, @utf8InCpp String token, @utf8InCpp String secret);
+ void addUserKeyAuth(int userId, int userSerial, @utf8InCpp String token,
+ @utf8InCpp String secret);
void fixateNewestUserKeyAuth(int userId);
- void unlockUserKey(int userId, int userSerial, @utf8InCpp String token, @utf8InCpp String secret);
+ void unlockUserKey(int userId, int userSerial, @utf8InCpp String token,
+ @utf8InCpp String secret);
void lockUserKey(int userId);
- void prepareUserStorage(@nullable @utf8InCpp String uuid, int userId, int userSerial, int storageFlags);
+ void prepareUserStorage(@nullable @utf8InCpp String uuid, int userId, int userSerial,
+ int storageFlags);
void destroyUserStorage(@nullable @utf8InCpp String uuid, int userId, int storageFlags);
const int ENCRYPTION_FLAG_NO_UI = 4;
diff --git a/model/EmulatedVolume.cpp b/model/EmulatedVolume.cpp
index 6e1ffce..7ec109c 100644
--- a/model/EmulatedVolume.cpp
+++ b/model/EmulatedVolume.cpp
@@ -27,8 +27,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;
@@ -38,22 +38,21 @@
static const char* kFusePath = "/system/bin/sdcard";
-EmulatedVolume::EmulatedVolume(const std::string& rawPath) :
- VolumeBase(Type::kEmulated), mFusePid(0) {
+EmulatedVolume::EmulatedVolume(const std::string& rawPath)
+ : VolumeBase(Type::kEmulated), mFusePid(0) {
setId("emulated");
mRawPath = rawPath;
mLabel = "emulated";
}
-EmulatedVolume::EmulatedVolume(const std::string& rawPath, dev_t device,
- const std::string& fsUuid) : VolumeBase(Type::kEmulated), mFusePid(0) {
+EmulatedVolume::EmulatedVolume(const std::string& rawPath, dev_t device, const std::string& fsUuid)
+ : VolumeBase(Type::kEmulated), mFusePid(0) {
setId(StringPrintf("emulated:%u,%u", major(device), minor(device)));
mRawPath = rawPath;
mLabel = fsUuid;
}
-EmulatedVolume::~EmulatedVolume() {
-}
+EmulatedVolume::~EmulatedVolume() {}
status_t EmulatedVolume::doMount() {
// We could have migrated storage to an adopted private volume, so always
@@ -71,8 +70,8 @@
setPath(StringPrintf("/storage/%s", label.c_str()));
if (fs_prepare_dir(mFuseDefault.c_str(), 0700, AID_ROOT, AID_ROOT) ||
- fs_prepare_dir(mFuseRead.c_str(), 0700, AID_ROOT, AID_ROOT) ||
- fs_prepare_dir(mFuseWrite.c_str(), 0700, AID_ROOT, AID_ROOT)) {
+ fs_prepare_dir(mFuseRead.c_str(), 0700, AID_ROOT, AID_ROOT) ||
+ fs_prepare_dir(mFuseWrite.c_str(), 0700, AID_ROOT, AID_ROOT)) {
PLOG(ERROR) << getId() << " failed to create mount points";
return -errno;
}
@@ -80,6 +79,7 @@
dev_t before = GetDevice(mFuseWrite);
if (!(mFusePid = fork())) {
+ // clang-format off
if (execl(kFusePath, kFusePath,
"-u", "1023", // AID_MEDIA_RW
"-g", "1023", // AID_MEDIA_RW
@@ -90,6 +90,7 @@
mRawPath.c_str(),
label.c_str(),
NULL)) {
+ // clang-format on
PLOG(ERROR) << "Failed to exec";
}
@@ -105,7 +106,7 @@
nsecs_t start = systemTime(SYSTEM_TIME_BOOTTIME);
while (before == GetDevice(mFuseWrite)) {
LOG(VERBOSE) << "Waiting for FUSE to spin up...";
- usleep(50000); // 50ms
+ usleep(50000); // 50ms
nsecs_t now = systemTime(SYSTEM_TIME_BOOTTIME);
if (nanoseconds_to_milliseconds(now - start) > 5000) {
diff --git a/model/PublicVolume.cpp b/model/PublicVolume.cpp
index 9f2ed85..7420c79 100644
--- a/model/PublicVolume.cpp
+++ b/model/PublicVolume.cpp
@@ -20,8 +20,8 @@
#include "fs/Exfat.h"
#include "fs/Vfat.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 <utils/Timers.h>
@@ -30,8 +30,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;
@@ -43,14 +43,12 @@
static const char* kAsecPath = "/mnt/secure/asec";
-PublicVolume::PublicVolume(dev_t device) :
- VolumeBase(Type::kPublic), mDevice(device), mFusePid(0) {
+PublicVolume::PublicVolume(dev_t device) : VolumeBase(Type::kPublic), mDevice(device), mFusePid(0) {
setId(StringPrintf("public:%u,%u", major(device), minor(device)));
mDevPath = StringPrintf("/dev/block/vold/%s", getId().c_str());
}
-PublicVolume::~PublicVolume() {
-}
+PublicVolume::~PublicVolume() {}
status_t PublicVolume::readMetadata() {
status_t res = ReadMetadataUntrusted(mDevPath, &mFsType, &mFsUuid, &mFsLabel);
@@ -66,8 +64,7 @@
std::string securePath(mRawPath + "/.android_secure");
// Recover legacy secure path
- if (!access(legacyPath.c_str(), R_OK | X_OK)
- && access(securePath.c_str(), R_OK | X_OK)) {
+ if (!access(legacyPath.c_str(), R_OK | X_OK) && access(securePath.c_str(), R_OK | X_OK)) {
if (rename(legacyPath.c_str(), securePath.c_str())) {
PLOG(WARNING) << getId() << " failed to rename legacy ASEC dir";
}
@@ -158,8 +155,8 @@
}
if (fs_prepare_dir(mFuseDefault.c_str(), 0700, AID_ROOT, AID_ROOT) ||
- fs_prepare_dir(mFuseRead.c_str(), 0700, AID_ROOT, AID_ROOT) ||
- fs_prepare_dir(mFuseWrite.c_str(), 0700, AID_ROOT, AID_ROOT)) {
+ fs_prepare_dir(mFuseRead.c_str(), 0700, AID_ROOT, AID_ROOT) ||
+ fs_prepare_dir(mFuseWrite.c_str(), 0700, AID_ROOT, AID_ROOT)) {
PLOG(ERROR) << getId() << " failed to create FUSE mount points";
return -errno;
}
@@ -168,6 +165,7 @@
if (!(mFusePid = fork())) {
if (getMountFlags() & MountFlags::kPrimary) {
+ // clang-format off
if (execl(kFusePath, kFusePath,
"-u", "1023", // AID_MEDIA_RW
"-g", "1023", // AID_MEDIA_RW
@@ -176,9 +174,11 @@
mRawPath.c_str(),
stableName.c_str(),
NULL)) {
+ // clang-format on
PLOG(ERROR) << "Failed to exec";
}
} else {
+ // clang-format off
if (execl(kFusePath, kFusePath,
"-u", "1023", // AID_MEDIA_RW
"-g", "1023", // AID_MEDIA_RW
@@ -186,6 +186,7 @@
mRawPath.c_str(),
stableName.c_str(),
NULL)) {
+ // clang-format on
PLOG(ERROR) << "Failed to exec";
}
}
@@ -202,7 +203,7 @@
nsecs_t start = systemTime(SYSTEM_TIME_BOOTTIME);
while (before == GetDevice(mFuseWrite)) {
LOG(VERBOSE) << "Waiting for FUSE to spin up...";
- usleep(50000); // 50ms
+ usleep(50000); // 50ms
nsecs_t now = systemTime(SYSTEM_TIME_BOOTTIME);
if (nanoseconds_to_milliseconds(now - start) > 5000) {
diff --git a/model/VolumeBase.cpp b/model/VolumeBase.cpp
index 429f134..300add1 100644
--- a/model/VolumeBase.cpp
+++ b/model/VolumeBase.cpp
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-#include "Utils.h"
#include "VolumeBase.h"
+#include "Utils.h"
#include "VolumeManager.h"
-#include <android-base/stringprintf.h>
#include <android-base/logging.h>
+#include <android-base/stringprintf.h>
#include <fcntl.h>
#include <stdlib.h>
@@ -32,10 +32,13 @@
namespace android {
namespace vold {
-VolumeBase::VolumeBase(Type type) :
- mType(type), mMountFlags(0), mMountUserId(-1), mCreated(false), mState(
- State::kUnmounted), mSilent(false) {
-}
+VolumeBase::VolumeBase(Type type)
+ : mType(type),
+ mMountFlags(0),
+ mMountUserId(-1),
+ mCreated(false),
+ mState(State::kUnmounted),
+ mSilent(false) {}
VolumeBase::~VolumeBase() {
CHECK(!mCreated);
@@ -45,7 +48,9 @@
mState = state;
auto listener = getListener();
- if (listener) listener->onVolumeStateChanged(getId(), static_cast<int32_t>(mState));
+ if (listener) {
+ listener->onVolumeStateChanged(getId(), static_cast<int32_t>(mState));
+ }
}
status_t VolumeBase::setDiskId(const std::string& diskId) {
@@ -131,7 +136,9 @@
mInternalPath = internalPath;
auto listener = getListener();
- if (listener) listener->onVolumeInternalPathChanged(getId(), mInternalPath);
+ if (listener) {
+ listener->onVolumeInternalPathChanged(getId(), mInternalPath);
+ }
return OK;
}
@@ -168,8 +175,9 @@
status_t res = doCreate();
auto listener = getListener();
- if (listener) listener->onVolumeCreated(getId(),
- static_cast<int32_t>(mType), mDiskId, mPartGuid);
+ if (listener) {
+ listener->onVolumeCreated(getId(), static_cast<int32_t>(mType), mDiskId, mPartGuid);
+ }
setState(State::kUnmounted);
return res;
@@ -189,9 +197,10 @@
setState(State::kRemoved);
}
-
auto listener = getListener();
- if (listener) listener->onVolumeDestroyed(getId());
+ if (listener) {
+ listener->onVolumeDestroyed(getId());
+ }
status_t res = doDestroy();
mCreated = false;
@@ -228,8 +237,7 @@
setState(State::kEjecting);
for (const auto& vol : mVolumes) {
if (vol->destroy()) {
- LOG(WARNING) << getId() << " failed to destroy " << vol->getId()
- << " stacked above";
+ LOG(WARNING) << getId() << " failed to destroy " << vol->getId() << " stacked above";
}
}
mVolumes.clear();
diff --git a/model/VolumeBase.h b/model/VolumeBase.h
index 4aa8b02..6532a80 100644
--- a/model/VolumeBase.h
+++ b/model/VolumeBase.h
@@ -17,8 +17,8 @@
#ifndef ANDROID_VOLD_VOLUME_BASE_H
#define ANDROID_VOLD_VOLUME_BASE_H
-#include "android/os/IVoldListener.h"
#include "Utils.h"
+#include "android/os/IVoldListener.h"
#include <cutils/multiuser.h>
#include <utils/Errors.h>
@@ -45,7 +45,7 @@
* volumes and removes any bind mounts before finally unmounting itself.
*/
class VolumeBase {
-public:
+ public:
virtual ~VolumeBase();
enum class Type {
@@ -102,7 +102,7 @@
status_t unmount();
status_t format(const std::string& fsType);
-protected:
+ protected:
explicit VolumeBase(Type type);
virtual status_t doCreate();
@@ -117,7 +117,7 @@
android::sp<android::os::IVoldListener> getListener();
-private:
+ private:
/* ID that uniquely references volume while alive */
std::string mId;
/* ID that uniquely references parent disk while alive */