vfsck-sol9-breadwrite-args-20041108
[openafs.git] / src / vfsck / utilities.c
index 82750f6..b247f2e 100644 (file)
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID("$Header$");
+RCSID
+    ("$Header$");
 
 #include <sys/param.h>
-#define VICE    /* allow us to put our changes in at will */
+#define VICE                   /* allow us to put our changes in at will */
 #include <sys/time.h>
 #ifdef AFS_OSF_ENV
 #include <sys/vnode.h>
@@ -34,7 +35,7 @@ RCSID("$Header$");
 #undef _KERNEL
 #undef _BSD
 #define        AFS_NEWCG_ENV
-#else  /* AFS_OSF_ENV */
+#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #include <sys/vnode.h>
 #ifdef   AFS_SUN5_ENV
@@ -67,7 +68,7 @@ RCSID("$Header$");
 #endif
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
+#endif /* AFS_OSF_ENV */
 
 #include <stdio.h>
 #include <ctype.h>
@@ -83,11 +84,11 @@ RCSID("$Header$");
 #undef AFS_NEWCG_ENV
 #endif
 
-long   diskreads, totalreads;  /* Disk cache statistics */
+long diskreads, totalreads;    /* Disk cache statistics */
 #if    !defined(AFS_HPUX101_ENV)
-long   lseek();
+long lseek();
 #endif
-char   *malloc();
+char *malloc();
 #if    defined(AFS_SUN_ENV) || defined(AFS_DEC_ENV)
 extern int iscorrupt;
 #endif
@@ -100,81 +101,81 @@ extern int isdirty;
 #include <sys/stat.h>
 #include <sys/vfstab.h>
 
-offset_t       llseek();
+offset_t llseek();
 #endif
 
 ftypeok(dp)
-       struct dinode *dp;
+     struct dinode *dp;
 {
-       switch (dp->di_mode & IFMT) {
-
-       case IFDIR:
-       case IFREG:
-       case IFBLK:
-       case IFCHR:
-       case IFLNK:
-       case IFSOCK:
+    switch (dp->di_mode & IFMT) {
+
+    case IFDIR:
+    case IFREG:
+    case IFBLK:
+    case IFCHR:
+    case IFLNK:
+    case IFSOCK:
 #ifdef AFS_HPUX_ENV
-        case IFNWK:
+    case IFNWK:
 #endif
 #ifdef IFIFO
-       case IFIFO:
+    case IFIFO:
 #else
 #ifdef IFPORT
-       case IFPORT:
+    case IFPORT:
 #endif
 #endif /* IFIFO */
-               return (1);
+       return (1);
 
-       default:
-               if (debug)
-                       printf("bad file type 0%o\n", dp->di_mode);
-               return (0);
-       }
+    default:
+       if (debug)
+           printf("bad file type 0%o\n", dp->di_mode);
+       return (0);
+    }
 }
 
 #ifdef AFS_HPUX_ENV
 extern int fixed;
 #endif
 reply(question)
-       char *question;
+     char *question;
 {
-       int persevere;
-       char c;
+    int persevere;
+    char c;
 
-       if (preen)
-               pfatal("INTERNAL ERROR: GOT TO reply()");
-       persevere = !strcmp(question, "CONTINUE");
-       printf("\n");
-       if (!persevere && (nflag || fswritefd < 0)) {
-               printf("%s? no\n\n", question);
+    if (preen)
+       pfatal("INTERNAL ERROR: GOT TO reply()");
+    persevere = !strcmp(question, "CONTINUE");
+    printf("\n");
+    if (!persevere && (nflag || fswritefd < 0)) {
+       printf("%s? no\n\n", question);
 #if    defined(AFS_SUN_ENV) || defined(AFS_DEC_ENV)
-               iscorrupt = 1;          /* known to be corrupt */
+       iscorrupt = 1;          /* known to be corrupt */
 #endif
+       return (0);
+    }
+    if (yflag || (persevere && nflag)) {
+       printf("%s? yes\n\n", question);
+       return (1);
+    }
+    do {
+       printf("%s? [yn] ", question);
+       (void)fflush(stdout);
+       c = getc(stdin);
+       while (c != '\n' && getc(stdin) != '\n')
+           if (feof(stdin))
                return (0);
-       }
-       if (yflag || (persevere && nflag)) {
-               printf("%s? yes\n\n", question);
-               return (1);
-       }
-       do      {
-               printf("%s? [yn] ", question);
-               (void) fflush(stdout);
-               c = getc(stdin);
-               while (c != '\n' && getc(stdin) != '\n')
-                       if (feof(stdin))
-                               return (0);
-       } while (c != 'y' && c != 'Y' && c != 'n' && c != 'N');
-       printf("\n");
-       if (c == 'y' || c == 'Y')
-               return (1);
+    } while (c != 'y' && c != 'Y' && c != 'n' && c != 'N');
+    printf("\n");
+    if (c == 'y' || c == 'Y')
+       return (1);
 #ifdef AFS_HPUX_ENV
-       fixed = 0;
+    fixed = 0;
 #endif
 #if    defined(AFS_SUN_ENV) || defined(AFS_DEC_ENV)
-       iscorrupt = 1;          /* known to be corrupt */
+    iscorrupt = 1;             /* known to be corrupt */
 #endif
-       return (0);
+    return (0);
 }
 
 /*
@@ -182,37 +183,37 @@ reply(question)
  */
 bufinit()
 {
-       register struct bufarea *bp;
-       long bufcnt, i;
-       char *bufp;
-
+    register struct bufarea *bp;
+    long bufcnt, i;
+    char *bufp;
+
+    bufp = malloc((unsigned int)sblock.fs_bsize);
+    if (bufp == 0)
+       errexit("cannot allocate buffer pool\n");
+    cgblk.b_un.b_buf = bufp;
+    initbarea(&cgblk);
+    bufhead.b_next = bufhead.b_prev = &bufhead;
+    bufcnt = MAXBUFSPACE / sblock.fs_bsize;
+    if (bufcnt < MINBUFS)
+       bufcnt = MINBUFS;
+    for (i = 0; i < bufcnt; i++) {
+       bp = (struct bufarea *)malloc(sizeof(struct bufarea));
        bufp = malloc((unsigned int)sblock.fs_bsize);
-       if (bufp == 0)
-               errexit("cannot allocate buffer pool\n");
-       cgblk.b_un.b_buf = bufp;
-       initbarea(&cgblk);
-       bufhead.b_next = bufhead.b_prev = &bufhead;
-       bufcnt = MAXBUFSPACE / sblock.fs_bsize;
-       if (bufcnt < MINBUFS)
-               bufcnt = MINBUFS;
-       for (i = 0; i < bufcnt; i++) {
-               bp = (struct bufarea *)malloc(sizeof(struct bufarea));
-               bufp = malloc((unsigned int)sblock.fs_bsize);
-               if (bp == NULL || bufp == NULL) {
-                       if (i >= MINBUFS)
-                               break;
-                       errexit("cannot allocate buffer pool\n");
-               }
-               bp->b_un.b_buf = bufp;
-               bp->b_prev = &bufhead;
-               bp->b_next = bufhead.b_next;
-               bufhead.b_next->b_prev = bp;
-               bufhead.b_next = bp;
-               initbarea(bp);
+       if (bp == NULL || bufp == NULL) {
+           if (i >= MINBUFS)
+               break;
+           errexit("cannot allocate buffer pool\n");
        }
-       bufhead.b_size = i;     /* save number of buffers */
+       bp->b_un.b_buf = bufp;
+       bp->b_prev = &bufhead;
+       bp->b_next = bufhead.b_next;
+       bufhead.b_next->b_prev = bp;
+       bufhead.b_next = bp;
+       initbarea(bp);
+    }
+    bufhead.b_size = i;                /* save number of buffers */
 #ifdef AFS_SUN5_ENVX
-       pbp = pdirbp = NULL;
+    pbp = pdirbp = NULL;
 #endif
 }
 
@@ -221,413 +222,425 @@ bufinit()
  */
 struct bufarea *
 getdatablk(blkno, size)
-       daddr_t blkno;
-       long size;
+     daddr_t blkno;
+     long size;
 {
-       register struct bufarea *bp;
-
-       for (bp = bufhead.b_next; bp != &bufhead; bp = bp->b_next)
-               if (bp->b_bno == fsbtodb(&sblock, blkno))
-                       goto foundit;
-       for (bp = bufhead.b_prev; bp != &bufhead; bp = bp->b_prev)
-               if ((bp->b_flags & B_INUSE) == 0)
-                       break;
-       if (bp == &bufhead)
-               errexit("deadlocked buffer pool\n");
-       getblk(bp, blkno, size);
-       /* fall through */
-foundit:
-       totalreads++;
-       bp->b_prev->b_next = bp->b_next;
-       bp->b_next->b_prev = bp->b_prev;
-       bp->b_prev = &bufhead;
-       bp->b_next = bufhead.b_next;
-       bufhead.b_next->b_prev = bp;
-       bufhead.b_next = bp;
-       bp->b_flags |= B_INUSE;
-       return (bp);
+    register struct bufarea *bp;
+
+    for (bp = bufhead.b_next; bp != &bufhead; bp = bp->b_next)
+       if (bp->b_bno == fsbtodb(&sblock, blkno))
+           goto foundit;
+    for (bp = bufhead.b_prev; bp != &bufhead; bp = bp->b_prev)
+       if ((bp->b_flags & B_INUSE) == 0)
+           break;
+    if (bp == &bufhead)
+       errexit("deadlocked buffer pool\n");
+    getblk(bp, blkno, size);
+    /* fall through */
+  foundit:
+    totalreads++;
+    bp->b_prev->b_next = bp->b_next;
+    bp->b_next->b_prev = bp->b_prev;
+    bp->b_prev = &bufhead;
+    bp->b_next = bufhead.b_next;
+    bufhead.b_next->b_prev = bp;
+    bufhead.b_next = bp;
+    bp->b_flags |= B_INUSE;
+    return (bp);
 }
 
 struct bufarea *
 getblk(bp, blk, size)
-       register struct bufarea *bp;
-       daddr_t blk;
-       long size;
+     register struct bufarea *bp;
+     daddr_t blk;
+     long size;
 {
-       daddr_t dblk;
+    daddr_t dblk;
 
-       dblk = fsbtodb(&sblock, blk);
-       if (bp->b_bno == dblk)
-               return (bp);
-       flush(fswritefd, bp);
-       diskreads++;
-       bp->b_errs = bread(fsreadfd, bp->b_un.b_buf, dblk, size);
-       bp->b_bno = dblk;
-       bp->b_size = size;
+    dblk = fsbtodb(&sblock, blk);
+    if (bp->b_bno == dblk)
        return (bp);
+    flush(fswritefd, bp);
+    diskreads++;
+    bp->b_errs = bread(fsreadfd, bp->b_un.b_buf, dblk, size);
+    bp->b_bno = dblk;
+    bp->b_size = size;
+    return (bp);
 }
 
 flush(fd, bp)
-       int fd;
-       register struct bufarea *bp;
+     int fd;
+     register struct bufarea *bp;
 {
-       register int i, j;
-       caddr_t sip;
-       long size;
-
-       if (!bp->b_dirty)
-               return;
-       if (bp->b_errs != 0) {
-               pfatal("WRITING %sZERO'ED BLOCK %d TO DISK\n",
-                   (bp->b_errs == bp->b_size / dev_bsize) ? "" : "PARTIALLY ", bp->b_bno);
+    register int i, j;
+    caddr_t sip;
+    long size;
+
+    if (!bp->b_dirty)
+       return;
+    if (bp->b_errs != 0) {
+       pfatal("WRITING %sZERO'ED BLOCK %d TO DISK\n",
+              (bp->b_errs == bp->b_size / dev_bsize) ? "" : "PARTIALLY ",
+              bp->b_bno);
 #ifdef AFS_DEC_ENV
-               iscorrupt = 1;
+       iscorrupt = 1;
 #endif
-           }
-       bp->b_dirty = 0;
-       bp->b_errs = 0;
-       bwrite(fd, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size);
-       if (bp != &sblk)
-               return;
+    }
+    bp->b_dirty = 0;
+    bp->b_errs = 0;
+    bwrite(fd, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size);
+    if (bp != &sblk)
+       return;
 #if    defined(AFS_HPUX101_ENV)
 #if     defined(AFS_HPUX110_ENV)
-        /* jpm: Need a fix here */
-        if (0)
-#else    /* AFS_HPUX110_ENV */
-        if ( bwrite(fswritefd, (char *)sblock.fs_csp[0],
-               fsbtodb(&sblock, sblock.fs_csaddr),
-               fragroundup(&sblock, sblock.fs_cssize)) == 1 )
-#endif   /* else AFS_HPUX110_ENV */
-       {
-               printf("\nUnable to write to cylinder group summary area (fs_csaddr)\n");
-               printf("\tDisk write error at block %u\n",fsbtodb(&sblock,sblock.fs_csaddr));
-       }
-               
+    /* jpm: Need a fix here */
+    if (0)
+#else /* AFS_HPUX110_ENV */
+    if (bwrite
+       (fswritefd, (char *)sblock.fs_csp[0],
+        fsbtodb(&sblock, sblock.fs_csaddr), fragroundup(&sblock,
+                                                        sblock.fs_cssize)) ==
+       1)
+#endif /* else AFS_HPUX110_ENV */
+    {
+       printf
+           ("\nUnable to write to cylinder group summary area (fs_csaddr)\n");
+       printf("\tDisk write error at block %u\n",
+              fsbtodb(&sblock, sblock.fs_csaddr));
+    }
 #else
 #if    defined(AFS_SUN56_ENV)
-        sip = (caddr_t)sblock.fs_u.fs_csp;
-        for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) {
-                size = sblock.fs_cssize - i < sblock.fs_bsize ?
-                    sblock.fs_cssize - i : sblock.fs_bsize;
-                bwrite(fswritefd, sip,
-                    fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag),
-                    size);
-                sip += size;
-        }
+    sip = (caddr_t) sblock.fs_u.fs_csp;
+    for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) {
+       size =
+           sblock.fs_cssize - i <
+           sblock.fs_bsize ? sblock.fs_cssize - i : sblock.fs_bsize;
+       bwrite(fswritefd, sip,
+              fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag), size);
+       sip += size;
+    }
 #else
-       for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) {
-               bwrite(fswritefd, (char *)sblock.fs_csp[j],
-                   fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag),
-                   sblock.fs_cssize - i < sblock.fs_bsize ?
-                   sblock.fs_cssize - i : sblock.fs_bsize);
-       }
-#endif  /* AFS_SUN56_ENV */
-#endif  /* AFS_HPUX101_ENV */
+    for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) {
+       bwrite(fswritefd, (char *)sblock.fs_csp[j],
+              fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag),
+              sblock.fs_cssize - i <
+              sblock.fs_bsize ? sblock.fs_cssize - i : sblock.fs_bsize);
+    }
+#endif /* AFS_SUN56_ENV */
+#endif /* AFS_HPUX101_ENV */
 }
 
 rwerror(mesg, blk)
-       char *mesg;
-       daddr_t blk;
+     char *mesg;
+     daddr_t blk;
 {
 
-       if (preen == 0)
-               printf("\n");
-       pfatal("CANNOT %s: BLK %ld", mesg, blk);
-       if (reply("CONTINUE") == 0)
-               errexit("Program terminated\n");
+    if (preen == 0)
+       printf("\n");
+    pfatal("CANNOT %s: BLK %ld", mesg, blk);
+    if (reply("CONTINUE") == 0)
+       errexit("Program terminated\n");
 }
 
 ckfini()
 {
-       register struct bufarea *bp, *nbp;
-       int cnt = 0;
+    register struct bufarea *bp, *nbp;
+    int cnt = 0;
 
-       flush(fswritefd, &sblk);
+    flush(fswritefd, &sblk);
 #ifdef AFS_NEWCG_ENV
-       if (havesb && sblk.b_bno != SBOFF / dev_bsize &&
-           !preen && reply("UPDATE STANDARD SUPERBLOCK")) {
-               sblk.b_bno = SBOFF / dev_bsize;
+    if (havesb && sblk.b_bno != SBOFF / dev_bsize && !preen
+       && reply("UPDATE STANDARD SUPERBLOCK")) {
+       sblk.b_bno = SBOFF / dev_bsize;
 #else /* AFS_NEWCG_ENV */
-       if (havesb && sblk.b_bno != SBLOCK &&
-           !preen && reply("UPDATE STANDARD SUPERBLOCK")) {
-               sblk.b_bno = SBLOCK;
+    if (havesb && sblk.b_bno != SBLOCK && !preen
+       && reply("UPDATE STANDARD SUPERBLOCK")) {
+       sblk.b_bno = SBLOCK;
 #endif /* AFS_NEWCG_ENV */
-               sbdirty();
-               flush(fswritefd, &sblk);
-       }
-       flush(fswritefd, &cgblk);
-       if (cgblk.b_un.b_buf) {
-               free(cgblk.b_un.b_buf);
-               cgblk.b_un.b_buf = NULL;
-       }
-       for (bp = bufhead.b_prev; bp != &bufhead; bp = nbp) {
-               cnt++;
-               flush(fswritefd, bp);
-               nbp = bp->b_prev;
-               free(bp->b_un.b_buf);
-               free((char *)bp);
-       }
+       sbdirty();
+       flush(fswritefd, &sblk);
+    }
+    flush(fswritefd, &cgblk);
+    if (cgblk.b_un.b_buf) {
+       free(cgblk.b_un.b_buf);
+       cgblk.b_un.b_buf = NULL;
+    }
+    for (bp = bufhead.b_prev; bp != &bufhead; bp = nbp) {
+       cnt++;
+       flush(fswritefd, bp);
+       nbp = bp->b_prev;
+       free(bp->b_un.b_buf);
+       free((char *)bp);
+    }
 #ifdef AFS_SUN5_ENVX
-       pbp = pdirbp = NULL;
+    pbp = pdirbp = NULL;
 #endif
-       if (bufhead.b_size != cnt)
-               errexit("Panic: lost %d buffers\n", bufhead.b_size - cnt);
-       if (debug)
-               printf("cache missed %d of %d (%d%%)\n", diskreads,
-                   totalreads, diskreads * 100 / totalreads);
-       (void)close(fsreadfd);
-       (void)close(fswritefd);
+    if (bufhead.b_size != cnt)
+       errexit("Panic: lost %d buffers\n", bufhead.b_size - cnt);
+    if (debug)
+       printf("cache missed %d of %d (%d%%)\n", diskreads, totalreads,
+              diskreads * 100 / totalreads);
+    (void)close(fsreadfd);
+    (void)close(fswritefd);
 }
 
 #if    !defined(AFS_HPUX101_ENV)
 bread(fd, buf, blk, size)
-       int fd;
-       char *buf;
-       daddr_t blk;
-       long size;
+     int fd;
+     char *buf;
+#ifdef AFS_SUN59_ENV
+     diskaddr_t blk;
+#else
+     daddr_t blk;
+#endif
+     long size;
 {
-       char *cp;
-       int i, errs;
+    char *cp;
+    int i, errs;
 #ifdef AFS_SUN5_ENV
-       offset_t offset = (offset_t)blk << DEV_BSHIFT;
-       offset_t addr;
+    offset_t offset = (offset_t) blk << DEV_BSHIFT;
+    offset_t addr;
 #endif
 
 #ifdef AFS_HPUX_ENV
-       /* To fix a stripping related bug?? */
-       if (lseek(fd, blk * dev_bsize, 0) == -1)
+    /* To fix a stripping related bug?? */
+    if (lseek(fd, blk * dev_bsize, 0) == -1)
 #else
 #ifdef AFS_SUN5_ENV
-       if (llseek(fd, offset , 0) < 0)
+    if (llseek(fd, offset, 0) < 0)
 #else
-       if (lseek(fd, blk * dev_bsize, 0) < 0)
+    if (lseek(fd, blk * dev_bsize, 0) < 0)
 #endif
 #endif
-               rwerror("SEEK", blk);
-       else if (read(fd, buf, (int)size) == size)
-               return (0);
-       rwerror("READ", blk);
+       rwerror("SEEK", blk);
+    else if (read(fd, buf, (int)size) == size)
+       return (0);
+    rwerror("READ", blk);
 #ifdef AFS_HPUX_ENV
-       /* To fix a stripping related bug?? */
-       if (lseek(fd, blk * dev_bsize, 0) == -1)
+    /* To fix a stripping related bug?? */
+    if (lseek(fd, blk * dev_bsize, 0) == -1)
 #else
 #ifdef AFS_SUN5_ENV
-       if (llseek(fd, offset , 0) < 0)
+    if (llseek(fd, offset, 0) < 0)
 #else
-       if (lseek(fd, blk * dev_bsize, 0) < 0)
+    if (lseek(fd, blk * dev_bsize, 0) < 0)
 #endif
 #endif
-               rwerror("SEEK", blk);
-       errs = 0;
-       memset(buf, 0, (int)size);
-       printf("THE FOLLOWING DISK SECTORS COULD NOT BE READ:");
+       rwerror("SEEK", blk);
+    errs = 0;
+    memset(buf, 0, (int)size);
+    printf("THE FOLLOWING DISK SECTORS COULD NOT BE READ:");
 #ifdef AFS_SUN5_ENV
-       for (cp = buf, i = 0; i < btodb(size); i++, cp += DEV_BSIZE) {
-               addr = (offset_t)(blk + i) << DEV_BSHIFT;
-               if (llseek(fd, addr, SEEK_CUR) < 0 ||
-                   read(fd, cp, (int)secsize) < 0) {
-                       printf(" %d", blk + i);
+    for (cp = buf, i = 0; i < btodb(size); i++, cp += DEV_BSIZE) {
+       addr = (offset_t) (blk + i) << DEV_BSHIFT;
+       if (llseek(fd, addr, SEEK_CUR) < 0 || read(fd, cp, (int)secsize) < 0) {
+           printf(" %d", blk + i);
 #else
-       for (cp = buf, i = 0; i < size; i += secsize, cp += secsize) {
-               if (read(fd, cp, (int)secsize) < 0) {
-                       lseek(fd, blk * dev_bsize + i + secsize, 0);
-                       if (secsize != dev_bsize && dev_bsize != 1)
-                               printf(" %d (%d),",
-                                   (blk * dev_bsize + i) / secsize,
-                                   blk + i / dev_bsize);
-                       else
-                               printf(" %d,", blk + i / dev_bsize);
+    for (cp = buf, i = 0; i < size; i += secsize, cp += secsize) {
+       if (read(fd, cp, (int)secsize) < 0) {
+           lseek(fd, blk * dev_bsize + i + secsize, 0);
+           if (secsize != dev_bsize && dev_bsize != 1)
+               printf(" %d (%d),", (blk * dev_bsize + i) / secsize,
+                      blk + i / dev_bsize);
+           else
+               printf(" %d,", blk + i / dev_bsize);
 #endif
-                       errs++;
-               }
+           errs++;
        }
-       printf("\n");
-       return (errs);
+    }
+    printf("\n");
+    return (errs);
 }
 
 bwrite(fd, buf, blk, size)
-       int fd;
-       char *buf;
-       daddr_t blk;
-       long size;
+     int fd;
+     char *buf;
+#ifdef AFS_SUN59_ENV
+     diskaddr_t blk;
+#else
+     daddr_t blk;
+#endif
+     long size;
 {
-       int i, n;
-       char *cp;
+    int i, n;
+    char *cp;
 #ifdef AFS_SUN5_ENV
-       offset_t offset = (offset_t)blk << DEV_BSHIFT;
-       offset_t addr;
-
-       if (blk < SBLOCK) {
-           char msg[256];
-           sprintf(msg, "WARNING: Attempt to write illegal blkno %d on %s\n", blk, devname);
-           if(debug) printf(msg);
-           return;
-       }
+    offset_t offset = (offset_t) blk << DEV_BSHIFT;
+    offset_t addr;
+
+    if (blk < SBLOCK) {
+       char msg[256];
+       sprintf(msg, "WARNING: Attempt to write illegal blkno %d on %s\n",
+               blk, devname);
+       if (debug)
+           printf(msg);
+       return;
+    }
 #endif
 
-       if (fd < 0)
-               return;
+    if (fd < 0)
+       return;
 #ifdef AFS_HPUX_ENV
-       /* To fix a stripping related bug?? */
-       if (lseek(fd, blk * dev_bsize, 0) == -1)
+    /* To fix a stripping related bug?? */
+    if (lseek(fd, blk * dev_bsize, 0) == -1)
 #else
 #ifdef AFS_SUN5_ENV
-       if (llseek(fd, offset , 0) < 0)
+    if (llseek(fd, offset, 0) < 0)
 #else
-       if (lseek(fd, blk * dev_bsize, 0) < 0)
+    if (lseek(fd, blk * dev_bsize, 0) < 0)
 #endif
 #endif
-               rwerror("SEEK", blk);
-       else if (write(fd, buf, (int)size) == size) {
-               fsmodified = 1;
-               return;
-       }
-       rwerror("WRITE", blk);
+       rwerror("SEEK", blk);
+    else if (write(fd, buf, (int)size) == size) {
+       fsmodified = 1;
+       return;
+    }
+    rwerror("WRITE", blk);
 #ifdef AFS_HPUX_ENV
-       /* To fix a stripping related bug?? */
-       if (lseek(fd, blk * dev_bsize, 0) == -1)
+    /* To fix a stripping related bug?? */
+    if (lseek(fd, blk * dev_bsize, 0) == -1)
 #else
 #ifdef AFS_SUN5_ENV
-       if (llseek(fd, offset , 0) < 0)
+    if (llseek(fd, offset, 0) < 0)
 #else
-       if (lseek(fd, blk * dev_bsize, 0) < 0)
+    if (lseek(fd, blk * dev_bsize, 0) < 0)
 #endif
 #endif
-               rwerror("SEEK", blk);
-       printf("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:");
+       rwerror("SEEK", blk);
+    printf("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:");
 #ifdef AFS_SUN5_ENV
-       for (cp = buf, i = 0; i < btodb(size); i++, cp += DEV_BSIZE) {
-               n = 0;
-               addr = (offset_t)(blk + i) << DEV_BSHIFT;
-               if (llseek(fd, addr, SEEK_CUR) < 0 ||
-                   (n = write(fd, cp, DEV_BSIZE)) < 0) {
-                       printf(" %d", blk + i);
-               } else if (n > 0) {
-                       fsmodified = 1;
-               }
-
+    for (cp = buf, i = 0; i < btodb(size); i++, cp += DEV_BSIZE) {
+       n = 0;
+       addr = (offset_t) (blk + i) << DEV_BSHIFT;
+       if (llseek(fd, addr, SEEK_CUR) < 0
+           || (n = write(fd, cp, DEV_BSIZE)) < 0) {
+           printf(" %d", blk + i);
+       } else if (n > 0) {
+           fsmodified = 1;
        }
+
+    }
 #else
-       for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize)
-               if (write(fd, cp, (int)dev_bsize) < 0) {
-                       lseek(fd, blk * dev_bsize + i + dev_bsize, 0);
-                       printf(" %d,", blk + i / dev_bsize);
-               }
+    for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize)
+       if (write(fd, cp, (int)dev_bsize) < 0) {
+           lseek(fd, blk * dev_bsize + i + dev_bsize, 0);
+           printf(" %d,", blk + i / dev_bsize);
+       }
 #endif
-       printf("\n");
-       return;
+    printf("\n");
+    return;
 }
 #endif /* AFS_HPUX101_ENV */
 /*
  * allocate a data block with the specified number of fragments
  */
 allocblk(frags)
-       long frags;
+     long frags;
 {
-       register int i, j, k;
+    register int i, j, k;
 
-       if (frags <= 0 || frags > sblock.fs_frag)
-               return (0);
-       for (i = 0; i < maxfsblock - sblock.fs_frag; i += sblock.fs_frag) {
-               for (j = 0; j <= sblock.fs_frag - frags; j++) {
-                       if (testbmap(i + j))
-                               continue;
-                       for (k = 1; k < frags; k++)
-                               if (testbmap(i + j + k))
-                                       break;
-                       if (k < frags) {
-                               j += k;
-                               continue;
-                       }
-                       for (k = 0; k < frags; k++)
-                               setbmap(i + j + k);
-                       n_blks += frags;
-                       return (i + j);
-               }
-       }
+    if (frags <= 0 || frags > sblock.fs_frag)
        return (0);
+    for (i = 0; i < maxfsblock - sblock.fs_frag; i += sblock.fs_frag) {
+       for (j = 0; j <= sblock.fs_frag - frags; j++) {
+           if (testbmap(i + j))
+               continue;
+           for (k = 1; k < frags; k++)
+               if (testbmap(i + j + k))
+                   break;
+           if (k < frags) {
+               j += k;
+               continue;
+           }
+           for (k = 0; k < frags; k++)
+               setbmap(i + j + k);
+           n_blks += frags;
+           return (i + j);
+       }
+    }
+    return (0);
 }
 
 /*
  * Free a previously allocated block
  */
 freeblk(blkno, frags)
-       daddr_t blkno;
-       long frags;
+     daddr_t blkno;
+     long frags;
 {
-       struct inodesc idesc;
+    struct inodesc idesc;
 
-       idesc.id_blkno = blkno;
-       idesc.id_numfrags = frags;
-       pass4check(&idesc);
+    idesc.id_blkno = blkno;
+    idesc.id_numfrags = frags;
+    pass4check(&idesc);
 }
 
 /*
  * Find a pathname
  */
 getpathname(namebuf, curdir, ino)
-       char *namebuf;
-       ino_t curdir, ino;
+     char *namebuf;
+     ino_t curdir, ino;
 {
-       int len;
-       register char *cp;
-       struct inodesc idesc;
-       extern int findname();
-
-       if (statemap[ino] != DSTATE && statemap[ino] != DFOUND) {
-               strcpy(namebuf, "?");
-               return;
-       }
-       memset((char *)&idesc, 0, sizeof(struct inodesc));
-       idesc.id_type = DATA;
-       cp = &namebuf[BUFSIZ - 1];
-       *cp = '\0';
-       if (curdir != ino) {
-               idesc.id_parent = curdir;
-               goto namelookup;
-       }
-       while (ino != ROOTINO) {
-               idesc.id_number = ino;
-               idesc.id_func = findino;
-               idesc.id_name = "..";
+    int len;
+    register char *cp;
+    struct inodesc idesc;
+    extern int findname();
+
+    if (statemap[ino] != DSTATE && statemap[ino] != DFOUND) {
+       strcpy(namebuf, "?");
+       return;
+    }
+    memset((char *)&idesc, 0, sizeof(struct inodesc));
+    idesc.id_type = DATA;
+    cp = &namebuf[BUFSIZ - 1];
+    *cp = '\0';
+    if (curdir != ino) {
+       idesc.id_parent = curdir;
+       goto namelookup;
+    }
+    while (ino != ROOTINO) {
+       idesc.id_number = ino;
+       idesc.id_func = findino;
+       idesc.id_name = "..";
 #ifdef AFS_SUN5_ENV
-               idesc.id_fix = NOFIX;
+       idesc.id_fix = NOFIX;
 #endif
-               if ((ckinode(ginode(ino), &idesc) & FOUND) == 0)
-                       break;
-       namelookup:
-               idesc.id_number = idesc.id_parent;
-               idesc.id_parent = ino;
-               idesc.id_func = findname;
-               idesc.id_name = namebuf;
+       if ((ckinode(ginode(ino), &idesc) & FOUND) == 0)
+           break;
+      namelookup:
+       idesc.id_number = idesc.id_parent;
+       idesc.id_parent = ino;
+       idesc.id_func = findname;
+       idesc.id_name = namebuf;
 #ifdef AFS_SUN5_ENV
-               idesc.id_fix = NOFIX;
+       idesc.id_fix = NOFIX;
 #endif
-               if ((ckinode(ginode(idesc.id_number), &idesc) & FOUND) == 0)
-                       break;
-               len = strlen(namebuf);
-               cp -= len;
-               if (cp < &namebuf[MAXNAMLEN])
-                       break;
-               memcpy(cp, namebuf, len);
-               *--cp = '/';
-               ino = idesc.id_number;
-       }
-       if (ino != ROOTINO) {
-               strcpy(namebuf, "?");
-               return;
-       }
-       memcpy(namebuf, cp, &namebuf[BUFSIZ] - cp);
+       if ((ckinode(ginode(idesc.id_number), &idesc) & FOUND) == 0)
+           break;
+       len = strlen(namebuf);
+       cp -= len;
+       if (cp < &namebuf[MAXNAMLEN])
+           break;
+       memcpy(cp, namebuf, len);
+       *--cp = '/';
+       ino = idesc.id_number;
+    }
+    if (ino != ROOTINO) {
+       strcpy(namebuf, "?");
+       return;
+    }
+    memcpy(namebuf, cp, &namebuf[BUFSIZ] - cp);
 }
 
 void
 catch()
 {
-       ckfini();
+    ckfini();
 #ifdef AFS_SUN5_ENV
-       exit(37);
+    exit(37);
 #else
-       exit(12);
+    exit(12);
 #endif
 }
 
@@ -639,11 +652,11 @@ catch()
 void
 catchquit()
 {
-       extern returntosingle;
+    extern returntosingle;
 
-       printf("returning to single-user after filesystem check\n");
-       returntosingle = 1;
-       (void)signal(SIGQUIT, SIG_DFL);
+    printf("returning to single-user after filesystem check\n");
+    returntosingle = 1;
+    (void)signal(SIGQUIT, SIG_DFL);
 }
 
 /*
@@ -654,60 +667,60 @@ void
 voidquit()
 {
 
-       sleep(1);
-       (void)signal(SIGQUIT, SIG_IGN);
-       (void)signal(SIGQUIT, SIG_DFL);
+    sleep(1);
+    (void)signal(SIGQUIT, SIG_IGN);
+    (void)signal(SIGQUIT, SIG_DFL);
 }
 
 /*
  * determine whether an inode should be fixed.
  */
 dofix(idesc, msg)
-       register struct inodesc *idesc;
-       char *msg;
+     register struct inodesc *idesc;
+     char *msg;
 {
 
-       switch (idesc->id_fix) {
-
-       case DONTKNOW:
-               if (idesc->id_type == DATA)
-                       direrror(idesc->id_number, msg);
-               else 
-                       pwarn(msg);
-               if (preen) {
-                       printf(" (SALVAGED)\n");
-                       idesc->id_fix = FIX;
-                       return (ALTERED);
-               }
-               if (reply("SALVAGE") == 0) {
-                       idesc->id_fix = NOFIX;
-                       return (0);
-               }
-               idesc->id_fix = FIX;
-               return (ALTERED);
-
-       case FIX:
-               return (ALTERED);
-
-       case NOFIX:
-               return (0);
+    switch (idesc->id_fix) {
 
-       default:
-               errexit("UNKNOWN INODESC FIX MODE %d\n", idesc->id_fix);
+    case DONTKNOW:
+       if (idesc->id_type == DATA)
+           direrror(idesc->id_number, msg);
+       else
+           pwarn(msg);
+       if (preen) {
+           printf(" (SALVAGED)\n");
+           idesc->id_fix = FIX;
+           return (ALTERED);
        }
-       /* NOTREACHED */
+       if (reply("SALVAGE") == 0) {
+           idesc->id_fix = NOFIX;
+           return (0);
+       }
+       idesc->id_fix = FIX;
+       return (ALTERED);
+
+    case FIX:
+       return (ALTERED);
+
+    case NOFIX:
+       return (0);
+
+    default:
+       errexit("UNKNOWN INODESC FIX MODE %d\n", idesc->id_fix);
+    }
+    /* NOTREACHED */
 }
 
 /* VARARGS1 */
 errexit(s1, s2, s3, s4)
-       char *s1;
-       long s2, s3, s4;
+     char *s1;
+     long s2, s3, s4;
 {
-       printf(s1, s2, s3, s4);
+    printf(s1, s2, s3, s4);
 #ifdef AFS_SUN5_ENV
-       exit(39);
+    exit(39);
 #else
-       exit(8);
+    exit(8);
 #endif
 }
 
@@ -717,22 +730,21 @@ errexit(s1, s2, s3, s4)
  */
 /* VARARGS1 */
 pfatal(s, a1, a2, a3)
-       char *s;
-       long a1, a2, a3;
+     char *s;
+     long a1, a2, a3;
 {
-       if (preen) {
-               printf("%s: ", devname);
-               printf(s, a1, a2, a3);
-               printf("\n");
-               printf("%s: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.\n",
-                       devname);
+    if (preen) {
+       printf("%s: ", devname);
+       printf(s, a1, a2, a3);
+       printf("\n");
+       printf("%s: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.\n", devname);
 #ifdef AFS_SUN5_ENV
-               exit(36);
+       exit(36);
 #else
-               exit(8);
+       exit(8);
 #endif
-       }
-       printf(s, a1, a2, a3);
+    }
+    printf(s, a1, a2, a3);
 }
 
 /*
@@ -741,12 +753,12 @@ pfatal(s, a1, a2, a3)
  */
 /* VARARGS1 */
 pwarn(s, a1, a2, a3, a4, a5, a6)
-       char *s;
-       long a1, a2, a3, a4, a5, a6;
+     char *s;
+     long a1, a2, a3, a4, a5, a6;
 {
-       if (preen)
-               printf("%s: ", devname);
-       printf(s, a1, a2, a3, a4, a5, a6);
+    if (preen)
+       printf("%s: ", devname);
+    printf(s, a1, a2, a3, a4, a5, a6);
 }
 
 /*
@@ -755,12 +767,12 @@ pwarn(s, a1, a2, a3, a4, a5, a6)
  */
 /* VARARGS1 */
 pinfo(s, a1, a2, a3, a4, a5, a6)
-       char *s;
-       long a1, a2, a3, a4, a5, a6;
+     char *s;
+     long a1, a2, a3, a4, a5, a6;
 {
-       if (preen)
-               printf("%s: ", devname);
-       printf(s, a1, a2, a3, a4, a5, a6);
+    if (preen)
+       printf("%s: ", devname);
+    printf(s, a1, a2, a3, a4, a5, a6);
 }
 
 #ifndef lint
@@ -768,18 +780,18 @@ pinfo(s, a1, a2, a3, a4, a5, a6)
  * Stub for routines from kernel.
  */
 panic(s)
-       char *s;
+     char *s;
 {
 
-       pfatal("INTERNAL INCONSISTENCY:");
-       errexit(s);
+    pfatal("INTERNAL INCONSISTENCY:");
+    errexit(s);
 }
 #endif
 
 #if    defined(AFS_SUN_ENV) && !defined(AFS_SUN3_ENV)
 debugclean()
 {
-    char       s[256];
+    char s[256];
 
     if (debug == 0)
        return;
@@ -801,10 +813,10 @@ debugclean()
 
 updateclean()
 {
-    struct bufarea     cleanbuf;
-    unsigned int       size;
-    unsigned int       bno;
-    unsigned int       fsclean;
+    struct bufarea cleanbuf;
+    unsigned int size;
+    unsigned int bno;
+    unsigned int fsclean;
 #if    defined(AFS_SUN56_ENV)
     offset_t sblkoff;
 #endif
@@ -820,26 +832,28 @@ updateclean()
        fsclean = FSACTIVE;
 
     /* if necessary, update fs_clean and fs_state */
-    switch(fsclean) {
-      case FSACTIVE:
-       if (iscorrupt == 0) fsclean = FSSTABLE;
+    switch (fsclean) {
+    case FSACTIVE:
+       if (iscorrupt == 0)
+           fsclean = FSSTABLE;
        break;
-      case FSCLEAN:
-      case FSSTABLE:
-       if (iscorrupt) fsclean = FSACTIVE;
+    case FSCLEAN:
+    case FSSTABLE:
+       if (iscorrupt)
+           fsclean = FSACTIVE;
        break;
-      default:
+    default:
        if (iscorrupt)
            fsclean = FSACTIVE;
        else
            fsclean = FSSTABLE;
     }
     /* if fs_clean and fs_state are ok, do nothing */
-    if ( (sblock.fs_clean == fsclean) &&
+    if ((sblock.fs_clean == fsclean) &&
 #ifdef AFS_SUN5_ENV
-       (FSOKAY == (sblock.fs_state + sblock.fs_time)) )
+       (FSOKAY == (sblock.fs_state + sblock.fs_time)))
 #else
-       (FSOKAY == (fs_get_state(&sblock) + sblock.fs_time)) )
+       (FSOKAY == (fs_get_state(&sblock) + sblock.fs_time)))
 #endif
        return;
     sblock.fs_clean = fsclean;
@@ -852,14 +866,14 @@ updateclean()
     if (fswritefd < 0)
        return;
     /* read private copy of superblock, update clean flag, and write it */
-    bno  = sblk.b_bno;
+    bno = sblk.b_bno;
     size = sblk.b_size;
 #if    defined(AFS_SUN56_ENV)
-    sblkoff = (OFF_T)(bno) << DEV_BSHIFT;
+    sblkoff = (OFF_T) (bno) << DEV_BSHIFT;
     if (llseek(fsreadfd, sblkoff, 0) == -1)
        return;
 #else
-    if (lseek(fsreadfd, (off_t)dbtob(bno), 0) == -1)
+    if (lseek(fsreadfd, (off_t) dbtob(bno), 0) == -1)
        return;
 #endif
     if ((cleanbuf.b_un.b_buf = malloc(size)) == NULL)
@@ -872,12 +886,12 @@ updateclean()
 #else
     fs_set_state(cleanbuf.b_un.b_fs, fs_get_state(&sblock));
 #endif
-    cleanbuf.b_un.b_fs->fs_time  = sblock.fs_time;
+    cleanbuf.b_un.b_fs->fs_time = sblock.fs_time;
 #if    defined(AFS_SUN56_ENV)
     if (llseek(fswritefd, sblkoff, 0) == -1)
        return;
 #else
-    if (lseek(fswritefd, (off_t)dbtob(bno), 0) == -1)
+    if (lseek(fswritefd, (off_t) dbtob(bno), 0) == -1)
        return;
 #endif
     if (write(fswritefd, cleanbuf.b_un.b_buf, (int)size) != size)
@@ -886,7 +900,7 @@ updateclean()
 
 printclean()
 {
-    char       *s;
+    char *s;
 
 #ifdef AFS_SUN5_ENV
     if (FSOKAY != (sblock.fs_state + sblock.fs_time))
@@ -896,17 +910,17 @@ printclean()
        s = "unknown";
     else
 
-       switch(sblock.fs_clean) {
-         case FSACTIVE:
+       switch (sblock.fs_clean) {
+       case FSACTIVE:
            s = "active";
            break;
-         case FSCLEAN:
+       case FSCLEAN:
            s = "clean";
            break;
-         case FSSTABLE:
+       case FSSTABLE:
            s = "stable";
            break;
-         default:
+       default:
            s = "unknown";
        }
     if (preen)
@@ -917,301 +931,298 @@ printclean()
 #endif
 
 #ifdef AFS_SUN52_ENV
-char *hasvfsopt(vfs, opt)
-        register struct vfstab *vfs;
-        register char *opt;
+char *
+hasvfsopt(vfs, opt)
+     register struct vfstab *vfs;
+     register char *opt;
 {
-        char *f, *opts;
-        static char *tmpopts;
-
-       if (vfs->vfs_mntopts == NULL)
-               return (NULL);
-        if (tmpopts == 0) {
-                tmpopts = (char *)calloc(256, sizeof (char));
-                if (tmpopts == 0)
-                        return (0);
-        }
-        strncpy(tmpopts, vfs->vfs_mntopts, (sizeof (tmpopts) - 1));
-        opts = tmpopts;
-        f = mntopt(&opts);
-        for (; *f; f = mntopt(&opts)) {
-                if (strncmp(opt, f, strlen(opt)) == 0)
-                        return (f - tmpopts + vfs->vfs_mntopts);
-        }
-        return (NULL);
+    char *f, *opts;
+    static char *tmpopts;
+
+    if (vfs->vfs_mntopts == NULL)
+       return (NULL);
+    if (tmpopts == 0) {
+       tmpopts = (char *)calloc(256, sizeof(char));
+       if (tmpopts == 0)
+           return (0);
+    }
+    strncpy(tmpopts, vfs->vfs_mntopts, (sizeof(tmpopts) - 1));
+    opts = tmpopts;
+    f = mntopt(&opts);
+    for (; *f; f = mntopt(&opts)) {
+       if (strncmp(opt, f, strlen(opt)) == 0)
+           return (f - tmpopts + vfs->vfs_mntopts);
+    }
+    return (NULL);
 }
 
 
 writable(name)
-       char *name;
+     char *name;
 {
-       int rw = 1;
-       struct vfstab vfsbuf;
-       FILE *vfstab;
-       char *blkname, *unrawname();
-
-       vfstab = fopen(VFSTAB, "r");
-       if (vfstab == NULL) {
-               printf("can't open %s\n", VFSTAB);
-               return (1);
-       }
-       blkname = unrawname(name);
-       if ((getvfsspec(vfstab, &vfsbuf, blkname) == 0) &&
-           (vfsbuf.vfs_fstype != NULL) &&
-           (strcmp(vfsbuf.vfs_fstype, MNTTYPE_UFS) == 0) &&
-           (hasvfsopt(&vfsbuf, MNTOPT_RO))) {
-               rw = 0;
-       }
-       fclose(vfstab);
-       return (rw);
+    int rw = 1;
+    struct vfstab vfsbuf;
+    FILE *vfstab;
+    char *blkname, *unrawname();
+
+    vfstab = fopen(VFSTAB, "r");
+    if (vfstab == NULL) {
+       printf("can't open %s\n", VFSTAB);
+       return (1);
+    }
+    blkname = unrawname(name);
+    if ((getvfsspec(vfstab, &vfsbuf, blkname) == 0)
+       && (vfsbuf.vfs_fstype != NULL)
+       && (strcmp(vfsbuf.vfs_fstype, MNTTYPE_UFS) == 0)
+       && (hasvfsopt(&vfsbuf, MNTOPT_RO))) {
+       rw = 0;
+    }
+    fclose(vfstab);
+    return (rw);
 }
 
 mounted(name)
-       char *name;
+     char *name;
 {
-       int found = 0;
-       struct mnttab mnt;
-       FILE *mnttab;
-       struct stat device_stat, mount_stat;
-       char *blkname, *unrawname();
-
-       mnttab = fopen(MNTTAB, "r");
-       if (mnttab == NULL) {
-               printf("can't open %s\n", MNTTAB);
-               return (0);
+    int found = 0;
+    struct mnttab mnt;
+    FILE *mnttab;
+    struct stat device_stat, mount_stat;
+    char *blkname, *unrawname();
+
+    mnttab = fopen(MNTTAB, "r");
+    if (mnttab == NULL) {
+       printf("can't open %s\n", MNTTAB);
+       return (0);
+    }
+    blkname = unrawname(name);
+    while ((getmntent(mnttab, &mnt)) == NULL) {
+       if (strcmp(mnt.mnt_fstype, MNTTYPE_UFS) != 0) {
+           continue;
        }
-       blkname = unrawname(name);
-       while ((getmntent(mnttab, &mnt)) == NULL) {
-               if (strcmp(mnt.mnt_fstype, MNTTYPE_UFS) != 0) {
-                       continue;
-               }
-               if (strcmp(blkname, mnt.mnt_special) == 0) {
-                       stat(mnt.mnt_mountp, &mount_stat);
-                       stat(mnt.mnt_special, &device_stat);
-                       if (device_stat.st_rdev == mount_stat.st_dev) {
-                               if (hasmntopt (&mnt, MNTOPT_RO) != 0)
-                                       found = 2;      /* mounted as RO */
-                               else    
-                                       found = 1;      /* mounted as R/W */
-                       }
-                       break;
-               }
+       if (strcmp(blkname, mnt.mnt_special) == 0) {
+           stat(mnt.mnt_mountp, &mount_stat);
+           stat(mnt.mnt_special, &device_stat);
+           if (device_stat.st_rdev == mount_stat.st_dev) {
+               if (hasmntopt(&mnt, MNTOPT_RO) != 0)
+                   found = 2;  /* mounted as RO */
+               else
+                   found = 1;  /* mounted as R/W */
+           }
+           break;
        }
-       fclose(mnttab);
-       return (found);
+    }
+    fclose(mnttab);
+    return (found);
 }
 
 #endif
 
 #if    defined(AFS_HPUX101_ENV)
 
-#include "libfs.h" 
+#include "libfs.h"
 #include <sys/stat.h>
 #include <sys/fcntl.h>
 
 int seek_options;
 
 bread(fd, buf, blk, size)
-        int fd;
-        char *buf;
-        daddr_t blk;
-        long size;
+     int fd;
+     char *buf;
+     daddr_t blk;
+     long size;
 {
-        int i = 0;
-        off_t lseek_offset;
+    int i = 0;
+    off_t lseek_offset;
 
-       switch( seek_options )
-       {
-               case BLKSEEK_ENABLED:     
-                       lseek_offset = blk;
-                       break;
+    switch (seek_options) {
+    case BLKSEEK_ENABLED:
+       lseek_offset = blk;
+       break;
 
-               case  BLKSEEK_NOT_ENABLED: /* File */
+    case BLKSEEK_NOT_ENABLED:  /* File */
 #if    defined(AFS_HPUX102_ENV)
-                       lseek_offset = dbtoo(blk);
+       lseek_offset = dbtoo(blk);
 #else
-                       lseek_offset = dbtob(blk);
+       lseek_offset = dbtob(blk);
 #endif
-                       break;
+       break;
 
-               default:
-                       rwerror("BLKSEEK", blk);
-       }
-       if (lseek(fd,(off_t) lseek_offset, 0) == (off_t) -1)
-               rwerror("SEEK", blk);
-       else if (read(fd, buf, (int)size) == size)
-               return 0;
-       rwerror("READ", blk);
-       return 1;
+    default:
+       rwerror("BLKSEEK", blk);
+    }
+    if (lseek(fd, (off_t) lseek_offset, 0) == (off_t) - 1)
+       rwerror("SEEK", blk);
+    else if (read(fd, buf, (int)size) == size)
+       return 0;
+    rwerror("READ", blk);
+    return 1;
 }
 
 bwrite(fd, buf, blk, size)
-        int fd;
-        char *buf;
-        daddr_t blk;
-        long size;
+     int fd;
+     char *buf;
+     daddr_t blk;
+     long size;
 {
-        off_t  lseek_offset;
+    off_t lseek_offset;
 
-        if (fd < 0)
-                return 1;
+    if (fd < 0)
+       return 1;
 
-       switch( seek_options )
-        {
-                case BLKSEEK_ENABLED:
-                        lseek_offset = blk;
-                        break;
+    switch (seek_options) {
+    case BLKSEEK_ENABLED:
+       lseek_offset = blk;
+       break;
 
-                case  BLKSEEK_NOT_ENABLED: /* File */
+    case BLKSEEK_NOT_ENABLED:  /* File */
 #if    defined(AFS_HPUX102_ENV)
-                        lseek_offset = dbtoo(blk);
+       lseek_offset = dbtoo(blk);
 #else
-                       lseek_offset = dbtob(blk);
+       lseek_offset = dbtob(blk);
 #endif
-                        break;
+       break;
 
-                default:
-                       rwerror("BLKSEEK", blk);
-       }
-       if (lseek(fd,(off_t) lseek_offset, 0) == (off_t) -1)
-               rwerror("SEEK", blk);
-       else if (write(fd, buf, (int)size) == size) 
-       {
-               fsmodified = 1;
-               return 0;
-       }
-       rwerror("WRITE", blk);
-       return 1;
+    default:
+       rwerror("BLKSEEK", blk);
+    }
+    if (lseek(fd, (off_t) lseek_offset, 0) == (off_t) - 1)
+       rwerror("SEEK", blk);
+    else if (write(fd, buf, (int)size) == size) {
+       fsmodified = 1;
+       return 0;
+    }
+    rwerror("WRITE", blk);
+    return 1;
 }
 
 int
 setup_block_seek(fd)
-     int  fd;   /* File descriptor */
+     int fd;                   /* File descriptor */
 {
-     int  flags=0;      /* Flags to/from fcntl() */
+    int flags = 0;             /* Flags to/from fcntl() */
 
-        return setup_block_seek_2(fd, &flags);
+    return setup_block_seek_2(fd, &flags);
 }
+
 #define set_fserror printf
 
 int
 setup_block_seek_2(fd, cntl_flags)
-     int  fd;           /* Input.     File descriptor    */
-     int  *cntl_flags;  /* Returned.  Flags from fcntl() */
+     int fd;                   /* Input.     File descriptor    */
+     int *cntl_flags;          /* Returned.  Flags from fcntl() */
 {
-     int         flags=0;         /* Flags to/from fcntl() */
-     off_t       lstatus;         /* Status from lseek()   */
-     struct stat statarea;
-     char        dummy[MAXBSIZE];
-
-        *cntl_flags = 0;
-        /*
-         *  Get control Flags
-         */
-        if ((flags = fcntl(fd, F_GETFL)) == -1) {
-                set_fserror("Cannot get file control flags.");
-                return(BLKSEEK_PROCESSING_ERROR);
-        }
-
-        /*
-         *  Check if fd is a non-device file
-         */
-
-        if (fstat(fd, &statarea) == -1) {
-                set_fserror("Cannot get status information on file descriptor.")
-;
-                return(BLKSEEK_PROCESSING_ERROR);
-        }
-        if (((statarea.st_mode & S_IFMT) != S_IFCHR) &&
-            ((statarea.st_mode & S_IFMT) != S_IFBLK)) {
-                /* Not a device file -- BLKSEEK only works on device files */
-                *cntl_flags = flags;    /* O_BLKSEEK bit never set */
-                return(BLKSEEK_NOT_ENABLED);
-        }
-
-        /*
-         *  Set the fd to O_BLKSEEK
-         */
-        if (fcntl(fd, F_SETFL, flags | O_BLKSEEK) == -1) {
-                set_fserror("Cannot set file control flags.");
-                return(BLKSEEK_PROCESSING_ERROR);
-        }
-        if (flags & O_WRONLY) {
-                /* Set lseek to location 0 before returning */
-                if (lseek(fd, (off_t) 0, SEEK_SET) == (off_t) -1) {
-                        set_fserror("Cannot lseek the device.");
-                        return(BLKSEEK_PROCESSING_ERROR);
-                }
-               if ( debug )
-                       set_fserror("File is write only.  Cannot Verify O_BLKSEEK mode set.");
-                *cntl_flags = flags | O_BLKSEEK;
-                return(BLKSEEK_FILE_WRITEONLY);
-        }
-
-        /*
-         *  Verify that kernel knows how to do O_BLKSEEK
-         */
-        if (lseek(fd, (off_t) 0, SEEK_SET) == (off_t) -1) {
-               set_fserror("Cannot lseek the device.");
-               return(BLKSEEK_PROCESSING_ERROR);
-        }
-        if (read(fd, &dummy[0], BBSIZE) != BBSIZE) {     /* BBSIZE = 8192 */
-               set_fserror("Cannot read from the device");
-               return(BLKSEEK_PROCESSING_ERROR);
-        }
-
-        if ((lstatus = lseek(fd, (off_t) 0, SEEK_CUR)) == (off_t) -1) {
-               set_fserror("Cannot lseek the device.");
-               return(BLKSEEK_PROCESSING_ERROR);
-        }
-
-        /*
-         *  Set lseek to location 0
-         */
-        if (lseek(fd, (off_t) 0, SEEK_SET) == (off_t) -1) {
-               set_fserror("Cannot lseek the device.");
-               return(BLKSEEK_PROCESSING_ERROR);
-        }
-
-        if (lstatus == (off_t) (BBSIZE / DEV_BSIZE)) {
-               *cntl_flags = flags | O_BLKSEEK;
-               return(BLKSEEK_ENABLED);  /* Successfully enabled O_BLKSEEK */
-        }
-        *cntl_flags = flags & (~O_BLKSEEK);  /* Turn off O_BLKSEEK bit */
-        return(BLKSEEK_NOT_ENABLED);     /* O_BLKSEEK not enabled */
+    int flags = 0;             /* Flags to/from fcntl() */
+    off_t lstatus;             /* Status from lseek()   */
+    struct stat statarea;
+    char dummy[MAXBSIZE];
+
+    *cntl_flags = 0;
+    /*
+     *  Get control Flags
+     */
+    if ((flags = fcntl(fd, F_GETFL)) == -1) {
+       set_fserror("Cannot get file control flags.");
+       return (BLKSEEK_PROCESSING_ERROR);
+    }
+
+    /*
+     *  Check if fd is a non-device file
+     */
+
+    if (fstat(fd, &statarea) == -1) {
+       set_fserror("Cannot get status information on file descriptor.");
+       return (BLKSEEK_PROCESSING_ERROR);
+    }
+    if (((statarea.st_mode & S_IFMT) != S_IFCHR)
+       && ((statarea.st_mode & S_IFMT) != S_IFBLK)) {
+       /* Not a device file -- BLKSEEK only works on device files */
+       *cntl_flags = flags;    /* O_BLKSEEK bit never set */
+       return (BLKSEEK_NOT_ENABLED);
+    }
+
+    /*
+     *  Set the fd to O_BLKSEEK
+     */
+    if (fcntl(fd, F_SETFL, flags | O_BLKSEEK) == -1) {
+       set_fserror("Cannot set file control flags.");
+       return (BLKSEEK_PROCESSING_ERROR);
+    }
+    if (flags & O_WRONLY) {
+       /* Set lseek to location 0 before returning */
+       if (lseek(fd, (off_t) 0, SEEK_SET) == (off_t) - 1) {
+           set_fserror("Cannot lseek the device.");
+           return (BLKSEEK_PROCESSING_ERROR);
+       }
+       if (debug)
+           set_fserror
+               ("File is write only.  Cannot Verify O_BLKSEEK mode set.");
+       *cntl_flags = flags | O_BLKSEEK;
+       return (BLKSEEK_FILE_WRITEONLY);
+    }
+
+    /*
+     *  Verify that kernel knows how to do O_BLKSEEK
+     */
+    if (lseek(fd, (off_t) 0, SEEK_SET) == (off_t) - 1) {
+       set_fserror("Cannot lseek the device.");
+       return (BLKSEEK_PROCESSING_ERROR);
+    }
+    if (read(fd, &dummy[0], BBSIZE) != BBSIZE) {       /* BBSIZE = 8192 */
+       set_fserror("Cannot read from the device");
+       return (BLKSEEK_PROCESSING_ERROR);
+    }
+
+    if ((lstatus = lseek(fd, (off_t) 0, SEEK_CUR)) == (off_t) - 1) {
+       set_fserror("Cannot lseek the device.");
+       return (BLKSEEK_PROCESSING_ERROR);
+    }
+
+    /*
+     *  Set lseek to location 0
+     */
+    if (lseek(fd, (off_t) 0, SEEK_SET) == (off_t) - 1) {
+       set_fserror("Cannot lseek the device.");
+       return (BLKSEEK_PROCESSING_ERROR);
+    }
+
+    if (lstatus == (off_t) (BBSIZE / DEV_BSIZE)) {
+       *cntl_flags = flags | O_BLKSEEK;
+       return (BLKSEEK_ENABLED);       /* Successfully enabled O_BLKSEEK */
+    }
+    *cntl_flags = flags & (~O_BLKSEEK);        /* Turn off O_BLKSEEK bit */
+    return (BLKSEEK_NOT_ENABLED);      /* O_BLKSEEK not enabled */
 }
 
 setup_all_block_seek()
 {
-               int opt=0;
-                seek_options = setup_block_seek(fsreadfd);
-                switch( seek_options )
-                {
-                  case BLKSEEK_ENABLED:
-                  case BLKSEEK_NOT_ENABLED:
-                        break;
-                  default:
-                        errexit("setup_block_seek on fsreadfd");
-                        break;
-                }
-               if( fswritefd == -1 )
-                       goto done;
-                switch( opt = setup_block_seek(fswritefd))
-                {
-                  case BLKSEEK_FILE_WRITEONLY:   /* WO block or char device. */
-                  case BLKSEEK_NOT_ENABLED:      /* regular file.            */
-                       if ( seek_options != opt )
-                               printf("seek_options on fsreadfd (%d) and fswritefd (%d) do not match",
-                                      seek_options, opt);
-                        break;
-                  default :
-                        errexit("setup_block_seek on fswritefd");
-                        break;
-                }
-done:
-                if ( debug )
-                        printf("read option = %d write option = %d\n", 
-                                                       seek_options,opt);
+    int opt = 0;
+    seek_options = setup_block_seek(fsreadfd);
+    switch (seek_options) {
+    case BLKSEEK_ENABLED:
+    case BLKSEEK_NOT_ENABLED:
+       break;
+    default:
+       errexit("setup_block_seek on fsreadfd");
+       break;
+    }
+    if (fswritefd == -1)
+       goto done;
+    switch (opt = setup_block_seek(fswritefd)) {
+    case BLKSEEK_FILE_WRITEONLY:       /* WO block or char device. */
+    case BLKSEEK_NOT_ENABLED:  /* regular file.            */
+       if (seek_options != opt)
+           printf
+               ("seek_options on fsreadfd (%d) and fswritefd (%d) do not match",
+                seek_options, opt);
+       break;
+    default:
+       errexit("setup_block_seek on fswritefd");
+       break;
+    }
+  done:
+    if (debug)
+       printf("read option = %d write option = %d\n", seek_options, opt);
 }