BSD 3 development
[unix-history] / usr / src / cmd / clri.c
index d4da6de..8c2fa62 100644 (file)
@@ -2,10 +2,10 @@
  * clri filsys inumber ...
  */
 
  * clri filsys inumber ...
  */
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/ino.h>
 #include <sys/ino.h>
+
 #define ISIZE  (sizeof(struct dinode))
 #define ISIZE  (sizeof(struct dinode))
-#define        BSIZE   512
 #define        NI      (BSIZE/ISIZE)
 struct ino
 {
 #define        NI      (BSIZE/ISIZE)
 struct ino
 {
@@ -43,7 +43,7 @@ char *argv[];
                        status = 1;
                        continue;
                }
                        status = 1;
                        continue;
                }
-               off = ((n-1)/NI + 2) * (long)512;
+               off = itod(n) * BSIZE;
                lseek(f, off, 0);
                if(read(f, (char *)buf, BSIZE) != BSIZE) {
                        printf("%s: read error\n", argv[i]);
                lseek(f, off, 0);
                if(read(f, (char *)buf, BSIZE) != BSIZE) {
                        printf("%s: read error\n", argv[i]);
@@ -55,10 +55,10 @@ char *argv[];
        for(i=2; i<argc; i++) {
                n = atoi(argv[i]);
                printf("clearing %u\n", n);
        for(i=2; i<argc; i++) {
                n = atoi(argv[i]);
                printf("clearing %u\n", n);
-               off = ((n-1)/NI + 2) * (long)512;
+               off = itod(n) * BSIZE;
                lseek(f, off, 0);
                read(f, (char *)buf, BSIZE);
                lseek(f, off, 0);
                read(f, (char *)buf, BSIZE);
-               j = (n-1)%NI;
+               j = itoo(n);
                for(k=0; k<ISIZE; k++)
                        buf[j].junk[k] = 0;
                lseek(f, off, 0);
                for(k=0; k<ISIZE; k++)
                        buf[j].junk[k] = 0;
                lseek(f, off, 0);