summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorPedro Martelletto <pedro@cvs.openbsd.org>2005-12-04 19:04:14 +0000
committerPedro Martelletto <pedro@cvs.openbsd.org>2005-12-04 19:04:14 +0000
commit0784df37f109c63efd07397600cbfaee98bea99b (patch)
tree452e61f31854a703be423c105c5e4ad1763e583c /sys/kern
parent5b9770a66fa930d5377ccb011a772079302e062f (diff)
Add vn_access(), discussed with and okay uwe@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_vnops.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 0f9506282d8..17fd874d989 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_vnops.c,v 1.47 2005/11/20 21:55:15 pedro Exp $ */
+/* $OpenBSD: vfs_vnops.c,v 1.48 2005/12/04 19:04:13 pedro Exp $ */
/* $NetBSD: vfs_vnops.c,v 1.20 1996/02/04 02:18:41 christos Exp $ */
/*
@@ -484,3 +484,21 @@ vn_kqfilter(struct file *fp, struct knote *kn)
{
return (VOP_KQFILTER(((struct vnode *)fp->f_data), kn));
}
+
+/*
+ * Common code for vnode access operations.
+ */
+int
+vn_access(struct vnode *vp, int mode)
+{
+ struct proc *p = curproc;
+ int error;
+
+ if ((error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p)))
+ return (error);
+
+ error = VOP_ACCESS(vp, mode, p->p_ucred, p);
+ VOP_UNLOCK(vp, 0, p);
+
+ return (error);
+}