wilde: utils/admin validate-skiplist.c,1.3,1.4
cvs at intevation.de
cvs at intevation.de
Sun Mar 26 13:22:06 CEST 2006
Author: wilde
Update of /kolabrepository/utils/admin
In directory doto:/tmp/cvs-serv18227
Modified Files:
validate-skiplist.c
Log Message:
Added a bit more elaborated parsing of ADD nodes.
Added a bit nicer formated hex output in messages.
Corrected address offset in "Bad node" error message.
Index: validate-skiplist.c
===================================================================
RCS file: /kolabrepository/utils/admin/validate-skiplist.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- validate-skiplist.c 26 Mar 2006 11:08:50 -0000 1.3
+++ validate-skiplist.c 26 Mar 2006 11:22:04 -0000 1.4
@@ -28,8 +28,8 @@
#include <unistd.h>
#include <err.h>
-#define INFO(blk) if (verbose) { blk }
-#define WARN(blk) if (warnings) { blk }
+#define INFO(blk) if (verbose) { blk }
+#define WARN(blk) if (warnings) { blk }
int verbose = 0;
int warnings = 0;
@@ -62,6 +62,14 @@
}
+inline long
+align (long addr)
+{
+ if (addr % 4)
+ addr += 4 - (addr % 4);
+ return addr;
+}
+
int32_t
read_word (FILE *file)
{
@@ -71,17 +79,18 @@
{
word = word << 8;
if ((c = fgetc (file)) == EOF)
- errx (1, "Unexpected end of file at 0x%X", ftell (file));
+ errx (1, "Unexpected end of file at 0x%0.8X", ftell (file));
word += c;
}
return word;
}
+
void
jump_to_position (FILE *file, long pos)
{
if (fseek (file, pos, SEEK_SET) == -1)
- errx (1, "Unexpected end of file at 0x%X", ftell (file));
+ errx (1, "Unexpected end of file at 0x%0.8X", ftell (file));
}
@@ -105,7 +114,12 @@
switch (word)
{
case ADD:
- /* FIXME: we should inspect add nodes more in depth. */
+ word = read_word (file); /* key size */
+ word = align (word);
+ jump_to_position (file, ftell (file) + word);
+ word = read_word (file); /* data size */
+ word = align (word);
+ jump_to_position (file, ftell (file) + word);
while (read_word (file) != 0xffffffff); /* skip till termination */
++add;
break;
@@ -114,8 +128,8 @@
++delete;
break;
default:
- errx (1, "Bad node: expected ADD or DELETE at 0x%X! (found 0x%X)",
- ftell (file), word);
+ errx (1, "Bad node: expected ADD or DELETE at 0x%0.8X! (found 0x%0.8X)",
+ ftell (file) - 4, word);
}
commit_maybe (file);
}
@@ -150,7 +164,7 @@
jump_to_position (file, 40);
logstart = read_word (file);
- INFO (printf ("Log start at 0x%X\n", logstart);
+ INFO (printf ("Log start at 0x%0.8X\n", logstart);
word = read_word (file);
printf ("Last recovery on %s\n", ctime (&word));
);
More information about the commits
mailing list