Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ec8c31a authored by David Anderson's avatar David Anderson Committed by Gerrit Code Review
Browse files

Merge "libsnapshot: Make the new Open calls look more like MapUpdateSnapshot."

parents fb2dafa5 f53794d1
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -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,
+7 −6
Original line number Diff line number Diff line
@@ -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(
+3 −3
Original line number Diff line number Diff line
@@ -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(
+6 −13
Original line number Diff line number Diff line
@@ -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;
    }

    (void)partition_name;
    (void)timeout_ms;
        const android::fs_mgr::CreateLogicalPartitionParams& params) {
    (void)params;

    // 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;
}

+4 −4
Original line number Diff line number Diff line
@@ -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;
}