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
This commit is contained in:
parent
a676df01e2
commit
8915d62847
9 changed files with 273 additions and 272 deletions
|
@ -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>
|
||||
|
@ -146,33 +146,37 @@ binder::Status checkArgumentHex(const std::string& hex) {
|
|||
return ok();
|
||||
}
|
||||
|
||||
#define ENFORCE_UID(uid) { \
|
||||
#define ENFORCE_UID(uid) \
|
||||
{ \
|
||||
binder::Status status = checkUid((uid)); \
|
||||
if (!status.isOk()) { \
|
||||
return status; \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
#define CHECK_ARGUMENT_ID(id) { \
|
||||
#define CHECK_ARGUMENT_ID(id) \
|
||||
{ \
|
||||
binder::Status status = checkArgumentId((id)); \
|
||||
if (!status.isOk()) { \
|
||||
return status; \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
#define CHECK_ARGUMENT_PATH(path) { \
|
||||
#define CHECK_ARGUMENT_PATH(path) \
|
||||
{ \
|
||||
binder::Status status = checkArgumentPath((path)); \
|
||||
if (!status.isOk()) { \
|
||||
return status; \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
#define CHECK_ARGUMENT_HEX(hex) { \
|
||||
#define CHECK_ARGUMENT_HEX(hex) \
|
||||
{ \
|
||||
binder::Status status = checkArgumentHex((hex)); \
|
||||
if (!status.isOk()) { \
|
||||
return status; \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
#define ACQUIRE_LOCK \
|
||||
std::lock_guard<std::mutex> lock(VolumeManager::Instance()->getLock()); \
|
||||
|
@ -196,7 +200,7 @@ status_t VoldNativeService::start() {
|
|||
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()) {
|
||||
|
@ -223,12 +227,8 @@ binder::Status VoldNativeService::monitor() {
|
|||
ENFORCE_UID(AID_SYSTEM);
|
||||
|
||||
// Simply acquire/release each lock for watchdog
|
||||
{
|
||||
ACQUIRE_LOCK;
|
||||
}
|
||||
{
|
||||
ACQUIRE_CRYPT_LOCK;
|
||||
}
|
||||
{ ACQUIRE_LOCK; }
|
||||
{ ACQUIRE_CRYPT_LOCK; }
|
||||
|
||||
return ok();
|
||||
}
|
||||
|
@ -293,10 +293,14 @@ binder::Status VoldNativeService::partition(const std::string& diskId, int32_t p
|
|||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,9 +391,7 @@ binder::Status VoldNativeService::benchmark(
|
|||
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 @@ binder::Status VoldNativeService::checkEncryption(const std::string& volId) {
|
|||
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 @@ binder::Status VoldNativeService::moveStorage(const std::string& fromVolId,
|
|||
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 @@ binder::Status VoldNativeService::remountUid(int32_t uid, int32_t remountMode) {
|
|||
|
||||
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,7 +459,8 @@ binder::Status VoldNativeService::mkdirs(const std::string& path) {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -467,14 +478,12 @@ binder::Status VoldNativeService::destroyObb(const std::string& volId) {
|
|||
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();
|
||||
}
|
||||
|
||||
|
@ -483,9 +492,7 @@ binder::Status VoldNativeService::runIdleMaint(
|
|||
ENFORCE_UID(AID_SYSTEM);
|
||||
ACQUIRE_LOCK;
|
||||
|
||||
std::thread([=]() {
|
||||
android::vold::RunIdleMaint(listener);
|
||||
}).detach();
|
||||
std::thread([=]() { android::vold::RunIdleMaint(listener); }).detach();
|
||||
return ok();
|
||||
}
|
||||
|
||||
|
@ -494,9 +501,7 @@ binder::Status VoldNativeService::abortIdleMaint(
|
|||
ENFORCE_UID(AID_SYSTEM);
|
||||
ACQUIRE_LOCK;
|
||||
|
||||
std::thread([=]() {
|
||||
android::vold::AbortIdleMaint(listener);
|
||||
}).detach();
|
||||
std::thread([=]() { android::vold::AbortIdleMaint(listener); }).detach();
|
||||
return ok();
|
||||
}
|
||||
|
||||
|
@ -562,8 +567,8 @@ static int fdeEnableInternal(int32_t passwordType, const std::string& password,
|
|||
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;
|
||||
|
||||
|
@ -595,8 +600,7 @@ binder::Status VoldNativeService::fdeVerifyPassword(const std::string& password)
|
|||
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::fdeGetField(const std::string& key,
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ binder::Status VoldNativeService::encryptFstab(const std::string& mountPoint) {
|
|||
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::destroyUserKey(int32_t userId) {
|
|||
}
|
||||
|
||||
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::fixateNewestUserKeyAuth(int32_t userId) {
|
|||
}
|
||||
|
||||
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::lockUserKey(int32_t userId) {
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -26,10 +26,10 @@ namespace android {
|
|||
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);
|
||||
|
||||
|
@ -67,10 +67,8 @@ public:
|
|||
|
||||
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);
|
||||
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);
|
||||
|
@ -79,10 +77,9 @@ public:
|
|||
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 @@ public:
|
|||
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
|
||||
|
|
|
@ -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 kMajorBlockMmc = 179;
|
|||
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 @@ VolumeManager::VolumeManager() {
|
|||
mSecureKeyguardShowing = true;
|
||||
}
|
||||
|
||||
VolumeManager::~VolumeManager() {
|
||||
}
|
||||
VolumeManager::~VolumeManager() {}
|
||||
|
||||
int VolumeManager::updateVirtualDisk() {
|
||||
ATRACE_NAME("VolumeManager::updateVirtualDisk");
|
||||
|
@ -117,7 +115,8 @@ int VolumeManager::updateVirtualDisk() {
|
|||
return -1;
|
||||
}
|
||||
|
||||
auto disk = new android::vold::Disk("virtual", buf.st_rdev, "virtual",
|
||||
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);
|
||||
|
@ -173,17 +172,17 @@ int VolumeManager::stop() {
|
|||
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;
|
||||
|
||||
|
@ -199,17 +198,16 @@ void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {
|
|||
// 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)) {
|
||||
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);
|
||||
auto disk =
|
||||
new android::vold::Disk(eventPath, device, source->getNickname(), flags);
|
||||
handleDiskAdded(std::shared_ptr<android::vold::Disk>(disk));
|
||||
break;
|
||||
}
|
||||
|
@ -226,7 +224,7 @@ void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {
|
|||
break;
|
||||
}
|
||||
default: {
|
||||
LOG(WARNING) << "Unexpected block event action " << (int) evt->getAction();
|
||||
LOG(WARNING) << "Unexpected block event action " << (int)evt->getAction();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -312,8 +310,7 @@ std::shared_ptr<android::vold::VolumeBase> VolumeManager::findVolume(const std::
|
|||
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);
|
||||
|
@ -522,26 +519,22 @@ int VolumeManager::remountUid(uid_t uid, const std::string& mode) {
|
|||
// 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 @@ int VolumeManager::remountUid(uid_t uid, const std::string& mode) {
|
|||
TEMP_FAILURE_RETRY(waitpid(child, nullptr, 0));
|
||||
}
|
||||
|
||||
next:
|
||||
next:
|
||||
close(nsFd);
|
||||
close(pidFd);
|
||||
}
|
||||
|
@ -680,12 +673,10 @@ static android::status_t mountInNamespace(uid_t uid, int device_fd, const std::s
|
|||
"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);
|
||||
device_fd, uid, uid);
|
||||
|
||||
const int result = TEMP_FAILURE_RETRY(mount(
|
||||
"/dev/fuse", path.c_str(), "fuse",
|
||||
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;
|
||||
|
@ -695,11 +686,8 @@ static android::status_t mountInNamespace(uid_t uid, int device_fd, const std::s
|
|||
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 @@ static android::status_t runCommandInNamespace(const std::string& command,
|
|||
|
||||
// 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;
|
||||
|
@ -739,8 +726,8 @@ static android::status_t runCommandInNamespace(const std::string& command,
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
@ -769,8 +756,8 @@ static android::status_t runCommandInNamespace(const std::string& command,
|
|||
} 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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
public:
|
||||
public:
|
||||
virtual ~VolumeManager();
|
||||
|
||||
// TODO: pipe all requests through VM to avoid exposing this lock
|
||||
|
@ -59,13 +59,12 @@ public:
|
|||
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) {
|
||||
}
|
||||
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);
|
||||
|
@ -110,7 +109,7 @@ public:
|
|||
int updateVirtualDisk();
|
||||
int setDebug(bool enable);
|
||||
|
||||
static VolumeManager *Instance();
|
||||
static VolumeManager* Instance();
|
||||
|
||||
/*
|
||||
* Ensure that all directories along given path exist, creating parent
|
||||
|
@ -128,7 +127,7 @@ public:
|
|||
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();
|
||||
|
||||
|
|
|
@ -50,8 +50,8 @@ interface IVold {
|
|||
|
||||
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 @@ interface IVold {
|
|||
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;
|
||||
|
|
|
@ -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 @@ namespace vold {
|
|||
|
||||
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
|
||||
|
@ -80,6 +79,7 @@ status_t EmulatedVolume::doMount() {
|
|||
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 @@ status_t EmulatedVolume::doMount() {
|
|||
mRawPath.c_str(),
|
||||
label.c_str(),
|
||||
NULL)) {
|
||||
// clang-format on
|
||||
PLOG(ERROR) << "Failed to exec";
|
||||
}
|
||||
|
||||
|
|
|
@ -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* kFusePath = "/system/bin/sdcard";
|
|||
|
||||
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 @@ status_t PublicVolume::initAsecStage() {
|
|||
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";
|
||||
}
|
||||
|
@ -168,6 +165,7 @@ status_t PublicVolume::doMount() {
|
|||
|
||||
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 @@ status_t PublicVolume::doMount() {
|
|||
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 @@ status_t PublicVolume::doMount() {
|
|||
mRawPath.c_str(),
|
||||
stableName.c_str(),
|
||||
NULL)) {
|
||||
// clang-format on
|
||||
PLOG(ERROR) << "Failed to exec";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 @@ using android::base::StringPrintf;
|
|||
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 @@ void VolumeBase::setState(State state) {
|
|||
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 @@ status_t VolumeBase::setInternalPath(const std::string& internalPath) {
|
|||
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 VolumeBase::create() {
|
|||
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 @@ status_t VolumeBase::destroy() {
|
|||
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 @@ status_t VolumeBase::unmount() {
|
|||
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();
|
||||
|
|
|
@ -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 @@ namespace vold {
|
|||
* volumes and removes any bind mounts before finally unmounting itself.
|
||||
*/
|
||||
class VolumeBase {
|
||||
public:
|
||||
public:
|
||||
virtual ~VolumeBase();
|
||||
|
||||
enum class Type {
|
||||
|
@ -102,7 +102,7 @@ public:
|
|||
status_t unmount();
|
||||
status_t format(const std::string& fsType);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
explicit VolumeBase(Type type);
|
||||
|
||||
virtual status_t doCreate();
|
||||
|
@ -117,7 +117,7 @@ protected:
|
|||
|
||||
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 */
|
||||
|
|
Loading…
Reference in a new issue