summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorbmilekic <bmilekic@FreeBSD.org>2004-04-03 16:55:56 +0000
committerbmilekic <bmilekic@FreeBSD.org>2004-04-03 16:55:56 +0000
commit7204d752f03abbfdd460f798e8a85fe0ca6bb7b3 (patch)
tree28ad418aceb5508d4c74a09bb0b205944312cf1f /bin
parent1d37410c51d4ea614965891eab4e733f3c683f23 (diff)
downloadFreeBSD-src-7204d752f03abbfdd460f798e8a85fe0ca6bb7b3.zip
FreeBSD-src-7204d752f03abbfdd460f798e8a85fe0ca6bb7b3.tar.gz
Stop iterating over ACLs if we've already determined we
will print them (i.e., number of successful calls to acl_get_entry() exceeds 3). This makes O(1) what was O(num_TYPE_ACCESS_ACLs). This is a slightly modified version of submitter's patch. PR: bin/65042 Submitted by: Christian S.J. Peron <maneo@bsdpro.com>
Diffstat (limited to 'bin')
-rw-r--r--bin/ls/print.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/bin/ls/print.c b/bin/ls/print.c
index d4cae67..e5f2575 100644
--- a/bin/ls/print.c
+++ b/bin/ls/print.c
@@ -694,11 +694,17 @@ aclmode(char *buf, const FTSENT *p, int *haveacls)
*haveacls = 1;
if ((facl = acl_get_file(name, ACL_TYPE_ACCESS)) != NULL) {
if (acl_get_entry(facl, ACL_FIRST_ENTRY, &ae) == 1) {
- entries = 0;
- do
- entries++;
- while (acl_get_entry(facl, ACL_NEXT_ENTRY, &ae) == 1);
- if (entries != 3)
+ entries = 1;
+ while (acl_get_entry(facl, ACL_NEXT_ENTRY, &ae) == 1)
+ if (++entries > 3)
+ break;
+ /*
+ * POSIX.1e requires that ACLs of type ACL_TYPE_ACCESS
+ * must have at least three entries (owner, group,
+ * and other). So anything with more than 3 ACLs looks
+ * interesting to us.
+ */
+ if (entries > 3)
buf[10] = '+';
}
acl_free(facl);
OpenPOWER on IntegriCloud