Extract common OMFS code into a library
[omfsprogs.git] / omfsck.c
blob5ad597708b3f8d7bdc75bba951c8c7e8b8fb7064
1 /*
2 * Filesystem check for OMFS
3 */
4 #include <stdlib.h>
5 #include <getopt.h>
6 #include "config.h"
7 #include "omfs.h"
8 #include "dirscan.h"
9 #include "check.h"
11 int main(int argc, char *argv[])
13 FILE *fp;
14 char *dev;
16 check_fs_config_t config = {
17 .is_quiet = 0,
20 while (1)
22 int c;
24 c = getopt(argc, argv, "q");
25 if (c == -1)
26 break;
28 switch(c)
30 case 'q':
31 config.is_quiet = 1;
32 break;
36 if (argc - optind < 1)
38 fprintf(stderr, "Usage: %s [options] <device>\n", argv[0]);
39 exit(1);
42 dev = argv[optind];
44 fp = fopen(dev, "r+");
45 if (!fp)
47 perror("omfsck: ");
48 exit(2);
51 if (!check_fs(fp, &config))
53 fclose(fp);
54 exit(3);
56 fclose(fp);
58 if (!config.is_quiet)
59 printf("File system check successful\n");
60 return 0;