53
53
/* command line argument to do page checks (that's it) */
54
54
/* another argument to specify page ranges... seek to right spot and go from there */
56
typedef uint32_t ulint;
57
typedef unsigned char uchar;
59
56
/* innodb function in name; modified slightly to not have the ASM version (lots of #ifs that didn't apply) */
60
static ulint mach_read_from_4(uchar *b)
57
static uint32_t mach_read_from_4(unsigned char *b)
62
return( ((ulint)(b[0]) << 24)
63
+ ((ulint)(b[1]) << 16)
64
+ ((ulint)(b[2]) << 8)
59
return( ((uint32_t)(b[0]) << 24)
60
+ ((uint32_t)(b[1]) << 16)
61
+ ((uint32_t)(b[2]) << 8)
67
ut_fold_uint32_t_pair(
71
68
/*===============*/
72
69
/* out: folded value */
73
ulint n1, /* in: ulint */
74
ulint n2) /* in: ulint */
70
uint32_t n1, /* in: uint32_t */
71
uint32_t n2) /* in: uint32_t */
76
73
return(((((n1 ^ n2 ^ UT_HASH_RANDOM_MASK2) << 8) + n1)
77
74
^ UT_HASH_RANDOM_MASK) + n2);
83
80
/* out: folded value */
84
uchar* str, /* in: string of bytes */
85
ulint len) /* in: length */
81
unsigned char* str, /* in: string of bytes */
82
uint32_t len) /* in: length */
90
87
for (i= 0; i < len; i++)
92
fold= ut_fold_ulint_pair(fold, (ulint)(*str));
89
fold= ut_fold_uint32_t_pair(fold, (uint32_t)(*str));
101
98
buf_calc_page_new_checksum(
102
99
/*=======================*/
103
100
/* out: checksum */
104
uchar* page) /* in: buffer page */
101
unsigned char* page) /* in: buffer page */
108
105
/* Since the fields FIL_PAGE_FILE_FLUSH_LSN and ..._ARCH_LOG_NO
109
106
are written outside the buffer pool to the first pages of data
122
119
return(checksum);
126
123
buf_calc_page_old_checksum(
127
124
/*=======================*/
128
125
/* out: checksum */
129
uchar* page) /* in: buffer page */
126
unsigned char* page) /* in: buffer page */
133
130
checksum= ut_fold_binary(page, FIL_PAGE_FILE_FLUSH_LSN);
141
138
int main(int argc, char **argv)
143
140
FILE *f; /* our input file */
144
uchar *p; /* storage of pages read */
141
unsigned char *p; /* storage of pages read */
145
142
int bytes; /* bytes read count */
146
ulint ct; /* current page number (0 based) */
143
uint32_t ct; /* current page number (0 based) */
147
144
int now; /* current time */
148
145
int lastt; /* last time */
149
ulint oldcsum, oldcsumfield, csum, csumfield, logseq, logseqfield; /* ulints for checksum storage */
146
uint32_t oldcsum, oldcsumfield, csum, csumfield, logseq, logseqfield; /* uint32_ts for checksum storage */
150
147
struct stat st; /* for stat, if you couldn't guess */
151
148
unsigned long long int size; /* size of file (has to be 64 bits) */
152
ulint pages; /* number of pages in file */
153
ulint start_page= 0, end_page= 0, use_end_page= 0; /* for starting and ending at certain pages */
149
uint32_t pages; /* number of pages in file */
150
uint32_t start_page= 0, end_page= 0, use_end_page= 0; /* for starting and ending at certain pages */
155
152
int just_count= 0; /* if true, just print page count */