From ff2751123334f5d80faa47567304d59aed236eba Mon Sep 17 00:00:00 2001 From: trasz Date: Thu, 25 Jun 2009 12:46:59 +0000 Subject: Add NFSv4 ACL support to libc. This adds the following functions to the acl(3) API: acl_add_flag_np, acl_clear_flags_np, acl_create_entry_np, acl_delete_entry_np, acl_delete_flag_np, acl_get_extended_np, acl_get_flag_np, acl_get_flagset_np, acl_set_extended_np, acl_set_flagset_np, acl_to_text_np, acl_is_trivial_np, acl_strip_np, acl_get_brand_np. Most of them are similar to what Darwin does. There are no backward-incompatible changes. Approved by: rwatson@ --- lib/libc/posix1e/acl_init.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'lib/libc/posix1e/acl_init.c') diff --git a/lib/libc/posix1e/acl_init.c b/lib/libc/posix1e/acl_init.c index 905df60..4fe4037 100644 --- a/lib/libc/posix1e/acl_init.c +++ b/lib/libc/posix1e/acl_init.c @@ -38,10 +38,22 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include + +#include "acl_support.h" + +#ifndef CTASSERT +#define CTASSERT(x) _CTASSERT(x, __LINE__) +#define _CTASSERT(x, y) __CTASSERT(x, y) +#define __CTASSERT(x, y) typedef char __assert_ ## y [(x) ? 1 : -1] +#endif + +CTASSERT(1 << _ACL_T_ALIGNMENT_BITS > sizeof(struct acl_t_struct)); acl_t acl_init(int count) { + int error; acl_t acl; if (count > ACL_MAX_ENTRIES) { @@ -53,11 +65,14 @@ acl_init(int count) return (NULL); } - acl = malloc(sizeof(struct acl_t_struct)); - if (acl != NULL) { - bzero(acl, sizeof(struct acl_t_struct)); - acl->ats_acl.acl_maxcnt = ACL_MAX_ENTRIES; - } + error = posix_memalign((void *)&acl, 1 << _ACL_T_ALIGNMENT_BITS, + sizeof(struct acl_t_struct)); + if (error) + return (NULL); + + bzero(acl, sizeof(struct acl_t_struct)); + acl->ats_brand = ACL_BRAND_UNKNOWN; + acl->ats_acl.acl_maxcnt = ACL_MAX_ENTRIES; return (acl); } -- cgit v1.1