From ce9c687d5aef3cbe5e23ab18a06aa13bdd5bbfcd Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 2 Apr 1999 05:38:15 +0000 Subject: [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. --- src/ls.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'src') 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 #endif +#if HAVE_SYS_ACL_H +# include +#endif + #include #include #include @@ -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)); -- cgit v1.2.3-54-g00ecf