1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00

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
This commit is contained in:
Robert Watson 2002-04-23 01:27:38 +00:00
parent 63976b9f34
commit 7a0776e477
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=95296
2 changed files with 30 additions and 16 deletions

View File

@ -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);

View File

@ -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);