summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-04-02 05:38:15 +0000
committerJim Meyering <jim@meyering.net>1999-04-02 05:38:15 +0000
commitce9c687d5aef3cbe5e23ab18a06aa13bdd5bbfcd (patch)
tree73f9a9210b08631f80f32a819fc3c30b336de861 /src
parenteaaff3246a7b4ae396cfdeb384c545775be2d0cf (diff)
downloadcoreutils-ce9c687d5aef3cbe5e23ab18a06aa13bdd5bbfcd.tar.xz
[HAVE_SYS_ACL_H]: Include sys/acl.h.
(struct fileinfo): New member `have_acl'. (gobble_file): Initialize it. (print_long_format): Use it. Mostly from Alen Muzinic.
Diffstat (limited to 'src')
-rw-r--r--src/ls.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/ls.c b/src/ls.c
index cc37308e9..f30094d6a 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -60,6 +60,10 @@
# include <sys/ptem.h>
#endif
+#if HAVE_SYS_ACL_H
+# include <sys/acl.h>
+#endif
+
#include <stdio.h>
#include <grp.h>
#include <pwd.h>
@@ -158,8 +162,20 @@ struct fileinfo
int linkok;
enum filetype filetype;
+
+#if HAVE_ACL
+ /* For long listings, nonzero if the file has an access control list,
+ otherwise zero. */
+ int have_acl;
+#endif
};
+#if HAVE_ACL
+# define FILE_HAS_ACL(F) ((F)->have_acl)
+#else
+# define FILE_HAS_ACL(F) 0
+#endif
+
#define LEN_STR_PAIR(s) sizeof (s) - 1, s
/* Null is a valid character in a color indicator (think about Epson
@@ -1715,13 +1731,18 @@ gobble_file (const char *name, int explicit_arg, const char *dirname)
{
val = stat (path, &files[files_index].stat);
if (val < 0)
- /* Perhaps a symbolically-linked to file doesn't exist; stat
- the link instead. */
- val = lstat (path, &files[files_index].stat);
+ {
+ /* Perhaps a symbolically-linked to file doesn't exist; stat
+ the link instead. */
+ val = lstat (path, &files[files_index].stat);
+ }
}
else
{
val = lstat (path, &files[files_index].stat);
+#if HAVE_ACL
+ files[files_index].have_acl = (acl (path, GETACLCNT, 0, NULL) > 4);
+#endif
}
if (val < 0)
@@ -2151,7 +2172,7 @@ print_current_files (void)
static void
print_long_format (const struct fileinfo *f)
{
- char modebuf[11];
+ char modebuf[12];
/* 7 fields that may require LONGEST_HUMAN_READABLE bytes,
1 10-byte mode string,
@@ -2178,7 +2199,8 @@ print_long_format (const struct fileinfo *f)
mode_string (f->stat.st_mode, modebuf);
#endif
- modebuf[10] = '\0';
+ modebuf[10] = (FILE_HAS_ACL (f) ? '+' : ' ');
+ modebuf[11] = '\0';
switch (time_type)
{
@@ -2235,9 +2257,9 @@ print_long_format (const struct fileinfo *f)
p += strlen (p);
}
- /* The space between the mode and the number of links is the POSIX
- "optional alternate access method flag". */
- sprintf (p, "%s %3u ", modebuf, (unsigned int) f->stat.st_nlink);
+ /* The last byte of the mode string is the POSIX
+ "optional alternate access method flag". */
+ sprintf (p, "%s%3u ", modebuf, (unsigned int) f->stat.st_nlink);
p += strlen (p);
user_name = (numeric_ids ? NULL : getuser (f->stat.st_uid));