summaryrefslogtreecommitdiff
path: root/VolumeManager.cpp
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-02-14 04:35:15 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-02-14 04:35:15 +0000
commitdd85fe2e5e65b221341ccf1a8ab5024e524cbf81 (patch)
tree48efbd2b3888615a1c03e614083689baf385111a /VolumeManager.cpp
parent50f7de29bead3a562f3fb0130385bc7f6ac552b7 (diff)
parent82e90de23d0ee47e785307e77c5ab0ba9a4de26f (diff)
downloadvold-dd85fe2e5e65b221341ccf1a8ab5024e524cbf81.tar.gz
Merge "Add disk for StubVolume"
Diffstat (limited to 'VolumeManager.cpp')
-rw-r--r--VolumeManager.cpp46
1 files changed, 20 insertions, 26 deletions
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 9eb78520..0c81cb76 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -114,7 +114,7 @@ VolumeManager* VolumeManager::Instance() {
VolumeManager::VolumeManager() {
mDebug = false;
mNextObbId = 0;
- mNextStubVolumeId = 0;
+ mNextStubId = 0;
// For security reasons, assume that a secure keyguard is
// showing until we hear otherwise
mSecureKeyguardShowing = true;
@@ -340,11 +340,6 @@ std::shared_ptr<android::vold::VolumeBase> VolumeManager::findVolume(const std::
return vol;
}
}
- for (const auto& vol : mStubVolumes) {
- if (vol->getId() == id) {
- return vol;
- }
- }
for (const auto& vol : mObbVolumes) {
if (vol->getId() == id) {
return vol;
@@ -767,7 +762,6 @@ int VolumeManager::shutdown() {
}
mInternalEmulatedVolumes.clear();
- mStubVolumes.clear();
mDisks.clear();
mPendingDisks.clear();
android::vold::sSleepOnUnmount = true;
@@ -782,9 +776,6 @@ int VolumeManager::unmountAll() {
for (const auto& vol : mInternalEmulatedVolumes) {
vol->unmount();
}
- for (const auto& stub : mStubVolumes) {
- stub->unmount();
- }
for (const auto& disk : mDisks) {
disk->unmountAll();
}
@@ -908,27 +899,30 @@ int VolumeManager::destroyObb(const std::string& volId) {
int VolumeManager::createStubVolume(const std::string& sourcePath, const std::string& mountPath,
const std::string& fsType, const std::string& fsUuid,
- const std::string& fsLabel, std::string* outVolId) {
- int id = mNextStubVolumeId++;
- auto vol = std::shared_ptr<android::vold::VolumeBase>(
- new android::vold::StubVolume(id, sourcePath, mountPath, fsType, fsUuid, fsLabel));
- vol->create();
-
- mStubVolumes.push_back(vol);
+ const std::string& fsLabel, int32_t flags __unused,
+ std::string* outVolId) {
+ dev_t stubId = --mNextStubId;
+ auto vol = std::shared_ptr<android::vold::StubVolume>(
+ new android::vold::StubVolume(stubId, sourcePath, mountPath, fsType, fsUuid, fsLabel));
+
+ // TODO (b/132796154): Passed each supported flags explicitly here.
+ // StubDisk doesn't have device node corresponds to it. So, a fake device
+ // number is used. The supported flags will be infered from the
+ // currently-unused flags parameter.
+ auto disk = std::shared_ptr<android::vold::Disk>(
+ new android::vold::Disk("stub", stubId, "stub", android::vold::Disk::Flags::kStub));
+ disk->initializePartition(vol);
+ handleDiskAdded(disk);
*outVolId = vol->getId();
return android::OK;
}
int VolumeManager::destroyStubVolume(const std::string& volId) {
- auto i = mStubVolumes.begin();
- while (i != mStubVolumes.end()) {
- if ((*i)->getId() == volId) {
- (*i)->destroy();
- i = mStubVolumes.erase(i);
- } else {
- ++i;
- }
- }
+ auto tokens = android::base::Split(volId, ":");
+ CHECK(tokens.size() == 2);
+ dev_t stubId;
+ CHECK(android::base::ParseUint(tokens[1], &stubId));
+ handleDiskRemoved(stubId);
return android::OK;
}