}
void Disk::listVolumes(VolumeBase::Type type, std::list<std::string>& list) {
- for (auto vol : mVolumes) {
+ for (const auto& vol : mVolumes) {
if (vol->getType() == type) {
list.push_back(vol->getId());
}
}
void Disk::destroyAllVolumes() {
- for (auto vol : mVolumes) {
+ for (const auto& vol : mVolumes) {
vol->destroy();
}
mVolumes.clear();
Table table = Table::kUnknown;
bool foundParts = false;
- for (auto line : output) {
+ for (const auto& line : output) {
char* cline = (char*) line.c_str();
char* token = strtok(cline, kSgdiskToken);
if (token == nullptr) continue;
}
status_t Disk::unmountAll() {
- for (auto vol : mVolumes) {
+ for (const auto& vol : mVolumes) {
vol->unmount();
}
return OK;
VolumeManager* vm = VolumeManager::Instance();
std::list<std::string> privateIds;
vm->listVolumes(VolumeBase::Type::kPrivate, privateIds);
- for (auto id : privateIds) {
+ for (const auto& id : privateIds) {
auto vol = vm->findVolume(id);
if (vol != nullptr && vol->getState() == VolumeBase::State::kMounted) {
mPaths.push_back(vol->getPath());
void TrimTask::run() {
acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock);
- for (auto path : mPaths) {
+ for (const auto& path : mPaths) {
LOG(DEBUG) << "Starting trim of " << path;
int fd = open(path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
switch (evt->getAction()) {
case NetlinkEvent::Action::kAdd: {
- for (auto source : mDiskSources) {
+ for (const auto& source : mDiskSources) {
if (source->matches(eventPath)) {
// For now, assume that MMC devices are SD, and that
// everything else is USB
}
case NetlinkEvent::Action::kChange: {
LOG(DEBUG) << "Disk at " << major << ":" << minor << " changed";
- for (auto disk : mDisks) {
+ for (const auto& disk : mDisks) {
if (disk->getDevice() == device) {
disk->readMetadata();
disk->readPartitions();
if (mInternalEmulated->getId() == id) {
return mInternalEmulated;
}
- for (auto disk : mDisks) {
+ for (const auto& disk : mDisks) {
auto vol = disk->findVolume(id);
if (vol != nullptr) {
return vol;
void VolumeManager::listVolumes(android::vold::VolumeBase::Type type,
std::list<std::string>& list) {
list.clear();
- for (auto disk : mDisks) {
+ for (const auto& disk : mDisks) {
disk->listVolumes(type, list);
}
}
}
endmntent(fp);
- for (auto path : toUnmount) {
+ for (const auto& path : toUnmount) {
if (umount2(path.c_str(), MNT_DETACH)) {
ALOGW("Failed to unmount %s: %s", path.c_str(), strerror(errno));
}
// newly connected framework hears all events.
mInternalEmulated->destroy();
mInternalEmulated->create();
- for (auto disk : mDisks) {
+ for (const auto& disk : mDisks) {
disk->destroy();
disk->create();
}
int VolumeManager::shutdown() {
mInternalEmulated->destroy();
- for (auto disk : mDisks) {
+ for (const auto& disk : mDisks) {
disk->destroy();
}
mDisks.clear();
if (mInternalEmulated != nullptr) {
mInternalEmulated->unmount();
}
- for (auto disk : mDisks) {
+ for (const auto& disk : mDisks) {
disk->unmountAll();
}
}
endmntent(fp);
- for (auto path : toUnmount) {
+ for (const auto& path : toUnmount) {
SLOGW("Tearing down stale mount %s", path.c_str());
android::vold::ForceUnmount(path);
}