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

Defined functions

isnumber defined in line 92; used 1 times
  • in line 45
main defined in line 27; never used

Defined variables

buf defined in line 24; used 4 times
sccsid defined in line 2; never used
status defined in line 25; used 6 times

Defined struct's

ino defined in line 20; used 2 times
  • in line 24(2)

Defined macros

BSIZE defined in line 17; used 7 times
ISIZE defined in line 15; used 3 times
NI defined in line 19; used 4 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 863
Valid CSS Valid XHTML 1.0 Strict