Commit adba557e authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

logdump didn't understand the magic. Addresses #20, #11

git-svn-id: file:///svn/tokudb@724 c7de825b-a66e-492c-adef-691d508d4ae1
parent ee171210
......@@ -493,7 +493,7 @@ int toku_fread_LOGGEDBRTHEADER(FILE *f, LOGGEDBRTHEADER *v, u_int32_t *crc, u_in
r = toku_fread_DISKOFF (f, &v->freelist, crc, len); if (r!=0) return r;
r = toku_fread_DISKOFF (f, &v->unused_memory, crc, len); if (r!=0) return r;
r = toku_fread_u_int32_t(f, &v->n_named_roots, crc, len); if (r!=0) return r;
assert(v->n_named_roots==0);
assert((signed)v->n_named_roots==-1);
r = toku_fread_DISKOFF (f, &v->root, crc, len); if (r!=0) return r;
return 0;
}
......
/* Dump the log from stdin to stdout. */
#include <arpa/inet.h>
#include <stdio.h>
#include <sys/types.h>
#include <ctype.h>
......@@ -116,6 +117,30 @@ void transcribe_header (void) {
printf("}");
}
void read_and_print_magic (void) {
{
char magic[8];
int r=fread(magic, 1, 8, stdin);
if (r!=8) {
fprintf(stderr, "Couldn't read the magic\n");
exit(1);
}
if (memcmp(magic, "tokulogg", 8)!=0) {
fprintf(stderr, "Magic is wrong.\n");
exit(1);
}
}
{
int version;
int r=fread(&version, 1, 4, stdin);
if (r!=4) {
fprintf(stderr, "Couldn't read the version\n");
exit(1);
}
printf("tokulog v.%d\n", ntohl(version));
}
}
#if 1
int main (int argc, char *argv[]) {
int count=-1;
......@@ -123,6 +148,7 @@ int main (int argc, char *argv[]) {
if (argc>1) {
count = atoi(argv[1]);
}
read_and_print_magic();
for (i=0; i!=count; i++) {
int r = toku_logprint_one_record(stdout, stdin);
if (r!=0) {
......@@ -142,6 +168,7 @@ int main (int argc, char *argv[]) {
if (argc>1) {
count = atoi(argv[1]);
}
read_and_print_magic();
for (i=0;
i!=count && (crc=0,actual_len=0,cmd=get_char())!=EOF;
i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment