From owner-svn-src-head@FreeBSD.ORG Sat Apr 18 16:47:34 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 02B231065672; Sat, 18 Apr 2009 16:47:34 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DA2B28FC13; Sat, 18 Apr 2009 16:47:33 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n3IGlXKs081438; Sat, 18 Apr 2009 16:47:33 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3IGlXdp081435; Sat, 18 Apr 2009 16:47:33 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <200904181647.n3IGlXdp081435@svn.freebsd.org> From: Edward Tomasz Napierala Date: Sat, 18 Apr 2009 16:47:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r191249 - in head/sys: kern sys ufs/ufs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Apr 2009 16:47:35 -0000 Author: trasz Date: Sat Apr 18 16:47:33 2009 New Revision: 191249 URL: http://svn.freebsd.org/changeset/base/191249 Log: 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. Modified: head/sys/kern/vfs_acl.c head/sys/sys/acl.h head/sys/ufs/ufs/ufs_vnops.c Modified: head/sys/kern/vfs_acl.c ============================================================================== --- head/sys/kern/vfs_acl.c Sat Apr 18 16:36:27 2009 (r191248) +++ head/sys/kern/vfs_acl.c Sat Apr 18 16:47:33 2009 (r191249) @@ -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, str 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 Modified: head/sys/sys/acl.h ============================================================================== --- head/sys/sys/acl.h Sat Apr 18 16:36:27 2009 (r191248) +++ head/sys/sys/acl.h Sat Apr 18 16:47:33 2009 (r191249) @@ -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. Modified: head/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- head/sys/ufs/ufs/ufs_vnops.c Sat Apr 18 16:36:27 2009 (r191248) +++ head/sys/ufs/ufs/ufs_vnops.c Sat Apr 18 16:47:33 2009 (r191249) @@ -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);