Module Name: src
Committed By: elad
Date: Wed Aug 26 03:40:48 UTC 2009
Modified Files:
src/sys/fs/nilfs: nilfs_vnops.c
Log Message:
Split nilfs_access() to nilfs_check_possible() and nilfs_check_permitted().
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/fs/nilfs/nilfs_vnops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/fs/nilfs/nilfs_vnops.c
diff -u src/sys/fs/nilfs/nilfs_vnops.c:1.1 src/sys/fs/nilfs/nilfs_vnops.c:1.2
--- src/sys/fs/nilfs/nilfs_vnops.c:1.1 Sat Jul 18 16:31:42 2009
+++ src/sys/fs/nilfs/nilfs_vnops.c Wed Aug 26 03:40:48 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vnops.c,v 1.1 2009/07/18 16:31:42 reinoud Exp $ */
+/* $NetBSD: nilfs_vnops.c,v 1.2 2009/08/26 03:40:48 elad Exp $ */
/*
* Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.1 2009/07/18 16:31:42 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.2 2009/08/26 03:40:48 elad Exp $");
#endif /* not lint */
@@ -971,31 +971,13 @@
/* --------------------------------------------------------------------- */
-int
-nilfs_access(void *v)
+static int
+nilfs_check_possible(struct vnode *vp, struct vattr *vap, mode_t mode)
{
- struct vop_access_args /* {
- struct vnode *a_vp;
- int a_mode;
- kauth_cred_t a_cred;
- struct proc *a_p;
- } */ *ap = v;
- struct vnode *vp = ap->a_vp;
- mode_t mode = ap->a_mode;
- kauth_cred_t cred = ap->a_cred;
- /* struct nilfs_node *nilfs_node = VTOI(vp); */
- struct vattr vap;
int flags;
- int error;
-
- DPRINTF(VFSCALL, ("nilfs_access called\n"));
-
- error = VOP_GETATTR(vp, &vap, NULL);
- if (error)
- return error;
/* check if we are allowed to write */
- switch (vap.va_type) {
+ switch (vap->va_type) {
case VDIR:
case VLNK:
case VREG:
@@ -1026,12 +1008,51 @@
if ((mode & VWRITE) && (flags & IMMUTABLE))
return EPERM;
+ return 0;
+}
+
+static int
+nilfs_check_permitted(struct vnode *vp, struct vattr *vap, mode_t mode,
+ kauth_cred_t cred)
+{
+
/* ask the generic genfs_can_access to advice on security */
return genfs_can_access(vp->v_type,
- vap.va_mode, vap.va_uid, vap.va_gid,
+ vap->va_mode, vap->va_uid, vap->va_gid,
mode, cred);
}
+int
+nilfs_access(void *v)
+{
+ struct vop_access_args /* {
+ struct vnode *a_vp;
+ int a_mode;
+ kauth_cred_t a_cred;
+ struct proc *a_p;
+ } */ *ap = v;
+ struct vnode *vp = ap->a_vp;
+ mode_t mode = ap->a_mode;
+ kauth_cred_t cred = ap->a_cred;
+ /* struct nilfs_node *nilfs_node = VTOI(vp); */
+ struct vattr vap;
+ int error;
+
+ DPRINTF(VFSCALL, ("nilfs_access called\n"));
+
+ error = VOP_GETATTR(vp, &vap, NULL);
+ if (error)
+ return error;
+
+ error = nilfs_check_possible(vp, &vap, mode);
+ if (error)
+ return error;
+
+ error = nilfs_check_permitted(vp, &vap, mode, cred);
+
+ return error;
+}
+
/* --------------------------------------------------------------------- */
int