$OpenBSD: patch-src_ls_c,v 1.1 2001/03/15 18:17:54 wilfried Exp $ --- src/ls.c.orig Sat Sep 19 13:09:23 1998 +++ src/ls.c Thu Mar 15 08:11:07 2001 @@ -368,13 +368,13 @@ enum color_type enum indicator_no { C_LEFT, C_RIGHT, C_END, C_NORM, C_FILE, C_DIR, C_LINK, C_FIFO, C_SOCK, - C_BLK, C_CHR, C_MISSING, C_ORPHAN, C_EXEC + C_BLK, C_CHR, C_MISSING, C_ORPHAN, C_EXEC, C_UID, C_GID, C_WRO, C_WT }; static const char *const indicator_name[]= { "lc", "rc", "ec", "no", "fi", "di", "ln", "pi", "so", - "bd", "cd", "mi", "or", "ex", NULL + "bd", "cd", "mi", "or", "ex", "su", "sg", "wo", "wt", NULL }; struct col_ext_type @@ -399,7 +399,11 @@ static struct bin_str color_indicator[] { LEN_STR_PAIR ("01;33") }, /* cd: Char device: bright yellow */ { 0, NULL }, /* mi: Missing file: undefined */ { 0, NULL }, /* or: Orphanned symlink: undefined */ - { LEN_STR_PAIR ("01;32") } /* ex: Executable: bright green */ + { LEN_STR_PAIR ("01;32") }, /* ex: Executable: bright green */ + { LEN_STR_PAIR ("37;41") }, /* su: setuid: white on red */ + { LEN_STR_PAIR ("30;43") }, /* sg: setgid: black on yellow */ + { LEN_STR_PAIR ("37;44") }, /* wo: writeable-other:white on blue */ + { LEN_STR_PAIR ("37;42") }, /* wt: wo w/ sticky: white on green */ }; /* FIXME: comment */ @@ -2477,7 +2481,14 @@ print_color_indicator (const char *name, else { if (S_ISDIR (mode)) - type = C_DIR; + { + if ((mode && MODE_WT) == MODE_WT) + type = C_WT; + else if ((mode && MODE_WRO) == MODE_WRO) + type = C_WRO; + else + type = C_DIR; + } #ifdef S_ISLNK else if (S_ISLNK (mode)) @@ -2505,7 +2516,13 @@ print_color_indicator (const char *name, type = C_CHR; #endif - if (type == C_FILE && (mode & S_IXUGO) != 0) + if ((type == C_FILE) && ((mode & S_ISUID) != 0)) + type = C_UID; + + else if ((type == C_FILE) && ((mode & S_ISGID) != 0)) + type = C_GID; + + else if (type == C_FILE && (mode & S_IXUGO) != 0) type = C_EXEC; /* Check the file's suffix only if still classified as C_FILE. */