diff options
author | Alex Buynytskyy <alexbuy@google.com> | 2020-03-31 15:30:21 -0700 |
---|---|---|
committer | Alex Buynytskyy <alexbuy@google.com> | 2020-04-02 00:31:41 +0000 |
commit | 5e860ba10563f092110cfd708d8b310372c4df3c (patch) | |
tree | 2e2eda058704f18549641f50bd99af74e7a5aad0 /services/incremental/IncrementalService.cpp | |
parent | 431c3abc1d769f7e65852b39f5f85a69ed34ffd7 (diff) |
Checking LOADER_USAGE_STATS before enabling read logs.
Bug: b/152633648
Test: atest PackageManagerShellCommandTest PackageManagerShellCommandIncrementalTest IncrementalServiceTest
Change-Id: Ic747a51b97b785c627c95bddecc6834ef602ff30
Diffstat (limited to 'services/incremental/IncrementalService.cpp')
-rw-r--r-- | services/incremental/IncrementalService.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp index 25da8fe4a2e8..90df240233f4 100644 --- a/services/incremental/IncrementalService.cpp +++ b/services/incremental/IncrementalService.cpp @@ -563,6 +563,36 @@ StorageId IncrementalService::findStorageId(std::string_view path) const { return it->second->second.storage; } +int IncrementalService::setStorageParams(StorageId storageId, bool enableReadLogs) { + const auto ifs = getIfs(storageId); + if (!ifs) { + return -EINVAL; + } + + using unique_fd = ::android::base::unique_fd; + ::android::os::incremental::IncrementalFileSystemControlParcel control; + control.cmd.reset(unique_fd(dup(ifs->control.cmd()))); + control.pendingReads.reset(unique_fd(dup(ifs->control.pendingReads()))); + auto logsFd = ifs->control.logs(); + if (logsFd >= 0) { + control.log.reset(unique_fd(dup(logsFd))); + } + + std::lock_guard l(mMountOperationLock); + const auto status = mVold->setIncFsMountOptions(control, enableReadLogs); + if (!status.isOk()) { + LOG(ERROR) << "Calling Vold::setIncFsMountOptions() failed: " << status.toString8(); + return status.exceptionCode() == binder::Status::EX_SERVICE_SPECIFIC + ? status.serviceSpecificErrorCode() > 0 ? -status.serviceSpecificErrorCode() + : status.serviceSpecificErrorCode() == 0 + ? -EFAULT + : status.serviceSpecificErrorCode() + : -EIO; + } + + return 0; +} + void IncrementalService::deleteStorage(StorageId storageId) { const auto ifs = getIfs(storageId); if (!ifs) { @@ -737,10 +767,12 @@ int IncrementalService::makeFile(StorageId storage, std::string_view path, int m if (auto ifs = getIfs(storage)) { std::string normPath = normalizePathToStorage(ifs, storage, path); if (normPath.empty()) { + LOG(ERROR) << "Internal error: storageId " << storage << " failed to normalize: " << path; return -EINVAL; } auto err = mIncFs->makeFile(ifs->control, normPath, mode, id, params); if (err) { + LOG(ERROR) << "Internal error: storageId " << storage << " failed to makeFile: " << err; return err; } std::vector<uint8_t> metadataBytes; |