diff options
author | Robert Watson <rwatson@FreeBSD.org> | 2002-04-23 01:27:38 +0000 |
---|---|---|
committer | Robert Watson <rwatson@FreeBSD.org> | 2002-04-23 01:27:38 +0000 |
commit | 7a0776e477aec100b36d8398a902131450876cf3 (patch) | |
tree | 7c6aa03e2c40f867bdea35b3eb339ace2c68a68d /sys/kern/vfs_extattr.c | |
parent | 63976b9f34f312b55a4964c95ce0ced884bb90dc (diff) | |
download | src-7a0776e477aec100b36d8398a902131450876cf3.tar.gz src-7a0776e477aec100b36d8398a902131450876cf3.zip |
Slightly restructure extattr_get_vp() so that there's only one entry point
to VOP_GETEXTATTR(). This simplifies code flow when inserting MAC hooks.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
Notes
Notes:
svn path=/head/; revision=95296
Diffstat (limited to 'sys/kern/vfs_extattr.c')
-rw-r--r-- | sys/kern/vfs_extattr.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 5254faa49b4f..24a349a838fd 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -4689,10 +4689,10 @@ static int extattr_get_vp(struct vnode *vp, int attrnamespace, const char *attrname, void *data, size_t nbytes, struct thread *td) { - struct uio auio; + struct uio auio, *auiop; struct iovec aiov; ssize_t cnt; - size_t size; + size_t size, *sizep; int error; VOP_LEASE(vp, td, td->td_ucred, LEASE_READ); @@ -4703,6 +4703,9 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, const char *attrname, * pointer, they don't want to receive the data, just the * maximum read length. */ + auiop = NULL; + sizep = NULL; + cnt = 0; if (data != NULL) { aiov.iov_base = data; aiov.iov_len = nbytes; @@ -4716,16 +4719,20 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, const char *attrname, auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; auio.uio_td = td; + auiop = &auio; cnt = nbytes; - error = VOP_GETEXTATTR(vp, attrnamespace, attrname, &auio, - NULL, td->td_ucred, td); + } else + sizep = &size; + + error = VOP_GETEXTATTR(vp, attrnamespace, attrname, auiop, sizep, + td->td_ucred, td); + + if (auiop != NULL) { cnt -= auio.uio_resid; td->td_retval[0] = cnt; - } else { - error = VOP_GETEXTATTR(vp, attrnamespace, attrname, NULL, - &size, td->td_ucred, td); + } else td->td_retval[0] = size; - } + done: VOP_UNLOCK(vp, 0, td); return (error); |