- break;
-#endif
- case LIST_FILENAME:
- printf("%s", dn->name);
- column += strlen(dn->name);
- break;
- case LIST_SYMLINK:
- if (S_ISLNK(dn->dstat.st_mode)) {
- char *lpath = xreadlink(dn->fullname);
- if (lpath) {
- printf(" -> %s", lpath);
-#ifdef CONFIG_FEATURE_LS_FILETYPES
- if (!stat(dn->fullname, &info)) {
- append = append_char(info.st_mode);
- }
+ }
+ break;
+#endif
+#ifdef CONFIG_SELINUX
+ case LIST_CONTEXT:
+ {
+ char context[64];
+ int len = sizeof(context);
+ if(security_sid_to_context(dn->sid, context, &len))
+ {
+ strcpy(context, "unknown");
+ len = 7;
+ }
+ printf("%-32s ", context);
+ column += MAX(33, len);
+ }
+ break;
+#endif
+ case LIST_FILENAME:
+#ifdef CONFIG_FEATURE_LS_COLOR
+ errno = 0;
+ if (show_color && !lstat(dn->fullname, &info)) {
+ printf("\033[%d;%dm", bgcolor(info.st_mode),
+ fgcolor(info.st_mode));
+ }
+#endif
+ column += printf("%s", dn->name);
+#ifdef CONFIG_FEATURE_LS_COLOR
+ if (show_color) {
+ printf("\033[0m");
+ }
+#endif
+ break;
+ case LIST_SYMLINK:
+ if (S_ISLNK(dn->dstat.st_mode)) {
+ char *lpath = xreadlink(dn->fullname);
+
+ if (lpath) {
+ printf(" -> ");
+#if defined(CONFIG_FEATURE_LS_FILETYPES) || defined (CONFIG_FEATURE_LS_COLOR)
+ if (!stat(dn->fullname, &info)) {
+ append = append_char(info.st_mode);
+ }
+#endif
+#ifdef CONFIG_FEATURE_LS_COLOR
+ if (show_color) {
+ errno = 0;
+ printf("\033[%d;%dm", bgcolor(info.st_mode),
+ fgcolor(info.st_mode));
+ }