summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_extattr.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2002-04-23 01:27:38 +0000
committerrwatson <rwatson@FreeBSD.org>2002-04-23 01:27:38 +0000
commit780f32f69392793930eb9f59f7b0cc0e10ad9c22 (patch)
tree7c6aa03e2c40f867bdea35b3eb339ace2c68a68d /sys/kern/vfs_extattr.c
parent7f9efdd860dc4f45acf35743d3b39b4bffe13cdf (diff)
downloadFreeBSD-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/vfs_extattr.c')
-rw-r--r--sys/kern/vfs_extattr.c23
1 files changed, 15 insertions, 8 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);
OpenPOWER on IntegriCloud