FreeCalypso > hg > freecalypso-reveng
changeset 44:074237879eca
pirollback: name check implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 06 Jul 2013 21:31:55 +0000 |
parents | 9f4469766c74 |
children | 18472a2ccf55 |
files | pirollback/Makefile pirollback/analyze.c pirollback/checknames.c pirollback/pathname.h pirollback/struct.h |
diffstat | 5 files changed, 69 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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}
--- 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); }
--- /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 <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#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); +}