1 /* Return the number of entries in an ACL.
3 Copyright (C) 2002-2003, 2005-2013 Free Software Foundation, Inc.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 Written by Paul Eggert and Andreas Gruenbacher. */
22 #include "acl-internal.h"
24 /* This file assumes POSIX-draft like ACLs
25 (Linux, FreeBSD, Mac OS X, IRIX, Tru64). */
27 /* Return the number of entries in ACL.
28 Return -1 and set errno upon failure to determine it. */
31 acl_entries (acl_t acl
)
37 #if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD, Mac OS X */
38 # if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
39 /* acl_get_entry returns 0 when it successfully fetches an entry,
40 and -1/EINVAL at the end. */
44 for (got_one
= acl_get_entry (acl
, ACL_FIRST_ENTRY
, &ace
);
46 got_one
= acl_get_entry (acl
, ACL_NEXT_ENTRY
, &ace
))
48 # else /* Linux, FreeBSD */
49 /* acl_get_entry returns 1 when it successfully fetches an entry,
54 for (got_one
= acl_get_entry (acl
, ACL_FIRST_ENTRY
, &ace
);
56 got_one
= acl_get_entry (acl
, ACL_NEXT_ENTRY
, &ace
))
61 #else /* IRIX, Tru64 */
62 # if HAVE_ACL_TO_SHORT_TEXT /* IRIX */
63 /* Don't use acl_get_entry: it is undocumented. */
66 # if HAVE_ACL_FREE_TEXT /* Tru64 */
67 /* Don't use acl_get_entry: it takes only one argument and does not