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.

mq.c 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 2004 Ulrich Drepper <drepper@redhat.com>
  3. * Copyright (c) 2005-2015 Dmitry V. Levin <ldv@altlinux.org>
  4. * Copyright (c) 2015-2018 The strace developers.
  5. * All rights reserved.
  6. *
  7. * SPDX-License-Identifier: LGPL-2.1-or-later
  8. */
  9. #include "defs.h"
  10. #include <fcntl.h>
  11. SYS_FUNC(mq_open)
  12. {
  13. printpath(tcp, tcp->u_arg[0]);
  14. tprints(", ");
  15. /* flags */
  16. tprint_open_modes(tcp->u_arg[1]);
  17. if (tcp->u_arg[1] & O_CREAT) {
  18. /* mode */
  19. tprints(", ");
  20. print_numeric_umode_t(tcp->u_arg[2]);
  21. tprints(", ");
  22. printmqattr(tcp, tcp->u_arg[3], false);
  23. }
  24. return RVAL_DECODED | RVAL_FD;
  25. }
  26. SYS_FUNC(mq_timedsend)
  27. {
  28. printfd(tcp, tcp->u_arg[0]);
  29. tprints(", ");
  30. printstrn(tcp, tcp->u_arg[1], tcp->u_arg[2]);
  31. tprintf(", %" PRI_klu ", %u, ", tcp->u_arg[2],
  32. (unsigned int) tcp->u_arg[3]);
  33. print_timespec(tcp, tcp->u_arg[4]);
  34. return RVAL_DECODED;
  35. }
  36. SYS_FUNC(mq_timedreceive)
  37. {
  38. if (entering(tcp)) {
  39. printfd(tcp, tcp->u_arg[0]);
  40. tprints(", ");
  41. } else {
  42. if (syserror(tcp))
  43. printaddr(tcp->u_arg[1]);
  44. else
  45. printstrn(tcp, tcp->u_arg[1], tcp->u_rval);
  46. tprintf(", %" PRI_klu ", ", tcp->u_arg[2]);
  47. printnum_int(tcp, tcp->u_arg[3], "%u");
  48. tprints(", ");
  49. /*
  50. * Since the timeout parameter is read by the kernel
  51. * on entering syscall, it has to be decoded the same way
  52. * whether the syscall has failed or not.
  53. */
  54. temporarily_clear_syserror(tcp);
  55. print_timespec(tcp, tcp->u_arg[4]);
  56. restore_cleared_syserror(tcp);
  57. }
  58. return 0;
  59. }
  60. SYS_FUNC(mq_notify)
  61. {
  62. printfd(tcp, tcp->u_arg[0]);
  63. tprints(", ");
  64. print_sigevent(tcp, tcp->u_arg[1]);
  65. return RVAL_DECODED;
  66. }
  67. SYS_FUNC(mq_getsetattr)
  68. {
  69. if (entering(tcp)) {
  70. printfd(tcp, tcp->u_arg[0]);
  71. tprints(", ");
  72. printmqattr(tcp, tcp->u_arg[1], true);
  73. tprints(", ");
  74. } else {
  75. printmqattr(tcp, tcp->u_arg[2], true);
  76. }
  77. return 0;
  78. }