4 #include "fsck_helper.h"
7 /* this function needs to be remade. IT IS NASTY */
8 static bool parse_directory(uint32_t inodeidx
)
13 SOInode inode
, newinode
;
14 SODirEntry dec
[DPC
]; /* direntry cluster */
18 fetch_superblock(&sb
);
19 printf("Parsing directory number %d.\n", inodeidx
);
23 fret
= soReadInode(&inode
, inodeidx
);
24 if (fret
< 0) FABORT(fret
, "parse_directory");
26 ictable_get(inodeidx
, &icstat
);
29 ictable_set(inodeidx
, busy
);
32 printf ("Inode %d is marked as free but is in use.\n", inodeidx
);
35 /* already parsed this inode */
38 printf("BUM! ictable has something strange in it.\n");
43 for (cn
= 0; (cn
*CLUSTER_SIZE
< inode
.size
) && (ret
!= false)
44 && (icstat
== bah
); ++cn
) {
45 /* read a new cluster */
46 fret
= soReadFileCluster(inodeidx
, cn
, dec
);
47 if (fret
< 0) FABORT(fret
, "parse_directory");
48 for (den
= 0; (den
< DPC
) && ((cn
*CLUSTER_SIZE
+ den
*sizeof(SODirEntry
))
49 < inode
.size
) && (ret
!= false); ++den
) {
50 /* process direntry */
51 if (dec
[den
].name
[0] != '\0') {
52 if (dec
[den
].inode
>= sb
->itotal
) {
53 printf("Direntry number %d of inode %d is pointing to %d, "
54 "which lies outside inode table.\n", den
+(cn
*DPC
),
55 inodeidx
, dec
[den
].inode
);
58 irtable_inc(dec
[den
].inode
);
59 fret
= soReadInode(&newinode
, dec
[den
].inode
);
60 if (fret
< 0) FABORT(fret
, "parse_directory");
61 if ((newinode
.mode
& INODE_DIR
) == INODE_DIR
) {
62 ret
= parse_directory(dec
[den
].inode
);
64 ictable_get(dec
[den
].inode
, &icstat
);
67 ictable_set(dec
[den
].inode
, busy
);
71 ("Inode %d is marked as free but is in "
72 "use.\n", dec
[den
].inode
);
76 /* already parsed this inode * */
79 printf("BUM! ictable has something strange in "
93 testresult_t
test_inused(void)
99 /* begin in root directory */
100 if (parse_directory(0) == false) {