diff options
author | trasz <trasz@FreeBSD.org> | 2009-06-25 12:46:59 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2009-06-25 12:46:59 +0000 |
commit | ff2751123334f5d80faa47567304d59aed236eba (patch) | |
tree | 2ef84b1a3d387c8edf2b81194552ad8337bd003b /lib/libc/posix1e/acl_entry.c | |
parent | 9a27798fa1cde67ed249d166ee358fee1a684179 (diff) | |
download | FreeBSD-src-ff2751123334f5d80faa47567304d59aed236eba.zip FreeBSD-src-ff2751123334f5d80faa47567304d59aed236eba.tar.gz |
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@
Diffstat (limited to 'lib/libc/posix1e/acl_entry.c')
-rw-r--r-- | lib/libc/posix1e/acl_entry.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/libc/posix1e/acl_entry.c b/lib/libc/posix1e/acl_entry.c index 407aff1..56396f9 100644 --- a/lib/libc/posix1e/acl_entry.c +++ b/lib/libc/posix1e/acl_entry.c @@ -74,6 +74,48 @@ acl_create_entry(acl_t *acl_p, acl_entry_t *entry_p) return (0); } +int +acl_create_entry_np(acl_t *acl_p, acl_entry_t *entry_p, int offset) +{ + int i; + struct acl *acl_int; + + if (acl_p == NULL) { + errno = EINVAL; + return (-1); + } + + acl_int = &(*acl_p)->ats_acl; + + if ((acl_int->acl_cnt + 1 >= ACL_MAX_ENTRIES) || (acl_int->acl_cnt < 0)) { + errno = EINVAL; + return (-1); + } + + if (offset < 0 || offset >= acl_int->acl_cnt) { + errno = EINVAL; + return (-1); + } + + /* Make room for the new entry. */ + for (i = acl_int->acl_cnt; i > offset; i--) + acl_int->acl_entry[i] = acl_int->acl_entry[i - 1]; + + acl_int->acl_cnt++; + + *entry_p = &acl_int->acl_entry[offset]; + + (**entry_p).ae_tag = ACL_UNDEFINED_TAG; + (**entry_p).ae_id = ACL_UNDEFINED_ID; + (**entry_p).ae_perm = ACL_PERM_NONE; + (**entry_p).ae_entry_type = 0; + (**entry_p).ae_flags= 0; + + (*acl_p)->ats_cur_entry = 0; + + return (0); +} + /* * acl_get_entry() (23.4.14): returns an ACL entry from an ACL * indicated by entry_id. |