Head cache cnt and idx were being checked the wrong way.
[fsck.sofs09.git] / test_infree.c
blobb31c71869fd35c73c0034806538db0220eb8476f
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;
12 fetch_superblock(&sb);
14 /* number of free inodes found in the free inode list */
15 uint32_t ifree;
17 /* current inode */
18 SOInode inode;
20 /* index of the current inode */
21 uint32_t inodeidx;
23 /* inode status from ictable */
24 ic_t icstat;
26 ret = nice;
27 ifree = 0;
28 inodeidx = sb->ihead;
29 while ((inodeidx != NULL_INODE) && (ret != corrupt)) {
30 if (inodeidx < sb->itotal) {
31 ictable_get(inodeidx, &icstat);
32 switch (icstat) {
33 case bah:
34 fret = soReadInode(&inode, inodeidx);
35 if (fret < 0) FABORT(fret, "test_infree");
36 ifree++;
37 ictable_set(inodeidx, idle);
38 break;
39 case busy:
40 printf("Free inode list contains used inodes.\n");
41 ret = corrupt;
42 break;
43 case idle:
44 printf("Free inode list closes over itself.\n");
45 ret = corrupt;
46 break;
47 default:
48 printf("BUM! ictable has something strange in it.\n");
49 return corrupt;
50 break;
52 } else {
53 printf("Free inode list has a member pointing to %d, which is "
54 "outside the list.\n", inodeidx);
55 ret = corrupt;
57 inodeidx = inode.next;
60 if ((ret != corrupt) && (ifree != sb->ifree)) {
61 printf("ifree is incorrect.\n");
62 ret = corrupt;
65 return ret;