Merge "Convert to lower fs path for createObb()." am: c237cbc575
am: 00382980e5
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1505371 Change-Id: Ibc7a9e7c4a3772e741d4f096fde99ee92e9dd06e
This commit is contained in:
commit
1e3addab7f
1 changed files with 35 additions and 1 deletions
|
@ -1056,8 +1056,42 @@ int VolumeManager::createObb(const std::string& sourcePath, const std::string& s
|
|||
int32_t ownerGid, std::string* outVolId) {
|
||||
int id = mNextObbId++;
|
||||
|
||||
std::string lowerSourcePath;
|
||||
|
||||
// Convert to lower filesystem path
|
||||
if (StartsWith(sourcePath, "/storage/")) {
|
||||
auto filter_fn = [&](const VolumeBase& vol) {
|
||||
if (vol.getState() != VolumeBase::State::kMounted) {
|
||||
// The volume must be mounted
|
||||
return false;
|
||||
}
|
||||
if ((vol.getMountFlags() & VolumeBase::MountFlags::kVisible) == 0) {
|
||||
// and visible
|
||||
return false;
|
||||
}
|
||||
if (vol.getInternalPath().empty()) {
|
||||
return false;
|
||||
}
|
||||
if (!sourcePath.empty() && StartsWith(sourcePath, vol.getPath())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
auto volume = findVolumeWithFilter(filter_fn);
|
||||
if (volume == nullptr) {
|
||||
LOG(ERROR) << "Failed to find mounted volume for " << sourcePath;
|
||||
return -EINVAL;
|
||||
} else {
|
||||
lowerSourcePath =
|
||||
volume->getInternalPath() + sourcePath.substr(volume->getPath().length());
|
||||
}
|
||||
} else {
|
||||
lowerSourcePath = sourcePath;
|
||||
}
|
||||
|
||||
auto vol = std::shared_ptr<android::vold::VolumeBase>(
|
||||
new android::vold::ObbVolume(id, sourcePath, sourceKey, ownerGid));
|
||||
new android::vold::ObbVolume(id, lowerSourcePath, sourceKey, ownerGid));
|
||||
vol->create();
|
||||
|
||||
mObbVolumes.push_back(vol);
|
||||
|
|
Loading…
Reference in a new issue