Keep going to show all errors.
[fsck.sofs09.git] / fsck.c
blob6e266e0be224fcd2c6c5996d551dd2a4d55723c7
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <errno.h>
5 /* open and close disc */
6 #include "sofs_rawdisc.h"
7 #include "fsck.h"
8 #include "fsck_helper.h"
9 #include "tests.h"
11 struct test_s {
12 testfunction_t function;
13 char *name;
15 typedef struct test_s test_t;
17 void main (int argc, char *argv[])
19 int ret;
20 int fret;
21 char *disc_path;
22 testresult_t testres;
23 int r;
24 int nfuncs;
26 /* functions containing the tests to be made */
27 test_t test[] =
29 {test_sbmagic, "sbmagic"},
30 {test_sbname, "sbname"},
31 {test_sbzones, "sbzones"},
32 {test_sbfctablesize, "sbfctablesize"},
33 {test_sbciutablesize, "sbciutablesize"},
34 {test_sbitotal, "sbitotal"},
35 {test_infree, "infree"},
36 {test_inused, "inused"},
37 {test_inlost, "inlost"},
38 {test_ininfo, "ininfo"},
39 {test_clusterfree, "clusterfree"},
40 {test_clusterused, "clusterused"},
41 {test_clusterlost, "clusterlost"},
44 if (argc != 2) ABORT(-EINVAL);
45 nfuncs = sizeof(test)/sizeof(test_t);
46 disc_path = argv[1];
48 printf("Opening file %s as disc.\n", disc_path);
49 fret = soOpenDevice(disc_path);
50 if (fret < 0) ABORT(fret);
51 atexit((void *)soCloseDevice);
53 /* create internal structures */
54 cctable_create();
55 atexit(cctable_free);
56 ictable_create();
57 atexit(ictable_free);
58 irtable_create();
59 atexit(irtable_free);
61 ret = EXIT_SUCCESS;
62 for (r = 0; (r < nfuncs) && (ret == EXIT_SUCCESS); ++r) {
63 testres = test[r].function();
64 switch (testres) {
65 case corrupt:
66 printf("System file corrupted.\n");
67 ret = EXIT_FAILURE;
68 break;
69 case weird:
70 printf("System file is weird.\n");
71 break;
72 case nice:
73 printf("Test %s passed with success.\n", test[r].name);
74 break;
75 default:
76 printf("BUM!\n");
77 ret = EXIT_FAILURE;
78 break;
82 cctable_print();
83 itable_print();
85 exit(ret);