~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to extra/innochecksum.c

  • Committer: Mark Atwood
  • Date: 2008-07-01 21:25:46 UTC
  • mto: This revision was merged to the branch mainline in revision 45.
  • Revision ID: mark@localhost.localdomain-20080701212546-jzs7ljtwcp2dcmgd
Remove all OpenSSL and all YaSSL code

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include <sys/types.h>
36
36
#include <sys/stat.h>
37
37
#include <unistd.h>
38
 
#include <stdint.h>
39
38
 
40
39
/* all of these ripped from InnoDB code from MySQL 4.0.22 */
41
40
#define UT_HASH_RANDOM_MASK     1463735687
51
50
/* command line argument to do page checks (that's it) */
52
51
/* another argument to specify page ranges... seek to right spot and go from there */
53
52
 
54
 
typedef uint32_t ulint;
 
53
typedef unsigned long int ulint;
55
54
typedef unsigned char uchar;
56
55
 
57
56
/* innodb function in name; modified slightly to not have the ASM version (lots of #ifs that didn't apply) */
58
 
static ulint mach_read_from_4(uchar *b)
 
57
ulint mach_read_from_4(uchar *b)
59
58
{
60
59
  return( ((ulint)(b[0]) << 24)
61
60
          + ((ulint)(b[1]) << 16)
64
63
          );
65
64
}
66
65
 
67
 
static ulint
 
66
ulint
68
67
ut_fold_ulint_pair(
69
68
/*===============*/
70
69
            /* out: folded value */
75
74
                        ^ UT_HASH_RANDOM_MASK) + n2);
76
75
}
77
76
 
78
 
static ulint
 
77
ulint
79
78
ut_fold_binary(
80
79
/*===========*/
81
80
            /* out: folded value */
95
94
    return(fold);
96
95
}
97
96
 
98
 
static ulint
 
97
ulint
99
98
buf_calc_page_new_checksum(
100
99
/*=======================*/
101
100
               /* out: checksum */
120
119
    return(checksum);
121
120
}
122
121
 
123
 
static ulint
 
122
ulint
124
123
buf_calc_page_old_checksum(
125
124
/*=======================*/
126
125
               /* out: checksum */
220
219
  pages= size / UNIV_PAGE_SIZE;
221
220
  if (just_count)
222
221
  {
223
 
    printf("%u\n", pages);
 
222
    printf("%lu\n", pages);
224
223
    return 0;
225
224
  }
226
225
  else if (verbose)
227
226
  {
228
 
    printf("file %s= %llu bytes (%u pages)...\n", argv[1], size, pages);
229
 
    printf("checking pages in range %u to %u\n", start_page, use_end_page ? end_page : (pages - 1));
 
227
    printf("file %s= %llu bytes (%lu pages)...\n", argv[1], size, pages);
 
228
    printf("checking pages in range %lu to %lu\n", start_page, use_end_page ? end_page : (pages - 1));
230
229
  }
231
230
 
232
231
  /* open the file for reading */
276
275
    logseq= mach_read_from_4(p + FIL_PAGE_LSN + 4);
277
276
    logseqfield= mach_read_from_4(p + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM + 4);
278
277
    if (debug)
279
 
      printf("page %u: log sequence number: first = %u; second = %u\n", ct, logseq, logseqfield);
 
278
      printf("page %lu: log sequence number: first = %lu; second = %lu\n", ct, logseq, logseqfield);
280
279
    if (logseq != logseqfield)
281
280
    {
282
 
      fprintf(stderr, "page %u invalid (fails log sequence number check)\n", ct);
 
281
      fprintf(stderr, "page %lu invalid (fails log sequence number check)\n", ct);
283
282
      return 1;
284
283
    }
285
284
 
287
286
    oldcsum= buf_calc_page_old_checksum(p);
288
287
    oldcsumfield= mach_read_from_4(p + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM);
289
288
    if (debug)
290
 
      printf("page %u: old style: calculated = %u; recorded = %u\n", ct, oldcsum, oldcsumfield);
 
289
      printf("page %lu: old style: calculated = %lu; recorded = %lu\n", ct, oldcsum, oldcsumfield);
291
290
    if (oldcsumfield != mach_read_from_4(p + FIL_PAGE_LSN) && oldcsumfield != oldcsum)
292
291
    {
293
 
      fprintf(stderr, "page %u invalid (fails old style checksum)\n", ct);
 
292
      fprintf(stderr, "page %lu invalid (fails old style checksum)\n", ct);
294
293
      return 1;
295
294
    }
296
295
 
298
297
    csum= buf_calc_page_new_checksum(p);
299
298
    csumfield= mach_read_from_4(p + FIL_PAGE_SPACE_OR_CHKSUM);
300
299
    if (debug)
301
 
      printf("page %u: new style: calculated = %u; recorded = %u\n", ct, csum, csumfield);
 
300
      printf("page %lu: new style: calculated = %lu; recorded = %lu\n", ct, csum, csumfield);
302
301
    if (csumfield != 0 && csum != csumfield)
303
302
    {
304
 
      fprintf(stderr, "page %u invalid (fails new style checksum)\n", ct);
 
303
      fprintf(stderr, "page %lu invalid (fails new style checksum)\n", ct);
305
304
      return 1;
306
305
    }
307
306
 
319
318
        if (!lastt) lastt= now;
320
319
        if (now - lastt >= 1)
321
320
        {
322
 
          printf("page %u okay: %.3f%% done\n", (ct - 1), (float) ct / pages * 100);
 
321
          printf("page %lu okay: %.3f%% done\n", (ct - 1), (float) ct / pages * 100);
323
322
          lastt= now;
324
323
        }
325
324
      }