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.

syslog.c 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2012-2015 Dmitry V. Levin <ldv@altlinux.org>
  3. * Copyright (c) 2014-2018 The strace developers.
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: LGPL-2.1-or-later
  7. */
  8. #include "defs.h"
  9. #include "xlat/syslog_action_type.h"
  10. #include "xlat/syslog_console_levels.h"
  11. SYS_FUNC(syslog)
  12. {
  13. int type = tcp->u_arg[0];
  14. int len = tcp->u_arg[2];
  15. if (entering(tcp)) {
  16. /* type */
  17. printxval_ex(syslog_action_type, type, "SYSLOG_ACTION_???",
  18. XLAT_STYLE_VERBOSE | XLAT_STYLE_FMT_D);
  19. }
  20. switch (type) {
  21. /* Those commands have bufp and len ignored */
  22. case SYSLOG_ACTION_CLOSE:
  23. case SYSLOG_ACTION_OPEN:
  24. case SYSLOG_ACTION_CLEAR:
  25. case SYSLOG_ACTION_CONSOLE_OFF:
  26. case SYSLOG_ACTION_CONSOLE_ON:
  27. case SYSLOG_ACTION_SIZE_UNREAD:
  28. case SYSLOG_ACTION_SIZE_BUFFER:
  29. return RVAL_DECODED;
  30. case SYSLOG_ACTION_READ:
  31. case SYSLOG_ACTION_READ_ALL:
  32. case SYSLOG_ACTION_READ_CLEAR:
  33. if (entering(tcp)) {
  34. tprints(", ");
  35. return 0;
  36. }
  37. break;
  38. case SYSLOG_ACTION_CONSOLE_LEVEL: /* Uses len */
  39. tprints(", ");
  40. printaddr64(tcp->u_arg[1]);
  41. tprints(", ");
  42. printxval_ex(syslog_console_levels, len, "LOGLEVEL_???",
  43. XLAT_STYLE_VERBOSE | XLAT_STYLE_FMT_D);
  44. return RVAL_DECODED;
  45. default:
  46. tprints(", ");
  47. printaddr64(tcp->u_arg[1]);
  48. tprintf(", %d", len);
  49. return RVAL_DECODED;
  50. }
  51. /* syscall exit handler for SYSLOG_ACTION_READ* */
  52. /* bufp */
  53. if (syserror(tcp))
  54. printaddr64(tcp->u_arg[1]);
  55. else
  56. printstrn(tcp, tcp->u_arg[1], tcp->u_rval);
  57. /* len */
  58. tprintf(", %d", len);
  59. return 0;
  60. }