Implement read/write to kernel space - I use this for a self-loading/

self-decompressing ram disk that I'm fiddling with..

(Note, this depends on the various syscalls having correctly set uio_segflag
 before calling physio - I've checked and they look correct.)
This commit is contained in:
peter 1995-11-28 02:40:38 +00:00
parent ecca6899e0
commit f22c665f0e

View File

@ -16,7 +16,7 @@
* 4. Modifications may be freely made to this file if the above conditions
* are met.
*
* $Id: kern_physio.c,v 1.11 1995/05/30 08:05:36 rgrimes Exp $
* $Id: kern_physio.c,v 1.12 1995/09/08 11:08:36 bde Exp $
*/
#include <sys/param.h>
@ -91,16 +91,19 @@ physio(strategy, bp, dev, rw, minp, uio)
bp->b_blkno = btodb(uio->uio_offset);
if (rw && !useracc(bp->b_data, bp->b_bufsize, B_WRITE)) {
error = EFAULT;
goto doerror;
}
if (!rw && !useracc(bp->b_data, bp->b_bufsize, B_READ)) {
error = EFAULT;
goto doerror;
}
if (uio->uio_segflg == UIO_USERSPACE) {
if (rw && !useracc(bp->b_data, bp->b_bufsize, B_WRITE)) {
error = EFAULT;
goto doerror;
}
if (!rw && !useracc(bp->b_data, bp->b_bufsize, B_READ)) {
error = EFAULT;
goto doerror;
}
vmapbuf(bp);
/* bring buffer into kernel space */
vmapbuf(bp);
}
/* perform transfer */
(*strategy)(bp);
@ -110,7 +113,9 @@ physio(strategy, bp, dev, rw, minp, uio)
tsleep((caddr_t)bp, PRIBIO, "physstr", 0);
splx(spl);
vunmapbuf(bp);
/* release mapping into kernel space */
if (uio->uio_segflg == UIO_USERSPACE)
vunmapbuf(bp);
/*
* update the uio data