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

Commit 4485a6df authored by David Anderson's avatar David Anderson
Browse files

libsnapshot: Move BLOCK_SZ to snapuserd.

Block sizes should not be hardcoded, since the value is set in the
cow header. Move this to snapuserd to isolate use.

Bug: 280529365
Test: builds
Change-Id: I62aa8c7b795f9d258d4b6deb0779a536cba65d52
parent de20e57f
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -28,9 +28,6 @@ static constexpr uint32_t kCowVersionMinor = 0;

static constexpr uint32_t kCowVersionManifest = 2;

static constexpr size_t BLOCK_SZ = 4096;
static constexpr size_t BLOCK_SHIFT = (__builtin_ffs(BLOCK_SZ) - 1);

// This header appears as the first sequence of bytes in the COW. All fields
// in the layout are little-endian encoded. The on-disk layout is:
//
+0 −2
Original line number Diff line number Diff line
@@ -57,8 +57,6 @@ std::ostream& operator<<(std::ostream& os, CowOperation const& op) {
    os << "data_length:" << op.data_length << ",\t";
    os << "new_block:" << op.new_block << ",\t";
    os << "source:" << op.source;
    if (op.type == kCowXorOp)
        os << " (block:" << op.source / BLOCK_SZ << " offset:" << op.source % BLOCK_SZ << ")";
    os << ")";
    return os;
}
+2 −2
Original line number Diff line number Diff line
@@ -517,8 +517,8 @@ bool CowReader::VerifyMergeOps() {
            block = op.source;
            offset = false;
        } else if (op.type == kCowXorOp) {
            block = op.source / BLOCK_SZ;
            offset = (op.source % BLOCK_SZ) != 0;
            block = op.source / header_.block_size;
            offset = (op.source % header_.block_size) != 0;
        } else {
            itr->Next();
            continue;
+3 −0
Original line number Diff line number Diff line
@@ -41,6 +41,9 @@ static constexpr uint32_t SNAPSHOT_VALID = 1;
 */
static constexpr uint32_t SECTOR_SHIFT = 9;

static constexpr size_t BLOCK_SZ = 4096;
static constexpr size_t BLOCK_SHIFT = (__builtin_ffs(BLOCK_SZ) - 1);

typedef __u64 sector_t;
typedef sector_t chunk_t;