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

Commit 4b155828 authored by David Anderson's avatar David Anderson Committed by Gerrit Code Review
Browse files

Merge "libsnapshot: Add stubs for Xor Ops and Sequence Data"

parents 1fc3a2d9 93edf303
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -58,6 +58,12 @@ bool ICowWriter::AddRawBlocks(uint64_t new_block_start, const void* data, size_t
    return EmitRawBlocks(new_block_start, data, size);
}

bool AddXorBlocks(uint32_t /*new_block_start*/, const void* /*data*/, size_t /*size*/,
                  uint32_t /*old_block*/, uint16_t /*offset*/) {
    LOG(ERROR) << "AddXorBlocks not yet implemented";
    return false;
}

bool ICowWriter::AddZeroBlocks(uint64_t new_block_start, uint64_t num_blocks) {
    uint64_t last_block = new_block_start + num_blocks - 1;
    if (!ValidateNewBlock(last_block)) {
@@ -70,6 +76,11 @@ bool ICowWriter::AddLabel(uint64_t label) {
    return EmitLabel(label);
}

bool AddSequenceData(size_t /*num_ops*/, const uint32_t* /*data*/) {
    LOG(ERROR) << "AddSequenceData not yet implemented";
    return false;
}

bool ICowWriter::ValidateNewBlock(uint64_t new_block) {
    if (options_.max_blocks && new_block >= options_.max_blocks.value()) {
        LOG(ERROR) << "New block " << new_block << " exceeds maximum block count "
+7 −0
Original line number Diff line number Diff line
@@ -55,12 +55,19 @@ class ICowWriter {
    // Encode a sequence of raw blocks. |size| must be a multiple of the block size.
    bool AddRawBlocks(uint64_t new_block_start, const void* data, size_t size);

    // Add a sequence of xor'd blocks. |size| must be a multiple of the block size.
    bool AddXorBlocks(uint32_t new_block_start, const void* data, size_t size, uint32_t old_block,
                      uint16_t offset);

    // Encode a sequence of zeroed blocks. |size| must be a multiple of the block size.
    bool AddZeroBlocks(uint64_t new_block_start, uint64_t num_blocks);

    // Add a label to the op sequence.
    bool AddLabel(uint64_t label);

    // Add sequence data for op merging. Data is a list of the destination block numbers.
    bool AddSequenceData(size_t num_ops, const uint32_t* data);

    // Flush all pending writes. This must be called before closing the writer
    // to ensure that the correct headers and footers are written.
    virtual bool Finalize() = 0;