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

Commit ed1a7d5f authored by Daniel Zheng's avatar Daniel Zheng
Browse files

Add v3 Cow Header

Adding Version 3 of CowHeader. This will inherit from original
CowHeader and add a compression field. We are no longer supporting
different compressions per operation so having this one field is enough.

Test: cow_api_test
Change-Id: If88dceda139807cc5e647b706ddeb2b3e83c024f
parent b3cd361b
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -91,6 +91,18 @@ struct CowHeader {

    // Scratch space used during merge
    uint32_t buffer_size;

} __attribute__((packed));

struct CowHeaderV3 : public CowHeader {
    // Location of sequence buffer in COW.
    uint64_t sequence_buffer_offset;
    // Size, in bytes, of the CowResumePoint buffer.
    uint32_t resume_buffer_size;
    // Size, in bytes, of the CowOperation buffer.
    uint32_t op_buffer_size;
    // Compression Algorithm
    uint32_t compression_algorithm;
} __attribute__((packed));

// This structure is the same size of a normal Operation, but is repurposed for the footer.
+2 −2
Original line number Diff line number Diff line
@@ -243,7 +243,7 @@ bool CowWriterV2::OpenForWrite() {

    // Headers are not complete, but this ensures the file is at the right
    // position.
    if (!android::base::WriteFully(fd_, &header_, sizeof(header_))) {
    if (!android::base::WriteFully(fd_, &header_, sizeof(CowHeader))) {
        PLOG(ERROR) << "write failed";
        return false;
    }
@@ -262,7 +262,7 @@ bool CowWriterV2::OpenForWrite() {
        return false;
    }

    if (lseek(fd_.get(), sizeof(header_) + header_.buffer_size, SEEK_SET) < 0) {
    if (lseek(fd_.get(), sizeof(CowHeader) + header_.buffer_size, SEEK_SET) < 0) {
        PLOG(ERROR) << "lseek failed";
        return false;
    }