add ifdefs for dev_bsize (almost working)
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Fri, 3 Apr 1987 06:41:36 +0000 (22:41 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Fri, 3 Apr 1987 06:41:36 +0000 (22:41 -0800)
SCCS-vsn: sys/kern/kern_exec.c 7.3.1.1
SCCS-vsn: sys/ufs/ffs/ffs_alloc.c 7.1.1.1
SCCS-vsn: sys/ufs/lfs/lfs_alloc.c 7.1.1.1
SCCS-vsn: sys/kern/vfs_bio.c 7.1.1.1
SCCS-vsn: sys/kern/vfs_cluster.c 7.1.1.1
SCCS-vsn: sys/ufs/ffs/ffs_balloc.c 7.1.1.1
SCCS-vsn: sys/ufs/lfs/lfs_balloc.c 7.1.1.1
SCCS-vsn: sys/ufs/ffs/ffs_inode.c 7.1.1.1
SCCS-vsn: sys/ufs/ffs/ufs_inode.c 7.1.1.1
SCCS-vsn: sys/ufs/lfs/lfs_inode.c 7.1.1.1
SCCS-vsn: sys/ufs/ufs/ufs_inode.c 7.1.1.1
SCCS-vsn: sys/ufs/ffs/ffs_vfsops.c 7.2.1.1
SCCS-vsn: sys/ufs/ffs/ufs_vfsops.c 7.2.1.1
SCCS-vsn: sys/ufs/lfs/lfs_vfsops.c 7.2.1.1
SCCS-vsn: sys/ufs/ufs/ufs_vfsops.c 7.2.1.1
SCCS-vsn: sys/kern/vfs_lookup.c 7.1.1.1
SCCS-vsn: sys/ufs/ffs/ufs_lookup.c 7.1.1.1
SCCS-vsn: sys/ufs/ufs/ufs_lookup.c 7.1.1.1
SCCS-vsn: sys/ufs/ffs/ffs_subr.c 7.3.1.1
SCCS-vsn: sys/vm/vm_swap.c 7.1.1.1
SCCS-vsn: sys/kern/kern_physio.c 7.2.1.1

21 files changed:
usr/src/sys/kern/kern_exec.c
usr/src/sys/kern/kern_physio.c
usr/src/sys/kern/vfs_bio.c
usr/src/sys/kern/vfs_cluster.c
usr/src/sys/kern/vfs_lookup.c
usr/src/sys/ufs/ffs/ffs_alloc.c
usr/src/sys/ufs/ffs/ffs_balloc.c
usr/src/sys/ufs/ffs/ffs_inode.c
usr/src/sys/ufs/ffs/ffs_subr.c
usr/src/sys/ufs/ffs/ffs_vfsops.c
usr/src/sys/ufs/ffs/ufs_inode.c
usr/src/sys/ufs/ffs/ufs_lookup.c
usr/src/sys/ufs/ffs/ufs_vfsops.c
usr/src/sys/ufs/lfs/lfs_alloc.c
usr/src/sys/ufs/lfs/lfs_balloc.c
usr/src/sys/ufs/lfs/lfs_inode.c
usr/src/sys/ufs/lfs/lfs_vfsops.c
usr/src/sys/ufs/ufs/ufs_inode.c
usr/src/sys/ufs/ufs/ufs_lookup.c
usr/src/sys/ufs/ufs/ufs_vfsops.c
usr/src/sys/vm/vm_swap.c

index 5c02363..91e44a4 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.
  *
- *     @(#)kern_exec.c 7.3 (Berkeley) %G%
+ *     @(#)kern_exec.c 7.3.1.1 (Berkeley) %G%
  */
 
 #include "../machine/reg.h"
  */
 
 #include "../machine/reg.h"
@@ -63,6 +63,9 @@ execve()
        } exdata;
        register struct nameidata *ndp = &u.u_nd;
        int resid, error;
        } exdata;
        register struct nameidata *ndp = &u.u_nd;
        int resid, error;
+#ifdef SECSIZE
+       extern long argdbsize;                  /* XXX */
+#endif SECSIZE
 
        ndp->ni_nameiop = LOOKUP | FOLLOW;
        ndp->ni_segflg = UIO_USERSPACE;
 
        ndp->ni_nameiop = LOOKUP | FOLLOW;
        ndp->ni_segflg = UIO_USERSPACE;
@@ -187,7 +190,11 @@ execve()
        nc = 0;
        cc = 0;
        uap = (struct execa *)u.u_ap;
        nc = 0;
        cc = 0;
        uap = (struct execa *)u.u_ap;
+#ifdef SECSIZE
+       bno = rmalloc(argmap, (clrnd((int)btoc(NCARGS))) * CLBYTES / argdbsize);
+#else SECSIZE
        bno = rmalloc(argmap, (long)ctod(clrnd((int)btoc(NCARGS))));
        bno = rmalloc(argmap, (long)ctod(clrnd((int)btoc(NCARGS))));
+#endif SECSIZE
        if (bno == 0) {
                swkill(u.u_procp, "exec: no swap space");
                goto bad;
        if (bno == 0) {
                swkill(u.u_procp, "exec: no swap space");
                goto bad;
@@ -229,7 +236,7 @@ execve()
                        if (cc <= 0) {
                                /*
                                 * We depend on NCARGS being a multiple of
                        if (cc <= 0) {
                                /*
                                 * We depend on NCARGS being a multiple of
-                                * CLSIZE*NBPG.  This way we need only check
+                                * CLBYTES.  This way we need only check
                                 * overflow before each buffer allocation.
                                 */
                                if (nc >= NCARGS-1) {
                                 * overflow before each buffer allocation.
                                 */
                                if (nc >= NCARGS-1) {
@@ -238,8 +245,13 @@ execve()
                                }
                                if (bp)
                                        bdwrite(bp);
                                }
                                if (bp)
                                        bdwrite(bp);
-                               cc = CLSIZE*NBPG;
+                               cc = CLBYTES;
+#ifdef SECSIZE
+                               bp = getblk(argdev, bno + nc / argdbsize, cc,
+                                   argdbsize);
+#else SECSIZE
                                bp = getblk(argdev, bno + ctod(nc/NBPG), cc);
                                bp = getblk(argdev, bno + ctod(nc/NBPG), cc);
+#endif SECSIZE
                                cp = bp->b_un.b_addr;
                        }
                        if (sharg) {
                                cp = bp->b_un.b_addr;
                        }
                        if (sharg) {
@@ -270,7 +282,12 @@ execve()
        if (u.u_error) {
 badarg:
                for (cc = 0; cc < nc; cc += CLSIZE*NBPG) {
        if (u.u_error) {
 badarg:
                for (cc = 0; cc < nc; cc += CLSIZE*NBPG) {
+#ifdef SECSIZE
+                       bp = baddr(argdev, bno + cc / argdbsize, CLSIZE*NBPG,
+                           argdbsize);
+#else SECSIZE
                        bp = baddr(argdev, bno + ctod(cc/NBPG), CLSIZE*NBPG);
                        bp = baddr(argdev, bno + ctod(cc/NBPG), CLSIZE*NBPG);
+#endif SECSIZE
                        if (bp) {
                                bp->b_flags |= B_AGE;           /* throw away */
                                bp->b_flags &= ~B_DELWRI;       /* cancel io */
                        if (bp) {
                                bp->b_flags |= B_AGE;           /* throw away */
                                bp->b_flags &= ~B_DELWRI;       /* cancel io */
@@ -305,8 +322,13 @@ badarg:
                        if (cc <= 0) {
                                if (bp)
                                        brelse(bp);
                        if (cc <= 0) {
                                if (bp)
                                        brelse(bp);
-                               cc = CLSIZE*NBPG;
+                               cc = CLBYTES;
+#ifdef SECSIZE
+                               bp = bread(argdev, bno + nc / argdbsize, cc,
+                                   argdbsize);
+#else SECSIZE
                                bp = bread(argdev, bno + ctod(nc / NBPG), cc);
                                bp = bread(argdev, bno + ctod(nc / NBPG), cc);
+#endif SECSIZE
                                bp->b_flags |= B_AGE;           /* throw away */
                                bp->b_flags &= ~B_DELWRI;       /* cancel io */
                                cp = bp->b_un.b_addr;
                                bp->b_flags |= B_AGE;           /* throw away */
                                bp->b_flags &= ~B_DELWRI;       /* cancel io */
                                cp = bp->b_un.b_addr;
@@ -367,7 +389,12 @@ bad:
        if (bp)
                brelse(bp);
        if (bno)
        if (bp)
                brelse(bp);
        if (bno)
+#ifdef SECSIZE
+               rmfree(argmap, (clrnd((int)btoc(NCARGS))) * CLBYTES / argdbsize,
+                   bno);
+#else SECSIZE
                rmfree(argmap, (long)ctod(clrnd((int) btoc(NCARGS))), bno);
                rmfree(argmap, (long)ctod(clrnd((int) btoc(NCARGS))), bno);
+#endif SECSIZE
        if (ip)
                iput(ip);
 }
        if (ip)
                iput(ip);
 }
index 618a2ac..96d7120 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.
  *
- *     @(#)kern_physio.c       7.2 (Berkeley) %G%
+ *     @(#)kern_physio.c       7.2.1.1 (Berkeley) %G%
  */
 
 #include "../machine/pte.h"
  */
 
 #include "../machine/pte.h"
 #include "trace.h"
 #include "map.h"
 #include "uio.h"
 #include "trace.h"
 #include "map.h"
 #include "uio.h"
+#ifdef SECSIZE
+#include "file.h"
+#include "ioctl.h"
+#include "disklabel.h"
+#endif SECSIZE
 
 /*
  * Swap IO headers -
 
 /*
  * Swap IO headers -
@@ -42,7 +47,7 @@ struct        buf *swbuf;
  * the index of the swap header that has been allocated.
  * We simply initialize the header and queue the I/O but
  * do not wait for completion. When the I/O completes,
  * the index of the swap header that has been allocated.
  * We simply initialize the header and queue the I/O but
  * do not wait for completion. When the I/O completes,
- * iodone() will link the header to a list of cleaned
+ * biodone() will link the header to a list of cleaned
  * pages to be processed by the pageout daemon.
  */
 swap(p, dblkno, addr, nbytes, rdflg, flag, dev, pfcent)
  * pages to be processed by the pageout daemon.
  */
 swap(p, dblkno, addr, nbytes, rdflg, flag, dev, pfcent)
@@ -71,6 +76,9 @@ swap(p, dblkno, addr, nbytes, rdflg, flag, dev, pfcent)
        splx(s);
 
        bp->b_flags = B_BUSY | B_PHYS | rdflg | flag;
        splx(s);
 
        bp->b_flags = B_BUSY | B_PHYS | rdflg | flag;
+#ifdef SECSIZE
+       bp->b_blksize = DEV_BSIZE;
+#endif SECSIZE
        if ((bp->b_flags & (B_DIRTY|B_PGIN)) == 0)
                if (rdflg == B_READ)
                        sum.v_pswpin += btoc(nbytes);
        if ((bp->b_flags & (B_DIRTY|B_PGIN)) == 0)
                if (rdflg == B_READ)
                        sum.v_pswpin += btoc(nbytes);
@@ -105,7 +113,7 @@ swap(p, dblkno, addr, nbytes, rdflg, flag, dev, pfcent)
                if (flag & B_DIRTY) {
                        if (c < nbytes)
                                panic("big push");
                if (flag & B_DIRTY) {
                        if (c < nbytes)
                                panic("big push");
-                       return (error);
+                       return (0);
                }
                bp->b_un.b_addr += c;
                bp->b_flags &= ~B_DONE;
                }
                bp->b_un.b_addr += c;
                bp->b_flags &= ~B_DONE;
@@ -116,6 +124,10 @@ swap(p, dblkno, addr, nbytes, rdflg, flag, dev, pfcent)
                        error = EIO;
                }
                nbytes -= c;
                        error = EIO;
                }
                nbytes -= c;
+#ifdef SECSIZE
+               if (flag & B_PGIN && nbytes > 0)
+                       panic("big pgin");
+#endif SECSIZE
                dblkno += btodb(c);
        }
        s = splbio();
                dblkno += btodb(c);
        }
        s = splbio();
@@ -200,64 +212,77 @@ physio(strat, bp, dev, rw, mincnt, uio)
        register int c;
        char *a;
        int s, error = 0;
        register int c;
        char *a;
        int s, error = 0;
+#ifdef SECSIZE
+       int bsize;
+       struct partinfo dpart;
+#endif SECSIZE
 
 
-nextiov:
-       if (uio->uio_iovcnt == 0)
-               return (0);
-       iov = uio->uio_iov;
-       if (useracc(iov->iov_base,(u_int)iov->iov_len,rw==B_READ?B_WRITE:B_READ) == NULL)
-               return (EFAULT);
-       s = splbio();
-       while (bp->b_flags&B_BUSY) {
-               bp->b_flags |= B_WANTED;
-               sleep((caddr_t)bp, PRIBIO+1);
-       }
-       splx(s);
-       bp->b_error = 0;
-       bp->b_proc = u.u_procp;
-       bp->b_un.b_addr = iov->iov_base;
-       while (iov->iov_len > 0) {
-               bp->b_flags = B_BUSY | B_PHYS | rw;
-               bp->b_dev = dev;
-               bp->b_blkno = btodb(uio->uio_offset);
-               bp->b_bcount = iov->iov_len;
-               (*mincnt)(bp);
-               c = bp->b_bcount;
-               u.u_procp->p_flag |= SPHYSIO;
-               vslock(a = bp->b_un.b_addr, c);
-               physstrat(bp, strat, PRIBIO);
-               (void) splbio();
-               vsunlock(a, c, rw);
-               u.u_procp->p_flag &= ~SPHYSIO;
-               if (bp->b_flags&B_WANTED)
-                       wakeup((caddr_t)bp);
+#ifdef SECSIZE
+       if ((unsigned)major(dev) < nchrdev &&
+           (*cdevsw[major(dev)].d_ioctl)(dev, DIOCGPART, (caddr_t)&dpart,
+           FREAD) == 0)
+               bsize = dpart.disklab->d_secsize;
+       else
+               bsize = DEV_BSIZE;
+#endif SECSIZE
+       for (;;) {
+               if (uio->uio_iovcnt == 0)
+                       return (0);
+               iov = uio->uio_iov;
+               if (useracc(iov->iov_base, (u_int)iov->iov_len,
+                   rw==B_READ? B_WRITE : B_READ) == NULL)
+                       return (EFAULT);
+               s = splbio();
+               while (bp->b_flags&B_BUSY) {
+                       bp->b_flags |= B_WANTED;
+                       sleep((caddr_t)bp, PRIBIO+1);
+               }
                splx(s);
                splx(s);
-               c -= bp->b_resid;
-               bp->b_un.b_addr += c;
-               iov->iov_len -= c;
-               uio->uio_resid -= c;
-               uio->uio_offset += c;
+               bp->b_error = 0;
+               bp->b_proc = u.u_procp;
+#ifdef SECSIZE
+               bp->b_blksize = bsize;
+#endif SECSIZE
+               bp->b_un.b_addr = iov->iov_base;
+               while (iov->iov_len > 0) {
+                       bp->b_flags = B_BUSY | B_PHYS | rw;
+                       bp->b_dev = dev;
+#ifdef SECSIZE
+                       bp->b_blkno = uio->uio_offset / bsize;
+#else SECSIZE
+                       bp->b_blkno = btodb(uio->uio_offset);
+#endif SECSIZE
+                       bp->b_bcount = iov->iov_len;
+                       (*mincnt)(bp);
+                       c = bp->b_bcount;
+                       u.u_procp->p_flag |= SPHYSIO;
+                       vslock(a = bp->b_un.b_addr, c);
+                       physstrat(bp, strat, PRIBIO);
+                       (void) splbio();
+                       vsunlock(a, c, rw);
+                       u.u_procp->p_flag &= ~SPHYSIO;
+                       if (bp->b_flags&B_WANTED)
+                               wakeup((caddr_t)bp);
+                       splx(s);
+                       c -= bp->b_resid;
+                       bp->b_un.b_addr += c;
+                       iov->iov_len -= c;
+                       uio->uio_resid -= c;
+                       uio->uio_offset += c;
+                       /* temp kludge for tape drives */
+                       if (bp->b_resid || (bp->b_flags&B_ERROR))
+                               break;
+               }
+               bp->b_flags &= ~(B_BUSY|B_WANTED|B_PHYS);
+               error = geterror(bp);
                /* temp kludge for tape drives */
                /* temp kludge for tape drives */
-               if (bp->b_resid || (bp->b_flags&B_ERROR))
-                       break;
+               if (bp->b_resid || error)
+                       return (error);
+               uio->uio_iov++;
+               uio->uio_iovcnt--;
        }
        }
-       bp->b_flags &= ~(B_BUSY|B_WANTED|B_PHYS);
-       error = geterror(bp);
-       /* temp kludge for tape drives */
-       if (bp->b_resid || error)
-               return (error);
-       uio->uio_iov++;
-       uio->uio_iovcnt--;
-       goto nextiov;
 }
 
 }
 
-#if defined(tahoe)
-#define        MAXPHYS (KLMAX * CLBYTES)
-#endif
-#if defined(vax)
-#define        MAXPHYS (63 * 1024)
-#endif
-
 unsigned
 minphys(bp)
        struct buf *bp;
 unsigned
 minphys(bp)
        struct buf *bp;
index fc01a27..29ec5df 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.
  *
- *     @(#)vfs_bio.c   7.1 (Berkeley) %G%
+ *     @(#)vfs_bio.c   7.1.1.1 (Berkeley) %G%
  */
 
 #include "../machine/pte.h"
  */
 
 #include "../machine/pte.h"
  * Read in (if necessary) the block and return a buffer pointer.
  */
 struct buf *
  * Read in (if necessary) the block and return a buffer pointer.
  */
 struct buf *
+#ifdef SECSIZE
+bread(dev, blkno, size, secsize)
+#else SECSIZE
 bread(dev, blkno, size)
 bread(dev, blkno, size)
+#endif SECSIZE
        dev_t dev;
        daddr_t blkno;
        int size;
        dev_t dev;
        daddr_t blkno;
        int size;
+#ifdef SECSIZE
+       long secsize;
+#endif SECSIZE
 {
        register struct buf *bp;
 
        if (size == 0)
                panic("bread: size 0");
 {
        register struct buf *bp;
 
        if (size == 0)
                panic("bread: size 0");
+#ifdef SECSIZE
+       bp = getblk(dev, blkno, size, secsize);
+#else SECSIZE
        bp = getblk(dev, blkno, size);
        bp = getblk(dev, blkno, size);
+#endif SECSIZE
        if (bp->b_flags&B_DONE) {
                trace(TR_BREADHIT, pack(dev, size), blkno);
                return (bp);
        if (bp->b_flags&B_DONE) {
                trace(TR_BREADHIT, pack(dev, size), blkno);
                return (bp);
@@ -52,9 +63,16 @@ bread(dev, blkno, size)
  * read-ahead block (which is not allocated to the caller)
  */
 struct buf *
  * read-ahead block (which is not allocated to the caller)
  */
 struct buf *
+#ifdef SECSIZE
+breada(dev, blkno, size, secsize, rablkno, rabsize)
+#else SECSIZE
 breada(dev, blkno, size, rablkno, rabsize)
 breada(dev, blkno, size, rablkno, rabsize)
+#endif SECSIZE
        dev_t dev;
        daddr_t blkno; int size;
        dev_t dev;
        daddr_t blkno; int size;
+#ifdef SECSIZE
+       long secsize;
+#endif SECSIZE
        daddr_t rablkno; int rabsize;
 {
        register struct buf *bp, *rabp;
        daddr_t rablkno; int rabsize;
 {
        register struct buf *bp, *rabp;
@@ -66,7 +84,11 @@ breada(dev, blkno, size, rablkno, rabsize)
         * for a cache hit).
         */
        if (!incore(dev, blkno)) {
         * for a cache hit).
         */
        if (!incore(dev, blkno)) {
+#ifdef SECSIZE
+               bp = getblk(dev, blkno, size, secsize);
+#else SECSIZE
                bp = getblk(dev, blkno, size);
                bp = getblk(dev, blkno, size);
+#endif SECSIZE
                if ((bp->b_flags&B_DONE) == 0) {
                        bp->b_flags |= B_READ;
                        if (bp->b_bcount > bp->b_bufsize)
                if ((bp->b_flags&B_DONE) == 0) {
                        bp->b_flags |= B_READ;
                        if (bp->b_bcount > bp->b_bufsize)
@@ -83,7 +105,11 @@ breada(dev, blkno, size, rablkno, rabsize)
         * on it also (as above).
         */
        if (rablkno && !incore(dev, rablkno)) {
         * on it also (as above).
         */
        if (rablkno && !incore(dev, rablkno)) {
+#ifdef SECSIZE
+               rabp = getblk(dev, rablkno, rabsize, secsize);
+#else SECSIZE
                rabp = getblk(dev, rablkno, rabsize);
                rabp = getblk(dev, rablkno, rabsize);
+#endif SECSIZE
                if (rabp->b_flags & B_DONE) {
                        brelse(rabp);
                        trace(TR_BREADHITRA, pack(dev, rabsize), blkno);
                if (rabp->b_flags & B_DONE) {
                        brelse(rabp);
                        trace(TR_BREADHITRA, pack(dev, rabsize), blkno);
@@ -103,7 +129,11 @@ breada(dev, blkno, size, rablkno, rabsize)
         * above, and just wait for it.
         */
        if (bp == NULL)
         * above, and just wait for it.
         */
        if (bp == NULL)
+#ifdef SECSIZE
+               return (bread(dev, blkno, size, secsize));
+#else SECSIZE
                return (bread(dev, blkno, size));
                return (bread(dev, blkno, size));
+#endif SECSIZE
        biowait(bp);
        return (bp);
 }
        biowait(bp);
        return (bp);
 }
@@ -149,12 +179,10 @@ bwrite(bp)
 bdwrite(bp)
        register struct buf *bp;
 {
 bdwrite(bp)
        register struct buf *bp;
 {
-       register int flags;
 
        if ((bp->b_flags&B_DELWRI) == 0)
                u.u_ru.ru_oublock++;            /* noone paid yet */
 
        if ((bp->b_flags&B_DELWRI) == 0)
                u.u_ru.ru_oublock++;            /* noone paid yet */
-       flags = bdevsw[major(bp->b_dev)].d_flags;
-       if(flags & B_TAPE)
+       if (bdevsw[major(bp->b_dev)].d_flags & B_TAPE)
                bawrite(bp);
        else {
                bp->b_flags |= B_DELWRI | B_DONE;
                bawrite(bp);
        else {
                bp->b_flags |= B_DELWRI | B_DONE;
@@ -244,14 +272,25 @@ incore(dev, blkno)
 }
 
 struct buf *
 }
 
 struct buf *
+#ifdef SECSIZE
+baddr(dev, blkno, size, secsize)
+#else SECSIZE
 baddr(dev, blkno, size)
 baddr(dev, blkno, size)
+#endif SECSIZE
        dev_t dev;
        daddr_t blkno;
        int size;
        dev_t dev;
        daddr_t blkno;
        int size;
+#ifdef SECSIZE
+       long secsize;
+#endif SECSIZE
 {
 
        if (incore(dev, blkno))
 {
 
        if (incore(dev, blkno))
+#ifdef SECSIZE
+               return (bread(dev, blkno, size, secsize));
+#else SECSIZE
                return (bread(dev, blkno, size));
                return (bread(dev, blkno, size));
+#endif SECSIZE
        return (0);
 }
 
        return (0);
 }
 
@@ -265,10 +304,17 @@ baddr(dev, blkno, size)
  * want to lower the ipl back to 0.
  */
 struct buf *
  * want to lower the ipl back to 0.
  */
 struct buf *
+#ifdef SECSIZE
+getblk(dev, blkno, size, secsize)
+#else SECSIZE
 getblk(dev, blkno, size)
 getblk(dev, blkno, size)
+#endif SECSIZE
        dev_t dev;
        daddr_t blkno;
        int size;
        dev_t dev;
        daddr_t blkno;
        int size;
+#ifdef SECSIZE
+       long secsize;
+#endif SECSIZE
 {
        register struct buf *bp, *dp;
        int s;
 {
        register struct buf *bp, *dp;
        int s;
@@ -317,6 +363,9 @@ loop:
        bremhash(bp);
        binshash(bp, dp);
        bp->b_dev = dev;
        bremhash(bp);
        binshash(bp, dp);
        bp->b_dev = dev;
+#ifdef SECSIZE
+       bp->b_blksize = secsize;
+#endif SECSIZE
        bp->b_blkno = blkno;
        bp->b_error = 0;
        if (brealloc(bp, size) == 0)
        bp->b_blkno = blkno;
        bp->b_error = 0;
        if (brealloc(bp, size) == 0)
@@ -344,6 +393,9 @@ loop:
        flist = &bfreelist[BQ_AGE];
        binshash(bp, flist);
        bp->b_dev = (dev_t)NODEV;
        flist = &bfreelist[BQ_AGE];
        binshash(bp, flist);
        bp->b_dev = (dev_t)NODEV;
+#ifdef SECSIZE
+       bp->b_blksize = DEV_BSIZE;
+#endif SECSIZE
        bp->b_error = 0;
        if (brealloc(bp, size) == 0)
                goto loop;
        bp->b_error = 0;
        if (brealloc(bp, size) == 0)
                goto loop;
@@ -364,7 +416,7 @@ brealloc(bp, size)
        int s;
 
        /*
        int s;
 
        /*
-        * First need to make sure that all overlaping previous I/O
+        * First need to make sure that all overlapping previous I/O
         * is dispatched with.
         */
        if (size == bp->b_bcount)
         * is dispatched with.
         */
        if (size == bp->b_bcount)
@@ -392,7 +444,11 @@ brealloc(bp, size)
         * when two buffer are trying to get the same set of disk blocks.
         */
        start = bp->b_blkno;
         * when two buffer are trying to get the same set of disk blocks.
         */
        start = bp->b_blkno;
+#ifdef SECSIZE
+       last = start + size/bp->b_blksize - 1;
+#else SECSIZE
        last = start + btodb(size) - 1;
        last = start + btodb(size) - 1;
+#endif SECSIZE
        dp = BUFHASH(bp->b_dev, bp->b_blkno);
 loop:
        for (ep = dp->b_forw; ep != dp; ep = ep->b_forw) {
        dp = BUFHASH(bp->b_dev, bp->b_blkno);
 loop:
        for (ep = dp->b_forw; ep != dp; ep = ep->b_forw) {
@@ -400,7 +456,11 @@ loop:
                        continue;
                /* look for overlap */
                if (ep->b_bcount == 0 || ep->b_blkno > last ||
                        continue;
                /* look for overlap */
                if (ep->b_bcount == 0 || ep->b_blkno > last ||
+#ifdef SECSIZE
+                   ep->b_blkno + ep->b_bcount/ep->b_blksize <= start)
+#else SECSIZE
                    ep->b_blkno + btodb(ep->b_bcount) <= start)
                    ep->b_blkno + btodb(ep->b_bcount) <= start)
+#endif SECSIZE
                        continue;
                s = splbio();
                if (ep->b_flags&B_BUSY) {
                        continue;
                s = splbio();
                if (ep->b_flags&B_BUSY) {
@@ -501,11 +561,18 @@ biodone(bp)
 
 /*
  * Insure that no part of a specified block is in an incore buffer.
 
 /*
  * Insure that no part of a specified block is in an incore buffer.
+#ifdef SECSIZE
+ * "size" is given in device blocks (the units of b_blkno).
+#endif SECSIZE
  */
 blkflush(dev, blkno, size)
        dev_t dev;
        daddr_t blkno;
  */
 blkflush(dev, blkno, size)
        dev_t dev;
        daddr_t blkno;
+#ifdef SECSIZE
+       int size;
+#else SECSIZE
        long size;
        long size;
+#endif SECSIZE
 {
        register struct buf *ep;
        struct buf *dp;
 {
        register struct buf *ep;
        struct buf *dp;
@@ -513,7 +580,11 @@ blkflush(dev, blkno, size)
        int s;
 
        start = blkno;
        int s;
 
        start = blkno;
+#ifdef SECSIZE
+       last = start + size - 1;
+#else SECSIZE
        last = start + btodb(size) - 1;
        last = start + btodb(size) - 1;
+#endif SECSIZE
        dp = BUFHASH(dev, blkno);
 loop:
        for (ep = dp->b_forw; ep != dp; ep = ep->b_forw) {
        dp = BUFHASH(dev, blkno);
 loop:
        for (ep = dp->b_forw; ep != dp; ep = ep->b_forw) {
@@ -521,7 +592,11 @@ loop:
                        continue;
                /* look for overlap */
                if (ep->b_bcount == 0 || ep->b_blkno > last ||
                        continue;
                /* look for overlap */
                if (ep->b_bcount == 0 || ep->b_blkno > last ||
+#ifdef SECSIZE
+                   ep->b_blkno + ep->b_bcount / ep->b_blksize <= start)
+#else SECSIZE
                    ep->b_blkno + btodb(ep->b_bcount) <= start)
                    ep->b_blkno + btodb(ep->b_bcount) <= start)
+#endif SECSIZE
                        continue;
                s = splbio();
                if (ep->b_flags&B_BUSY) {
                        continue;
                s = splbio();
                if (ep->b_flags&B_BUSY) {
index 77a87bd..c711ed0 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.
  *
- *     @(#)vfs_cluster.c       7.1 (Berkeley) %G%
+ *     @(#)vfs_cluster.c       7.1.1.1 (Berkeley) %G%
  */
 
 #include "../machine/pte.h"
  */
 
 #include "../machine/pte.h"
  * Read in (if necessary) the block and return a buffer pointer.
  */
 struct buf *
  * Read in (if necessary) the block and return a buffer pointer.
  */
 struct buf *
+#ifdef SECSIZE
+bread(dev, blkno, size, secsize)
+#else SECSIZE
 bread(dev, blkno, size)
 bread(dev, blkno, size)
+#endif SECSIZE
        dev_t dev;
        daddr_t blkno;
        int size;
        dev_t dev;
        daddr_t blkno;
        int size;
+#ifdef SECSIZE
+       long secsize;
+#endif SECSIZE
 {
        register struct buf *bp;
 
        if (size == 0)
                panic("bread: size 0");
 {
        register struct buf *bp;
 
        if (size == 0)
                panic("bread: size 0");
+#ifdef SECSIZE
+       bp = getblk(dev, blkno, size, secsize);
+#else SECSIZE
        bp = getblk(dev, blkno, size);
        bp = getblk(dev, blkno, size);
+#endif SECSIZE
        if (bp->b_flags&B_DONE) {
                trace(TR_BREADHIT, pack(dev, size), blkno);
                return (bp);
        if (bp->b_flags&B_DONE) {
                trace(TR_BREADHIT, pack(dev, size), blkno);
                return (bp);
@@ -52,9 +63,16 @@ bread(dev, blkno, size)
  * read-ahead block (which is not allocated to the caller)
  */
 struct buf *
  * read-ahead block (which is not allocated to the caller)
  */
 struct buf *
+#ifdef SECSIZE
+breada(dev, blkno, size, secsize, rablkno, rabsize)
+#else SECSIZE
 breada(dev, blkno, size, rablkno, rabsize)
 breada(dev, blkno, size, rablkno, rabsize)
+#endif SECSIZE
        dev_t dev;
        daddr_t blkno; int size;
        dev_t dev;
        daddr_t blkno; int size;
+#ifdef SECSIZE
+       long secsize;
+#endif SECSIZE
        daddr_t rablkno; int rabsize;
 {
        register struct buf *bp, *rabp;
        daddr_t rablkno; int rabsize;
 {
        register struct buf *bp, *rabp;
@@ -66,7 +84,11 @@ breada(dev, blkno, size, rablkno, rabsize)
         * for a cache hit).
         */
        if (!incore(dev, blkno)) {
         * for a cache hit).
         */
        if (!incore(dev, blkno)) {
+#ifdef SECSIZE
+               bp = getblk(dev, blkno, size, secsize);
+#else SECSIZE
                bp = getblk(dev, blkno, size);
                bp = getblk(dev, blkno, size);
+#endif SECSIZE
                if ((bp->b_flags&B_DONE) == 0) {
                        bp->b_flags |= B_READ;
                        if (bp->b_bcount > bp->b_bufsize)
                if ((bp->b_flags&B_DONE) == 0) {
                        bp->b_flags |= B_READ;
                        if (bp->b_bcount > bp->b_bufsize)
@@ -83,7 +105,11 @@ breada(dev, blkno, size, rablkno, rabsize)
         * on it also (as above).
         */
        if (rablkno && !incore(dev, rablkno)) {
         * on it also (as above).
         */
        if (rablkno && !incore(dev, rablkno)) {
+#ifdef SECSIZE
+               rabp = getblk(dev, rablkno, rabsize, secsize);
+#else SECSIZE
                rabp = getblk(dev, rablkno, rabsize);
                rabp = getblk(dev, rablkno, rabsize);
+#endif SECSIZE
                if (rabp->b_flags & B_DONE) {
                        brelse(rabp);
                        trace(TR_BREADHITRA, pack(dev, rabsize), blkno);
                if (rabp->b_flags & B_DONE) {
                        brelse(rabp);
                        trace(TR_BREADHITRA, pack(dev, rabsize), blkno);
@@ -103,7 +129,11 @@ breada(dev, blkno, size, rablkno, rabsize)
         * above, and just wait for it.
         */
        if (bp == NULL)
         * above, and just wait for it.
         */
        if (bp == NULL)
+#ifdef SECSIZE
+               return (bread(dev, blkno, size, secsize));
+#else SECSIZE
                return (bread(dev, blkno, size));
                return (bread(dev, blkno, size));
+#endif SECSIZE
        biowait(bp);
        return (bp);
 }
        biowait(bp);
        return (bp);
 }
@@ -149,12 +179,10 @@ bwrite(bp)
 bdwrite(bp)
        register struct buf *bp;
 {
 bdwrite(bp)
        register struct buf *bp;
 {
-       register int flags;
 
        if ((bp->b_flags&B_DELWRI) == 0)
                u.u_ru.ru_oublock++;            /* noone paid yet */
 
        if ((bp->b_flags&B_DELWRI) == 0)
                u.u_ru.ru_oublock++;            /* noone paid yet */
-       flags = bdevsw[major(bp->b_dev)].d_flags;
-       if(flags & B_TAPE)
+       if (bdevsw[major(bp->b_dev)].d_flags & B_TAPE)
                bawrite(bp);
        else {
                bp->b_flags |= B_DELWRI | B_DONE;
                bawrite(bp);
        else {
                bp->b_flags |= B_DELWRI | B_DONE;
@@ -244,14 +272,25 @@ incore(dev, blkno)
 }
 
 struct buf *
 }
 
 struct buf *
+#ifdef SECSIZE
+baddr(dev, blkno, size, secsize)
+#else SECSIZE
 baddr(dev, blkno, size)
 baddr(dev, blkno, size)
+#endif SECSIZE
        dev_t dev;
        daddr_t blkno;
        int size;
        dev_t dev;
        daddr_t blkno;
        int size;
+#ifdef SECSIZE
+       long secsize;
+#endif SECSIZE
 {
 
        if (incore(dev, blkno))
 {
 
        if (incore(dev, blkno))
+#ifdef SECSIZE
+               return (bread(dev, blkno, size, secsize));
+#else SECSIZE
                return (bread(dev, blkno, size));
                return (bread(dev, blkno, size));
+#endif SECSIZE
        return (0);
 }
 
        return (0);
 }
 
@@ -265,10 +304,17 @@ baddr(dev, blkno, size)
  * want to lower the ipl back to 0.
  */
 struct buf *
  * want to lower the ipl back to 0.
  */
 struct buf *
+#ifdef SECSIZE
+getblk(dev, blkno, size, secsize)
+#else SECSIZE
 getblk(dev, blkno, size)
 getblk(dev, blkno, size)
+#endif SECSIZE
        dev_t dev;
        daddr_t blkno;
        int size;
        dev_t dev;
        daddr_t blkno;
        int size;
+#ifdef SECSIZE
+       long secsize;
+#endif SECSIZE
 {
        register struct buf *bp, *dp;
        int s;
 {
        register struct buf *bp, *dp;
        int s;
@@ -317,6 +363,9 @@ loop:
        bremhash(bp);
        binshash(bp, dp);
        bp->b_dev = dev;
        bremhash(bp);
        binshash(bp, dp);
        bp->b_dev = dev;
+#ifdef SECSIZE
+       bp->b_blksize = secsize;
+#endif SECSIZE
        bp->b_blkno = blkno;
        bp->b_error = 0;
        if (brealloc(bp, size) == 0)
        bp->b_blkno = blkno;
        bp->b_error = 0;
        if (brealloc(bp, size) == 0)
@@ -344,6 +393,9 @@ loop:
        flist = &bfreelist[BQ_AGE];
        binshash(bp, flist);
        bp->b_dev = (dev_t)NODEV;
        flist = &bfreelist[BQ_AGE];
        binshash(bp, flist);
        bp->b_dev = (dev_t)NODEV;
+#ifdef SECSIZE
+       bp->b_blksize = DEV_BSIZE;
+#endif SECSIZE
        bp->b_error = 0;
        if (brealloc(bp, size) == 0)
                goto loop;
        bp->b_error = 0;
        if (brealloc(bp, size) == 0)
                goto loop;
@@ -364,7 +416,7 @@ brealloc(bp, size)
        int s;
 
        /*
        int s;
 
        /*
-        * First need to make sure that all overlaping previous I/O
+        * First need to make sure that all overlapping previous I/O
         * is dispatched with.
         */
        if (size == bp->b_bcount)
         * is dispatched with.
         */
        if (size == bp->b_bcount)
@@ -392,7 +444,11 @@ brealloc(bp, size)
         * when two buffer are trying to get the same set of disk blocks.
         */
        start = bp->b_blkno;
         * when two buffer are trying to get the same set of disk blocks.
         */
        start = bp->b_blkno;
+#ifdef SECSIZE
+       last = start + size/bp->b_blksize - 1;
+#else SECSIZE
        last = start + btodb(size) - 1;
        last = start + btodb(size) - 1;
+#endif SECSIZE
        dp = BUFHASH(bp->b_dev, bp->b_blkno);
 loop:
        for (ep = dp->b_forw; ep != dp; ep = ep->b_forw) {
        dp = BUFHASH(bp->b_dev, bp->b_blkno);
 loop:
        for (ep = dp->b_forw; ep != dp; ep = ep->b_forw) {
@@ -400,7 +456,11 @@ loop:
                        continue;
                /* look for overlap */
                if (ep->b_bcount == 0 || ep->b_blkno > last ||
                        continue;
                /* look for overlap */
                if (ep->b_bcount == 0 || ep->b_blkno > last ||
+#ifdef SECSIZE
+                   ep->b_blkno + ep->b_bcount/ep->b_blksize <= start)
+#else SECSIZE
                    ep->b_blkno + btodb(ep->b_bcount) <= start)
                    ep->b_blkno + btodb(ep->b_bcount) <= start)
+#endif SECSIZE
                        continue;
                s = splbio();
                if (ep->b_flags&B_BUSY) {
                        continue;
                s = splbio();
                if (ep->b_flags&B_BUSY) {
@@ -501,11 +561,18 @@ biodone(bp)
 
 /*
  * Insure that no part of a specified block is in an incore buffer.
 
 /*
  * Insure that no part of a specified block is in an incore buffer.
+#ifdef SECSIZE
+ * "size" is given in device blocks (the units of b_blkno).
+#endif SECSIZE
  */
 blkflush(dev, blkno, size)
        dev_t dev;
        daddr_t blkno;
  */
 blkflush(dev, blkno, size)
        dev_t dev;
        daddr_t blkno;
+#ifdef SECSIZE
+       int size;
+#else SECSIZE
        long size;
        long size;
+#endif SECSIZE
 {
        register struct buf *ep;
        struct buf *dp;
 {
        register struct buf *ep;
        struct buf *dp;
@@ -513,7 +580,11 @@ blkflush(dev, blkno, size)
        int s;
 
        start = blkno;
        int s;
 
        start = blkno;
+#ifdef SECSIZE
+       last = start + size - 1;
+#else SECSIZE
        last = start + btodb(size) - 1;
        last = start + btodb(size) - 1;
+#endif SECSIZE
        dp = BUFHASH(dev, blkno);
 loop:
        for (ep = dp->b_forw; ep != dp; ep = ep->b_forw) {
        dp = BUFHASH(dev, blkno);
 loop:
        for (ep = dp->b_forw; ep != dp; ep = ep->b_forw) {
@@ -521,7 +592,11 @@ loop:
                        continue;
                /* look for overlap */
                if (ep->b_bcount == 0 || ep->b_blkno > last ||
                        continue;
                /* look for overlap */
                if (ep->b_bcount == 0 || ep->b_blkno > last ||
+#ifdef SECSIZE
+                   ep->b_blkno + ep->b_bcount / ep->b_blksize <= start)
+#else SECSIZE
                    ep->b_blkno + btodb(ep->b_bcount) <= start)
                    ep->b_blkno + btodb(ep->b_bcount) <= start)
+#endif SECSIZE
                        continue;
                s = splbio();
                if (ep->b_flags&B_BUSY) {
                        continue;
                s = splbio();
                if (ep->b_flags&B_BUSY) {
index b6368f4..64b9d8f 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.
  *
- *     @(#)vfs_lookup.c        7.1 (Berkeley) %G%
+ *     @(#)vfs_lookup.c        7.1.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -1060,7 +1060,11 @@ blkatoff(ip, offset, res)
                dirbad(ip, offset, "hole in dir");
                return (0);
        }
                dirbad(ip, offset, "hole in dir");
                return (0);
        }
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, bn), bsize, fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), bsize);
        bp = bread(ip->i_dev, fsbtodb(fs, bn), bsize);
+#endif SECSIZE
        if (bp->b_flags & B_ERROR) {
                brelse(bp);
                return (0);
        if (bp->b_flags & B_ERROR) {
                brelse(bp);
                return (0);
index 72eb9a9..0dd37ef 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.
  *
- *     @(#)ffs_alloc.c 7.1 (Berkeley) %G%
+ *     @(#)ffs_alloc.c 7.1.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -86,7 +86,11 @@ alloc(ip, bpref, size)
                goto nospace;
        ip->i_blocks += btodb(size);
        ip->i_flag |= IUPD|ICHG;
                goto nospace;
        ip->i_blocks += btodb(size);
        ip->i_flag |= IUPD|ICHG;
+#ifdef SECSIZE
+       bp = getblk(ip->i_dev, fsbtodb(fs, bno), size, fs->fs_dbsize);
+#else SECSIZE
        bp = getblk(ip->i_dev, fsbtodb(fs, bno), size);
        bp = getblk(ip->i_dev, fsbtodb(fs, bno), size);
+#endif SECSIZE
        clrbuf(bp);
        return (bp);
 nospace:
        clrbuf(bp);
        return (bp);
 nospace:
@@ -140,7 +144,12 @@ realloccg(ip, bprev, bpref, osize, nsize)
        bno = fragextend(ip, cg, (long)bprev, osize, nsize);
        if (bno != 0) {
                do {
        bno = fragextend(ip, cg, (long)bprev, osize, nsize);
        if (bno != 0) {
                do {
+#ifdef SECSIZE
+                       bp = bread(ip->i_dev, fsbtodb(fs, bno), osize,
+                           fs->fs_dbsize);
+#else SECSIZE
                        bp = bread(ip->i_dev, fsbtodb(fs, bno), osize);
                        bp = bread(ip->i_dev, fsbtodb(fs, bno), osize);
+#endif SECSIZE
                        if (bp->b_flags & B_ERROR) {
                                brelse(bp);
                                return (NULL);
                        if (bp->b_flags & B_ERROR) {
                                brelse(bp);
                                return (NULL);
@@ -200,20 +209,30 @@ realloccg(ip, bprev, bpref, osize, nsize)
        bno = (daddr_t)hashalloc(ip, cg, (long)bpref, request,
                (u_long (*)())alloccg);
        if (bno > 0) {
        bno = (daddr_t)hashalloc(ip, cg, (long)bpref, request,
                (u_long (*)())alloccg);
        if (bno > 0) {
+#ifdef SECSIZE
+               obp = bread(ip->i_dev, fsbtodb(fs, bprev), osize,
+                   fs->fs_dbsize);
+#else SECSIZE
                obp = bread(ip->i_dev, fsbtodb(fs, bprev), osize);
                obp = bread(ip->i_dev, fsbtodb(fs, bprev), osize);
+#endif SECSIZE
                if (obp->b_flags & B_ERROR) {
                        brelse(obp);
                        return (NULL);
                }
                bn = fsbtodb(fs, bno);
                if (obp->b_flags & B_ERROR) {
                        brelse(obp);
                        return (NULL);
                }
                bn = fsbtodb(fs, bno);
+#ifdef SECSIZE
+               bp = getblk(ip->i_dev, bn, nsize, fs->fs_dbsize);
+#else SECSIZE
                bp = getblk(ip->i_dev, bn, nsize);
                bp = getblk(ip->i_dev, bn, nsize);
+#endif SECSIZE
                bcopy(obp->b_un.b_addr, bp->b_un.b_addr, (u_int)osize);
                bcopy(obp->b_un.b_addr, bp->b_un.b_addr, (u_int)osize);
-               count = howmany(osize, DEV_BSIZE);
-               s = splimp();
-               for (i = 0; i < count; i += CLBYTES / DEV_BSIZE)
-                       if (mfind(ip->i_dev, bn + i))
-                               munhash(ip->i_dev, bn + i);
-               splx(s);
+               count = howmany(osize, CLBYTES);
+               for (i = 0; i < count; i++)
+#ifdef SECSIZE
+                       munhash(ip->i_dev, bn + i * CLBYTES / fs->fs_dbsize);
+#else SECSIZE
+                       munhash(ip->i_dev, bn + i * CLBYTES / DEV_BSIZE);
+#endif SECSIZE
                bzero(bp->b_un.b_addr + osize, (unsigned)nsize - osize);
                if (obp->b_flags & B_DELWRI) {
                        obp->b_flags &= ~B_DELWRI;
                bzero(bp->b_un.b_addr + osize, (unsigned)nsize - osize);
                if (obp->b_flags & B_DELWRI) {
                        obp->b_flags &= ~B_DELWRI;
@@ -497,10 +516,15 @@ fragextend(ip, cg, bprev, osize, nsize)
        frags = numfrags(fs, nsize);
        bbase = fragnum(fs, bprev);
        if (bbase > fragnum(fs, (bprev + frags - 1))) {
        frags = numfrags(fs, nsize);
        bbase = fragnum(fs, bprev);
        if (bbase > fragnum(fs, (bprev + frags - 1))) {
-               /* cannot extend across a block boundry */
+               /* cannot extend across a block boundary */
                return (NULL);
        }
                return (NULL);
        }
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
@@ -559,7 +583,12 @@ alloccg(ip, cg, bpref, size)
        fs = ip->i_fs;
        if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize)
                return (NULL);
        fs = ip->i_fs;
        if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize)
                return (NULL);
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC ||
            (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) {
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC ||
            (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) {
@@ -754,7 +783,12 @@ ialloccg(ip, cg, ipref, mode)
        fs = ip->i_fs;
        if (fs->fs_cs(fs, cg).cs_nifree == 0)
                return (NULL);
        fs = ip->i_fs;
        if (fs->fs_cs(fs, cg).cs_nifree == 0)
                return (NULL);
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC ||
            cgp->cg_cs.cs_nifree == 0) {
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC ||
            cgp->cg_cs.cs_nifree == 0) {
@@ -837,7 +871,12 @@ free(ip, bno, size)
                printf("bad block %d, ino %d\n", bno, ip->i_number);
                return;
        }
                printf("bad block %d, ino %d\n", bno, ip->i_number);
                return;
        }
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
@@ -926,7 +965,12 @@ ifree(ip, ino, mode)
                panic("ifree: range");
        }
        cg = itog(fs, ino);
                panic("ifree: range");
        }
        cg = itog(fs, ino);
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
index ea80e2a..3f115b4 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.
  *
- *     @(#)ffs_balloc.c        7.1 (Berkeley) %G%
+ *     @(#)ffs_balloc.c        7.1.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -161,7 +161,12 @@ gotit:
         * fetch through the indirect blocks
         */
        for (; j <= NIADDR; j++) {
         * fetch through the indirect blocks
         */
        for (; j <= NIADDR; j++) {
+#ifdef SECSIZE
+               bp = bread(ip->i_dev, fsbtodb(fs, nb), (int)fs->fs_bsize,
+                   fs->fs_dbsize);
+#else SECSIZE
                bp = bread(ip->i_dev, fsbtodb(fs, nb), (int)fs->fs_bsize);
                bp = bread(ip->i_dev, fsbtodb(fs, nb), (int)fs->fs_bsize);
+#endif SECSIZE
                if (bp->b_flags & B_ERROR) {
                        brelse(bp);
                        return ((daddr_t)0);
                if (bp->b_flags & B_ERROR) {
                        brelse(bp);
                        return ((daddr_t)0);
index 1b979ac..2320433 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.
  *
- *     @(#)ffs_inode.c 7.1 (Berkeley) %G%
+ *     @(#)ffs_inode.c 7.1.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -185,7 +185,12 @@ loop:
 #ifdef QUOTA
        dqrele(ip->i_dquot);
 #endif
 #ifdef QUOTA
        dqrele(ip->i_dquot);
 #endif
+#ifdef SECSIZE
+       bp = bread(dev, fsbtodb(fs, itod(fs, ino)), (int)fs->fs_bsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(dev, fsbtodb(fs, itod(fs, ino)), (int)fs->fs_bsize);
        bp = bread(dev, fsbtodb(fs, itod(fs, ino)), (int)fs->fs_bsize);
+#endif SECSIZE
        /*
         * Check I/O errors
         */
        /*
         * Check I/O errors
         */
@@ -334,14 +339,19 @@ iupdat(ip, ta, tm, waitfor)
 {
        register struct buf *bp;
        struct dinode *dp;
 {
        register struct buf *bp;
        struct dinode *dp;
-       register struct fs *fp;
+       register struct fs *fs;
 
 
-       fp = ip->i_fs;
+       fs = ip->i_fs;
        if ((ip->i_flag & (IUPD|IACC|ICHG|IMOD)) != 0) {
        if ((ip->i_flag & (IUPD|IACC|ICHG|IMOD)) != 0) {
-               if (fp->fs_ronly)
+               if (fs->fs_ronly)
                        return;
                        return;
-               bp = bread(ip->i_dev, fsbtodb(fp, itod(fp, ip->i_number)),
-                       (int)fp->fs_bsize);
+#ifdef SECSIZE
+               bp = bread(ip->i_dev, fsbtodb(fs, itod(fs, ip->i_number)),
+                       (int)fs->fs_bsize, fs->fs_dbsize);
+#else SECSIZE
+               bp = bread(ip->i_dev, fsbtodb(fs, itod(fs, ip->i_number)),
+                       (int)fs->fs_bsize);
+#endif SECSIZE
                if (bp->b_flags & B_ERROR) {
                        brelse(bp);
                        return;
                if (bp->b_flags & B_ERROR) {
                        brelse(bp);
                        return;
@@ -353,7 +363,7 @@ iupdat(ip, ta, tm, waitfor)
                if (ip->i_flag&ICHG)
                        ip->i_ctime = time.tv_sec;
                ip->i_flag &= ~(IUPD|IACC|ICHG|IMOD);
                if (ip->i_flag&ICHG)
                        ip->i_ctime = time.tv_sec;
                ip->i_flag &= ~(IUPD|IACC|ICHG|IMOD);
-               dp = bp->b_un.b_dino + itoo(fp, ip->i_number);
+               dp = bp->b_un.b_dino + itoo(fs, ip->i_number);
                dp->di_ic = ip->i_ic;
                if (waitfor)
                        bwrite(bp);
                dp->di_ic = ip->i_ic;
                if (waitfor)
                        bwrite(bp);
@@ -382,13 +392,12 @@ itrunc(oip, length)
        register struct fs *fs;
        register struct inode *ip;
        struct buf *bp;
        register struct fs *fs;
        register struct inode *ip;
        struct buf *bp;
-       int offset, osize, size, count, level, s;
+       int offset, osize, size, count, level;
        long nblocks, blocksreleased = 0;
        register int i;
        dev_t dev;
        struct inode tip;
        extern long indirtrunc();
        long nblocks, blocksreleased = 0;
        register int i;
        dev_t dev;
        struct inode tip;
        extern long indirtrunc();
-       extern struct cmap *mfind();
 
        if (oip->i_size <= length) {
                oip->i_flag |= ICHG|IUPD;
 
        if (oip->i_size <= length) {
                oip->i_flag |= ICHG|IUPD;
@@ -425,13 +434,14 @@ itrunc(oip, length)
                        return;
                oip->i_size = length;
                size = blksize(fs, oip, lbn);
                        return;
                oip->i_size = length;
                size = blksize(fs, oip, lbn);
-               count = howmany(size, DEV_BSIZE);
+               count = howmany(size, CLBYTES);
                dev = oip->i_dev;
                dev = oip->i_dev;
-               s = splimp();
-               for (i = 0; i < count; i += CLSIZE)
-                       if (mfind(dev, bn + i))
-                               munhash(dev, bn + i);
-               splx(s);
+               for (i = 0; i < count; i++)
+#ifdef SECSIZE
+                       munhash(dev, bn + i * CLBYTES / fs->fs_dbsize);
+#else SECSIZE
+                       munhash(dev, bn + i * CLBYTES / DEV_BSIZE);
+#endif SECSIZE
                bp = bread(dev, bn, size);
                if (bp->b_flags & B_ERROR) {
                        u.u_error = EIO;
                bp = bread(dev, bn, size);
                if (bp->b_flags & B_ERROR) {
                        u.u_error = EIO;
@@ -586,7 +596,12 @@ indirtrunc(ip, bn, lastbn, level)
         * and update on disk copy first.
         */
        copy = geteblk((int)fs->fs_bsize);
         * and update on disk copy first.
         */
        copy = geteblk((int)fs->fs_bsize);
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
+#endif SECSIZE
        if (bp->b_flags&B_ERROR) {
                brelse(copy);
                brelse(bp);
        if (bp->b_flags&B_ERROR) {
                brelse(copy);
                brelse(bp);
@@ -627,17 +642,10 @@ indirtrunc(ip, bn, lastbn, level)
 }
 
 /*
 }
 
 /*
- * remove any inodes in the inode cache belonging to dev
+ * Remove any inodes in the inode cache belonging to dev.
  *
  * There should not be any active ones, return error if any are found
  *
  * There should not be any active ones, return error if any are found
- * (nb: this is a user error, not a system err)
- *
- * Also, count the references to dev by block devices - this really
- * has nothing to do with the object of the procedure, but as we have
- * to scan the inode table here anyway, we might as well get the
- * extra benefit.
- *
- * this is called from sumount()/sys3.c when dev is being unmounted
+ * (nb: this is a user error, not a system err).
  */
 #ifdef QUOTA
 iflush(dev, iq)
  */
 #ifdef QUOTA
 iflush(dev, iq)
@@ -649,7 +657,6 @@ iflush(dev)
 #endif
 {
        register struct inode *ip;
 #endif
 {
        register struct inode *ip;
-       register open = 0;
 
        for (ip = inode; ip < inodeNINODE; ip++) {
 #ifdef QUOTA
 
        for (ip = inode; ip < inodeNINODE; ip++) {
 #ifdef QUOTA
@@ -658,7 +665,7 @@ iflush(dev)
                if (ip->i_dev == dev)
 #endif
                        if (ip->i_count)
                if (ip->i_dev == dev)
 #endif
                        if (ip->i_count)
-                               return(-1);
+                               return (EBUSY);
                        else {
                                remque(ip);
                                ip->i_forw = ip;
                        else {
                                remque(ip);
                                ip->i_forw = ip;
@@ -677,11 +684,8 @@ iflush(dev)
                                ip->i_dquot = NODQUOT;
 #endif
                        }
                                ip->i_dquot = NODQUOT;
 #endif
                        }
-               else if (ip->i_count && (ip->i_mode&IFMT)==IFBLK &&
-                   ip->i_rdev == dev)
-                       open++;
        }
        }
-       return (open);
+       return (0);
 }
 
 /*
 }
 
 /*
index ddb724d..e2ed4f2 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.
  *
- *     @(#)ffs_subr.c  7.3 (Berkeley) %G%
+ *     @(#)ffs_subr.c  7.3.1.1 (Berkeley) %G%
  */
 
 #ifdef KERNEL
  */
 
 #ifdef KERNEL
@@ -116,10 +116,22 @@ syncip(ip)
        fs = ip->i_fs;
        lastlbn = howmany(ip->i_size, fs->fs_bsize);
        if (lastlbn < nbuf / 2) {
        fs = ip->i_fs;
        lastlbn = howmany(ip->i_size, fs->fs_bsize);
        if (lastlbn < nbuf / 2) {
+#ifdef SECSIZE
+               lastlbn--;
+               s = fsbtodb(fs, fs->fs_frag);
+               for (lbn = 0; lbn < lastlbn; lbn++) {
+                       blkno = fsbtodb(fs, bmap(ip, lbn, B_READ));
+                       blkflush(ip->i_dev, blkno, s);
+               }
+               if (lastlbn >= 0)
+                       blkflush(ip->i_dev, blkno, (int)fsbtodb(fs,
+                           blksize(fs, ip, lbn) / fs->fs_fsize));
+#else SECSIZE
                for (lbn = 0; lbn < lastlbn; lbn++) {
                        blkno = fsbtodb(fs, bmap(ip, lbn, B_READ));
                        blkflush(ip->i_dev, blkno, blksize(fs, ip, lbn));
                }
                for (lbn = 0; lbn < lastlbn; lbn++) {
                        blkno = fsbtodb(fs, bmap(ip, lbn, B_READ));
                        blkflush(ip->i_dev, blkno, blksize(fs, ip, lbn));
                }
+#endif SECSIZE
        } else {
                lastbufp = &buf[nbuf];
                for (bp = buf; bp < lastbufp; bp++) {
        } else {
                lastbufp = &buf[nbuf];
                for (bp = buf; bp < lastbufp; bp++) {
index 2ba716d..7942a36 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.
  *
- *     @(#)ffs_vfsops.c        7.2 (Berkeley) %G%
+ *     @(#)ffs_vfsops.c        7.2.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -17,6 +17,9 @@
 #include "mount.h"
 #include "file.h"
 #include "conf.h"
 #include "mount.h"
 #include "file.h"
 #include "conf.h"
+#include "ioctl.h"
+#include "disklabel.h"
+#include "stat.h"
 
 smount()
 {
 
 smount()
 {
@@ -68,25 +71,48 @@ mountfs(dev, ronly, ip)
        struct buf *tp = 0;
        register struct buf *bp = 0;
        register struct fs *fs;
        struct buf *tp = 0;
        register struct buf *bp = 0;
        register struct fs *fs;
-       int blks;
+       struct partinfo dpart;
+       int havepart = 0, blks;
        caddr_t space;
        int i, size;
        register error;
        int needclose = 0;
 
        error =
        caddr_t space;
        int i, size;
        register error;
        int needclose = 0;
 
        error =
-           (*bdevsw[major(dev)].d_open)(dev, ronly ? FREAD : FREAD|FWRITE);
+           (*bdevsw[major(dev)].d_open)(dev, ronly ? FREAD : FREAD|FWRITE,
+               S_IFBLK);
        if (error)
                goto out;
        needclose = 1;
        if (error)
                goto out;
        needclose = 1;
+#ifdef SECSIZE
+       /*
+        * If possible, determine hardware sector size
+        * and adjust fsbtodb to correspond.
+        */
+#endif SECSIZE
+       if ((*bdevsw[major(dev)].d_ioctl)(dev, DIOCGPART,
+           (caddr_t)&dpart, FREAD) == 0) {
+               havepart = 1;
+               size = dpart.disklab->d_secsize;
+#ifdef SECSIZE
+               if (size < MINSECSIZE) {
+                       error = EINVAL;
+                       goto out;
+               }
+#endif SECSIZE
+       } else
+               size = DEV_BSIZE;
+#ifdef SECSIZE
+       tp = bread(dev, (daddr_t)(SBOFF / size), SBSIZE, size);
+#else SECSIZE
        tp = bread(dev, SBLOCK, SBSIZE);
        tp = bread(dev, SBLOCK, SBSIZE);
+#endif SECSIZE
        if (tp->b_flags & B_ERROR)
                goto out;
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
                if (mp->m_bufp != 0 && dev == mp->m_dev) {
                        mp = 0;
                        error = EBUSY;
        if (tp->b_flags & B_ERROR)
                goto out;
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
                if (mp->m_bufp != 0 && dev == mp->m_dev) {
                        mp = 0;
                        error = EBUSY;
-                       needclose = 0;
                        goto out;
                }
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
                        goto out;
                }
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
@@ -99,8 +125,8 @@ found:
        mp->m_bufp = tp;        /* just to reserve this slot */
        mp->m_dev = NODEV;
        fs = tp->b_un.b_fs;
        mp->m_bufp = tp;        /* just to reserve this slot */
        mp->m_dev = NODEV;
        fs = tp->b_un.b_fs;
-       if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE
-           || fs->fs_bsize < sizeof(struct fs)) {
+       if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE ||
+           fs->fs_bsize < sizeof(struct fs)) {
                error = EINVAL;         /* also needs translation */
                goto out;
        }
                error = EINVAL;         /* also needs translation */
                goto out;
        }
@@ -114,6 +140,31 @@ found:
        fs->fs_ronly = (ronly != 0);
        if (ronly == 0)
                fs->fs_fmod = 1;
        fs->fs_ronly = (ronly != 0);
        if (ronly == 0)
                fs->fs_fmod = 1;
+#ifdef SECSIZE
+       /*
+        * If we have a disk label, force per-partition
+        * filesystem information to be correct
+        * and set correct current fsbtodb shift.
+        */
+#endif SECSIZE
+       if (havepart) {
+               dpart.part->p_fstype = FS_BSDFFS;
+               dpart.part->p_fsize = fs->fs_fsize;
+               dpart.part->p_frag = fs->fs_frag;
+#ifdef SECSIZE
+#ifdef tahoe
+               /*
+                * Save the original fsbtodb shift to restore on updates.
+                * (Console doesn't understand fsbtodb changes.)
+                */
+               fs->fs_sparecon[0] = fs->fs_fsbtodb;
+#endif
+               i = fs->fs_fsize / size;
+               for (fs->fs_fsbtodb = 0; i > 1; i >>= 1)
+                       fs->fs_fsbtodb++;
+#endif SECSIZE
+               fs->fs_dbsize = size;
+       }
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = wmemall(vmemall, (int)fs->fs_cssize);
        if (space == 0) {
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = wmemall(vmemall, (int)fs->fs_cssize);
        if (space == 0) {
@@ -124,7 +175,12 @@ found:
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
+#ifdef SECSIZE
+               tp = bread(dev, fsbtodb(fs, fs->fs_csaddr + i), size,
+                   fs->fs_dbsize);
+#else SECSIZE
                tp = bread(dev, fsbtodb(fs, fs->fs_csaddr + i), size);
                tp = bread(dev, fsbtodb(fs, fs->fs_csaddr + i), size);
+#endif SECSIZE
                if (tp->b_flags&B_ERROR) {
                        wmemfree(space, (int)fs->fs_cssize);
                        goto out;
                if (tp->b_flags&B_ERROR) {
                        wmemfree(space, (int)fs->fs_cssize);
                        goto out;
@@ -145,10 +201,14 @@ found:
        /* Sanity checks for old file systems.                     XXX */
        fs->fs_npsect = MAX(fs->fs_npsect, fs->fs_nsect);       /* XXX */
        fs->fs_interleave = MAX(fs->fs_interleave, 1);          /* XXX */
        /* Sanity checks for old file systems.                     XXX */
        fs->fs_npsect = MAX(fs->fs_npsect, fs->fs_nsect);       /* XXX */
        fs->fs_interleave = MAX(fs->fs_interleave, 1);          /* XXX */
+
        return (fs);
 out:
        if (error == 0)
                error = EIO;
        return (fs);
 out:
        if (error == 0)
                error = EIO;
+       if (needclose)
+               (void) closei((dev_t)ip->i_rdev, IFBLK,
+                   ronly? FREAD : FREAD|FWRITE);
        if (ip)
                iput(ip);
        if (mp)
        if (ip)
                iput(ip);
        if (mp)
@@ -157,10 +217,6 @@ out:
                brelse(bp);
        if (tp)
                brelse(tp);
                brelse(bp);
        if (tp)
                brelse(tp);
-       if (needclose) {
-               (*bdevsw[major(dev)].d_close)(dev, ronly? FREAD : FREAD|FWRITE);
-               binval(dev);
-       }
        u.u_error = error;
        return (0);
 }
        u.u_error = error;
        return (0);
 }
@@ -180,10 +236,11 @@ unmount1(fname, forcibly)
 {
        dev_t dev;
        register struct mount *mp;
 {
        dev_t dev;
        register struct mount *mp;
-       int stillopen, flag, error;
+       int error;
        register struct inode *ip;
        register struct fs *fs;
 
        register struct inode *ip;
        register struct fs *fs;
 
+       forcibly = 0;                                   /* XXX */
        error = getmdev(&dev, fname);
        if (error)
                return (error);
        error = getmdev(&dev, fname);
        if (error)
                return (error);
@@ -196,36 +253,30 @@ found:
        nchinval(dev);  /* flush the name cache */
        update();
 #ifdef QUOTA
        nchinval(dev);  /* flush the name cache */
        update();
 #ifdef QUOTA
-       if ((stillopen = iflush(dev, mp->m_qinod)) < 0 && !forcibly)
+       if ((error = iflush(dev, mp->m_qinod)) && !forcibly)
 #else
 #else
-       if ((stillopen = iflush(dev)) < 0 && !forcibly)
+       if ((error = iflush(dev)) && !forcibly)
 #endif
 #endif
-               return (EBUSY);
-       if (stillopen < 0)
-               return (EBUSY);                 /* XXX */
+               return (error);
 #ifdef QUOTA
        closedq(mp);
        /*
         * Here we have to iflush again to get rid of the quota inode.
 #ifdef QUOTA
        closedq(mp);
        /*
         * Here we have to iflush again to get rid of the quota inode.
-        * A drag, but it would be ugly to cheat, & this doesn't happen often
+        * A drag, but it would be ugly to cheat, & this doesn't happen often.
         */
        (void)iflush(dev, (struct inode *)NULL);
 #endif
        ip = mp->m_inodp;
        ip->i_flag &= ~IMOUNT;
         */
        (void)iflush(dev, (struct inode *)NULL);
 #endif
        ip = mp->m_inodp;
        ip->i_flag &= ~IMOUNT;
-       irele(ip);
        fs = mp->m_bufp->b_un.b_fs;
        wmemfree((caddr_t)fs->fs_csp[0], (int)fs->fs_cssize);
        fs = mp->m_bufp->b_un.b_fs;
        wmemfree((caddr_t)fs->fs_csp[0], (int)fs->fs_cssize);
-       flag = !fs->fs_ronly;
        brelse(mp->m_bufp);
        mp->m_bufp = 0;
        mp->m_dev = 0;
        mpurge(mp - &mount[0]);
        brelse(mp->m_bufp);
        mp->m_bufp = 0;
        mp->m_dev = 0;
        mpurge(mp - &mount[0]);
-       if (!stillopen) {
-               (*bdevsw[major(dev)].d_close)(dev, flag);
-               binval(dev);
-       }
-       return (0);
+       error = closei(dev, IFBLK, fs->fs_ronly? FREAD : FREAD|FWRITE);
+       irele(ip);
+       return (error);
 }
 
 sbupdate(mp)
 }
 
 sbupdate(mp)
@@ -237,8 +288,20 @@ sbupdate(mp)
        caddr_t space;
        int i, size;
 
        caddr_t space;
        int i, size;
 
+#ifdef SECSIZE
+       bp = getblk(mp->m_dev, (daddr_t)fsbtodb(fs, SBOFF / fs->fs_fsize),
+           (int)fs->fs_sbsize, fs->fs_dbsize);
+#else SECSIZE
        bp = getblk(mp->m_dev, SBLOCK, (int)fs->fs_sbsize);
        bp = getblk(mp->m_dev, SBLOCK, (int)fs->fs_sbsize);
+#endif SECSIZE
        bcopy((caddr_t)fs, bp->b_un.b_addr, (u_int)fs->fs_sbsize);
        bcopy((caddr_t)fs, bp->b_un.b_addr, (u_int)fs->fs_sbsize);
+#ifdef SECSIZE
+#ifdef tahoe
+       /* restore standard fsbtodb shift */
+       bp->b_un.b_fs->fs_fsbtodb = fs->fs_sparecon[0];
+       bp->b_un.b_fs->fs_sparecon[0] = 0;
+#endif
+#endif SECSIZE
        bwrite(bp);
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = (caddr_t)fs->fs_csp[0];
        bwrite(bp);
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = (caddr_t)fs->fs_csp[0];
@@ -246,7 +309,12 @@ sbupdate(mp)
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
+#ifdef SECSIZE
+               bp = getblk(mp->m_dev, fsbtodb(fs, fs->fs_csaddr + i), size,
+                   fs->fs_dbsize);
+#else SECSIZE
                bp = getblk(mp->m_dev, fsbtodb(fs, fs->fs_csaddr + i), size);
                bp = getblk(mp->m_dev, fsbtodb(fs, fs->fs_csaddr + i), size);
+#endif SECSIZE
                bcopy(space, bp->b_un.b_addr, (u_int)size);
                space += size;
                bwrite(bp);
                bcopy(space, bp->b_un.b_addr, (u_int)size);
                space += size;
                bwrite(bp);
index 23dfa09..c72684c 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.
  *
- *     @(#)ufs_inode.c 7.1 (Berkeley) %G%
+ *     @(#)ufs_inode.c 7.1.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -185,7 +185,12 @@ loop:
 #ifdef QUOTA
        dqrele(ip->i_dquot);
 #endif
 #ifdef QUOTA
        dqrele(ip->i_dquot);
 #endif
+#ifdef SECSIZE
+       bp = bread(dev, fsbtodb(fs, itod(fs, ino)), (int)fs->fs_bsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(dev, fsbtodb(fs, itod(fs, ino)), (int)fs->fs_bsize);
        bp = bread(dev, fsbtodb(fs, itod(fs, ino)), (int)fs->fs_bsize);
+#endif SECSIZE
        /*
         * Check I/O errors
         */
        /*
         * Check I/O errors
         */
@@ -334,14 +339,19 @@ iupdat(ip, ta, tm, waitfor)
 {
        register struct buf *bp;
        struct dinode *dp;
 {
        register struct buf *bp;
        struct dinode *dp;
-       register struct fs *fp;
+       register struct fs *fs;
 
 
-       fp = ip->i_fs;
+       fs = ip->i_fs;
        if ((ip->i_flag & (IUPD|IACC|ICHG|IMOD)) != 0) {
        if ((ip->i_flag & (IUPD|IACC|ICHG|IMOD)) != 0) {
-               if (fp->fs_ronly)
+               if (fs->fs_ronly)
                        return;
                        return;
-               bp = bread(ip->i_dev, fsbtodb(fp, itod(fp, ip->i_number)),
-                       (int)fp->fs_bsize);
+#ifdef SECSIZE
+               bp = bread(ip->i_dev, fsbtodb(fs, itod(fs, ip->i_number)),
+                       (int)fs->fs_bsize, fs->fs_dbsize);
+#else SECSIZE
+               bp = bread(ip->i_dev, fsbtodb(fs, itod(fs, ip->i_number)),
+                       (int)fs->fs_bsize);
+#endif SECSIZE
                if (bp->b_flags & B_ERROR) {
                        brelse(bp);
                        return;
                if (bp->b_flags & B_ERROR) {
                        brelse(bp);
                        return;
@@ -353,7 +363,7 @@ iupdat(ip, ta, tm, waitfor)
                if (ip->i_flag&ICHG)
                        ip->i_ctime = time.tv_sec;
                ip->i_flag &= ~(IUPD|IACC|ICHG|IMOD);
                if (ip->i_flag&ICHG)
                        ip->i_ctime = time.tv_sec;
                ip->i_flag &= ~(IUPD|IACC|ICHG|IMOD);
-               dp = bp->b_un.b_dino + itoo(fp, ip->i_number);
+               dp = bp->b_un.b_dino + itoo(fs, ip->i_number);
                dp->di_ic = ip->i_ic;
                if (waitfor)
                        bwrite(bp);
                dp->di_ic = ip->i_ic;
                if (waitfor)
                        bwrite(bp);
@@ -382,13 +392,12 @@ itrunc(oip, length)
        register struct fs *fs;
        register struct inode *ip;
        struct buf *bp;
        register struct fs *fs;
        register struct inode *ip;
        struct buf *bp;
-       int offset, osize, size, count, level, s;
+       int offset, osize, size, count, level;
        long nblocks, blocksreleased = 0;
        register int i;
        dev_t dev;
        struct inode tip;
        extern long indirtrunc();
        long nblocks, blocksreleased = 0;
        register int i;
        dev_t dev;
        struct inode tip;
        extern long indirtrunc();
-       extern struct cmap *mfind();
 
        if (oip->i_size <= length) {
                oip->i_flag |= ICHG|IUPD;
 
        if (oip->i_size <= length) {
                oip->i_flag |= ICHG|IUPD;
@@ -425,13 +434,14 @@ itrunc(oip, length)
                        return;
                oip->i_size = length;
                size = blksize(fs, oip, lbn);
                        return;
                oip->i_size = length;
                size = blksize(fs, oip, lbn);
-               count = howmany(size, DEV_BSIZE);
+               count = howmany(size, CLBYTES);
                dev = oip->i_dev;
                dev = oip->i_dev;
-               s = splimp();
-               for (i = 0; i < count; i += CLSIZE)
-                       if (mfind(dev, bn + i))
-                               munhash(dev, bn + i);
-               splx(s);
+               for (i = 0; i < count; i++)
+#ifdef SECSIZE
+                       munhash(dev, bn + i * CLBYTES / fs->fs_dbsize);
+#else SECSIZE
+                       munhash(dev, bn + i * CLBYTES / DEV_BSIZE);
+#endif SECSIZE
                bp = bread(dev, bn, size);
                if (bp->b_flags & B_ERROR) {
                        u.u_error = EIO;
                bp = bread(dev, bn, size);
                if (bp->b_flags & B_ERROR) {
                        u.u_error = EIO;
@@ -586,7 +596,12 @@ indirtrunc(ip, bn, lastbn, level)
         * and update on disk copy first.
         */
        copy = geteblk((int)fs->fs_bsize);
         * and update on disk copy first.
         */
        copy = geteblk((int)fs->fs_bsize);
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
+#endif SECSIZE
        if (bp->b_flags&B_ERROR) {
                brelse(copy);
                brelse(bp);
        if (bp->b_flags&B_ERROR) {
                brelse(copy);
                brelse(bp);
@@ -627,17 +642,10 @@ indirtrunc(ip, bn, lastbn, level)
 }
 
 /*
 }
 
 /*
- * remove any inodes in the inode cache belonging to dev
+ * Remove any inodes in the inode cache belonging to dev.
  *
  * There should not be any active ones, return error if any are found
  *
  * There should not be any active ones, return error if any are found
- * (nb: this is a user error, not a system err)
- *
- * Also, count the references to dev by block devices - this really
- * has nothing to do with the object of the procedure, but as we have
- * to scan the inode table here anyway, we might as well get the
- * extra benefit.
- *
- * this is called from sumount()/sys3.c when dev is being unmounted
+ * (nb: this is a user error, not a system err).
  */
 #ifdef QUOTA
 iflush(dev, iq)
  */
 #ifdef QUOTA
 iflush(dev, iq)
@@ -649,7 +657,6 @@ iflush(dev)
 #endif
 {
        register struct inode *ip;
 #endif
 {
        register struct inode *ip;
-       register open = 0;
 
        for (ip = inode; ip < inodeNINODE; ip++) {
 #ifdef QUOTA
 
        for (ip = inode; ip < inodeNINODE; ip++) {
 #ifdef QUOTA
@@ -658,7 +665,7 @@ iflush(dev)
                if (ip->i_dev == dev)
 #endif
                        if (ip->i_count)
                if (ip->i_dev == dev)
 #endif
                        if (ip->i_count)
-                               return(-1);
+                               return (EBUSY);
                        else {
                                remque(ip);
                                ip->i_forw = ip;
                        else {
                                remque(ip);
                                ip->i_forw = ip;
@@ -677,11 +684,8 @@ iflush(dev)
                                ip->i_dquot = NODQUOT;
 #endif
                        }
                                ip->i_dquot = NODQUOT;
 #endif
                        }
-               else if (ip->i_count && (ip->i_mode&IFMT)==IFBLK &&
-                   ip->i_rdev == dev)
-                       open++;
        }
        }
-       return (open);
+       return (0);
 }
 
 /*
 }
 
 /*
index 04eb5fb..9a2f656 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.
  *
- *     @(#)ufs_lookup.c        7.1 (Berkeley) %G%
+ *     @(#)ufs_lookup.c        7.1.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -1060,7 +1060,11 @@ blkatoff(ip, offset, res)
                dirbad(ip, offset, "hole in dir");
                return (0);
        }
                dirbad(ip, offset, "hole in dir");
                return (0);
        }
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, bn), bsize, fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), bsize);
        bp = bread(ip->i_dev, fsbtodb(fs, bn), bsize);
+#endif SECSIZE
        if (bp->b_flags & B_ERROR) {
                brelse(bp);
                return (0);
        if (bp->b_flags & B_ERROR) {
                brelse(bp);
                return (0);
index f1a9c5e..fc3de6d 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.
  *
- *     @(#)ufs_vfsops.c        7.2 (Berkeley) %G%
+ *     @(#)ufs_vfsops.c        7.2.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -17,6 +17,9 @@
 #include "mount.h"
 #include "file.h"
 #include "conf.h"
 #include "mount.h"
 #include "file.h"
 #include "conf.h"
+#include "ioctl.h"
+#include "disklabel.h"
+#include "stat.h"
 
 smount()
 {
 
 smount()
 {
@@ -68,25 +71,48 @@ mountfs(dev, ronly, ip)
        struct buf *tp = 0;
        register struct buf *bp = 0;
        register struct fs *fs;
        struct buf *tp = 0;
        register struct buf *bp = 0;
        register struct fs *fs;
-       int blks;
+       struct partinfo dpart;
+       int havepart = 0, blks;
        caddr_t space;
        int i, size;
        register error;
        int needclose = 0;
 
        error =
        caddr_t space;
        int i, size;
        register error;
        int needclose = 0;
 
        error =
-           (*bdevsw[major(dev)].d_open)(dev, ronly ? FREAD : FREAD|FWRITE);
+           (*bdevsw[major(dev)].d_open)(dev, ronly ? FREAD : FREAD|FWRITE,
+               S_IFBLK);
        if (error)
                goto out;
        needclose = 1;
        if (error)
                goto out;
        needclose = 1;
+#ifdef SECSIZE
+       /*
+        * If possible, determine hardware sector size
+        * and adjust fsbtodb to correspond.
+        */
+#endif SECSIZE
+       if ((*bdevsw[major(dev)].d_ioctl)(dev, DIOCGPART,
+           (caddr_t)&dpart, FREAD) == 0) {
+               havepart = 1;
+               size = dpart.disklab->d_secsize;
+#ifdef SECSIZE
+               if (size < MINSECSIZE) {
+                       error = EINVAL;
+                       goto out;
+               }
+#endif SECSIZE
+       } else
+               size = DEV_BSIZE;
+#ifdef SECSIZE
+       tp = bread(dev, (daddr_t)(SBOFF / size), SBSIZE, size);
+#else SECSIZE
        tp = bread(dev, SBLOCK, SBSIZE);
        tp = bread(dev, SBLOCK, SBSIZE);
+#endif SECSIZE
        if (tp->b_flags & B_ERROR)
                goto out;
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
                if (mp->m_bufp != 0 && dev == mp->m_dev) {
                        mp = 0;
                        error = EBUSY;
        if (tp->b_flags & B_ERROR)
                goto out;
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
                if (mp->m_bufp != 0 && dev == mp->m_dev) {
                        mp = 0;
                        error = EBUSY;
-                       needclose = 0;
                        goto out;
                }
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
                        goto out;
                }
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
@@ -99,8 +125,8 @@ found:
        mp->m_bufp = tp;        /* just to reserve this slot */
        mp->m_dev = NODEV;
        fs = tp->b_un.b_fs;
        mp->m_bufp = tp;        /* just to reserve this slot */
        mp->m_dev = NODEV;
        fs = tp->b_un.b_fs;
-       if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE
-           || fs->fs_bsize < sizeof(struct fs)) {
+       if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE ||
+           fs->fs_bsize < sizeof(struct fs)) {
                error = EINVAL;         /* also needs translation */
                goto out;
        }
                error = EINVAL;         /* also needs translation */
                goto out;
        }
@@ -114,6 +140,31 @@ found:
        fs->fs_ronly = (ronly != 0);
        if (ronly == 0)
                fs->fs_fmod = 1;
        fs->fs_ronly = (ronly != 0);
        if (ronly == 0)
                fs->fs_fmod = 1;
+#ifdef SECSIZE
+       /*
+        * If we have a disk label, force per-partition
+        * filesystem information to be correct
+        * and set correct current fsbtodb shift.
+        */
+#endif SECSIZE
+       if (havepart) {
+               dpart.part->p_fstype = FS_BSDFFS;
+               dpart.part->p_fsize = fs->fs_fsize;
+               dpart.part->p_frag = fs->fs_frag;
+#ifdef SECSIZE
+#ifdef tahoe
+               /*
+                * Save the original fsbtodb shift to restore on updates.
+                * (Console doesn't understand fsbtodb changes.)
+                */
+               fs->fs_sparecon[0] = fs->fs_fsbtodb;
+#endif
+               i = fs->fs_fsize / size;
+               for (fs->fs_fsbtodb = 0; i > 1; i >>= 1)
+                       fs->fs_fsbtodb++;
+#endif SECSIZE
+               fs->fs_dbsize = size;
+       }
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = wmemall(vmemall, (int)fs->fs_cssize);
        if (space == 0) {
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = wmemall(vmemall, (int)fs->fs_cssize);
        if (space == 0) {
@@ -124,7 +175,12 @@ found:
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
+#ifdef SECSIZE
+               tp = bread(dev, fsbtodb(fs, fs->fs_csaddr + i), size,
+                   fs->fs_dbsize);
+#else SECSIZE
                tp = bread(dev, fsbtodb(fs, fs->fs_csaddr + i), size);
                tp = bread(dev, fsbtodb(fs, fs->fs_csaddr + i), size);
+#endif SECSIZE
                if (tp->b_flags&B_ERROR) {
                        wmemfree(space, (int)fs->fs_cssize);
                        goto out;
                if (tp->b_flags&B_ERROR) {
                        wmemfree(space, (int)fs->fs_cssize);
                        goto out;
@@ -145,10 +201,14 @@ found:
        /* Sanity checks for old file systems.                     XXX */
        fs->fs_npsect = MAX(fs->fs_npsect, fs->fs_nsect);       /* XXX */
        fs->fs_interleave = MAX(fs->fs_interleave, 1);          /* XXX */
        /* Sanity checks for old file systems.                     XXX */
        fs->fs_npsect = MAX(fs->fs_npsect, fs->fs_nsect);       /* XXX */
        fs->fs_interleave = MAX(fs->fs_interleave, 1);          /* XXX */
+
        return (fs);
 out:
        if (error == 0)
                error = EIO;
        return (fs);
 out:
        if (error == 0)
                error = EIO;
+       if (needclose)
+               (void) closei((dev_t)ip->i_rdev, IFBLK,
+                   ronly? FREAD : FREAD|FWRITE);
        if (ip)
                iput(ip);
        if (mp)
        if (ip)
                iput(ip);
        if (mp)
@@ -157,10 +217,6 @@ out:
                brelse(bp);
        if (tp)
                brelse(tp);
                brelse(bp);
        if (tp)
                brelse(tp);
-       if (needclose) {
-               (*bdevsw[major(dev)].d_close)(dev, ronly? FREAD : FREAD|FWRITE);
-               binval(dev);
-       }
        u.u_error = error;
        return (0);
 }
        u.u_error = error;
        return (0);
 }
@@ -180,10 +236,11 @@ unmount1(fname, forcibly)
 {
        dev_t dev;
        register struct mount *mp;
 {
        dev_t dev;
        register struct mount *mp;
-       int stillopen, flag, error;
+       int error;
        register struct inode *ip;
        register struct fs *fs;
 
        register struct inode *ip;
        register struct fs *fs;
 
+       forcibly = 0;                                   /* XXX */
        error = getmdev(&dev, fname);
        if (error)
                return (error);
        error = getmdev(&dev, fname);
        if (error)
                return (error);
@@ -196,36 +253,30 @@ found:
        nchinval(dev);  /* flush the name cache */
        update();
 #ifdef QUOTA
        nchinval(dev);  /* flush the name cache */
        update();
 #ifdef QUOTA
-       if ((stillopen = iflush(dev, mp->m_qinod)) < 0 && !forcibly)
+       if ((error = iflush(dev, mp->m_qinod)) && !forcibly)
 #else
 #else
-       if ((stillopen = iflush(dev)) < 0 && !forcibly)
+       if ((error = iflush(dev)) && !forcibly)
 #endif
 #endif
-               return (EBUSY);
-       if (stillopen < 0)
-               return (EBUSY);                 /* XXX */
+               return (error);
 #ifdef QUOTA
        closedq(mp);
        /*
         * Here we have to iflush again to get rid of the quota inode.
 #ifdef QUOTA
        closedq(mp);
        /*
         * Here we have to iflush again to get rid of the quota inode.
-        * A drag, but it would be ugly to cheat, & this doesn't happen often
+        * A drag, but it would be ugly to cheat, & this doesn't happen often.
         */
        (void)iflush(dev, (struct inode *)NULL);
 #endif
        ip = mp->m_inodp;
        ip->i_flag &= ~IMOUNT;
         */
        (void)iflush(dev, (struct inode *)NULL);
 #endif
        ip = mp->m_inodp;
        ip->i_flag &= ~IMOUNT;
-       irele(ip);
        fs = mp->m_bufp->b_un.b_fs;
        wmemfree((caddr_t)fs->fs_csp[0], (int)fs->fs_cssize);
        fs = mp->m_bufp->b_un.b_fs;
        wmemfree((caddr_t)fs->fs_csp[0], (int)fs->fs_cssize);
-       flag = !fs->fs_ronly;
        brelse(mp->m_bufp);
        mp->m_bufp = 0;
        mp->m_dev = 0;
        mpurge(mp - &mount[0]);
        brelse(mp->m_bufp);
        mp->m_bufp = 0;
        mp->m_dev = 0;
        mpurge(mp - &mount[0]);
-       if (!stillopen) {
-               (*bdevsw[major(dev)].d_close)(dev, flag);
-               binval(dev);
-       }
-       return (0);
+       error = closei(dev, IFBLK, fs->fs_ronly? FREAD : FREAD|FWRITE);
+       irele(ip);
+       return (error);
 }
 
 sbupdate(mp)
 }
 
 sbupdate(mp)
@@ -237,8 +288,20 @@ sbupdate(mp)
        caddr_t space;
        int i, size;
 
        caddr_t space;
        int i, size;
 
+#ifdef SECSIZE
+       bp = getblk(mp->m_dev, (daddr_t)fsbtodb(fs, SBOFF / fs->fs_fsize),
+           (int)fs->fs_sbsize, fs->fs_dbsize);
+#else SECSIZE
        bp = getblk(mp->m_dev, SBLOCK, (int)fs->fs_sbsize);
        bp = getblk(mp->m_dev, SBLOCK, (int)fs->fs_sbsize);
+#endif SECSIZE
        bcopy((caddr_t)fs, bp->b_un.b_addr, (u_int)fs->fs_sbsize);
        bcopy((caddr_t)fs, bp->b_un.b_addr, (u_int)fs->fs_sbsize);
+#ifdef SECSIZE
+#ifdef tahoe
+       /* restore standard fsbtodb shift */
+       bp->b_un.b_fs->fs_fsbtodb = fs->fs_sparecon[0];
+       bp->b_un.b_fs->fs_sparecon[0] = 0;
+#endif
+#endif SECSIZE
        bwrite(bp);
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = (caddr_t)fs->fs_csp[0];
        bwrite(bp);
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = (caddr_t)fs->fs_csp[0];
@@ -246,7 +309,12 @@ sbupdate(mp)
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
+#ifdef SECSIZE
+               bp = getblk(mp->m_dev, fsbtodb(fs, fs->fs_csaddr + i), size,
+                   fs->fs_dbsize);
+#else SECSIZE
                bp = getblk(mp->m_dev, fsbtodb(fs, fs->fs_csaddr + i), size);
                bp = getblk(mp->m_dev, fsbtodb(fs, fs->fs_csaddr + i), size);
+#endif SECSIZE
                bcopy(space, bp->b_un.b_addr, (u_int)size);
                space += size;
                bwrite(bp);
                bcopy(space, bp->b_un.b_addr, (u_int)size);
                space += size;
                bwrite(bp);
index 753d21a..98712a8 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.
  *
- *     @(#)lfs_alloc.c 7.1 (Berkeley) %G%
+ *     @(#)lfs_alloc.c 7.1.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -86,7 +86,11 @@ alloc(ip, bpref, size)
                goto nospace;
        ip->i_blocks += btodb(size);
        ip->i_flag |= IUPD|ICHG;
                goto nospace;
        ip->i_blocks += btodb(size);
        ip->i_flag |= IUPD|ICHG;
+#ifdef SECSIZE
+       bp = getblk(ip->i_dev, fsbtodb(fs, bno), size, fs->fs_dbsize);
+#else SECSIZE
        bp = getblk(ip->i_dev, fsbtodb(fs, bno), size);
        bp = getblk(ip->i_dev, fsbtodb(fs, bno), size);
+#endif SECSIZE
        clrbuf(bp);
        return (bp);
 nospace:
        clrbuf(bp);
        return (bp);
 nospace:
@@ -140,7 +144,12 @@ realloccg(ip, bprev, bpref, osize, nsize)
        bno = fragextend(ip, cg, (long)bprev, osize, nsize);
        if (bno != 0) {
                do {
        bno = fragextend(ip, cg, (long)bprev, osize, nsize);
        if (bno != 0) {
                do {
+#ifdef SECSIZE
+                       bp = bread(ip->i_dev, fsbtodb(fs, bno), osize,
+                           fs->fs_dbsize);
+#else SECSIZE
                        bp = bread(ip->i_dev, fsbtodb(fs, bno), osize);
                        bp = bread(ip->i_dev, fsbtodb(fs, bno), osize);
+#endif SECSIZE
                        if (bp->b_flags & B_ERROR) {
                                brelse(bp);
                                return (NULL);
                        if (bp->b_flags & B_ERROR) {
                                brelse(bp);
                                return (NULL);
@@ -200,20 +209,30 @@ realloccg(ip, bprev, bpref, osize, nsize)
        bno = (daddr_t)hashalloc(ip, cg, (long)bpref, request,
                (u_long (*)())alloccg);
        if (bno > 0) {
        bno = (daddr_t)hashalloc(ip, cg, (long)bpref, request,
                (u_long (*)())alloccg);
        if (bno > 0) {
+#ifdef SECSIZE
+               obp = bread(ip->i_dev, fsbtodb(fs, bprev), osize,
+                   fs->fs_dbsize);
+#else SECSIZE
                obp = bread(ip->i_dev, fsbtodb(fs, bprev), osize);
                obp = bread(ip->i_dev, fsbtodb(fs, bprev), osize);
+#endif SECSIZE
                if (obp->b_flags & B_ERROR) {
                        brelse(obp);
                        return (NULL);
                }
                bn = fsbtodb(fs, bno);
                if (obp->b_flags & B_ERROR) {
                        brelse(obp);
                        return (NULL);
                }
                bn = fsbtodb(fs, bno);
+#ifdef SECSIZE
+               bp = getblk(ip->i_dev, bn, nsize, fs->fs_dbsize);
+#else SECSIZE
                bp = getblk(ip->i_dev, bn, nsize);
                bp = getblk(ip->i_dev, bn, nsize);
+#endif SECSIZE
                bcopy(obp->b_un.b_addr, bp->b_un.b_addr, (u_int)osize);
                bcopy(obp->b_un.b_addr, bp->b_un.b_addr, (u_int)osize);
-               count = howmany(osize, DEV_BSIZE);
-               s = splimp();
-               for (i = 0; i < count; i += CLBYTES / DEV_BSIZE)
-                       if (mfind(ip->i_dev, bn + i))
-                               munhash(ip->i_dev, bn + i);
-               splx(s);
+               count = howmany(osize, CLBYTES);
+               for (i = 0; i < count; i++)
+#ifdef SECSIZE
+                       munhash(ip->i_dev, bn + i * CLBYTES / fs->fs_dbsize);
+#else SECSIZE
+                       munhash(ip->i_dev, bn + i * CLBYTES / DEV_BSIZE);
+#endif SECSIZE
                bzero(bp->b_un.b_addr + osize, (unsigned)nsize - osize);
                if (obp->b_flags & B_DELWRI) {
                        obp->b_flags &= ~B_DELWRI;
                bzero(bp->b_un.b_addr + osize, (unsigned)nsize - osize);
                if (obp->b_flags & B_DELWRI) {
                        obp->b_flags &= ~B_DELWRI;
@@ -497,10 +516,15 @@ fragextend(ip, cg, bprev, osize, nsize)
        frags = numfrags(fs, nsize);
        bbase = fragnum(fs, bprev);
        if (bbase > fragnum(fs, (bprev + frags - 1))) {
        frags = numfrags(fs, nsize);
        bbase = fragnum(fs, bprev);
        if (bbase > fragnum(fs, (bprev + frags - 1))) {
-               /* cannot extend across a block boundry */
+               /* cannot extend across a block boundary */
                return (NULL);
        }
                return (NULL);
        }
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
@@ -559,7 +583,12 @@ alloccg(ip, cg, bpref, size)
        fs = ip->i_fs;
        if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize)
                return (NULL);
        fs = ip->i_fs;
        if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize)
                return (NULL);
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC ||
            (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) {
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC ||
            (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) {
@@ -754,7 +783,12 @@ ialloccg(ip, cg, ipref, mode)
        fs = ip->i_fs;
        if (fs->fs_cs(fs, cg).cs_nifree == 0)
                return (NULL);
        fs = ip->i_fs;
        if (fs->fs_cs(fs, cg).cs_nifree == 0)
                return (NULL);
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC ||
            cgp->cg_cs.cs_nifree == 0) {
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC ||
            cgp->cg_cs.cs_nifree == 0) {
@@ -837,7 +871,12 @@ free(ip, bno, size)
                printf("bad block %d, ino %d\n", bno, ip->i_number);
                return;
        }
                printf("bad block %d, ino %d\n", bno, ip->i_number);
                return;
        }
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
@@ -926,7 +965,12 @@ ifree(ip, ino, mode)
                panic("ifree: range");
        }
        cg = itog(fs, ino);
                panic("ifree: range");
        }
        cg = itog(fs, ino);
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
index a92b727..48870ad 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.
  *
- *     @(#)lfs_balloc.c        7.1 (Berkeley) %G%
+ *     @(#)lfs_balloc.c        7.1.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -161,7 +161,12 @@ gotit:
         * fetch through the indirect blocks
         */
        for (; j <= NIADDR; j++) {
         * fetch through the indirect blocks
         */
        for (; j <= NIADDR; j++) {
+#ifdef SECSIZE
+               bp = bread(ip->i_dev, fsbtodb(fs, nb), (int)fs->fs_bsize,
+                   fs->fs_dbsize);
+#else SECSIZE
                bp = bread(ip->i_dev, fsbtodb(fs, nb), (int)fs->fs_bsize);
                bp = bread(ip->i_dev, fsbtodb(fs, nb), (int)fs->fs_bsize);
+#endif SECSIZE
                if (bp->b_flags & B_ERROR) {
                        brelse(bp);
                        return ((daddr_t)0);
                if (bp->b_flags & B_ERROR) {
                        brelse(bp);
                        return ((daddr_t)0);
index 3b96a16..998c3a1 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.
  *
- *     @(#)lfs_inode.c 7.1 (Berkeley) %G%
+ *     @(#)lfs_inode.c 7.1.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -185,7 +185,12 @@ loop:
 #ifdef QUOTA
        dqrele(ip->i_dquot);
 #endif
 #ifdef QUOTA
        dqrele(ip->i_dquot);
 #endif
+#ifdef SECSIZE
+       bp = bread(dev, fsbtodb(fs, itod(fs, ino)), (int)fs->fs_bsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(dev, fsbtodb(fs, itod(fs, ino)), (int)fs->fs_bsize);
        bp = bread(dev, fsbtodb(fs, itod(fs, ino)), (int)fs->fs_bsize);
+#endif SECSIZE
        /*
         * Check I/O errors
         */
        /*
         * Check I/O errors
         */
@@ -334,14 +339,19 @@ iupdat(ip, ta, tm, waitfor)
 {
        register struct buf *bp;
        struct dinode *dp;
 {
        register struct buf *bp;
        struct dinode *dp;
-       register struct fs *fp;
+       register struct fs *fs;
 
 
-       fp = ip->i_fs;
+       fs = ip->i_fs;
        if ((ip->i_flag & (IUPD|IACC|ICHG|IMOD)) != 0) {
        if ((ip->i_flag & (IUPD|IACC|ICHG|IMOD)) != 0) {
-               if (fp->fs_ronly)
+               if (fs->fs_ronly)
                        return;
                        return;
-               bp = bread(ip->i_dev, fsbtodb(fp, itod(fp, ip->i_number)),
-                       (int)fp->fs_bsize);
+#ifdef SECSIZE
+               bp = bread(ip->i_dev, fsbtodb(fs, itod(fs, ip->i_number)),
+                       (int)fs->fs_bsize, fs->fs_dbsize);
+#else SECSIZE
+               bp = bread(ip->i_dev, fsbtodb(fs, itod(fs, ip->i_number)),
+                       (int)fs->fs_bsize);
+#endif SECSIZE
                if (bp->b_flags & B_ERROR) {
                        brelse(bp);
                        return;
                if (bp->b_flags & B_ERROR) {
                        brelse(bp);
                        return;
@@ -353,7 +363,7 @@ iupdat(ip, ta, tm, waitfor)
                if (ip->i_flag&ICHG)
                        ip->i_ctime = time.tv_sec;
                ip->i_flag &= ~(IUPD|IACC|ICHG|IMOD);
                if (ip->i_flag&ICHG)
                        ip->i_ctime = time.tv_sec;
                ip->i_flag &= ~(IUPD|IACC|ICHG|IMOD);
-               dp = bp->b_un.b_dino + itoo(fp, ip->i_number);
+               dp = bp->b_un.b_dino + itoo(fs, ip->i_number);
                dp->di_ic = ip->i_ic;
                if (waitfor)
                        bwrite(bp);
                dp->di_ic = ip->i_ic;
                if (waitfor)
                        bwrite(bp);
@@ -382,13 +392,12 @@ itrunc(oip, length)
        register struct fs *fs;
        register struct inode *ip;
        struct buf *bp;
        register struct fs *fs;
        register struct inode *ip;
        struct buf *bp;
-       int offset, osize, size, count, level, s;
+       int offset, osize, size, count, level;
        long nblocks, blocksreleased = 0;
        register int i;
        dev_t dev;
        struct inode tip;
        extern long indirtrunc();
        long nblocks, blocksreleased = 0;
        register int i;
        dev_t dev;
        struct inode tip;
        extern long indirtrunc();
-       extern struct cmap *mfind();
 
        if (oip->i_size <= length) {
                oip->i_flag |= ICHG|IUPD;
 
        if (oip->i_size <= length) {
                oip->i_flag |= ICHG|IUPD;
@@ -425,13 +434,14 @@ itrunc(oip, length)
                        return;
                oip->i_size = length;
                size = blksize(fs, oip, lbn);
                        return;
                oip->i_size = length;
                size = blksize(fs, oip, lbn);
-               count = howmany(size, DEV_BSIZE);
+               count = howmany(size, CLBYTES);
                dev = oip->i_dev;
                dev = oip->i_dev;
-               s = splimp();
-               for (i = 0; i < count; i += CLSIZE)
-                       if (mfind(dev, bn + i))
-                               munhash(dev, bn + i);
-               splx(s);
+               for (i = 0; i < count; i++)
+#ifdef SECSIZE
+                       munhash(dev, bn + i * CLBYTES / fs->fs_dbsize);
+#else SECSIZE
+                       munhash(dev, bn + i * CLBYTES / DEV_BSIZE);
+#endif SECSIZE
                bp = bread(dev, bn, size);
                if (bp->b_flags & B_ERROR) {
                        u.u_error = EIO;
                bp = bread(dev, bn, size);
                if (bp->b_flags & B_ERROR) {
                        u.u_error = EIO;
@@ -586,7 +596,12 @@ indirtrunc(ip, bn, lastbn, level)
         * and update on disk copy first.
         */
        copy = geteblk((int)fs->fs_bsize);
         * and update on disk copy first.
         */
        copy = geteblk((int)fs->fs_bsize);
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
+#endif SECSIZE
        if (bp->b_flags&B_ERROR) {
                brelse(copy);
                brelse(bp);
        if (bp->b_flags&B_ERROR) {
                brelse(copy);
                brelse(bp);
@@ -627,17 +642,10 @@ indirtrunc(ip, bn, lastbn, level)
 }
 
 /*
 }
 
 /*
- * remove any inodes in the inode cache belonging to dev
+ * Remove any inodes in the inode cache belonging to dev.
  *
  * There should not be any active ones, return error if any are found
  *
  * There should not be any active ones, return error if any are found
- * (nb: this is a user error, not a system err)
- *
- * Also, count the references to dev by block devices - this really
- * has nothing to do with the object of the procedure, but as we have
- * to scan the inode table here anyway, we might as well get the
- * extra benefit.
- *
- * this is called from sumount()/sys3.c when dev is being unmounted
+ * (nb: this is a user error, not a system err).
  */
 #ifdef QUOTA
 iflush(dev, iq)
  */
 #ifdef QUOTA
 iflush(dev, iq)
@@ -649,7 +657,6 @@ iflush(dev)
 #endif
 {
        register struct inode *ip;
 #endif
 {
        register struct inode *ip;
-       register open = 0;
 
        for (ip = inode; ip < inodeNINODE; ip++) {
 #ifdef QUOTA
 
        for (ip = inode; ip < inodeNINODE; ip++) {
 #ifdef QUOTA
@@ -658,7 +665,7 @@ iflush(dev)
                if (ip->i_dev == dev)
 #endif
                        if (ip->i_count)
                if (ip->i_dev == dev)
 #endif
                        if (ip->i_count)
-                               return(-1);
+                               return (EBUSY);
                        else {
                                remque(ip);
                                ip->i_forw = ip;
                        else {
                                remque(ip);
                                ip->i_forw = ip;
@@ -677,11 +684,8 @@ iflush(dev)
                                ip->i_dquot = NODQUOT;
 #endif
                        }
                                ip->i_dquot = NODQUOT;
 #endif
                        }
-               else if (ip->i_count && (ip->i_mode&IFMT)==IFBLK &&
-                   ip->i_rdev == dev)
-                       open++;
        }
        }
-       return (open);
+       return (0);
 }
 
 /*
 }
 
 /*
index 10ac271..0628f9e 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.
  *
- *     @(#)lfs_vfsops.c        7.2 (Berkeley) %G%
+ *     @(#)lfs_vfsops.c        7.2.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -17,6 +17,9 @@
 #include "mount.h"
 #include "file.h"
 #include "conf.h"
 #include "mount.h"
 #include "file.h"
 #include "conf.h"
+#include "ioctl.h"
+#include "disklabel.h"
+#include "stat.h"
 
 smount()
 {
 
 smount()
 {
@@ -68,25 +71,48 @@ mountfs(dev, ronly, ip)
        struct buf *tp = 0;
        register struct buf *bp = 0;
        register struct fs *fs;
        struct buf *tp = 0;
        register struct buf *bp = 0;
        register struct fs *fs;
-       int blks;
+       struct partinfo dpart;
+       int havepart = 0, blks;
        caddr_t space;
        int i, size;
        register error;
        int needclose = 0;
 
        error =
        caddr_t space;
        int i, size;
        register error;
        int needclose = 0;
 
        error =
-           (*bdevsw[major(dev)].d_open)(dev, ronly ? FREAD : FREAD|FWRITE);
+           (*bdevsw[major(dev)].d_open)(dev, ronly ? FREAD : FREAD|FWRITE,
+               S_IFBLK);
        if (error)
                goto out;
        needclose = 1;
        if (error)
                goto out;
        needclose = 1;
+#ifdef SECSIZE
+       /*
+        * If possible, determine hardware sector size
+        * and adjust fsbtodb to correspond.
+        */
+#endif SECSIZE
+       if ((*bdevsw[major(dev)].d_ioctl)(dev, DIOCGPART,
+           (caddr_t)&dpart, FREAD) == 0) {
+               havepart = 1;
+               size = dpart.disklab->d_secsize;
+#ifdef SECSIZE
+               if (size < MINSECSIZE) {
+                       error = EINVAL;
+                       goto out;
+               }
+#endif SECSIZE
+       } else
+               size = DEV_BSIZE;
+#ifdef SECSIZE
+       tp = bread(dev, (daddr_t)(SBOFF / size), SBSIZE, size);
+#else SECSIZE
        tp = bread(dev, SBLOCK, SBSIZE);
        tp = bread(dev, SBLOCK, SBSIZE);
+#endif SECSIZE
        if (tp->b_flags & B_ERROR)
                goto out;
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
                if (mp->m_bufp != 0 && dev == mp->m_dev) {
                        mp = 0;
                        error = EBUSY;
        if (tp->b_flags & B_ERROR)
                goto out;
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
                if (mp->m_bufp != 0 && dev == mp->m_dev) {
                        mp = 0;
                        error = EBUSY;
-                       needclose = 0;
                        goto out;
                }
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
                        goto out;
                }
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
@@ -99,8 +125,8 @@ found:
        mp->m_bufp = tp;        /* just to reserve this slot */
        mp->m_dev = NODEV;
        fs = tp->b_un.b_fs;
        mp->m_bufp = tp;        /* just to reserve this slot */
        mp->m_dev = NODEV;
        fs = tp->b_un.b_fs;
-       if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE
-           || fs->fs_bsize < sizeof(struct fs)) {
+       if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE ||
+           fs->fs_bsize < sizeof(struct fs)) {
                error = EINVAL;         /* also needs translation */
                goto out;
        }
                error = EINVAL;         /* also needs translation */
                goto out;
        }
@@ -114,6 +140,31 @@ found:
        fs->fs_ronly = (ronly != 0);
        if (ronly == 0)
                fs->fs_fmod = 1;
        fs->fs_ronly = (ronly != 0);
        if (ronly == 0)
                fs->fs_fmod = 1;
+#ifdef SECSIZE
+       /*
+        * If we have a disk label, force per-partition
+        * filesystem information to be correct
+        * and set correct current fsbtodb shift.
+        */
+#endif SECSIZE
+       if (havepart) {
+               dpart.part->p_fstype = FS_BSDFFS;
+               dpart.part->p_fsize = fs->fs_fsize;
+               dpart.part->p_frag = fs->fs_frag;
+#ifdef SECSIZE
+#ifdef tahoe
+               /*
+                * Save the original fsbtodb shift to restore on updates.
+                * (Console doesn't understand fsbtodb changes.)
+                */
+               fs->fs_sparecon[0] = fs->fs_fsbtodb;
+#endif
+               i = fs->fs_fsize / size;
+               for (fs->fs_fsbtodb = 0; i > 1; i >>= 1)
+                       fs->fs_fsbtodb++;
+#endif SECSIZE
+               fs->fs_dbsize = size;
+       }
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = wmemall(vmemall, (int)fs->fs_cssize);
        if (space == 0) {
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = wmemall(vmemall, (int)fs->fs_cssize);
        if (space == 0) {
@@ -124,7 +175,12 @@ found:
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
+#ifdef SECSIZE
+               tp = bread(dev, fsbtodb(fs, fs->fs_csaddr + i), size,
+                   fs->fs_dbsize);
+#else SECSIZE
                tp = bread(dev, fsbtodb(fs, fs->fs_csaddr + i), size);
                tp = bread(dev, fsbtodb(fs, fs->fs_csaddr + i), size);
+#endif SECSIZE
                if (tp->b_flags&B_ERROR) {
                        wmemfree(space, (int)fs->fs_cssize);
                        goto out;
                if (tp->b_flags&B_ERROR) {
                        wmemfree(space, (int)fs->fs_cssize);
                        goto out;
@@ -145,10 +201,14 @@ found:
        /* Sanity checks for old file systems.                     XXX */
        fs->fs_npsect = MAX(fs->fs_npsect, fs->fs_nsect);       /* XXX */
        fs->fs_interleave = MAX(fs->fs_interleave, 1);          /* XXX */
        /* Sanity checks for old file systems.                     XXX */
        fs->fs_npsect = MAX(fs->fs_npsect, fs->fs_nsect);       /* XXX */
        fs->fs_interleave = MAX(fs->fs_interleave, 1);          /* XXX */
+
        return (fs);
 out:
        if (error == 0)
                error = EIO;
        return (fs);
 out:
        if (error == 0)
                error = EIO;
+       if (needclose)
+               (void) closei((dev_t)ip->i_rdev, IFBLK,
+                   ronly? FREAD : FREAD|FWRITE);
        if (ip)
                iput(ip);
        if (mp)
        if (ip)
                iput(ip);
        if (mp)
@@ -157,10 +217,6 @@ out:
                brelse(bp);
        if (tp)
                brelse(tp);
                brelse(bp);
        if (tp)
                brelse(tp);
-       if (needclose) {
-               (*bdevsw[major(dev)].d_close)(dev, ronly? FREAD : FREAD|FWRITE);
-               binval(dev);
-       }
        u.u_error = error;
        return (0);
 }
        u.u_error = error;
        return (0);
 }
@@ -180,10 +236,11 @@ unmount1(fname, forcibly)
 {
        dev_t dev;
        register struct mount *mp;
 {
        dev_t dev;
        register struct mount *mp;
-       int stillopen, flag, error;
+       int error;
        register struct inode *ip;
        register struct fs *fs;
 
        register struct inode *ip;
        register struct fs *fs;
 
+       forcibly = 0;                                   /* XXX */
        error = getmdev(&dev, fname);
        if (error)
                return (error);
        error = getmdev(&dev, fname);
        if (error)
                return (error);
@@ -196,36 +253,30 @@ found:
        nchinval(dev);  /* flush the name cache */
        update();
 #ifdef QUOTA
        nchinval(dev);  /* flush the name cache */
        update();
 #ifdef QUOTA
-       if ((stillopen = iflush(dev, mp->m_qinod)) < 0 && !forcibly)
+       if ((error = iflush(dev, mp->m_qinod)) && !forcibly)
 #else
 #else
-       if ((stillopen = iflush(dev)) < 0 && !forcibly)
+       if ((error = iflush(dev)) && !forcibly)
 #endif
 #endif
-               return (EBUSY);
-       if (stillopen < 0)
-               return (EBUSY);                 /* XXX */
+               return (error);
 #ifdef QUOTA
        closedq(mp);
        /*
         * Here we have to iflush again to get rid of the quota inode.
 #ifdef QUOTA
        closedq(mp);
        /*
         * Here we have to iflush again to get rid of the quota inode.
-        * A drag, but it would be ugly to cheat, & this doesn't happen often
+        * A drag, but it would be ugly to cheat, & this doesn't happen often.
         */
        (void)iflush(dev, (struct inode *)NULL);
 #endif
        ip = mp->m_inodp;
        ip->i_flag &= ~IMOUNT;
         */
        (void)iflush(dev, (struct inode *)NULL);
 #endif
        ip = mp->m_inodp;
        ip->i_flag &= ~IMOUNT;
-       irele(ip);
        fs = mp->m_bufp->b_un.b_fs;
        wmemfree((caddr_t)fs->fs_csp[0], (int)fs->fs_cssize);
        fs = mp->m_bufp->b_un.b_fs;
        wmemfree((caddr_t)fs->fs_csp[0], (int)fs->fs_cssize);
-       flag = !fs->fs_ronly;
        brelse(mp->m_bufp);
        mp->m_bufp = 0;
        mp->m_dev = 0;
        mpurge(mp - &mount[0]);
        brelse(mp->m_bufp);
        mp->m_bufp = 0;
        mp->m_dev = 0;
        mpurge(mp - &mount[0]);
-       if (!stillopen) {
-               (*bdevsw[major(dev)].d_close)(dev, flag);
-               binval(dev);
-       }
-       return (0);
+       error = closei(dev, IFBLK, fs->fs_ronly? FREAD : FREAD|FWRITE);
+       irele(ip);
+       return (error);
 }
 
 sbupdate(mp)
 }
 
 sbupdate(mp)
@@ -237,8 +288,20 @@ sbupdate(mp)
        caddr_t space;
        int i, size;
 
        caddr_t space;
        int i, size;
 
+#ifdef SECSIZE
+       bp = getblk(mp->m_dev, (daddr_t)fsbtodb(fs, SBOFF / fs->fs_fsize),
+           (int)fs->fs_sbsize, fs->fs_dbsize);
+#else SECSIZE
        bp = getblk(mp->m_dev, SBLOCK, (int)fs->fs_sbsize);
        bp = getblk(mp->m_dev, SBLOCK, (int)fs->fs_sbsize);
+#endif SECSIZE
        bcopy((caddr_t)fs, bp->b_un.b_addr, (u_int)fs->fs_sbsize);
        bcopy((caddr_t)fs, bp->b_un.b_addr, (u_int)fs->fs_sbsize);
+#ifdef SECSIZE
+#ifdef tahoe
+       /* restore standard fsbtodb shift */
+       bp->b_un.b_fs->fs_fsbtodb = fs->fs_sparecon[0];
+       bp->b_un.b_fs->fs_sparecon[0] = 0;
+#endif
+#endif SECSIZE
        bwrite(bp);
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = (caddr_t)fs->fs_csp[0];
        bwrite(bp);
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = (caddr_t)fs->fs_csp[0];
@@ -246,7 +309,12 @@ sbupdate(mp)
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
+#ifdef SECSIZE
+               bp = getblk(mp->m_dev, fsbtodb(fs, fs->fs_csaddr + i), size,
+                   fs->fs_dbsize);
+#else SECSIZE
                bp = getblk(mp->m_dev, fsbtodb(fs, fs->fs_csaddr + i), size);
                bp = getblk(mp->m_dev, fsbtodb(fs, fs->fs_csaddr + i), size);
+#endif SECSIZE
                bcopy(space, bp->b_un.b_addr, (u_int)size);
                space += size;
                bwrite(bp);
                bcopy(space, bp->b_un.b_addr, (u_int)size);
                space += size;
                bwrite(bp);
index 23dfa09..c72684c 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.
  *
- *     @(#)ufs_inode.c 7.1 (Berkeley) %G%
+ *     @(#)ufs_inode.c 7.1.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -185,7 +185,12 @@ loop:
 #ifdef QUOTA
        dqrele(ip->i_dquot);
 #endif
 #ifdef QUOTA
        dqrele(ip->i_dquot);
 #endif
+#ifdef SECSIZE
+       bp = bread(dev, fsbtodb(fs, itod(fs, ino)), (int)fs->fs_bsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(dev, fsbtodb(fs, itod(fs, ino)), (int)fs->fs_bsize);
        bp = bread(dev, fsbtodb(fs, itod(fs, ino)), (int)fs->fs_bsize);
+#endif SECSIZE
        /*
         * Check I/O errors
         */
        /*
         * Check I/O errors
         */
@@ -334,14 +339,19 @@ iupdat(ip, ta, tm, waitfor)
 {
        register struct buf *bp;
        struct dinode *dp;
 {
        register struct buf *bp;
        struct dinode *dp;
-       register struct fs *fp;
+       register struct fs *fs;
 
 
-       fp = ip->i_fs;
+       fs = ip->i_fs;
        if ((ip->i_flag & (IUPD|IACC|ICHG|IMOD)) != 0) {
        if ((ip->i_flag & (IUPD|IACC|ICHG|IMOD)) != 0) {
-               if (fp->fs_ronly)
+               if (fs->fs_ronly)
                        return;
                        return;
-               bp = bread(ip->i_dev, fsbtodb(fp, itod(fp, ip->i_number)),
-                       (int)fp->fs_bsize);
+#ifdef SECSIZE
+               bp = bread(ip->i_dev, fsbtodb(fs, itod(fs, ip->i_number)),
+                       (int)fs->fs_bsize, fs->fs_dbsize);
+#else SECSIZE
+               bp = bread(ip->i_dev, fsbtodb(fs, itod(fs, ip->i_number)),
+                       (int)fs->fs_bsize);
+#endif SECSIZE
                if (bp->b_flags & B_ERROR) {
                        brelse(bp);
                        return;
                if (bp->b_flags & B_ERROR) {
                        brelse(bp);
                        return;
@@ -353,7 +363,7 @@ iupdat(ip, ta, tm, waitfor)
                if (ip->i_flag&ICHG)
                        ip->i_ctime = time.tv_sec;
                ip->i_flag &= ~(IUPD|IACC|ICHG|IMOD);
                if (ip->i_flag&ICHG)
                        ip->i_ctime = time.tv_sec;
                ip->i_flag &= ~(IUPD|IACC|ICHG|IMOD);
-               dp = bp->b_un.b_dino + itoo(fp, ip->i_number);
+               dp = bp->b_un.b_dino + itoo(fs, ip->i_number);
                dp->di_ic = ip->i_ic;
                if (waitfor)
                        bwrite(bp);
                dp->di_ic = ip->i_ic;
                if (waitfor)
                        bwrite(bp);
@@ -382,13 +392,12 @@ itrunc(oip, length)
        register struct fs *fs;
        register struct inode *ip;
        struct buf *bp;
        register struct fs *fs;
        register struct inode *ip;
        struct buf *bp;
-       int offset, osize, size, count, level, s;
+       int offset, osize, size, count, level;
        long nblocks, blocksreleased = 0;
        register int i;
        dev_t dev;
        struct inode tip;
        extern long indirtrunc();
        long nblocks, blocksreleased = 0;
        register int i;
        dev_t dev;
        struct inode tip;
        extern long indirtrunc();
-       extern struct cmap *mfind();
 
        if (oip->i_size <= length) {
                oip->i_flag |= ICHG|IUPD;
 
        if (oip->i_size <= length) {
                oip->i_flag |= ICHG|IUPD;
@@ -425,13 +434,14 @@ itrunc(oip, length)
                        return;
                oip->i_size = length;
                size = blksize(fs, oip, lbn);
                        return;
                oip->i_size = length;
                size = blksize(fs, oip, lbn);
-               count = howmany(size, DEV_BSIZE);
+               count = howmany(size, CLBYTES);
                dev = oip->i_dev;
                dev = oip->i_dev;
-               s = splimp();
-               for (i = 0; i < count; i += CLSIZE)
-                       if (mfind(dev, bn + i))
-                               munhash(dev, bn + i);
-               splx(s);
+               for (i = 0; i < count; i++)
+#ifdef SECSIZE
+                       munhash(dev, bn + i * CLBYTES / fs->fs_dbsize);
+#else SECSIZE
+                       munhash(dev, bn + i * CLBYTES / DEV_BSIZE);
+#endif SECSIZE
                bp = bread(dev, bn, size);
                if (bp->b_flags & B_ERROR) {
                        u.u_error = EIO;
                bp = bread(dev, bn, size);
                if (bp->b_flags & B_ERROR) {
                        u.u_error = EIO;
@@ -586,7 +596,12 @@ indirtrunc(ip, bn, lastbn, level)
         * and update on disk copy first.
         */
        copy = geteblk((int)fs->fs_bsize);
         * and update on disk copy first.
         */
        copy = geteblk((int)fs->fs_bsize);
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
+#endif SECSIZE
        if (bp->b_flags&B_ERROR) {
                brelse(copy);
                brelse(bp);
        if (bp->b_flags&B_ERROR) {
                brelse(copy);
                brelse(bp);
@@ -627,17 +642,10 @@ indirtrunc(ip, bn, lastbn, level)
 }
 
 /*
 }
 
 /*
- * remove any inodes in the inode cache belonging to dev
+ * Remove any inodes in the inode cache belonging to dev.
  *
  * There should not be any active ones, return error if any are found
  *
  * There should not be any active ones, return error if any are found
- * (nb: this is a user error, not a system err)
- *
- * Also, count the references to dev by block devices - this really
- * has nothing to do with the object of the procedure, but as we have
- * to scan the inode table here anyway, we might as well get the
- * extra benefit.
- *
- * this is called from sumount()/sys3.c when dev is being unmounted
+ * (nb: this is a user error, not a system err).
  */
 #ifdef QUOTA
 iflush(dev, iq)
  */
 #ifdef QUOTA
 iflush(dev, iq)
@@ -649,7 +657,6 @@ iflush(dev)
 #endif
 {
        register struct inode *ip;
 #endif
 {
        register struct inode *ip;
-       register open = 0;
 
        for (ip = inode; ip < inodeNINODE; ip++) {
 #ifdef QUOTA
 
        for (ip = inode; ip < inodeNINODE; ip++) {
 #ifdef QUOTA
@@ -658,7 +665,7 @@ iflush(dev)
                if (ip->i_dev == dev)
 #endif
                        if (ip->i_count)
                if (ip->i_dev == dev)
 #endif
                        if (ip->i_count)
-                               return(-1);
+                               return (EBUSY);
                        else {
                                remque(ip);
                                ip->i_forw = ip;
                        else {
                                remque(ip);
                                ip->i_forw = ip;
@@ -677,11 +684,8 @@ iflush(dev)
                                ip->i_dquot = NODQUOT;
 #endif
                        }
                                ip->i_dquot = NODQUOT;
 #endif
                        }
-               else if (ip->i_count && (ip->i_mode&IFMT)==IFBLK &&
-                   ip->i_rdev == dev)
-                       open++;
        }
        }
-       return (open);
+       return (0);
 }
 
 /*
 }
 
 /*
index 04eb5fb..9a2f656 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.
  *
- *     @(#)ufs_lookup.c        7.1 (Berkeley) %G%
+ *     @(#)ufs_lookup.c        7.1.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -1060,7 +1060,11 @@ blkatoff(ip, offset, res)
                dirbad(ip, offset, "hole in dir");
                return (0);
        }
                dirbad(ip, offset, "hole in dir");
                return (0);
        }
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, bn), bsize, fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), bsize);
        bp = bread(ip->i_dev, fsbtodb(fs, bn), bsize);
+#endif SECSIZE
        if (bp->b_flags & B_ERROR) {
                brelse(bp);
                return (0);
        if (bp->b_flags & B_ERROR) {
                brelse(bp);
                return (0);
index f1a9c5e..fc3de6d 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.
  *
- *     @(#)ufs_vfsops.c        7.2 (Berkeley) %G%
+ *     @(#)ufs_vfsops.c        7.2.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -17,6 +17,9 @@
 #include "mount.h"
 #include "file.h"
 #include "conf.h"
 #include "mount.h"
 #include "file.h"
 #include "conf.h"
+#include "ioctl.h"
+#include "disklabel.h"
+#include "stat.h"
 
 smount()
 {
 
 smount()
 {
@@ -68,25 +71,48 @@ mountfs(dev, ronly, ip)
        struct buf *tp = 0;
        register struct buf *bp = 0;
        register struct fs *fs;
        struct buf *tp = 0;
        register struct buf *bp = 0;
        register struct fs *fs;
-       int blks;
+       struct partinfo dpart;
+       int havepart = 0, blks;
        caddr_t space;
        int i, size;
        register error;
        int needclose = 0;
 
        error =
        caddr_t space;
        int i, size;
        register error;
        int needclose = 0;
 
        error =
-           (*bdevsw[major(dev)].d_open)(dev, ronly ? FREAD : FREAD|FWRITE);
+           (*bdevsw[major(dev)].d_open)(dev, ronly ? FREAD : FREAD|FWRITE,
+               S_IFBLK);
        if (error)
                goto out;
        needclose = 1;
        if (error)
                goto out;
        needclose = 1;
+#ifdef SECSIZE
+       /*
+        * If possible, determine hardware sector size
+        * and adjust fsbtodb to correspond.
+        */
+#endif SECSIZE
+       if ((*bdevsw[major(dev)].d_ioctl)(dev, DIOCGPART,
+           (caddr_t)&dpart, FREAD) == 0) {
+               havepart = 1;
+               size = dpart.disklab->d_secsize;
+#ifdef SECSIZE
+               if (size < MINSECSIZE) {
+                       error = EINVAL;
+                       goto out;
+               }
+#endif SECSIZE
+       } else
+               size = DEV_BSIZE;
+#ifdef SECSIZE
+       tp = bread(dev, (daddr_t)(SBOFF / size), SBSIZE, size);
+#else SECSIZE
        tp = bread(dev, SBLOCK, SBSIZE);
        tp = bread(dev, SBLOCK, SBSIZE);
+#endif SECSIZE
        if (tp->b_flags & B_ERROR)
                goto out;
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
                if (mp->m_bufp != 0 && dev == mp->m_dev) {
                        mp = 0;
                        error = EBUSY;
        if (tp->b_flags & B_ERROR)
                goto out;
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
                if (mp->m_bufp != 0 && dev == mp->m_dev) {
                        mp = 0;
                        error = EBUSY;
-                       needclose = 0;
                        goto out;
                }
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
                        goto out;
                }
        for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
@@ -99,8 +125,8 @@ found:
        mp->m_bufp = tp;        /* just to reserve this slot */
        mp->m_dev = NODEV;
        fs = tp->b_un.b_fs;
        mp->m_bufp = tp;        /* just to reserve this slot */
        mp->m_dev = NODEV;
        fs = tp->b_un.b_fs;
-       if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE
-           || fs->fs_bsize < sizeof(struct fs)) {
+       if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE ||
+           fs->fs_bsize < sizeof(struct fs)) {
                error = EINVAL;         /* also needs translation */
                goto out;
        }
                error = EINVAL;         /* also needs translation */
                goto out;
        }
@@ -114,6 +140,31 @@ found:
        fs->fs_ronly = (ronly != 0);
        if (ronly == 0)
                fs->fs_fmod = 1;
        fs->fs_ronly = (ronly != 0);
        if (ronly == 0)
                fs->fs_fmod = 1;
+#ifdef SECSIZE
+       /*
+        * If we have a disk label, force per-partition
+        * filesystem information to be correct
+        * and set correct current fsbtodb shift.
+        */
+#endif SECSIZE
+       if (havepart) {
+               dpart.part->p_fstype = FS_BSDFFS;
+               dpart.part->p_fsize = fs->fs_fsize;
+               dpart.part->p_frag = fs->fs_frag;
+#ifdef SECSIZE
+#ifdef tahoe
+               /*
+                * Save the original fsbtodb shift to restore on updates.
+                * (Console doesn't understand fsbtodb changes.)
+                */
+               fs->fs_sparecon[0] = fs->fs_fsbtodb;
+#endif
+               i = fs->fs_fsize / size;
+               for (fs->fs_fsbtodb = 0; i > 1; i >>= 1)
+                       fs->fs_fsbtodb++;
+#endif SECSIZE
+               fs->fs_dbsize = size;
+       }
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = wmemall(vmemall, (int)fs->fs_cssize);
        if (space == 0) {
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = wmemall(vmemall, (int)fs->fs_cssize);
        if (space == 0) {
@@ -124,7 +175,12 @@ found:
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
+#ifdef SECSIZE
+               tp = bread(dev, fsbtodb(fs, fs->fs_csaddr + i), size,
+                   fs->fs_dbsize);
+#else SECSIZE
                tp = bread(dev, fsbtodb(fs, fs->fs_csaddr + i), size);
                tp = bread(dev, fsbtodb(fs, fs->fs_csaddr + i), size);
+#endif SECSIZE
                if (tp->b_flags&B_ERROR) {
                        wmemfree(space, (int)fs->fs_cssize);
                        goto out;
                if (tp->b_flags&B_ERROR) {
                        wmemfree(space, (int)fs->fs_cssize);
                        goto out;
@@ -145,10 +201,14 @@ found:
        /* Sanity checks for old file systems.                     XXX */
        fs->fs_npsect = MAX(fs->fs_npsect, fs->fs_nsect);       /* XXX */
        fs->fs_interleave = MAX(fs->fs_interleave, 1);          /* XXX */
        /* Sanity checks for old file systems.                     XXX */
        fs->fs_npsect = MAX(fs->fs_npsect, fs->fs_nsect);       /* XXX */
        fs->fs_interleave = MAX(fs->fs_interleave, 1);          /* XXX */
+
        return (fs);
 out:
        if (error == 0)
                error = EIO;
        return (fs);
 out:
        if (error == 0)
                error = EIO;
+       if (needclose)
+               (void) closei((dev_t)ip->i_rdev, IFBLK,
+                   ronly? FREAD : FREAD|FWRITE);
        if (ip)
                iput(ip);
        if (mp)
        if (ip)
                iput(ip);
        if (mp)
@@ -157,10 +217,6 @@ out:
                brelse(bp);
        if (tp)
                brelse(tp);
                brelse(bp);
        if (tp)
                brelse(tp);
-       if (needclose) {
-               (*bdevsw[major(dev)].d_close)(dev, ronly? FREAD : FREAD|FWRITE);
-               binval(dev);
-       }
        u.u_error = error;
        return (0);
 }
        u.u_error = error;
        return (0);
 }
@@ -180,10 +236,11 @@ unmount1(fname, forcibly)
 {
        dev_t dev;
        register struct mount *mp;
 {
        dev_t dev;
        register struct mount *mp;
-       int stillopen, flag, error;
+       int error;
        register struct inode *ip;
        register struct fs *fs;
 
        register struct inode *ip;
        register struct fs *fs;
 
+       forcibly = 0;                                   /* XXX */
        error = getmdev(&dev, fname);
        if (error)
                return (error);
        error = getmdev(&dev, fname);
        if (error)
                return (error);
@@ -196,36 +253,30 @@ found:
        nchinval(dev);  /* flush the name cache */
        update();
 #ifdef QUOTA
        nchinval(dev);  /* flush the name cache */
        update();
 #ifdef QUOTA
-       if ((stillopen = iflush(dev, mp->m_qinod)) < 0 && !forcibly)
+       if ((error = iflush(dev, mp->m_qinod)) && !forcibly)
 #else
 #else
-       if ((stillopen = iflush(dev)) < 0 && !forcibly)
+       if ((error = iflush(dev)) && !forcibly)
 #endif
 #endif
-               return (EBUSY);
-       if (stillopen < 0)
-               return (EBUSY);                 /* XXX */
+               return (error);
 #ifdef QUOTA
        closedq(mp);
        /*
         * Here we have to iflush again to get rid of the quota inode.
 #ifdef QUOTA
        closedq(mp);
        /*
         * Here we have to iflush again to get rid of the quota inode.
-        * A drag, but it would be ugly to cheat, & this doesn't happen often
+        * A drag, but it would be ugly to cheat, & this doesn't happen often.
         */
        (void)iflush(dev, (struct inode *)NULL);
 #endif
        ip = mp->m_inodp;
        ip->i_flag &= ~IMOUNT;
         */
        (void)iflush(dev, (struct inode *)NULL);
 #endif
        ip = mp->m_inodp;
        ip->i_flag &= ~IMOUNT;
-       irele(ip);
        fs = mp->m_bufp->b_un.b_fs;
        wmemfree((caddr_t)fs->fs_csp[0], (int)fs->fs_cssize);
        fs = mp->m_bufp->b_un.b_fs;
        wmemfree((caddr_t)fs->fs_csp[0], (int)fs->fs_cssize);
-       flag = !fs->fs_ronly;
        brelse(mp->m_bufp);
        mp->m_bufp = 0;
        mp->m_dev = 0;
        mpurge(mp - &mount[0]);
        brelse(mp->m_bufp);
        mp->m_bufp = 0;
        mp->m_dev = 0;
        mpurge(mp - &mount[0]);
-       if (!stillopen) {
-               (*bdevsw[major(dev)].d_close)(dev, flag);
-               binval(dev);
-       }
-       return (0);
+       error = closei(dev, IFBLK, fs->fs_ronly? FREAD : FREAD|FWRITE);
+       irele(ip);
+       return (error);
 }
 
 sbupdate(mp)
 }
 
 sbupdate(mp)
@@ -237,8 +288,20 @@ sbupdate(mp)
        caddr_t space;
        int i, size;
 
        caddr_t space;
        int i, size;
 
+#ifdef SECSIZE
+       bp = getblk(mp->m_dev, (daddr_t)fsbtodb(fs, SBOFF / fs->fs_fsize),
+           (int)fs->fs_sbsize, fs->fs_dbsize);
+#else SECSIZE
        bp = getblk(mp->m_dev, SBLOCK, (int)fs->fs_sbsize);
        bp = getblk(mp->m_dev, SBLOCK, (int)fs->fs_sbsize);
+#endif SECSIZE
        bcopy((caddr_t)fs, bp->b_un.b_addr, (u_int)fs->fs_sbsize);
        bcopy((caddr_t)fs, bp->b_un.b_addr, (u_int)fs->fs_sbsize);
+#ifdef SECSIZE
+#ifdef tahoe
+       /* restore standard fsbtodb shift */
+       bp->b_un.b_fs->fs_fsbtodb = fs->fs_sparecon[0];
+       bp->b_un.b_fs->fs_sparecon[0] = 0;
+#endif
+#endif SECSIZE
        bwrite(bp);
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = (caddr_t)fs->fs_csp[0];
        bwrite(bp);
        blks = howmany(fs->fs_cssize, fs->fs_fsize);
        space = (caddr_t)fs->fs_csp[0];
@@ -246,7 +309,12 @@ sbupdate(mp)
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
                size = fs->fs_bsize;
                if (i + fs->fs_frag > blks)
                        size = (blks - i) * fs->fs_fsize;
+#ifdef SECSIZE
+               bp = getblk(mp->m_dev, fsbtodb(fs, fs->fs_csaddr + i), size,
+                   fs->fs_dbsize);
+#else SECSIZE
                bp = getblk(mp->m_dev, fsbtodb(fs, fs->fs_csaddr + i), size);
                bp = getblk(mp->m_dev, fsbtodb(fs, fs->fs_csaddr + i), size);
+#endif SECSIZE
                bcopy(space, bp->b_un.b_addr, (u_int)size);
                space += size;
                bwrite(bp);
                bcopy(space, bp->b_un.b_addr, (u_int)size);
                space += size;
                bwrite(bp);
index c61cfc2..9f43187 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.
  *
- *     @(#)vm_swap.c   7.1 (Berkeley) %G%
+ *     @(#)vm_swap.c   7.1.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -16,6 +16,7 @@
 #include "map.h"
 #include "uio.h"
 #include "file.h"
 #include "map.h"
 #include "uio.h"
 #include "file.h"
+#include "stat.h"
 
 struct buf rswbuf;
 /*
 
 struct buf rswbuf;
 /*
@@ -24,8 +25,8 @@ struct        buf rswbuf;
 swstrategy(bp)
        register struct buf *bp;
 {
 swstrategy(bp)
        register struct buf *bp;
 {
-       int sz, off, seg;
-       dev_t dev;
+       int sz, off, seg, index;
+       register struct swdevt *sp;
 
 #ifdef GENERIC
        /*
 
 #ifdef GENERIC
        /*
@@ -41,26 +42,31 @@ swstrategy(bp)
        sz = howmany(bp->b_bcount, DEV_BSIZE);
        if (bp->b_blkno+sz > nswap) {
                bp->b_flags |= B_ERROR;
        sz = howmany(bp->b_bcount, DEV_BSIZE);
        if (bp->b_blkno+sz > nswap) {
                bp->b_flags |= B_ERROR;
-               iodone(bp);
+               biodone(bp);
                return;
        }
        if (nswdev > 1) {
                off = bp->b_blkno % dmmax;
                if (off+sz > dmmax) {
                        bp->b_flags |= B_ERROR;
                return;
        }
        if (nswdev > 1) {
                off = bp->b_blkno % dmmax;
                if (off+sz > dmmax) {
                        bp->b_flags |= B_ERROR;
-                       iodone(bp);
+                       biodone(bp);
                        return;
                }
                seg = bp->b_blkno / dmmax;
                        return;
                }
                seg = bp->b_blkno / dmmax;
-               dev = swdevt[seg % nswdev].sw_dev;
+               index = seg % nswdev;
                seg /= nswdev;
                bp->b_blkno = seg*dmmax + off;
        } else
                seg /= nswdev;
                bp->b_blkno = seg*dmmax + off;
        } else
-               dev = swdevt[0].sw_dev;
-       bp->b_dev = dev;
-       if (dev == 0)
+               index = 0;
+       sp = &swdevt[index];
+#ifdef SECSIZE
+       bp->b_blkno <<= sp->sw_bshift;
+       bp->b_blksize = sp->sw_blksize;
+#endif SECSIZE
+       bp->b_dev = sp->sw_dev;
+       if (bp->b_dev == 0)
                panic("swstrategy");
                panic("swstrategy");
-       (*bdevsw[major(dev)].d_strategy)(bp);
+       (*bdevsw[major(bp->b_dev)].d_strategy)(bp);
 }
 
 swread(dev, uio)
 }
 
 swread(dev, uio)
@@ -119,12 +125,16 @@ swapon()
                                u.u_error = EBUSY;
                                return;
                        }
                                u.u_error = EBUSY;
                                return;
                        }
-                       swfree(sp - swdevt);
+                       u.u_error = swfree(sp - swdevt);
                        return;
                }
        u.u_error = EINVAL;
 }
 
                        return;
                }
        u.u_error = EINVAL;
 }
 
+#ifdef SECSIZE
+long   argdbsize;              /* XXX */
+
+#endif SECSIZE
 /*
  * Swfree(index) frees the index'th portion of the swap map.
  * Each of the nswdev devices provides 1/nswdev'th of the swap
 /*
  * Swfree(index) frees the index'th portion of the swap map.
  * Each of the nswdev devices provides 1/nswdev'th of the swap
@@ -134,16 +144,20 @@ swapon()
 swfree(index)
        int index;
 {
 swfree(index)
        int index;
 {
+       register struct swdevt *sp;
        register swblk_t vsbase;
        register long blk;
        dev_t dev;
        register swblk_t dvbase;
        register int nblks;
        register swblk_t vsbase;
        register long blk;
        dev_t dev;
        register swblk_t dvbase;
        register int nblks;
+       int error;
 
 
-       dev = swdevt[index].sw_dev;
-       (*bdevsw[major(dev)].d_open)(dev, FREAD|FWRITE);
-       swdevt[index].sw_freed = 1;
-       nblks = swdevt[index].sw_nblks;
+       sp = &swdevt[index];
+       dev = sp->sw_dev;
+       if (error = (*bdevsw[major(dev)].d_open)(dev, FREAD|FWRITE, S_IFBLK))
+               return (error);
+       sp->sw_freed = 1;
+       nblks = sp->sw_nblks;
        for (dvbase = 0; dvbase < nblks; dvbase += dmmax) {
                blk = nblks - dvbase;
                if ((vsbase = index*dmmax + dvbase*nswdev) >= nswap)
        for (dvbase = 0; dvbase < nblks; dvbase += dmmax) {
                blk = nblks - dvbase;
                if ((vsbase = index*dmmax + dvbase*nswdev) >= nswap)
@@ -156,16 +170,31 @@ swfree(index)
                         * but need some space for argmap so use 1/2 this
                         * hunk which needs special treatment anyways.
                         */
                         * but need some space for argmap so use 1/2 this
                         * hunk which needs special treatment anyways.
                         */
-                       argdev = swdevt[0].sw_dev;
+                       argdev = sp->sw_dev;
+#ifdef SECSIZE
+                       argdbsize = sp->sw_blksize;
+                       rminit(argmap,
+                          ((blk / 2) * DEV_BSIZE - CLBYTES) / argdbsize,
+                          CLBYTES / argdbsize, "argmap", ARGMAPSIZE);
+#else SECSIZE
                        rminit(argmap, (long)(blk/2-ctod(CLSIZE)),
                            (long)ctod(CLSIZE), "argmap", ARGMAPSIZE);
                        rminit(argmap, (long)(blk/2-ctod(CLSIZE)),
                            (long)ctod(CLSIZE), "argmap", ARGMAPSIZE);
+#endif SECSIZE
                        /*
                         * First of all chunks... initialize the swapmap
                         * the second half of the hunk.
                         */
                        rminit(swapmap, (long)blk/2, (long)blk/2,
                            "swap", nswapmap);
                        /*
                         * First of all chunks... initialize the swapmap
                         * the second half of the hunk.
                         */
                        rminit(swapmap, (long)blk/2, (long)blk/2,
                            "swap", nswapmap);
+               } else if (dvbase == 0) {
+                       /*
+                        * Don't use the first cluster of the device
+                        * in case it starts with a label or boot block.
+                        */
+                       rmfree(swapmap, blk - ctod(CLSIZE),
+                           vsbase + ctod(CLSIZE));
                } else
                        rmfree(swapmap, blk, vsbase);
        }
                } else
                        rmfree(swapmap, blk, vsbase);
        }
+       return (0);
 }
 }