# HG changeset patch # User Michael Spacefalcon # Date 1373146315 0 # Node ID 074237879ecaa43199fbe1da653e84930d542fb4 # Parent 9f4469766c7418352c2dc5b84c8d16f103565966 pirollback: name check implemented diff -r 9f4469766c74 -r 074237879eca pirollback/Makefile --- a/pirollback/Makefile Sat Jul 06 20:52:09 2013 +0000 +++ b/pirollback/Makefile Sat Jul 06 21:31:55 2013 +0000 @@ -2,7 +2,7 @@ CFLAGS= -O2 PROGS= analyze -ANALYZE_OBJS= analyze.o init.o treewalk.o +ANALYZE_OBJS= analyze.o checknames.o init.o treewalk.o all: ${PROGS} diff -r 9f4469766c74 -r 074237879eca pirollback/analyze.c --- a/pirollback/analyze.c Sat Jul 06 20:52:09 2013 +0000 +++ b/pirollback/analyze.c Sat Jul 06 21:31:55 2013 +0000 @@ -17,5 +17,7 @@ printf("Last inode is #%x\n", last_inode); walk_tree(); printf("Tree walk succeeded\n"); + check_object_names(); + printf("Name check succeeded\n"); exit(0); } diff -r 9f4469766c74 -r 074237879eca pirollback/checknames.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pirollback/checknames.c Sat Jul 06 21:31:55 2013 +0000 @@ -0,0 +1,63 @@ +#include +#include +#include +#include "types.h" +#include "struct.h" +#include "pathname.h" + +extern struct inode_info inode[]; +extern int last_inode; + +static void +check_inode(ino) +{ + struct inode_info *in; + u8 *cp; + int cnt; + + in = inode + ino; + switch (in->type) { + case 0xE1: + case 0xF1: + case 0xF2: + break; + default: + return; + } + for (cp = in->dataptr, cnt = 0; ; cp++, cnt++) { + if (cnt >= in->len) { + fprintf(stderr, + "inode #%x: name expected at %x: length overrun\n", + ino, in->offset); + exit(1); + } + if (!*cp) + break; + if (cnt >= MAX_FN_COMPONENT) { + fprintf(stderr, + "inode #%x: name exceeds program limit of %d chars\n", + ino, MAX_FN_COMPONENT); + exit(1); + } + if (*cp < '!' || *cp > '~') { + fprintf(stderr, + "inode #%x: name expected at %x: bad character\n", + ino, in->offset); + exit(1); + } + } + if (!cnt) { + fprintf(stderr, "inode #%x: name expected at %x: null string\n", + ino, in->offset); + exit(1); + } + in->byte_after_name = cp + 1; +} + +check_object_names() +{ + int ino; + + for (ino = 1; ino <= last_inode; ino++) + check_inode(ino); +} diff -r 9f4469766c74 -r 074237879eca pirollback/pathname.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pirollback/pathname.h Sat Jul 06 21:31:55 2013 +0000 @@ -0,0 +1,2 @@ +#define MAX_FN_COMPONENT 20 +#define MAX_DIR_NEST 6 diff -r 9f4469766c74 -r 074237879eca pirollback/struct.h --- a/pirollback/struct.h Sat Jul 06 20:52:09 2013 +0000 +++ b/pirollback/struct.h Sat Jul 06 21:31:55 2013 +0000 @@ -21,4 +21,5 @@ u16 len; int descend; int sibling; + u8 *byte_after_name; };