create netif directory
[unix-history] / usr / src / sys / vm / vm_swap.c
index 141e8e1..d1b3f4a 100644 (file)
@@ -1,4 +1,4 @@
-/*     vm_swap.c       4.1     %G%     */
+/*     vm_swap.c       4.12    82/10/22        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -8,6 +8,7 @@
 #include "../h/user.h"
 #include "../h/inode.h"
 #include "../h/map.h"
 #include "../h/user.h"
 #include "../h/inode.h"
 #include "../h/map.h"
+#include "../h/uio.h"
 
 struct buf rswbuf;
 /*
 
 struct buf rswbuf;
 /*
@@ -19,6 +20,17 @@ swstrategy(bp)
        int sz, off, seg;
        dev_t dev;
 
        int sz, off, seg;
        dev_t dev;
 
+#ifdef GENERIC
+       /*
+        * A mini-root gets copied into the front of the swap
+        * and we run over top of the swap area just long
+        * enough for us to do a mkfs and restor of the real
+        * root (sure beats rewriting standalone restor).
+        */
+#define        MINIROOTSIZE    2048
+       if (rootdev == dumpdev)
+               bp->b_blkno += MINIROOTSIZE;
+#endif
        sz = (bp->b_bcount+511)/512;
        off = bp->b_blkno % DMMAX;
        if (bp->b_blkno+sz > nswap || off+sz > DMMAX) {
        sz = (bp->b_bcount+511)/512;
        off = bp->b_blkno % DMMAX;
        if (bp->b_blkno+sz > nswap || off+sz > DMMAX) {
@@ -36,16 +48,20 @@ swstrategy(bp)
        (*bdevsw[major(dev)].d_strategy)(bp);
 }
 
        (*bdevsw[major(dev)].d_strategy)(bp);
 }
 
-swread(dev)
+swread(dev, uio)
+       dev_t dev;
+       struct uio *uio;
 {
 
 {
 
-       physio(swstrategy, &rswbuf, dev, B_READ, minphys);
+       return (physio(swstrategy, &rswbuf, dev, B_READ, minphys, uio));
 }
 
 }
 
-swwrite(dev)
+swwrite(dev, uio)
+       dev_t dev;
+       struct uio *uio;
 {
 
 {
 
-       physio(swstrategy, &rswbuf, dev, B_WRITE, minphys);
+       return (physio(swstrategy, &rswbuf, dev, B_WRITE, minphys, uio));
 }
 
 /*
 }
 
 /*
@@ -53,17 +69,13 @@ swwrite(dev)
  * which must be in the swdevsw.  Return EBUSY
  * if already swapping on this device.
  */
  * which must be in the swdevsw.  Return EBUSY
  * if already swapping on this device.
  */
-vswapon()
+oswapon()
 {
 {
-       register struct a {
-               char    *sname;
-       } *uap;
        register struct inode *ip;
        dev_t dev;
        register struct swdevt *sp;
 
        register struct inode *ip;
        dev_t dev;
        register struct swdevt *sp;
 
-       uap = (struct a *)u.u_ap;
-       ip = namei(uchar, 0);
+       ip = namei(uchar, 0, 1);
        if (ip == NULL)
                return;
        if ((ip->i_mode&IFMT) != IFBLK) {
        if (ip == NULL)
                return;
        if ((ip->i_mode&IFMT) != IFBLK) {
@@ -71,7 +83,7 @@ vswapon()
                iput(ip);
                return;
        }
                iput(ip);
                return;
        }
-       dev = (dev_t)ip->i_un.i_rdev;
+       dev = (dev_t)ip->i_rdev;
        iput(ip);
        if (major(dev) >= nblkdev) {
                u.u_error = ENXIO;
        iput(ip);
        if (major(dev) >= nblkdev) {
                u.u_error = ENXIO;
@@ -103,7 +115,7 @@ swfree(index)
        int index;
 {
        register swblk_t vsbase;
        int index;
 {
        register swblk_t vsbase;
-       register int blk;
+       register long blk;
 
        swdevt[index].sw_freed = 1;
        for (vsbase = index*DMMAX; vsbase < nswap; vsbase += nswdev*DMMAX) {
 
        swdevt[index].sw_freed = 1;
        for (vsbase = index*DMMAX; vsbase < nswap; vsbase += nswdev*DMMAX) {
@@ -113,12 +125,19 @@ swfree(index)
                if (vsbase == 0) {
                        /*
                         * Can't free a block starting at 0 in the swapmap
                if (vsbase == 0) {
                        /*
                         * Can't free a block starting at 0 in the swapmap
-                        * but need some space for argmap so use this
+                        * but need some space for argmap so use 1/2 this
                         * hunk which needs special treatment anyways.
                         */
                        argdev = swdevt[0].sw_dev;
                         * hunk which needs special treatment anyways.
                         */
                        argdev = swdevt[0].sw_dev;
-                       mfree(argmap, blk-CLSIZE, vsbase+CLSIZE);
+                       rminit(argmap, (long)(blk/2-CLSIZE), (long)CLSIZE,
+                           "argmap", ARGMAPSIZE);
+                       /*
+                        * First of all chunks... initialize the swapmap
+                        * the second half of the hunk.
+                        */
+                       rminit(swapmap, (long)blk/2, (long)blk/2,
+                           "swap", nswapmap);
                } else
                } else
-                       mfree(swapmap, blk, vsbase);
+                       rmfree(swapmap, blk, vsbase);
        }
 }
        }
 }