]> granicus.if.org Git - strace/commitdiff
printmode: add xlat style support to print_symbolic_mode_t
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 4 Apr 2018 13:32:05 +0000 (15:32 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 27 Apr 2018 00:56:25 +0000 (00:56 +0000)
* printmode.c (print_symbolic_mode_t): Set ifmt to an empty string,
print raw and decoded values based on current xlat_verbosity setting.

printmode.c

index d9dcfa3967bdda32612372c14fc5514599d1b2d4..ed28a71ded98a861be89b07291bf318fcf11e055 100644 (file)
 void
 print_symbolic_mode_t(const unsigned int mode)
 {
-       const char *ifmt;
+       const char *ifmt = "";
 
-       if (mode & S_IFMT) {
+       if (mode & S_IFMT)
                ifmt = xlookup(modetypes, mode & S_IFMT);
-               if (!ifmt) {
-                       tprintf("%#03o", mode);
-                       return;
-               }
-       } else {
-               ifmt = NULL;
-       }
 
-       tprintf("%s%s%s%s%s%#03o",
-               ifmt ? ifmt : "",
-               ifmt ? "|" : "",
-               (mode & S_ISUID) ? "S_ISUID|" : "",
-               (mode & S_ISGID) ? "S_ISGID|" : "",
-               (mode & S_ISVTX) ? "S_ISVTX|" : "",
-               mode & ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX));
+       if (!ifmt || xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
+               tprintf("%#03o", mode);
+
+       if (!ifmt || xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
+               return;
+
+       (xlat_verbose(xlat_verbosity) == XLAT_STYLE_ABBREV
+               ? tprintf : tprintf_comment)("%s%s%s%s%s%#03o",
+                       ifmt, ifmt[0] ? "|" : "",
+                       (mode & S_ISUID) ? "S_ISUID|" : "",
+                       (mode & S_ISGID) ? "S_ISGID|" : "",
+                       (mode & S_ISVTX) ? "S_ISVTX|" : "",
+                       mode & ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX));
 }
 
 void