Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/nilfs Split nilfs_access() to nilfs_check_possible() ...



details:   https://anonhg.NetBSD.org/src/rev/e2a2bfbf9a5f
branches:  trunk
changeset: 746978:e2a2bfbf9a5f
user:      elad <elad%NetBSD.org@localhost>
date:      Wed Aug 26 03:40:48 2009 +0000

description:
Split nilfs_access() to nilfs_check_possible() and nilfs_check_permitted().

diffstat:

 sys/fs/nilfs/nilfs_vnops.c |  69 ++++++++++++++++++++++++++++++----------------
 1 files changed, 45 insertions(+), 24 deletions(-)

diffs (106 lines):

diff -r 55548358a140 -r e2a2bfbf9a5f sys/fs/nilfs/nilfs_vnops.c
--- a/sys/fs/nilfs/nilfs_vnops.c        Wed Aug 26 03:39:16 2009 +0000
+++ b/sys/fs/nilfs/nilfs_vnops.c        Wed Aug 26 03:40:48 2009 +0000
@@ -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



Home | Main Index | Thread Index | Old Index