summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_acl.c
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2009-04-18 16:47:33 +0000
committertrasz <trasz@FreeBSD.org>2009-04-18 16:47:33 +0000
commit858b10f6e2c8e94e4810f7789837166f0cb2701c (patch)
treead51ac610ee5b776443a5dbf46be0e0c4de1c9c4 /sys/kern/vfs_acl.c
parentc18c28353dc66cc25c439ccf86c893b190476c2c (diff)
downloadFreeBSD-src-858b10f6e2c8e94e4810f7789837166f0cb2701c.zip
FreeBSD-src-858b10f6e2c8e94e4810f7789837166f0cb2701c.tar.gz
Use acl_alloc() and acl_free() instead of using uma(9) directly.
This will make switching to malloc(9) easier; also, it would be neccessary to add these routines if/when we implement variable-size ACLs.
Diffstat (limited to 'sys/kern/vfs_acl.c')
-rw-r--r--sys/kern/vfs_acl.c55
1 files changed, 40 insertions, 15 deletions
diff --git a/sys/kern/vfs_acl.c b/sys/kern/vfs_acl.c
index 6a7c461..c6ade04 100644
--- a/sys/kern/vfs_acl.c
+++ b/sys/kern/vfs_acl.c
@@ -81,28 +81,31 @@ static int
vacl_set_acl(struct thread *td, struct vnode *vp, acl_type_t type,
struct acl *aclp)
{
- struct acl inkernacl;
+ struct acl *inkernelacl;
struct mount *mp;
int error;
- error = copyin(aclp, &inkernacl, sizeof(struct acl));
+ inkernelacl = acl_alloc(M_WAITOK);
+ error = copyin(aclp, inkernelacl, sizeof(struct acl));
if (error)
- return(error);
+ goto out;
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error != 0)
- return (error);
+ goto out;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
#ifdef MAC
- error = mac_vnode_check_setacl(td->td_ucred, vp, type, &inkernacl);
+ error = mac_vnode_check_setacl(td->td_ucred, vp, type, inkernelacl);
if (error != 0)
- goto out;
+ goto out_unlock;
#endif
- error = VOP_SETACL(vp, type, &inkernacl, td->td_ucred, td);
+ error = VOP_SETACL(vp, type, inkernelacl, td->td_ucred, td);
#ifdef MAC
-out:
+out_unlock:
#endif
VOP_UNLOCK(vp, 0);
vn_finished_write(mp);
+out:
+ acl_free(inkernelacl);
return(error);
}
@@ -113,22 +116,24 @@ static int
vacl_get_acl(struct thread *td, struct vnode *vp, acl_type_t type,
struct acl *aclp)
{
- struct acl inkernelacl;
+ struct acl *inkernelacl;
int error;
+ inkernelacl = acl_alloc(M_WAITOK);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
#ifdef MAC
error = mac_vnode_check_getacl(td->td_ucred, vp, type);
if (error != 0)
goto out;
#endif
- error = VOP_GETACL(vp, type, &inkernelacl, td->td_ucred, td);
+ error = VOP_GETACL(vp, type, inkernelacl, td->td_ucred, td);
#ifdef MAC
out:
#endif
VOP_UNLOCK(vp, 0);
if (error == 0)
- error = copyout(&inkernelacl, aclp, sizeof(struct acl));
+ error = copyout(inkernelacl, aclp, sizeof(struct acl));
+ acl_free(inkernelacl);
return (error);
}
@@ -166,13 +171,16 @@ static int
vacl_aclcheck(struct thread *td, struct vnode *vp, acl_type_t type,
struct acl *aclp)
{
- struct acl inkernelacl;
+ struct acl *inkernelacl;
int error;
- error = copyin(aclp, &inkernelacl, sizeof(struct acl));
+ inkernelacl = acl_alloc(M_WAITOK);
+ error = copyin(aclp, inkernelacl, sizeof(struct acl));
if (error)
- return(error);
- error = VOP_ACLCHECK(vp, type, &inkernelacl, td->td_ucred, td);
+ goto out;
+ error = VOP_ACLCHECK(vp, type, inkernelacl, td->td_ucred, td);
+out:
+ acl_free(inkernelacl);
return (error);
}
@@ -417,6 +425,23 @@ __acl_aclcheck_fd(struct thread *td, struct __acl_aclcheck_fd_args *uap)
return (error);
}
+struct acl *
+acl_alloc(int flags)
+{
+ struct acl *aclp;
+
+ aclp = uma_zalloc(acl_zone, flags);
+
+ return (aclp);
+}
+
+void
+acl_free(struct acl *aclp)
+{
+
+ uma_zfree(acl_zone, aclp);
+}
+
/* ARGUSED */
static void
OpenPOWER on IntegriCloud