242
242
oldcsum= buf_calc_page_old_checksum(p);
243
243
oldcsumfield= mach_read_from_4(p + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM);
245
printf("page %lu: old style: calculated = %lu; recorded = %lu\n", ct, oldcsum, oldcsumfield);
245
printf("page %lu: old style: calculated = 0x%08X; recorded = 0x%08X\n", ct, oldcsum, oldcsumfield);
246
246
if (oldcsumfield != oldcsum)
248
248
fprintf(stderr, "page %lu invalid (fails old style checksum)\n", ct);
249
fprintf(stderr, "page %lu: old style: calculated = 0x%X; recorded = 0x%X\n", ct, oldcsum, oldcsumfield);
249
fprintf(stderr, "page %lu: old style: calculated = 0x%08X; recorded = 0x%08X\n", ct, oldcsum, oldcsumfield);
250
250
if(fix_checksum){
251
251
fprintf(stderr, "fixing old checksum of page %lu\n", ct);
252
252
// rewite recorded checksum with calculated one
272
/* now check the new method */
273
csum= buf_calc_page_new_checksum(p);
274
csumfield= mach_read_from_4(p + FIL_PAGE_SPACE_OR_CHKSUM);
276
printf("page %lu: new style: calculated = 0x%08X; recorded = 0x%08X\n", ct, csum, csumfield);
277
if (csumfield != 0 && csum != csumfield)
279
fprintf(stderr, "page %lu invalid (fails new style checksum)\n", ct);
280
fprintf(stderr, "page %lu: new style: calculated = 0x%08X; recorded = 0x%08X\n", ct, csum, csumfield);
282
fprintf(stderr, "fixing new checksum of page %lu\n", ct);
283
// rewite recorded checksum with calculated one
284
fixed_chksum = mach_read_from_4((uchar*)&csum);
285
memcpy(p + FIL_PAGE_SPACE_OR_CHKSUM, &fixed_chksum, sizeof(fixed_chksum));
286
// move to beginning of the page
287
if(0 != fsetpos(f, &pos)){
288
perror("couldn't set a position to the start of the page");
291
if(1 != fwrite(p, UNIV_PAGE_SIZE, 1, f)){
292
perror("couldn't update the page");
270
302
/* end if this was the last page we were supposed to check */
271
303
if (use_end_page && (ct >= end_page))