home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / filesy~1 / mfs610s.zoo / fsck / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-13  |  1.9 KB  |  130 lines

  1. /* This File is part of 'fsck' copyright S.N. Henson */
  2.  
  3. #define EXTERN /**/
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <unistd.h>
  9.  
  10. #include "fs.h"
  11. #include "global.h"
  12. #include "proto.h"
  13.  
  14. void main(argc,argv)
  15. int argc;
  16. char **argv;
  17. {
  18.     int rw;
  19.     int c;
  20.     extern void do_fsck1(),do_fsck2();
  21.  
  22.     extern int optind,opterr;
  23.     extern char *optarg;
  24.  
  25.     if(!__mint)
  26.     {
  27.         fprintf(stderr,"Fatal: MiNT not active\n");
  28.         exit(1);
  29.     }
  30.  
  31.     rw=1;
  32.     opterr=0;
  33.     while( (c=getopt(argc,argv,"pyYnNd:D:sSRi:e"))!=EOF )
  34.     {
  35.         switch(c)
  36.         {
  37.             case 'y':
  38.             case 'Y':
  39.             ally=1;
  40.             break;
  41.             
  42.             case 'n':
  43.             case 'N':
  44.             rw=0;
  45.             alln=1;
  46.             break;
  47.  
  48.             case 'd':
  49.             case 'D':
  50.             incr=atoi(optarg);
  51.             if( (incr<1) || (incr>8) || NPOW2(incr))
  52.             {
  53.                 fprintf(stderr,"Invalid Increment Value\n");
  54.                 exit(1);
  55.             }
  56.             break;
  57.  
  58.             case 's':
  59.             info=1;
  60.             break;
  61.  
  62.             case 'S':
  63.             info=2;
  64.             break;
  65.  
  66.             case 'R':
  67.             badroot=1;
  68.             break;
  69.  
  70.             case 'i':
  71.             comma_parse(optarg,&inums);
  72.             break;
  73. #if notyet
  74.             case 'u':
  75.             ul=malloc(sizeof(llist));
  76.             if(!ul) fatal("Out of Memory");
  77.             ul->member=(long)strdup(optarg);
  78.             ul->next=unlist;
  79.             unlist=ul;
  80.             break;
  81. #endif
  82.  
  83.             case 'p':
  84.             preen=1;
  85.             break;
  86.  
  87.             case 'e':
  88.             no_size=1;
  89.             break;
  90.  
  91.             case '?':
  92.             usage();
  93.             break;        
  94.         }
  95.     }
  96.  
  97.     if( (argc-optind!=1) || opterr) usage();
  98.  
  99.     if(preen && (ally || alln))
  100.     {
  101.         fprintf(stderr,"-p option cannot be mixed with -n or -y\n");
  102.         exit(1);
  103.     }
  104.  
  105.     if(preen) ally=1;
  106.  
  107.     if(badroot && !incr)
  108.     {
  109.         fprintf(stderr,"'-R' option needs '-d'\n");
  110.         exit(1);
  111.     } 
  112.  
  113.     drvnam=strdup(argv[optind]);
  114.  
  115.     if( init_device(argv[optind],rw))
  116.     {
  117.         fprintf(stderr,"Can't Open Device %s\n",argv[optind]);
  118.         exit(1);
  119.     }
  120.  
  121.     read_tables();
  122.  
  123.     if(version) do_fsck2();
  124.     else do_fsck1();
  125.  
  126.     showinfo();
  127.     close_device();
  128.     exit(0);
  129. }
  130.