Commit d4c3edc7 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#3489 add --rootnode option to brtdump refs[t:3489]

git-svn-id: file:///svn/toku/tokudb@30576 c7de825b-a66e-492c-adef-691d508d4ae1
parent 92312d4c
...@@ -10,23 +10,10 @@ static void ...@@ -10,23 +10,10 @@ static void
format_time(const uint64_t time_int, char *buf) { format_time(const uint64_t time_int, char *buf) {
time_t timer = (time_t) time_int; time_t timer = (time_t) time_int;
ctime_r(&timer, buf); ctime_r(&timer, buf);
size_t len = strlen(buf); assert(buf[24] == '\n');
assert(len < 26); buf[24] = 0;
char end;
assert(len>=1);
end = buf[len-1];
while (end == '\n' || end == '\r') {
buf[len-1] = '\0';
len--;
assert(len>=1);
end = buf[len-1];
}
} }
static int dump_data = 1; static int dump_data = 1;
static CACHETABLE ct; static CACHETABLE ct;
...@@ -365,7 +352,7 @@ set_file(int f, u_int64_t offset, unsigned char newc) { ...@@ -365,7 +352,7 @@ set_file(int f, u_int64_t offset, unsigned char newc) {
toku_os_pwrite(f, &newc, sizeof newc, offset); toku_os_pwrite(f, &newc, sizeof newc, offset);
} }
static void static int
readline (char *line, int maxline) { readline (char *line, int maxline) {
int i = 0; int i = 0;
int c; int c;
...@@ -373,6 +360,7 @@ readline (char *line, int maxline) { ...@@ -373,6 +360,7 @@ readline (char *line, int maxline) {
line[i++] = (char)c; line[i++] = (char)c;
} }
line[i++] = 0; line[i++] = 0;
return c == EOF ? EOF : i;
} }
static int static int
...@@ -387,7 +375,7 @@ split_fields (char *line, char *fields[], int maxfields) { ...@@ -387,7 +375,7 @@ split_fields (char *line, char *fields[], int maxfields) {
static int static int
usage(const char *arg0) { usage(const char *arg0) {
printf("Usage: %s [--nodata] [--interactive] brtfilename\n", arg0); printf("Usage: %s [--nodata] [--interactive] [--rootnode] brtfilename\n", arg0);
return 1; return 1;
} }
...@@ -427,14 +415,18 @@ getuint64(const char *f) { ...@@ -427,14 +415,18 @@ getuint64(const char *f) {
int int
main (int argc, const char *const argv[]) { main (int argc, const char *const argv[]) {
const char *arg0 = argv[0];
int interactive = 0; int interactive = 0;
int rootnode = 0;
const char *arg0 = argv[0];
argc--; argv++; argc--; argv++;
while (argc>0) { while (argc>0) {
if (strcmp(argv[0], "--nodata") == 0) { if (strcmp(argv[0], "--nodata") == 0) {
dump_data = 0; dump_data = 0;
} else if (strcmp(argv[0], "--interactive") == 0 || strcmp(argv[0], "--i") == 0) { } else if (strcmp(argv[0], "--interactive") == 0 || strcmp(argv[0], "--i") == 0) {
interactive = 1; interactive = 1;
} else if (strcmp(argv[0], "--rootnode") == 0) {
rootnode = 1;
} else if (strcmp(argv[0], "--help") == 0) { } else if (strcmp(argv[0], "--help") == 0) {
return usage(arg0); return usage(arg0);
} else } else
...@@ -459,8 +451,8 @@ main (int argc, const char *const argv[]) { ...@@ -459,8 +451,8 @@ main (int argc, const char *const argv[]) {
printf("brtdump>"); fflush(stdout); printf("brtdump>"); fflush(stdout);
enum { maxline = 64}; enum { maxline = 64};
char line[maxline+1]; char line[maxline+1];
readline(line, maxline); r = readline(line, maxline);
if (strcmp(line, "") == 0) if (r == EOF)
break; break;
const int maxfields = 4; const int maxfields = 4;
char *fields[maxfields]; char *fields[maxfields];
...@@ -502,6 +494,8 @@ main (int argc, const char *const argv[]) { ...@@ -502,6 +494,8 @@ main (int argc, const char *const argv[]) {
break; break;
} }
} }
} else if (rootnode) {
dump_node(f, h->root, h);
} else { } else {
printf("Block translation:"); printf("Block translation:");
......
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