1: char    *sccsid = "@(#)clri.c 2.3";
   2: 
   3: /*
   4:  * clri filsys inumber ...
   5:  */
   6: 
   7: #include <sys/param.h>
   8: #include <sys/fs.h>
   9: #include <sys/file.h>
  10: #include <sys/inode.h>
  11: #include <stdio.h>
  12: #include <ctype.h>
  13: 
  14: #define ISIZE   (sizeof(struct dinode))
  15: #define NI  (DEV_BSIZE/ISIZE)
  16: 
  17: struct ino {
  18:     char    junk[ISIZE];
  19: };
  20: 
  21: struct ino  buf[NI];
  22: 
  23: main(argc, argv)
  24: int argc;
  25: char    **argv;
  26: {
  27:     register int    i,
  28:             f;
  29:     u_int   n;
  30:     int j,
  31:         k,
  32:         errors = 0;
  33:     long    off,
  34:         lseek();
  35: 
  36:     if (argc < 3) {
  37:         fprintf(stderr,"usage: %s filsys inumber ...\n",*argv);
  38:         exit(4);
  39:     }
  40:     if ((f = open(argv[1], O_RDWR)) < 0) {
  41:         perror(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:             ++errors;
  48:             continue;
  49:         }
  50:         n = atoi(argv[i]);
  51:         if (n == 0) {
  52:             printf("%s: is zero\n",argv[i]);
  53:             ++errors;
  54:             continue;
  55:         }
  56:         off = itod(n) * DEV_BSIZE;
  57:         lseek(f, off, L_SET);
  58:         if (read(f,(char *)buf,DEV_BSIZE != DEV_BSIZE)) {
  59:             perror(argv[i]);
  60:             ++errors;
  61:         }
  62:     }
  63:     if (errors)
  64:         exit(1);
  65:     for (i = 2;i < argc;i++) {
  66:         n = atoi(argv[i]);
  67:         printf("clearing %u\n",n);
  68:         off = itod(n) * DEV_BSIZE;
  69:         lseek(f,off,L_SET);
  70:         read(f,(char *)buf,DEV_BSIZE);
  71:         j = itoo(n);
  72:         for(k = 0;k < ISIZE;k++)
  73:             buf[j].junk[k] = 0;
  74:         lseek(f,off,L_SET);
  75:         write(f,(char *)buf,DEV_BSIZE);
  76:     }
  77:     exit(0);
  78: }
  79: 
  80: static
  81: isnumber(s)
  82: char    *s;
  83: {
  84:     for (;*s;++s)
  85:         if (!isdigit(*s))
  86:             return(0);
  87:     return(1);
  88: }

Defined functions

isnumber defined in line 80; used 1 times
  • in line 45
main defined in line 23; never used

Defined variables

buf defined in line 21; used 4 times
sccsid defined in line 1; never used

Defined struct's

ino defined in line 17; used 2 times
  • in line 21(2)

Defined macros

ISIZE defined in line 14; used 3 times
NI defined in line 15; used 1 times
  • in line 21
Last modified: 1987-02-19
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3490
Valid CSS Valid XHTML 1.0 Strict