print errno when init can't be executed
[unix-history] / usr / src / sys / kern / vfs_bio.c
index 2fb4b3e..fc01a27 100644 (file)
@@ -1,9 +1,9 @@
 /*
 /*
- * Copyright (c) 1982 Regents of the University of California.
+ * Copyright (c) 1982, 1986 Regents of the University of California.
  * 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.
  *
- *     @(#)vfs_bio.c   6.5 (Berkeley) %G%
+ *     @(#)vfs_bio.c   7.1 (Berkeley) %G%
  */
 
 #include "../machine/pte.h"
  */
 
 #include "../machine/pte.h"
@@ -35,7 +35,7 @@ bread(dev, blkno, size)
        bp = getblk(dev, blkno, size);
        if (bp->b_flags&B_DONE) {
                trace(TR_BREADHIT, pack(dev, size), blkno);
        bp = getblk(dev, blkno, size);
        if (bp->b_flags&B_DONE) {
                trace(TR_BREADHIT, pack(dev, size), blkno);
-               return(bp);
+               return (bp);
        }
        bp->b_flags |= B_READ;
        if (bp->b_bcount > bp->b_bufsize)
        }
        bp->b_flags |= B_READ;
        if (bp->b_bcount > bp->b_bufsize)
@@ -44,7 +44,7 @@ bread(dev, blkno, size)
        trace(TR_BREADMISS, pack(dev, size), blkno);
        u.u_ru.ru_inblock++;            /* pay for read */
        biowait(bp);
        trace(TR_BREADMISS, pack(dev, size), blkno);
        u.u_ru.ru_inblock++;            /* pay for read */
        biowait(bp);
-       return(bp);
+       return (bp);
 }
 
 /*
 }
 
 /*
@@ -202,7 +202,7 @@ brelse(bp)
        /*
         * Stick the buffer back on a free list.
         */
        /*
         * Stick the buffer back on a free list.
         */
-       s = spl6();
+       s = splbio();
        if (bp->b_bufsize <= 0) {
                /* block has no buffer ... put at front of unused buffer list */
                flist = &bfreelist[BQ_EMPTY];
        if (bp->b_bufsize <= 0) {
                /* block has no buffer ... put at front of unused buffer list */
                flist = &bfreelist[BQ_EMPTY];
@@ -273,8 +273,18 @@ getblk(dev, blkno, size)
        register struct buf *bp, *dp;
        int s;
 
        register struct buf *bp, *dp;
        int s;
 
-       if ((unsigned)blkno >= 1 << (sizeof(int)*NBBY-PGSHIFT)) /* XXX */
-               blkno = 1 << ((sizeof(int)*NBBY-PGSHIFT) + 1);
+       if (size > MAXBSIZE)
+               panic("getblk: size too big");
+       /*
+        * To prevent overflow of 32-bit ints when converting block
+        * numbers to byte offsets, blknos > 2^32 / DEV_BSIZE are set
+        * to the maximum number that can be converted to a byte offset
+        * without overflow. This is historic code; what bug it fixed,
+        * or whether it is still a reasonable thing to do is open to
+        * dispute. mkm 9/85
+        */
+       if ((unsigned)blkno >= 1 << (sizeof(int)*NBBY-DEV_BSHIFT))
+               blkno = 1 << ((sizeof(int)*NBBY-DEV_BSHIFT) + 1);
        /*
         * Search the cache for the block.  If we hit, but
         * the buffer is in use for i/o, then we wait until
        /*
         * Search the cache for the block.  If we hit, but
         * the buffer is in use for i/o, then we wait until
@@ -286,7 +296,7 @@ loop:
                if (bp->b_blkno != blkno || bp->b_dev != dev ||
                    bp->b_flags&B_INVAL)
                        continue;
                if (bp->b_blkno != blkno || bp->b_dev != dev ||
                    bp->b_flags&B_INVAL)
                        continue;
-               s = spl6();
+               s = splbio();
                if (bp->b_flags&B_BUSY) {
                        bp->b_flags |= B_WANTED;
                        sleep((caddr_t)bp, PRIBIO+1);
                if (bp->b_flags&B_BUSY) {
                        bp->b_flags |= B_WANTED;
                        sleep((caddr_t)bp, PRIBIO+1);
@@ -298,7 +308,7 @@ loop:
                if (bp->b_bcount != size && brealloc(bp, size) == 0)
                        goto loop;
                bp->b_flags |= B_CACHE;
                if (bp->b_bcount != size && brealloc(bp, size) == 0)
                        goto loop;
                bp->b_flags |= B_CACHE;
-               return(bp);
+               return (bp);
        }
        if (major(dev) >= nblkdev)
                panic("blkdev");
        }
        if (major(dev) >= nblkdev)
                panic("blkdev");
@@ -311,7 +321,7 @@ loop:
        bp->b_error = 0;
        if (brealloc(bp, size) == 0)
                goto loop;
        bp->b_error = 0;
        if (brealloc(bp, size) == 0)
                goto loop;
-       return(bp);
+       return (bp);
 }
 
 /*
 }
 
 /*
@@ -324,6 +334,8 @@ geteblk(size)
 {
        register struct buf *bp, *flist;
 
 {
        register struct buf *bp, *flist;
 
+       if (size > MAXBSIZE)
+               panic("geteblk: size too big");
 loop:
        bp = getnewbuf();
        bp->b_flags |= B_INVAL;
 loop:
        bp = getnewbuf();
        bp->b_flags |= B_INVAL;
@@ -335,7 +347,7 @@ loop:
        bp->b_error = 0;
        if (brealloc(bp, size) == 0)
                goto loop;
        bp->b_error = 0;
        if (brealloc(bp, size) == 0)
                goto loop;
-       return(bp);
+       return (bp);
 }
 
 /*
 }
 
 /*
@@ -390,7 +402,7 @@ loop:
                if (ep->b_bcount == 0 || ep->b_blkno > last ||
                    ep->b_blkno + btodb(ep->b_bcount) <= start)
                        continue;
                if (ep->b_bcount == 0 || ep->b_blkno > last ||
                    ep->b_blkno + btodb(ep->b_bcount) <= start)
                        continue;
-               s = spl6();
+               s = splbio();
                if (ep->b_flags&B_BUSY) {
                        ep->b_flags |= B_WANTED;
                        sleep((caddr_t)ep, PRIBIO+1);
                if (ep->b_flags&B_BUSY) {
                        ep->b_flags |= B_WANTED;
                        sleep((caddr_t)ep, PRIBIO+1);
@@ -421,7 +433,7 @@ getnewbuf()
        int s;
 
 loop:
        int s;
 
 loop:
-       s = spl6();
+       s = splbio();
        for (dp = &bfreelist[BQ_AGE]; dp > bfreelist; dp--)
                if (dp->av_forw != dp)
                        break;
        for (dp = &bfreelist[BQ_AGE]; dp > bfreelist; dp--)
                if (dp->av_forw != dp)
                        break;
@@ -453,7 +465,7 @@ biowait(bp)
 {
        int s;
 
 {
        int s;
 
-       s = spl6();
+       s = splbio();
        while ((bp->b_flags&B_DONE)==0)
                sleep((caddr_t)bp, PRIBIO);
        splx(s);
        while ((bp->b_flags&B_DONE)==0)
                sleep((caddr_t)bp, PRIBIO);
        splx(s);
@@ -511,7 +523,7 @@ loop:
                if (ep->b_bcount == 0 || ep->b_blkno > last ||
                    ep->b_blkno + btodb(ep->b_bcount) <= start)
                        continue;
                if (ep->b_bcount == 0 || ep->b_blkno > last ||
                    ep->b_blkno + btodb(ep->b_bcount) <= start)
                        continue;
-               s = spl6();
+               s = splbio();
                if (ep->b_flags&B_BUSY) {
                        ep->b_flags |= B_WANTED;
                        sleep((caddr_t)ep, PRIBIO+1);
                if (ep->b_flags&B_BUSY) {
                        ep->b_flags |= B_WANTED;
                        sleep((caddr_t)ep, PRIBIO+1);
@@ -542,7 +554,7 @@ bflush(dev)
        int s;
 
 loop:
        int s;
 
 loop:
-       s = spl6();
+       s = splbio();
        for (flist = bfreelist; flist < &bfreelist[BQ_EMPTY]; flist++)
        for (bp = flist->av_forw; bp != flist; bp = bp->av_forw) {
                if ((bp->b_flags & B_DELWRI) == 0)
        for (flist = bfreelist; flist < &bfreelist[BQ_EMPTY]; flist++)
        for (bp = flist->av_forw; bp != flist; bp = bp->av_forw) {
                if ((bp->b_flags & B_DELWRI) == 0)
@@ -560,9 +572,7 @@ loop:
 
 /*
  * Pick up the device's error number and pass it to the user;
 
 /*
  * Pick up the device's error number and pass it to the user;
- * if there is an error but the number is 0 set a generalized
- * code.  Actually the latter is always true because devices
- * don't yet return specific errors.
+ * if there is an error but the number is 0 set a generalized code.
  */
 geterror(bp)
        register struct buf *bp;
  */
 geterror(bp)
        register struct buf *bp;