diff options
author | phk <phk@FreeBSD.org> | 1999-08-31 21:01:57 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1999-08-31 21:01:57 +0000 |
commit | 06a6c50517f44cfc4d72a6688a9a523e64de4866 (patch) | |
tree | 793174efa446efae8a69cd713e43a82dd8dafa02 /sys/fs | |
parent | 606e8cc53ce6cd3fb81a1891e3c5d0bb59940c3f (diff) | |
download | FreeBSD-src-06a6c50517f44cfc4d72a6688a9a523e64de4866.zip FreeBSD-src-06a6c50517f44cfc4d72a6688a9a523e64de4866.tar.gz |
Make buffered acces to bdevs from userland controllable with
a sysctl vfs.bdev_access.
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/specfs/spec_vnops.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c index e097ef8..d16b9e6 100644 --- a/sys/fs/specfs/spec_vnops.c +++ b/sys/fs/specfs/spec_vnops.c @@ -47,6 +47,7 @@ #include <sys/fcntl.h> #include <sys/disklabel.h> #include <sys/vmmeter.h> +#include <sys/sysctl.h> #include <vm/vm.h> #include <vm/vm_prot.h> @@ -234,6 +235,15 @@ spec_open(ap) return (0); } +#ifdef ALLOW_BDEV_ACCESS +static int bdev_access = 1; +#else +static int bdev_access; +#endif + +SYSCTL_INT(_vfs, OID_AUTO, bdev_access, CTLFLAG_RW, &bdev_access, 0, + "allow block device access"); + /* * Vnode op for read */ @@ -247,8 +257,8 @@ spec_read(ap) struct ucred *a_cred; } */ *ap; { - register struct vnode *vp = ap->a_vp; - register struct uio *uio = ap->a_uio; + struct vnode *vp = ap->a_vp; + struct uio *uio = ap->a_uio; struct proc *p = uio->uio_procp; struct buf *bp; daddr_t bn, nextbn; @@ -273,7 +283,7 @@ spec_read(ap) switch (vp->v_type) { case VBLK: -#ifdef ALLOW_BDEV_ACCESS +if (bdev_access) { if (uio->uio_offset < 0) return (EINVAL); @@ -307,7 +317,7 @@ spec_read(ap) brelse(bp); } while (error == 0 && uio->uio_resid > 0 && n != 0); return (error); -#endif /* ALLOW_BDEV_ACCESS */ +} case VCHR: VOP_UNLOCK(vp, 0, p); error = (*devsw(dev)->d_read) (dev, uio, ap->a_ioflag); @@ -333,8 +343,8 @@ spec_write(ap) struct ucred *a_cred; } */ *ap; { - register struct vnode *vp = ap->a_vp; - register struct uio *uio = ap->a_uio; + struct vnode *vp = ap->a_vp; + struct uio *uio = ap->a_uio; struct proc *p = uio->uio_procp; struct buf *bp; daddr_t bn; @@ -357,7 +367,7 @@ spec_write(ap) switch (vp->v_type) { case VBLK: -#ifdef ALLOW_BDEV_ACCESS +if (bdev_access) { if (uio->uio_offset < 0) return (EINVAL); @@ -393,7 +403,7 @@ spec_write(ap) bdwrite(bp); } while (error == 0 && uio->uio_resid > 0 && n != 0); return (error); -#endif /* ALLOW_BDEV_ACCESS */ +} case VCHR: VOP_UNLOCK(vp, 0, p); |