diff options
author | rwatson <rwatson@FreeBSD.org> | 2002-04-23 01:27:38 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2002-04-23 01:27:38 +0000 |
commit | 780f32f69392793930eb9f59f7b0cc0e10ad9c22 (patch) | |
tree | 7c6aa03e2c40f867bdea35b3eb339ace2c68a68d /sys/kern | |
parent | 7f9efdd860dc4f45acf35743d3b39b4bffe13cdf (diff) | |
download | FreeBSD-src-780f32f69392793930eb9f59f7b0cc0e10ad9c22.zip FreeBSD-src-780f32f69392793930eb9f59f7b0cc0e10ad9c22.tar.gz |
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
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/vfs_extattr.c | 23 | ||||
-rw-r--r-- | sys/kern/vfs_syscalls.c | 23 |
2 files changed, 30 insertions, 16 deletions
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 5254faa..24a349a 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); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 5254faa..24a349a 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.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); |