summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-06-11 11:04:50 +0200
committerYorhel <git@yorhel.nl>2021-06-11 11:13:14 +0200
commit52daeafcd8a56bebb1947f424efba91e2eafab90 (patch)
tree6236a2201afb64807beab1fce5d2ff996ca0d82f
parentbd01f5773d0a8c6966a95a1ad6501b9f21993df9 (diff)
Display setuid/setgid and sticky bits in file mode
Same way that coreutils 'ls -l' displays them.
-rw-r--r--src/util.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/util.c b/src/util.c
index 2d92718..5a1abea 100644
--- a/src/util.c
+++ b/src/util.c
@@ -134,13 +134,13 @@ char *fmtmode(unsigned short mode) {
: ft == S_IFBLK ? 'b' : '?';
buf[1] = mode & 0400 ? 'r' : '-';
buf[2] = mode & 0200 ? 'w' : '-';
- buf[3] = mode & 0100 ? 'x' : '-';
+ buf[3] = mode &04000 ? 's' : mode & 0100 ? 'x' : '-';
buf[4] = mode & 0040 ? 'r' : '-';
buf[5] = mode & 0020 ? 'w' : '-';
- buf[6] = mode & 0010 ? 'x' : '-';
+ buf[6] = mode &02000 ? 's' : mode & 0010 ? 'x' : '-';
buf[7] = mode & 0004 ? 'r' : '-';
buf[8] = mode & 0002 ? 'w' : '-';
- buf[9] = mode & 0001 ? 'x' : '-';
+ buf[9] = mode &01000 ? (S_ISDIR(mode) ? 't' : 'T') : mode & 0001 ? 'x' : '-';
buf[10] = 0;
return buf;
}