4 #include "fsck_helper.h"
7 testresult_t
test_sbzones (void)
14 fetch_superblock(&sb
);
16 /* current position inside the disc, in blocks */
20 /* start position, in blocks, of this zone */
22 /* size, in blocks, of this zone */
27 struct zone_s zone
[] = {
28 {sb
->fctable_start
, sb
->fctable_size
, "FCT"},
29 {sb
->ciutable_start
, sb
->ciutable_size
, "CIUT"},
30 {sb
->itable_start
, sb
->itable_size
, "IT"},
31 {sb
->dzone_start
, sb
->dzone_size
*BLOCKS_PER_CLUSTER
, "DATA"},
33 struct zone_s tempzone
;
37 /* sort zones by start position (bubble sort) */
38 nzones
= sizeof(zone
)/sizeof(struct zone_s
);
39 for (r
= 0; r
< nzones
-1; ++r
) {
40 for (s
= r
; s
< nzones
-1-r
; ++s
) {
41 if (zone
[r
].start
> zone
[r
+1].start
) {
51 /* advance superblock */
54 for (r
= 0; (r
< nzones
) && (ret
!= corrupt
); ++r
) {
55 if (cpos
> zone
[r
].start
) {
56 printf("Zones overlap.\n");
59 if (cpos
!= zone
[r
].start
) {
60 printf("Zones are not contiguous.\n");
65 if (cpos
> sb
->ntotal
) {
66 printf("Zones exceed disc size.\n");
72 printf("Detected structure: ZONE_NAME (start,end)\n");
73 printf("0: SB (0,1) : ");
74 for (r
= 0; r
< nzones
; ++r
) {
75 printf("%s (%d,%d): ", zone
[r
].name
, zone
[r
].start
,
76 zone
[r
].start
+ zone
[r
].size
);
78 printf("%d\n", sb
->ntotal
);