Keep going to show all errors.
[fsck.sofs09.git] / test_infree.c
blob7bfacf92213bc625c55de652748ffec48ff41e21
1 #include <stdio.h>
2 #include "fsck.h"
3 #include "fsck_helper.h"
4 #include "sofs09.h"
6 testresult_t test_infree (void)
8 testresult_t ret;
9 uint32_t fret;
10 SOSuperBlock *sb;
11 uint32_t ifree;
12 SOInode inode;
13 uint32_t inodeidx;
14 ic_t icstat;
16 ret = nice;
18 fetch_superblock(&sb);
20 ifree = 0;
21 inodeidx = sb->ihead;
22 while (inodeidx != NULL_INODE) {
23 if (inodeidx < sb->itotal) {
24 ictable_get(inodeidx, &icstat);
25 switch (icstat) {
26 case bah:
27 fret = soReadInode(&inode, inodeidx);
28 if (fret < 0) FABORT(fret, "test_infree");
29 ifree++;
30 ictable_set(inodeidx, idle);
31 break;
32 case busy:
33 printf("Inode number %u is marked as used and is in free"
34 "inode list.\n", inodeidx);
35 ret = corrupt;
36 break;
37 case idle:
38 printf("Free inode list closes over itself.\n");
39 return corrupt;
40 break;
41 default:
42 printf("BUM! ictable has something strange in it.\n");
43 return corrupt;
44 break;
46 } else {
47 printf("Free inode list has a member pointing to %u, which is "
48 "outside the list.\n", inodeidx);
49 return corrupt;
51 inodeidx = inode.next;
54 if (ifree != sb->ifree) {
55 printf("ifree is %u, should be %u.\n", sb->ifree, ifree);
56 ret = corrupt;
59 return ret;