Merge "libsnapshot: Make the new Open calls look more like MapUpdateSnapshot." am: 9ec8c31afb
am: ef77597707
am: d24bfd33c9
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1433352 Change-Id: I146b9f0d3c2f992d06bd6244f594b00dbd0611e2
This commit is contained in:
commit
52c8bd65ce
5 changed files with 22 additions and 30 deletions
|
@ -39,11 +39,9 @@ class MockSnapshotManager : public ISnapshotManager {
|
|||
std::string* snapshot_path),
|
||||
(override));
|
||||
MOCK_METHOD(std::unique_ptr<ICowWriter>, OpenSnapshotWriter,
|
||||
(const std::string& partition_name, std::chrono::milliseconds timeout_ms),
|
||||
(override));
|
||||
(const android::fs_mgr::CreateLogicalPartitionParams& params), (override));
|
||||
MOCK_METHOD(std::unique_ptr<FileDescriptor>, OpenSnapshotReader,
|
||||
(const std::string& partition_name, std::chrono::milliseconds timeout_ms),
|
||||
(override));
|
||||
(const android::fs_mgr::CreateLogicalPartitionParams& params), (override));
|
||||
MOCK_METHOD(bool, UnmapUpdateSnapshot, (const std::string& target_partition_name), (override));
|
||||
MOCK_METHOD(bool, NeedSnapshotsInFirstStageMount, (), (override));
|
||||
MOCK_METHOD(bool, CreateLogicalAndSnapshotPartitions,
|
||||
|
|
|
@ -187,14 +187,15 @@ class ISnapshotManager {
|
|||
virtual bool MapUpdateSnapshot(const android::fs_mgr::CreateLogicalPartitionParams& params,
|
||||
std::string* snapshot_path) = 0;
|
||||
|
||||
// Create an ICowWriter to build a snapshot against a target partition.
|
||||
// Create an ICowWriter to build a snapshot against a target partition. The partition name must
|
||||
// be suffixed.
|
||||
virtual std::unique_ptr<ICowWriter> OpenSnapshotWriter(
|
||||
const std::string& partition_name, std::chrono::milliseconds timeout_ms = {}) = 0;
|
||||
const android::fs_mgr::CreateLogicalPartitionParams& params) = 0;
|
||||
|
||||
// Open a snapshot for reading. A file-like interface is provided through the FileDescriptor.
|
||||
// In this mode, writes are not supported.
|
||||
// In this mode, writes are not supported. The partition name must be suffixed.
|
||||
virtual std::unique_ptr<FileDescriptor> OpenSnapshotReader(
|
||||
const std::string& partition_name, std::chrono::milliseconds timeout_ms = {}) = 0;
|
||||
const android::fs_mgr::CreateLogicalPartitionParams& params) = 0;
|
||||
|
||||
// Unmap a snapshot device or CowWriter that was previously opened with MapUpdateSnapshot,
|
||||
// OpenSnapshotWriter, or OpenSnapshotReader. All outstanding open descriptors, writers,
|
||||
|
@ -310,9 +311,9 @@ class SnapshotManager final : public ISnapshotManager {
|
|||
bool MapUpdateSnapshot(const CreateLogicalPartitionParams& params,
|
||||
std::string* snapshot_path) override;
|
||||
std::unique_ptr<ICowWriter> OpenSnapshotWriter(
|
||||
const std::string& partition_name, std::chrono::milliseconds timeout_ms = {}) override;
|
||||
const android::fs_mgr::CreateLogicalPartitionParams& params) override;
|
||||
std::unique_ptr<FileDescriptor> OpenSnapshotReader(
|
||||
const std::string& partition_name, std::chrono::milliseconds timeout_ms = {}) override;
|
||||
const android::fs_mgr::CreateLogicalPartitionParams& params) override;
|
||||
bool UnmapUpdateSnapshot(const std::string& target_partition_name) override;
|
||||
bool NeedSnapshotsInFirstStageMount() override;
|
||||
bool CreateLogicalAndSnapshotPartitions(
|
||||
|
|
|
@ -36,10 +36,10 @@ class SnapshotManagerStub : public ISnapshotManager {
|
|||
const chromeos_update_engine::DeltaArchiveManifest& manifest) override;
|
||||
bool MapUpdateSnapshot(const android::fs_mgr::CreateLogicalPartitionParams& params,
|
||||
std::string* snapshot_path) override;
|
||||
std::unique_ptr<ICowWriter> OpenSnapshotWriter(const std::string& partition_name,
|
||||
std::chrono::milliseconds timeout_ms) override;
|
||||
std::unique_ptr<ICowWriter> OpenSnapshotWriter(
|
||||
const android::fs_mgr::CreateLogicalPartitionParams& params) override;
|
||||
std::unique_ptr<FileDescriptor> OpenSnapshotReader(
|
||||
const std::string& partition_name, std::chrono::milliseconds timeout_ms = {}) override;
|
||||
const android::fs_mgr::CreateLogicalPartitionParams& params) override;
|
||||
bool UnmapUpdateSnapshot(const std::string& target_partition_name) override;
|
||||
bool NeedSnapshotsInFirstStageMount() override;
|
||||
bool CreateLogicalAndSnapshotPartitions(
|
||||
|
|
|
@ -2442,25 +2442,18 @@ bool SnapshotManager::MapUpdateSnapshot(const CreateLogicalPartitionParams& para
|
|||
}
|
||||
|
||||
std::unique_ptr<ICowWriter> SnapshotManager::OpenSnapshotWriter(
|
||||
const std::string& partition_name, std::chrono::milliseconds timeout_ms) {
|
||||
if (!IsCompressionEnabled()) {
|
||||
LOG(ERROR) << "OpenSnapshotWriter can only be called in compression mode.";
|
||||
return nullptr;
|
||||
}
|
||||
const android::fs_mgr::CreateLogicalPartitionParams& params) {
|
||||
(void)params;
|
||||
|
||||
(void)partition_name;
|
||||
(void)timeout_ms;
|
||||
|
||||
// Not yet implemented.
|
||||
LOG(ERROR) << "OpenSnapshotWriter not yet implemented";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<FileDescriptor> SnapshotManager::OpenSnapshotReader(
|
||||
const std::string& partition_name, std::chrono::milliseconds timeout_ms) {
|
||||
(void)partition_name;
|
||||
(void)timeout_ms;
|
||||
const android::fs_mgr::CreateLogicalPartitionParams& params) {
|
||||
(void)params;
|
||||
|
||||
// Not yet implemented.
|
||||
LOG(ERROR) << "OpenSnapshotReader not yet implemented";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,14 +130,14 @@ ISnapshotMergeStats* SnapshotManagerStub::GetSnapshotMergeStatsInstance() {
|
|||
return &snapshot_merge_stats;
|
||||
}
|
||||
|
||||
std::unique_ptr<ICowWriter> SnapshotManagerStub::OpenSnapshotWriter(const std::string&,
|
||||
std::chrono::milliseconds) {
|
||||
std::unique_ptr<ICowWriter> SnapshotManagerStub::OpenSnapshotWriter(
|
||||
const CreateLogicalPartitionParams&) {
|
||||
LOG(ERROR) << __FUNCTION__ << " should never be called.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<FileDescriptor> SnapshotManagerStub::OpenSnapshotReader(const std::string&,
|
||||
std::chrono::milliseconds) {
|
||||
std::unique_ptr<FileDescriptor> SnapshotManagerStub::OpenSnapshotReader(
|
||||
const CreateLogicalPartitionParams&) {
|
||||
LOG(ERROR) << __FUNCTION__ << " should never be called.";
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue