diff -uprN coreutils-6.9-base/src/ls.c coreutils-6.9/src/ls.c --- coreutils-6.9-base/src/ls.c 2007-03-18 14:36:43.000000000 -0700 +++ coreutils-6.9/src/ls.c 2007-04-17 06:42:14.000000000 -0700 @@ -37,6 +37,7 @@ #include #include +#include #if HAVE_TERMIOS_H # include @@ -180,6 +181,9 @@ struct fileinfo /* For long listings, true if the file has an access control list, or an SELinux security context. */ bool have_acl; + + /* Smack label */ + char smack[8]; }; #define LEN_STR_PAIR(s) sizeof (s) - 1, s @@ -640,6 +644,10 @@ static size_t tabsize; static bool print_dir_name; +/* True means print the SMACK attribute. */ + +static bool print_smack; + /* The line length to use for breaking lines in many-per-line format. Can be set with -w. */ @@ -764,6 +772,7 @@ static struct option const long_options[ {"ignore", required_argument, NULL, 'I'}, {"indicator-style", required_argument, NULL, INDICATOR_STYLE_OPTION}, {"dereference", no_argument, NULL, 'L'}, + {"smack", no_argument, NULL, 'M'}, {"literal", no_argument, NULL, 'N'}, {"quote-name", no_argument, NULL, 'Q'}, {"quoting-style", required_argument, NULL, QUOTING_STYLE_OPTION}, @@ -1508,7 +1517,7 @@ decode_switches (int argc, char **argv) { int oi = -1; int c = getopt_long (argc, argv, - "abcdfghiklmnopqrstuvw:xABCDFGHI:LNQRST:UXZ1", + "abcdfghiklmnopqrstuvw:xABCDFGHI:LMNQRST:UX1", long_options, &oi); if (c == -1) break; @@ -1671,6 +1680,10 @@ decode_switches (int argc, char **argv) dereference = DEREF_ALWAYS; break; + case 'M': + print_smack = true; + break; + case 'N': set_quoting_style (NULL, literal_quoting_style); break; @@ -2817,6 +2833,18 @@ gobble_file (char const *name, enum file file_size_width = len; } } + + if (print_smack) + { + int len = 0; + int err = getxattr (absolute_name, "security.SMACK64", f->smack, &len); + if (err < 0) + { +perror(absolute_name); + f->smack[0] = '?'; + f->smack[1] = '\0'; + } + } } if (print_inode) @@ -3470,6 +3495,12 @@ print_long_format (const struct fileinfo p = buf; + if (print_smack) + { + sprintf(p, "%-8s", f->smack); + p += 8; + } + if (print_inode) { char hbuf[INT_BUFSIZE_BOUND (uintmax_t)];