comparison pirollback/checknames.c @ 44:074237879eca

pirollback: name check implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 06 Jul 2013 21:31:55 +0000
parents
children 78ac405716db
comparison
equal deleted inserted replaced
43:9f4469766c74 44:074237879eca
1 #include <sys/types.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include "types.h"
5 #include "struct.h"
6 #include "pathname.h"
7
8 extern struct inode_info inode[];
9 extern int last_inode;
10
11 static void
12 check_inode(ino)
13 {
14 struct inode_info *in;
15 u8 *cp;
16 int cnt;
17
18 in = inode + ino;
19 switch (in->type) {
20 case 0xE1:
21 case 0xF1:
22 case 0xF2:
23 break;
24 default:
25 return;
26 }
27 for (cp = in->dataptr, cnt = 0; ; cp++, cnt++) {
28 if (cnt >= in->len) {
29 fprintf(stderr,
30 "inode #%x: name expected at %x: length overrun\n",
31 ino, in->offset);
32 exit(1);
33 }
34 if (!*cp)
35 break;
36 if (cnt >= MAX_FN_COMPONENT) {
37 fprintf(stderr,
38 "inode #%x: name exceeds program limit of %d chars\n",
39 ino, MAX_FN_COMPONENT);
40 exit(1);
41 }
42 if (*cp < '!' || *cp > '~') {
43 fprintf(stderr,
44 "inode #%x: name expected at %x: bad character\n",
45 ino, in->offset);
46 exit(1);
47 }
48 }
49 if (!cnt) {
50 fprintf(stderr, "inode #%x: name expected at %x: null string\n",
51 ino, in->offset);
52 exit(1);
53 }
54 in->byte_after_name = cp + 1;
55 }
56
57 check_object_names()
58 {
59 int ino;
60
61 for (ino = 1; ino <= last_inode; ino++)
62 check_inode(ino);
63 }