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

Commit a10bfe1d authored by Daniel Zheng's avatar Daniel Zheng Committed by Gerrit Code Review
Browse files

Merge "Add CowOperationV2" into main

parents 81400915 d2ad53cf
Loading
Loading
Loading
Loading
+36 −0
Original line number Original line Diff line number Diff line
@@ -143,6 +143,42 @@ struct CowOperation {
    uint64_t source;
    uint64_t source;
} __attribute__((packed));
} __attribute__((packed));


// The on disk format of cow (currently ==  CowOperation)
struct CowOperationV2 {
    // The operation code (see the constants and structures below).
    uint8_t type;

    // If this operation reads from the data section of the COW, this contains
    // the compression type of that data (see constants below).
    uint8_t compression;

    // If this operation reads from the data section of the COW, this contains
    // the length.
    uint16_t data_length;

    // The block of data in the new image that this operation modifies.
    uint64_t new_block;

    // The value of |source| depends on the operation code.
    //
    // For copy operations, this is a block location in the source image.
    //
    // For replace operations, this is a byte offset within the COW's data
    // sections (eg, not landing within the header or metadata). It is an
    // absolute position within the image.
    //
    // For zero operations (replace with all zeroes), this is unused and must
    // be zero.
    //
    // For Label operations, this is the value of the applied label.
    //
    // For Cluster operations, this is the length of the following data region
    //
    // For Xor operations, this is the byte location in the source image.
    uint64_t source;
} __attribute__((packed));

static_assert(sizeof(CowOperationV2) == sizeof(CowOperation));
static_assert(sizeof(CowOperation) == sizeof(CowFooterOperation));
static_assert(sizeof(CowOperation) == sizeof(CowFooterOperation));


static constexpr uint8_t kCowCopyOp = 1;
static constexpr uint8_t kCowCopyOp = 1;
+0 −1
Original line number Original line Diff line number Diff line
@@ -165,7 +165,6 @@ class CowReader final : public ICowReader {
    void UpdateMergeOpsCompleted(int num_merge_ops) { header_.num_merge_ops += num_merge_ops; }
    void UpdateMergeOpsCompleted(int num_merge_ops) { header_.num_merge_ops += num_merge_ops; }


  private:
  private:
    bool ParseOps(std::optional<uint64_t> label);
    bool PrepMergeOps();
    bool PrepMergeOps();
    uint64_t FindNumCopyops();
    uint64_t FindNumCopyops();
    uint8_t GetCompressionType(const CowOperation* op);
    uint8_t GetCompressionType(const CowOperation* op);