MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / assert_cksum_lsn

Function assert_cksum_lsn

tools/comdb2ar/increment.cpp:81–98  ·  view source on GitHub ↗

Determine whether the file has changed, ie if the page's current LSN + Checksum is the same as it is in the .incr diff file

Source from the content-addressed store, hash-verified

79// Determine whether the file has changed, ie if the page's current LSN + Checksum
80// is the same as it is in the .incr diff file
81bool assert_cksum_lsn(FileInfo &file, uint8_t *new_pagep, uint8_t *old_pagep, size_t pagesize) {
82 uint32_t new_lsn_file = LSN(new_pagep).file;
83 uint32_t new_lsn_offs = LSN(new_pagep).offset;
84 bool verify_ret;
85 uint32_t new_cksum;
86 bool crypto = file.get_crypto();
87 bool swapped = file.get_swapped();
88 verify_checksum(new_pagep, pagesize, crypto, swapped, &verify_ret, &new_cksum);
89
90 uint8_t cmp_arr[12];
91 for (int i = 0; i < 4; ++i){
92 cmp_arr[i] = ((uint8_t *) &new_lsn_file)[i];
93 cmp_arr[4 + i] = ((uint8_t *) &new_lsn_offs)[i];
94 cmp_arr[8 + i] = ((uint8_t *) &new_cksum)[i];
95 }
96
97 return (memcmp(cmp_arr, old_pagep, 12) != 0);
98}
99
100// Compare the page with the diff file to determine whether it has changed - driver
101// For each file, populate pages with the page numbers fo the changed pages

Callers 1

compare_checksumFunction · 0.85

Calls 3

verify_checksumFunction · 0.85
get_cryptoMethod · 0.45
get_swappedMethod · 0.45

Tested by

no test coverage detected