use physical sector size for partial buffer reads;
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Thu, 12 Mar 1987 12:06:28 +0000 (04:06 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Thu, 12 Mar 1987 12:06:28 +0000 (04:06 -0800)
-n implies "yes" answer for "CONTINUE?"

SCCS-vsn: sbin/fsck/fsck.h 5.4
SCCS-vsn: sbin/fsck/setup.c 5.12
SCCS-vsn: sbin/fsck/utilities.c 5.9

usr/src/sbin/fsck/fsck.h
usr/src/sbin/fsck/setup.c
usr/src/sbin/fsck/utilities.c

index c7df6e5..bb97a18 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)fsck.h      5.3 (Berkeley) %G%
+ *     @(#)fsck.h      5.4 (Berkeley) %G%
  */
 
 #define        MAXDUP          10      /* limit on dup blks (per inode) */
  */
 
 #define        MAXDUP          10      /* limit on dup blks (per inode) */
@@ -133,6 +133,7 @@ struct zlncnt *zlnhead;             /* head of zero link count list */
 char   rawflg;
 char   *devname;
 long   dev_bsize;              /* computed value of DEV_BSIZE */
 char   rawflg;
 char   *devname;
 long   dev_bsize;              /* computed value of DEV_BSIZE */
+long   secsize;                /* actual disk sector size */
 char   nflag;                  /* assume a no response */
 char   yflag;                  /* assume a yes response */
 int    bflag;                  /* location of alternate super block */
 char   nflag;                  /* assume a no response */
 char   yflag;                  /* assume a yes response */
 int    bflag;                  /* location of alternate super block */
index 20fa24f..bd4c960 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)setup.c    5.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)setup.c    5.12 (Berkeley) %G%";
 #endif not lint
 
 #define DKTYPENAMES
 #endif not lint
 
 #define DKTYPENAMES
@@ -182,6 +182,7 @@ readsb(listerr)
        int listerr;
 {
        BUFAREA asblk;
        int listerr;
 {
        BUFAREA asblk;
+       struct disklabel *getdisklabel(), *lp;
 #      define altsblock asblk.b_un.b_fs
        daddr_t super = bflag ? bflag * DEV_BSIZE : SBOFF;
 
 #      define altsblock asblk.b_un.b_fs
        daddr_t super = bflag ? bflag * DEV_BSIZE : SBOFF;
 
@@ -211,6 +212,10 @@ readsb(listerr)
         * When an alternate super-block is specified this check is skipped.
         */
        dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1);
         * When an alternate super-block is specified this check is skipped.
         */
        dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1);
+       if (lp = getdisklabel((char *)NULL, dfile.rfdes))
+               secsize = lp->d_secsize;
+       else
+               secsize = dev_bsize;
        sblk.b_bno = sblk.b_bno / dev_bsize;
        if (bflag)
                return (1);
        sblk.b_bno = sblk.b_bno / dev_bsize;
        if (bflag)
                return (1);
@@ -275,7 +280,6 @@ calcsb(dev, devfd, fs)
        register struct disklabel *lp;
        register struct partition *pp;
        register char *cp;
        register struct disklabel *lp;
        register struct partition *pp;
        register char *cp;
-       struct disklabel *getdisklabel();
        int i;
 
        cp = index(dev, '\0') - 1;
        int i;
 
        cp = index(dev, '\0') - 1;
@@ -328,6 +332,8 @@ getdisklabel(s, fd)
        static struct disklabel lab;
 
        if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) {
        static struct disklabel lab;
 
        if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) {
+               if (s == NULL)
+                       return ((struct disklabel *)NULL);
                pwarn("");
                perror("ioctl (GDINFO)");
                errexit("%s: can't read disk label", s);
                pwarn("");
                perror("ioctl (GDINFO)");
                errexit("%s: can't read disk label", s);
index 6f96573..05c6937 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)utilities.c        5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)utilities.c        5.9 (Berkeley) %G%";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
@@ -42,15 +42,16 @@ reply(s)
        char *s;
 {
        char line[80];
        char *s;
 {
        char line[80];
+       int cont = (strcmp(s, "CONTINUE") == 0);
 
        if (preen)
                pfatal("INTERNAL ERROR: GOT TO reply()");
        printf("\n%s? ", s);
 
        if (preen)
                pfatal("INTERNAL ERROR: GOT TO reply()");
        printf("\n%s? ", s);
-       if (nflag || dfile.wfdes < 0) {
+       if (!cont && (nflag || dfile.wfdes < 0)) {
                printf(" no\n\n");
                return (0);
        }
                printf(" no\n\n");
                return (0);
        }
-       if (yflag) {
+       if (yflag || (cont && nflag)) {
                printf(" yes\n\n");
                return (1);
        }
                printf(" yes\n\n");
                return (1);
        }
@@ -111,7 +112,9 @@ flush(fcp, bp)
        if (!bp->b_dirty)
                return;
        if (bp->b_errs != 0)
        if (!bp->b_dirty)
                return;
        if (bp->b_errs != 0)
-               pfatal("WRITING ZERO'ED BLOCK %d TO DISK\n", bp->b_bno);
+               pfatal("WRITING %sZERO'ED BLOCK %d TO DISK\n",
+                   (bp->b_errs == bp->b_size / dev_bsize) ? "" : "PARTIALLY ",
+                   bp->b_bno);
        bp->b_dirty = 0;
        bp->b_errs = 0;
        bwrite(fcp, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size);
        bp->b_dirty = 0;
        bp->b_errs = 0;
        bwrite(fcp, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size);
@@ -142,7 +145,7 @@ ckfini()
 
        flush(&dfile, &fileblk);
        flush(&dfile, &sblk);
 
        flush(&dfile, &fileblk);
        flush(&dfile, &sblk);
-       if (sblk.b_bno != SBOFF / dev_bsize &&
+       if (dev_bsize && sblk.b_bno != SBOFF / dev_bsize &&
            !preen && reply("UPDATE STANDARD SUPERBLOCK")) {
                sblk.b_bno = SBOFF / dev_bsize;
                sbdirty();
            !preen && reply("UPDATE STANDARD SUPERBLOCK")) {
                sblk.b_bno = SBOFF / dev_bsize;
                sbdirty();
@@ -172,11 +175,16 @@ bread(fcp, buf, blk, size)
                rwerr("SEEK", blk);
        errs = 0;
        bzero(buf, size);
                rwerr("SEEK", blk);
        errs = 0;
        bzero(buf, size);
-       pfatal("THE FOLLOWING SECTORS COULD NOT BE READ:");
-       for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize) {
-               if (read(fcp->rfdes, cp, dev_bsize) < 0) {
-                       lseek(fcp->rfdes, blk * dev_bsize + i + dev_bsize, 0);
-                       printf(" %d,", blk + i / dev_bsize);
+       printf("THE FOLLOWING DISK SECTORS COULD NOT BE READ:");
+       for (cp = buf, i = 0; i < size; i += secsize, cp += secsize) {
+               if (read(fcp->rfdes, cp, secsize) < 0) {
+                       lseek(fcp->rfdes, blk * dev_bsize + i + secsize, 0);
+                       if (secsize != dev_bsize)
+                               printf(" %d (%d),",
+                                   (blk * dev_bsize + i) / secsize,
+                                   blk + i / dev_bsize);
+                       else
+                               printf(" %d,", blk + i / dev_bsize);
                        errs++;
                }
        }
                        errs++;
                }
        }
@@ -204,7 +212,7 @@ bwrite(fcp, buf, blk, size)
        rwerr("WRITE", blk);
        if (lseek(fcp->wfdes, blk * dev_bsize, 0) < 0)
                rwerr("SEEK", blk);
        rwerr("WRITE", blk);
        if (lseek(fcp->wfdes, blk * dev_bsize, 0) < 0)
                rwerr("SEEK", blk);
-       pfatal("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:");
+       printf("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:");
        for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize)
                if (write(fcp->wfdes, cp, dev_bsize) < 0) {
                        lseek(fcp->rfdes, blk * dev_bsize + i + dev_bsize, 0);
        for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize)
                if (write(fcp->wfdes, cp, dev_bsize) < 0) {
                        lseek(fcp->rfdes, blk * dev_bsize + i + dev_bsize, 0);