diff options
author | trasz <trasz@FreeBSD.org> | 2009-04-18 16:47:33 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2009-04-18 16:47:33 +0000 |
commit | 858b10f6e2c8e94e4810f7789837166f0cb2701c (patch) | |
tree | ad51ac610ee5b776443a5dbf46be0e0c4de1c9c4 /sys | |
parent | c18c28353dc66cc25c439ccf86c893b190476c2c (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sys/kern/vfs_acl.c | 55 | ||||
-rw-r--r-- | sys/sys/acl.h | 4 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 38 |
3 files changed, 61 insertions, 36 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 diff --git a/sys/sys/acl.h b/sys/sys/acl.h index e875385b..6e4a731 100644 --- a/sys/sys/acl.h +++ b/sys/sys/acl.h @@ -116,8 +116,6 @@ typedef struct acl_t_struct *acl_t; #ifdef _KERNEL -extern uma_zone_t acl_zone; - /* * POSIX.1e ACLs are capable of expressing the read, write, and execute bits * of the POSIX mode field. We provide two masks: one that defines the bits @@ -141,6 +139,8 @@ mode_t acl_posix1e_perms_to_mode( mode_t acl_posix1e_acl_to_mode(struct acl *acl); mode_t acl_posix1e_newfilemode(mode_t cmode, struct acl *dacl); +struct acl *acl_alloc(int flags); +void acl_free(struct acl *aclp); /* * File system independent syntax check for a POSIX.1e ACL. diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 675c55c..7646b05 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -374,7 +374,7 @@ relock: #ifdef UFS_ACL if ((vp->v_mount->mnt_flag & MNT_ACLS) != 0) { - acl = uma_zalloc(acl_zone, M_WAITOK); + acl = acl_alloc(M_WAITOK); error = VOP_GETACL(vp, ACL_TYPE_ACCESS, acl, ap->a_cred, ap->a_td); switch (error) { @@ -398,7 +398,7 @@ relock: error = vaccess(vp->v_type, ip->i_mode, ip->i_uid, ip->i_gid, ap->a_accmode, ap->a_cred, NULL); } - uma_zfree(acl_zone, acl); + acl_free(acl); } else #endif /* !UFS_ACL */ error = vaccess(vp->v_type, ip->i_mode, ip->i_uid, ip->i_gid, @@ -1507,8 +1507,8 @@ ufs_mkdir(ap) #ifdef UFS_ACL acl = dacl = NULL; if ((dvp->v_mount->mnt_flag & MNT_ACLS) != 0) { - acl = uma_zalloc(acl_zone, M_WAITOK); - dacl = uma_zalloc(acl_zone, M_WAITOK); + acl = acl_alloc(M_WAITOK); + dacl = acl_alloc(M_WAITOK); /* * Retrieve default ACL from parent, if any. @@ -1538,16 +1538,16 @@ ufs_mkdir(ap) */ ip->i_mode = dmode; DIP_SET(ip, i_mode, dmode); - uma_zfree(acl_zone, acl); - uma_zfree(acl_zone, dacl); + acl_free(acl); + acl_free(dacl); dacl = acl = NULL; break; default: UFS_VFREE(tvp, ip->i_number, dmode); vput(tvp); - uma_zfree(acl_zone, acl); - uma_zfree(acl_zone, dacl); + acl_free(acl); + acl_free(dacl); return (error); } } else { @@ -1617,13 +1617,13 @@ ufs_mkdir(ap) break; default: - uma_zfree(acl_zone, acl); - uma_zfree(acl_zone, dacl); + acl_free(acl); + acl_free(dacl); dacl = acl = NULL; goto bad; } - uma_zfree(acl_zone, acl); - uma_zfree(acl_zone, dacl); + acl_free(acl); + acl_free(dacl); dacl = acl = NULL; } #endif /* !UFS_ACL */ @@ -1689,9 +1689,9 @@ bad: } else { #ifdef UFS_ACL if (acl != NULL) - uma_zfree(acl_zone, acl); + acl_free(acl); if (dacl != NULL) - uma_zfree(acl_zone, dacl); + acl_free(dacl); #endif dp->i_effnlink--; dp->i_nlink--; @@ -2325,7 +2325,7 @@ ufs_makeinode(mode, dvp, vpp, cnp) #ifdef UFS_ACL acl = NULL; if ((dvp->v_mount->mnt_flag & MNT_ACLS) != 0) { - acl = uma_zalloc(acl_zone, M_WAITOK); + acl = acl_alloc(M_WAITOK); /* * Retrieve default ACL for parent, if any. @@ -2360,14 +2360,14 @@ ufs_makeinode(mode, dvp, vpp, cnp) */ ip->i_mode = mode; DIP_SET(ip, i_mode, mode); - uma_zfree(acl_zone, acl); + acl_free(acl); acl = NULL; break; default: UFS_VFREE(tvp, ip->i_number, mode); vput(tvp); - uma_zfree(acl_zone, acl); + acl_free(acl); acl = NULL; return (error); } @@ -2433,10 +2433,10 @@ ufs_makeinode(mode, dvp, vpp, cnp) break; default: - uma_zfree(acl_zone, acl); + acl_free(acl); goto bad; } - uma_zfree(acl_zone, acl); + acl_free(acl); } #endif /* !UFS_ACL */ ufs_makedirentry(ip, cnp, &newdir); |