1: /*
   2:  * clri filsys inumber ...
   3:  */
   4: 
   5: #include <sys/types.h>
   6: #include <sys/ino.h>
   7: #define ISIZE   (sizeof(struct dinode))
   8: #define BSIZE   512
   9: #define NI  (BSIZE/ISIZE)
  10: struct  ino
  11: {
  12:     char    junk[ISIZE];
  13: };
  14: struct  ino buf[NI];
  15: int status;
  16: 
  17: main(argc, argv)
  18: char *argv[];
  19: {
  20:     register i, f;
  21:     unsigned n;
  22:     int j, k;
  23:     long off;
  24: 
  25:     if(argc < 3) {
  26:         printf("usage: clri filsys inumber ...\n");
  27:         exit(4);
  28:     }
  29:     f = open(argv[1], 2);
  30:     if(f < 0) {
  31:         printf("cannot open %s\n", argv[1]);
  32:         exit(4);
  33:     }
  34:     for(i=2; i<argc; i++) {
  35:         if(!isnumber(argv[i])) {
  36:             printf("%s: is not a number\n", argv[i]);
  37:             status = 1;
  38:             continue;
  39:         }
  40:         n = atoi(argv[i]);
  41:         if(n == 0) {
  42:             printf("%s: is zero\n", argv[i]);
  43:             status = 1;
  44:             continue;
  45:         }
  46:         off = ((n-1)/NI + 2) * (long)512;
  47:         lseek(f, off, 0);
  48:         if(read(f, (char *)buf, BSIZE) != BSIZE) {
  49:             printf("%s: read error\n", argv[i]);
  50:             status = 1;
  51:         }
  52:     }
  53:     if(status)
  54:         exit(status);
  55:     for(i=2; i<argc; i++) {
  56:         n = atoi(argv[i]);
  57:         printf("clearing %u\n", n);
  58:         off = ((n-1)/NI + 2) * (long)512;
  59:         lseek(f, off, 0);
  60:         read(f, (char *)buf, BSIZE);
  61:         j = (n-1)%NI;
  62:         for(k=0; k<ISIZE; k++)
  63:             buf[j].junk[k] = 0;
  64:         lseek(f, off, 0);
  65:         write(f, (char *)buf, BSIZE);
  66:     }
  67:     exit(status);
  68: }
  69: 
  70: isnumber(s)
  71: char *s;
  72: {
  73:     register c;
  74: 
  75:     while(c = *s++)
  76:         if(c < '0' || c > '9')
  77:             return(0);
  78:     return(1);
  79: }

Defined functions

isnumber defined in line 70; used 1 times
  • in line 35
main defined in line 17; never used

Defined variables

buf defined in line 14; used 4 times
status defined in line 15; used 6 times

Defined struct's

ino defined in line 10; used 2 times
  • in line 14(2)

Defined macros

BSIZE defined in line 8; used 5 times
ISIZE defined in line 7; used 3 times
NI defined in line 9; used 4 times
Last modified: 1979-01-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 703
Valid CSS Valid XHTML 1.0 Strict