Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/fs/filecorefs/filecore_vnops.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/fs/filecorefs/filecore_vnops.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.28 retrieving revision 1.28.4.2 diff -u -p -r1.28 -r1.28.4.2 --- src/sys/fs/filecorefs/filecore_vnops.c 2008/11/26 20:17:33 1.28 +++ src/sys/fs/filecorefs/filecore_vnops.c 2009/07/23 23:32:32 1.28.4.2 @@ -1,4 +1,4 @@ -/* $NetBSD: filecore_vnops.c,v 1.28 2008/11/26 20:17:33 pooka Exp $ */ +/* $NetBSD: filecore_vnops.c,v 1.28.4.2 2009/07/23 23:32:32 jym Exp $ */ /*- * Copyright (c) 1994 The Regents of the University of California. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: filecore_vnops.c,v 1.28 2008/11/26 20:17:33 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: filecore_vnops.c,v 1.28.4.2 2009/07/23 23:32:32 jym Exp $"); #include #include @@ -91,30 +91,17 @@ __KERNEL_RCSID(0, "$NetBSD: filecore_vno #include #include -/* - * Check mode permission on inode pointer. Mode is READ, WRITE or EXEC. - * The mode is shifted to select the owner/group/other fields. The - * super user is granted all permissions. - */ -int -filecore_access(v) - void *v; +static int +filecore_check_possible(struct vnode *vp, struct filecore_node *ip, + mode_t mode) { - struct vop_access_args /* { - struct vnode *a_vp; - int a_mode; - kauth_cred_t a_cred; - } */ *ap = v; - struct vnode *vp = ap->a_vp; - struct filecore_node *ip = VTOI(vp); - struct filecore_mnt *fcmp = ip->i_mnt; /* * Disallow write attempts unless the file is a socket, * fifo, or a block or character device resident on the * file system. */ - if (ap->a_mode & VWRITE) { + if (mode & VWRITE) { switch (vp->v_type) { case VDIR: case VLNK: @@ -125,13 +112,47 @@ filecore_access(v) } } - return (vaccess(vp->v_type, filecore_mode(ip), - fcmp->fc_uid, fcmp->fc_gid, ap->a_mode, ap->a_cred)); + return 0; +} + +/* + * Check mode permission on inode pointer. Mode is READ, WRITE or EXEC. + * The mode is shifted to select the owner/group/other fields. The + * super user is granted all permissions. + */ +static int +filecore_check_permitted(struct vnode *vp, struct filecore_node *ip, + mode_t mode, kauth_cred_t cred) +{ + struct filecore_mnt *fcmp = ip->i_mnt; + + return genfs_can_access(vp->v_type, filecore_mode(ip), + fcmp->fc_uid, fcmp->fc_gid, mode, cred); +} + +int +filecore_access(void *v) +{ + struct vop_access_args /* { + struct vnode *a_vp; + int a_mode; + kauth_cred_t a_cred; + } */ *ap = v; + struct vnode *vp = ap->a_vp; + struct filecore_node *ip = VTOI(vp); + int error; + + error = filecore_check_possible(vp, ip, ap->a_mode); + if (error) + return error; + + error = filecore_check_permitted(vp, ip, ap->a_mode, ap->a_cred); + + return error; } int -filecore_getattr(v) - void *v; +filecore_getattr(void *v) { struct vop_getattr_args /* { struct vnode *a_vp; @@ -168,8 +189,7 @@ filecore_getattr(v) * Vnode op for reading. */ int -filecore_read(v) - void *v; +filecore_read(void *v) { struct vop_read_args /* { struct vnode *a_vp; @@ -263,8 +283,7 @@ out: * Vnode op for readdir */ int -filecore_readdir(v) - void *v; +filecore_readdir(void *v) { struct vop_readdir_args /* { struct vnode *a_vp; @@ -390,8 +409,7 @@ out: * But otherwise the block read here is in the block buffer two times. */ int -filecore_readlink(v) - void *v; +filecore_readlink(void *v) { #if 0 struct vop_readlink_args /* { @@ -405,8 +423,7 @@ filecore_readlink(v) } int -filecore_link(v) - void *v; +filecore_link(void *v) { struct vop_link_args /* { struct vnode *a_dvp; @@ -420,8 +437,7 @@ filecore_link(v) } int -filecore_symlink(v) - void *v; +filecore_symlink(void *v) { struct vop_symlink_args /* { struct vnode *a_dvp; @@ -441,8 +457,7 @@ filecore_symlink(v) * then call the device strategy routine. */ int -filecore_strategy(v) - void *v; +filecore_strategy(void *v) { struct vop_strategy_args /* { struct vnode *a_vp; @@ -477,8 +492,7 @@ filecore_strategy(v) */ /*ARGSUSED*/ int -filecore_print(v) - void *v; +filecore_print(void *v) { printf("tag VT_FILECORE, filecore vnode\n"); @@ -489,8 +503,7 @@ filecore_print(v) * Return POSIX pathconf information applicable to filecore filesystems. */ int -filecore_pathconf(v) - void *v; +filecore_pathconf(void *v) { struct vop_pathconf_args /* { struct vnode *a_vp; @@ -546,7 +559,7 @@ filecore_pathconf(v) /* * Global vfs data structures for filecore */ -int (**filecore_vnodeop_p) __P((void *)); +int (**filecore_vnodeop_p)(void *); const struct vnodeopv_entry_desc filecore_vnodeop_entries[] = { { &vop_default_desc, vn_default_error }, { &vop_lookup_desc, filecore_lookup }, /* lookup */