Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

printmode.c 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  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.
  8. * All rights reserved.
  9. *
  10. * SPDX-License-Identifier: LGPL-2.1-or-later
  11. */
  12. #include "defs.h"
  13. #include <fcntl.h>
  14. #include <sys/stat.h>
  15. #include "xlat/modetypes.h"
  16. void
  17. print_symbolic_mode_t(const unsigned int mode)
  18. {
  19. const char *ifmt = "";
  20. if (mode & S_IFMT)
  21. ifmt = xlookup(modetypes, mode & S_IFMT);
  22. if (!ifmt || xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
  23. tprintf("%#03o", mode);
  24. if (!ifmt || xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
  25. return;
  26. (xlat_verbose(xlat_verbosity) == XLAT_STYLE_ABBREV
  27. ? tprintf : tprintf_comment)("%s%s%s%s%s%#03o",
  28. ifmt, ifmt[0] ? "|" : "",
  29. (mode & S_ISUID) ? "S_ISUID|" : "",
  30. (mode & S_ISGID) ? "S_ISGID|" : "",
  31. (mode & S_ISVTX) ? "S_ISVTX|" : "",
  32. mode & ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX));
  33. }
  34. void
  35. print_numeric_umode_t(const unsigned short mode)
  36. {
  37. tprintf("%#03ho", mode);
  38. }
  39. void
  40. print_numeric_long_umask(const unsigned long mode)
  41. {
  42. tprintf("%#03lo", mode);
  43. }