2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993-1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6 * Copyright (c) 2012 Denys Vlasenko <vda.linux@googlemail.com>
7 * Copyright (c) 2012-2018 The strace developers.
10 * SPDX-License-Identifier: LGPL-2.1-or-later
18 #include "xlat/modetypes.h"
21 print_symbolic_mode_t(const unsigned int mode)
23 const char *ifmt = "";
26 ifmt = xlookup(modetypes, mode & S_IFMT);
28 if (!ifmt || xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
29 tprintf("%#03o", mode);
31 if (!ifmt || xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
34 (xlat_verbose(xlat_verbosity) == XLAT_STYLE_ABBREV
35 ? tprintf : tprintf_comment)("%s%s%s%s%s%#03o",
36 ifmt, ifmt[0] ? "|" : "",
37 (mode & S_ISUID) ? "S_ISUID|" : "",
38 (mode & S_ISGID) ? "S_ISGID|" : "",
39 (mode & S_ISVTX) ? "S_ISVTX|" : "",
40 mode & ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX));
44 print_numeric_umode_t(const unsigned short mode)
46 tprintf("%#03ho", mode);
50 print_numeric_long_umask(const unsigned long mode)
52 tprintf("%#03lo", mode);