diff options
author | Yurii Zubrytskyi <zyy@google.com> | 2020-04-03 13:12:51 -0700 |
---|---|---|
committer | Yurii Zubrytskyi <zyy@google.com> | 2020-04-03 13:15:53 -0700 |
commit | 107ae354444175218fd19bed1c1c4947969aa006 (patch) | |
tree | af513ff9d6180d59def19f19d9b888ffeae2e593 /services/incremental/IncrementalService.cpp | |
parent | 8885e4f11569ac5aeb37074884bc4025972797c3 (diff) |
[incfs] fix the storage loading for existing mounts
IncrementalService used to keep the storage parameters in the
directory metadata, but our current incfs doesn't support
metadata on directories - so the storage id is encoded in its
name. But the loading code used to think it's still in the
metadata and couldn't load anything for that reason
Bug: 151241369
Test: install an app and reboot the phone. It's still there
Change-Id: Ic93f8f368b48fc5c5cc9bb726eff80478183596c
Diffstat (limited to 'services/incremental/IncrementalService.cpp')
-rw-r--r-- | services/incremental/IncrementalService.cpp | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp index 5e3c337da11e..7349cf673cc4 100644 --- a/services/incremental/IncrementalService.cpp +++ b/services/incremental/IncrementalService.cpp @@ -35,6 +35,7 @@ #include <uuid/uuid.h> #include <zlib.h> +#include <charconv> #include <ctime> #include <filesystem> #include <iterator> @@ -275,12 +276,15 @@ void IncrementalService::onDump(int fd) { const IncFsMount& mnt = *ifs.get(); dprintf(fd, "\t[%d]:\n", id); dprintf(fd, "\t\tmountId: %d\n", mnt.mountId); + dprintf(fd, "\t\troot: %s\n", mnt.root.c_str()); dprintf(fd, "\t\tnextStorageDirNo: %d\n", mnt.nextStorageDirNo.load()); dprintf(fd, "\t\tdataLoaderStatus: %d\n", mnt.dataLoaderStatus.load()); dprintf(fd, "\t\tconnectionLostTime: %s\n", toString(mnt.connectionLostTime)); - if (mnt.savedDataLoaderParams) { + dprintf(fd, "\t\tsavedDataLoaderParams:\n"); + if (!mnt.savedDataLoaderParams) { + dprintf(fd, "\t\t\tnone\n"); + } else { const auto& params = mnt.savedDataLoaderParams.value(); - dprintf(fd, "\t\tsavedDataLoaderParams:\n"); dprintf(fd, "\t\t\ttype: %s\n", toString(params.type).c_str()); dprintf(fd, "\t\t\tpackageName: %s\n", params.packageName.c_str()); dprintf(fd, "\t\t\tclassName: %s\n", params.className.c_str()); @@ -987,13 +991,13 @@ void IncrementalService::mountExistingImages() { continue; } const auto root = path::join(mIncrementalDir, name); - if (!mountExistingImage(root, name)) { + if (!mountExistingImage(root)) { IncFsMount::cleanupFilesystem(path); } } } -bool IncrementalService::mountExistingImage(std::string_view root, std::string_view key) { +bool IncrementalService::mountExistingImage(std::string_view root) { auto mountTarget = path::join(root, constants().mount); const auto backing = path::join(root, constants().backing); @@ -1044,16 +1048,24 @@ bool IncrementalService::mountExistingImage(std::string_view root, std::string_v } auto name = std::string_view(e->d_name); if (name.starts_with(constants().storagePrefix)) { - auto md = parseFromIncfs<metadata::Storage>(mIncFs.get(), ifs->control, - path::join(mountTarget, name)); - auto [_, inserted] = mMounts.try_emplace(md.id(), ifs); + int storageId; + const auto res = std::from_chars(name.data() + constants().storagePrefix.size() + 1, + name.data() + name.size(), storageId); + if (res.ec != std::errc{} || *res.ptr != '_') { + LOG(WARNING) << "Ignoring storage with invalid name '" << name << "' for mount " + << root; + continue; + } + auto [_, inserted] = mMounts.try_emplace(storageId, ifs); if (!inserted) { - LOG(WARNING) << "Ignoring storage with duplicate id " << md.id() + LOG(WARNING) << "Ignoring storage with duplicate id " << storageId << " for mount " << root; continue; } - ifs->storages.insert_or_assign(md.id(), IncFsMount::Storage{std::string(name)}); - mNextId = std::max(mNextId, md.id() + 1); + ifs->storages.insert_or_assign(storageId, + IncFsMount::Storage{ + path::join(root, constants().mount, name)}); + mNextId = std::max(mNextId, storageId + 1); } } } |