tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Splitting <fs>_access to two internal routines
Following up on myself:
Elad Efrat wrote:
Are there any objections for such restructuring? if not, I'll follow-up
with a diff implementing the changes for review.
I've attached a diff implementing the proposed changes for ufs_access:
- Functions are named ufs_check_{possible,permitted} as we're
returning an error code rather than a boolean answer,
- The prototypes are:
static int
ufs_check_possible(struct vnode *vp, struct inode *ip,
mode_t mode, kauth_cred_t cred)
static int
ufs_check_permitted(struct vnode *vp, struct inode *ip,
mode_t mode, kauth_cred_t cred)
Looking at other file-systems, it seems that the prototypes will be
similar, except of course for the second argument which will be the
internal node type.
Please have a look -- before I post a diff for all file-systems I'd like
to make sure that the interfaces are acceptable (even if they're
private).
Thanks,
-e.
Index: sys/ufs/ufs/ufs_vnops.c
===================================================================
RCS file: /usr/cvs/src/sys/ufs/ufs/ufs_vnops.c,v
retrieving revision 1.178
diff -u -p -r1.178 ufs_vnops.c
--- sys/ufs/ufs/ufs_vnops.c 23 Jun 2009 19:36:40 -0000 1.178
+++ sys/ufs/ufs/ufs_vnops.c 23 Jun 2009 02:58:23 -0000
@@ -272,24 +272,14 @@ ufs_close(void *v)
return (0);
}
-int
-ufs_access(void *v)
+static int
+ufs_check_possible(struct vnode *vp, struct inode *ip, mode_t mode,
+ kauth_cred_t cred)
{
- struct vop_access_args /* {
- struct vnode *a_vp;
- int a_mode;
- kauth_cred_t a_cred;
- } */ *ap = v;
- struct vnode *vp;
- struct inode *ip;
- mode_t mode;
#ifdef QUOTA
- int error;
-#endif
+ int error;
+#endif /* QUOTA */
- vp = ap->a_vp;
- ip = VTOI(vp);
- mode = ap->a_mode;
/*
* Disallow write attempts on read-only file systems;
* unless the file is a socket, fifo, or a block or
@@ -328,8 +318,40 @@ ufs_access(void *v)
if ((mode & VWRITE) && (ip->i_flags & IMMUTABLE))
return (EPERM);
- return (genfs_can_access(vp->v_type, ip->i_mode & ALLPERMS,
- ip->i_uid, ip->i_gid, mode, ap->a_cred));
+ return 0;
+}
+
+static int
+ufs_check_permitted(struct vnode *vp, struct inode *ip, mode_t mode,
+ kauth_cred_t cred)
+{
+
+ return genfs_can_access(vp->v_type, ip->i_mode & ALLPERMS, ip->i_uid,
+ ip->i_gid, mode, cred);
+}
+
+int
+ufs_access(void *v)
+{
+ struct vop_access_args /* {
+ struct vnode *a_vp;
+ int a_mode;
+ kauth_cred_t a_cred;
+ } */ *ap = v;
+ struct vnode *vp;
+ struct inode *ip;
+ mode_t mode;
+ int error;
+
+ vp = ap->a_vp;
+ ip = VTOI(vp);
+ mode = ap->a_mode;
+
+ error = ufs_check_possible(vp, ip, mode, ap->a_cred);
+ if (error)
+ return error;
+
+ return ufs_check_permitted(vp, ip, mode, ap->a_cred);
}
/* ARGSUSED */
Home |
Main Index |
Thread Index |
Old Index