? Makefile ? vncrypt.c.diff ? vncrypt.txt Index: vn2.c =================================================================== RCS file: /cvsroot/vncrypt/src/src/sys/dev/vncrypt/vn2.c,v retrieving revision 1.8 diff -u -p -u -r1.8 vn2.c --- vn2.c 27 May 2002 12:27:27 -0000 1.8 +++ vn2.c 16 Mar 2004 21:50:06 -0000 @@ -90,7 +90,7 @@ #include #include -#include +#include "vn_crypt.h" static d_ioctl_t vnioctl; static d_open_t vnopen; @@ -110,6 +110,12 @@ static d_strategy_t vnstrategy; */ static struct cdevsw vn_cdevsw = { + /* name */ "vn", + /* maj */ CDEV_MAJOR, + /* flags */ D_DISK|D_CANFREE, + /* port */ NULL, + /* autoq */ 0, + /* open */ vnopen, /* close */ vnclose, /* read */ physread, @@ -118,12 +124,8 @@ static struct cdevsw vn_cdevsw = { /* poll */ nopoll, /* mmap */ nommap, /* strategy */ vnstrategy, - /* name */ "vn", - /* maj */ CDEV_MAJOR, /* dump */ nodump, - /* psize */ vnsize, - /* flags */ D_DISK|D_CANFREE, - /* bmaj */ BDEV_MAJOR + /* psize */ vnsize }; #define getvnbuf() \ @@ -165,15 +167,15 @@ static int userconfig; static int vnsetcred (struct vn_softc *vn, struct ucred *cred); static void vnclear (struct vn_softc *vn); static int vn2_modevent (module_t, int, void *); -static int vniocattach_file (struct vn_softc *, struct vn_ioctl *, dev_t dev, int flag, struct proc *p); -static int vniocattach_swap (struct vn_softc *, struct vn_ioctl *, dev_t dev, int flag, struct proc *p); +static int vniocattach_file (struct vn_softc *, struct vn_ioctl *, dev_t dev, int flag, struct thread *td); +static int vniocattach_swap (struct vn_softc *, struct vn_ioctl *, dev_t dev, int flag, struct thread *td); SYSCTL_NODE(_vfs, OID_AUTO, vncrypt, CTLFLAG_RW, 0, "vncrypt params"); SYSCTL_INT(_vfs_vncrypt, OID_AUTO, userconfig, CTLFLAG_RW, &userconfig, 0, "Allow users to configure vncrypt devices"); static int -vnclose(dev_t dev, int flags, int mode, struct proc *p) +vnclose(dev_t dev, int flags, int mode, struct thread *td) { struct vn_softc *vn = dev->si_drv1; @@ -222,7 +224,7 @@ vnfindvn(dev_t dev) } static int -vnopen(dev_t dev, int flags, int mode, struct proc *p) +vnopen(dev_t dev, int flags, int mode, struct thread *td) { struct vn_softc *vn; @@ -251,7 +253,7 @@ vnopen(dev_t dev, int flags, int mode, s IFOPT(vn, VN_FOLLOW) printf("vnopen(%s, 0x%x, 0x%x, %p)\n", - devtoname(dev), flags, mode, (void *)p); + devtoname(dev), flags, mode, (void *)td); /* * Initialize label @@ -310,7 +312,7 @@ vnblockio(struct vn_softc *vn, void *bas auio.uio_segflg = UIO_SYSSPACE; auio.uio_rw = rw; auio.uio_resid = size; - auio.uio_procp = curproc; + auio.uio_td = curthread; if (rw == UIO_READ) error = VOP_READ(vn->sc_vp, &auio, IO_DIRECT, vn->sc_cred); @@ -435,7 +437,7 @@ vnstrategy(struct buf *bp) * still valid. */ - vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curproc); + vn_lock(vn->sc_vp, NULL, LK_EXCLUSIVE | LK_RETRY, curthread); if ((bp->b_flags & B_READ) || vn->sc_crypt == NULL) { /* read operation or non-encrypted device */ enum uio_rw dir; @@ -477,7 +479,7 @@ vnstrategy(struct buf *bp) } } - VOP_UNLOCK(vn->sc_vp, 0, curproc); + VOP_UNLOCK(vn->sc_vp, NULL, 0, curthread); if (error) { bp->b_error = error; @@ -519,7 +521,7 @@ vnstrategy(struct buf *bp) /* ARGSUSED */ static int -vnioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +vnioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct vn_softc *vn; struct vn_ioctl *vio; @@ -529,7 +531,7 @@ vnioctl(dev_t dev, u_long cmd, caddr_t d vn = dev->si_drv1; IFOPT(vn,VN_FOLLOW) printf("vnioctl(%s, 0x%lx, %p, 0x%x, %p): unit %d\n", - devtoname(dev), cmd, (void *)data, flag, (void *)p, + devtoname(dev), cmd, (void *)data, flag, (void *)td, dkunit(dev)); switch (cmd) { @@ -557,7 +559,7 @@ vnioctl(dev_t dev, u_long cmd, caddr_t d vn_specific: if (!userconfig) - error = suser(p); + error = suser(td); else error = 0; if (error) @@ -572,9 +574,9 @@ vnioctl(dev_t dev, u_long cmd, caddr_t d return(EBUSY); if (vio->vn_file == NULL) - error = vniocattach_swap(vn, vio, dev, flag, p); + error = vniocattach_swap(vn, vio, dev, flag, td); else - error = vniocattach_file(vn, vio, dev, flag, p); + error = vniocattach_file(vn, vio, dev, flag, td); break; case VNIOCDETACH: @@ -643,37 +645,37 @@ vnioctl(dev_t dev, u_long cmd, caddr_t d */ static int -vniocattach_file(vn, vio, dev, flag, p) +vniocattach_file(vn, vio, dev, flag, td) struct vn_softc *vn; struct vn_ioctl *vio; dev_t dev; int flag; - struct proc *p; + struct thread *td; { struct vattr vattr; struct nameidata nd; int error, flags; flags = FREAD|FWRITE; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, vio->vn_file, p); + NDINIT(&nd, NAMEI_LOOKUP, CNP_FOLLOW, UIO_USERSPACE, vio->vn_file, td); error = vn_open(&nd, flags, 0); if (error) { if (error != EACCES && error != EPERM && error != EROFS) return (error); flags &= ~FWRITE; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, vio->vn_file, p); + NDINIT(&nd, NAMEI_LOOKUP, CNP_FOLLOW, UIO_USERSPACE, vio->vn_file, td); error = vn_open(&nd, flags, 0); if (error) return (error); } NDFREE(&nd, NDF_ONLY_PNBUF); if (nd.ni_vp->v_type != VREG || - (error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, p))) { - VOP_UNLOCK(nd.ni_vp, 0, p); - (void) vn_close(nd.ni_vp, flags, p->p_ucred, p); + (error = VOP_GETATTR(nd.ni_vp, &vattr, td))) { + VOP_UNLOCK(nd.ni_vp, NULL, 0, curthread); + (void) vn_close(nd.ni_vp, flags, td); return (error ? error : EINVAL); } - VOP_UNLOCK(nd.ni_vp, 0, p); + VOP_UNLOCK(nd.ni_vp, NULL, 0, td); vn->sc_secsize = DEV_BSIZE; vn->sc_vp = nd.ni_vp; @@ -685,9 +687,9 @@ vniocattach_file(vn, vio, dev, flag, p) vn->sc_size = (quad_t)vio->vn_size * PAGE_SIZE / vn->sc_secsize; else vn->sc_size = vattr.va_size / vn->sc_secsize; - error = vnsetcred(vn, p->p_ucred); + error = vnsetcred(vn, td->td_proc->p_ucred); if (error) { - (void) vn_close(nd.ni_vp, flags, p->p_ucred, p); + (void) vn_close(nd.ni_vp, flags, td); return(error); } vn->sc_flags |= VNF_INITED; @@ -701,7 +703,7 @@ vniocattach_file(vn, vio, dev, flag, p) * no other slices or labels are open. Otherwise, * we rely on VNIOCCLR not being abused. */ - error = vnopen(dev, flag, S_IFCHR, p); + error = vnopen(dev, flag, S_IFCHR, td); if (error) vnclear(vn); } @@ -719,12 +721,12 @@ vniocattach_file(vn, vio, dev, flag, p) */ static int -vniocattach_swap(vn, vio, dev, flag, p) +vniocattach_swap(vn, vio, dev, flag, td) struct vn_softc *vn; struct vn_ioctl *vio; dev_t dev; int flag; - struct proc *p; + struct thread *td; { int error; @@ -759,7 +761,7 @@ vniocattach_swap(vn, vio, dev, flag, p) } vn->sc_flags |= VNF_INITED; - error = vnsetcred(vn, p->p_ucred); + error = vnsetcred(vn, td->td_proc->p_ucred); if (error == 0) { IFOPT(vn, VN_LABELS) { /* @@ -769,7 +771,7 @@ vniocattach_swap(vn, vio, dev, flag, p) * no other slices or labels are open. Otherwise, * we rely on VNIOCCLR not being abused. */ - error = vnopen(dev, flag, S_IFCHR, p); + error = vnopen(dev, flag, S_IFCHR, td); } } if (error == 0) { @@ -822,9 +824,9 @@ vnsetcred(struct vn_softc *vn, struct uc auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; auio.uio_resid = aiov.iov_len; - vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curproc); + vn_lock(vn->sc_vp, NULL, LK_EXCLUSIVE | LK_RETRY, curthread); error = VOP_READ(vn->sc_vp, &auio, 0, vn->sc_cred); - VOP_UNLOCK(vn->sc_vp, 0, curproc); + VOP_UNLOCK(vn->sc_vp, NULL, 0, curthread); free(tmpbuf, M_TEMP); } return (error); @@ -833,7 +835,7 @@ vnsetcred(struct vn_softc *vn, struct uc void vnclear(struct vn_softc *vn) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ IFOPT(vn, VN_FOLLOW) printf("vnclear(%p): vp=%p\n", vn, vn->sc_vp); @@ -842,7 +844,7 @@ vnclear(struct vn_softc *vn) vn->sc_flags &= ~VNF_INITED; if (vn->sc_vp != NULL) { (void)vn_close(vn->sc_vp, vn->sc_flags & VNF_READONLY ? - FREAD : (FREAD|FWRITE), vn->sc_cred, p); + FREAD : (FREAD|FWRITE), td); vn->sc_vp = NULL; } vn->sc_flags &= ~VNF_READONLY; Index: vn_aes_cbc.c =================================================================== RCS file: /cvsroot/vncrypt/src/src/sys/dev/vncrypt/vn_aes_cbc.c,v retrieving revision 1.3 diff -u -p -u -r1.3 vn_aes_cbc.c --- vn_aes_cbc.c 25 Feb 2002 21:51:52 -0000 1.3 +++ vn_aes_cbc.c 16 Mar 2004 21:50:06 -0000 @@ -42,7 +42,7 @@ #include #include #include -#include +#include "vn_crypt.h" #include #if BITSPERBLOCK != 128 Index: vn_aes_multi.c =================================================================== RCS file: /cvsroot/vncrypt/src/src/sys/dev/vncrypt/vn_aes_multi.c,v retrieving revision 1.4 diff -u -p -u -r1.4 vn_aes_multi.c --- vn_aes_multi.c 28 Feb 2002 14:28:28 -0000 1.4 +++ vn_aes_multi.c 16 Mar 2004 21:50:06 -0000 @@ -42,7 +42,7 @@ #include #include #include -#include +#include "vn_crypt.h" #include #if BITSPERBLOCK != 128 Index: vn_bf_cbc.c =================================================================== RCS file: /cvsroot/vncrypt/src/src/sys/dev/vncrypt/vn_bf_cbc.c,v retrieving revision 1.9 diff -u -p -u -r1.9 vn_bf_cbc.c --- vn_bf_cbc.c 21 Aug 2002 12:58:58 -0000 1.9 +++ vn_bf_cbc.c 16 Mar 2004 21:50:06 -0000 @@ -42,7 +42,7 @@ #include #include #include -#include +#include "vn_crypt.h" #include #if __FreeBSD_version < 450002 Index: vn_crypt.c =================================================================== RCS file: /cvsroot/vncrypt/src/src/sys/dev/vncrypt/vn_crypt.c,v retrieving revision 1.5 diff -u -p -u -r1.5 vn_crypt.c --- vn_crypt.c 7 Dec 2001 10:10:57 -0000 1.5 +++ vn_crypt.c 16 Mar 2004 21:50:06 -0000 @@ -31,12 +31,13 @@ * */ /* $Id: vn_crypt.c,v 1.5 2001/12/07 10:10:57 rblaze Exp $ */ -#include #include #include #include #include -#include +#include + +#include "vn_crypt.h" MALLOC_DEFINE(M_VNCRYPTKEY, "vncrypt_key", "vncrypt key info");