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.

ipc_msgctl.c 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (c) 1993 Ulrich Pegelow <pegelow@moorea.uni-muenster.de>
  3. * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  4. * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
  5. * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  6. * Copyright (c) 2003-2006 Roland McGrath <roland@redhat.com>
  7. * Copyright (c) 2006-2015 Dmitry V. Levin <ldv@altlinux.org>
  8. * Copyright (c) 2015-2020 The strace developers.
  9. * All rights reserved.
  10. *
  11. * SPDX-License-Identifier: LGPL-2.1-or-later
  12. */
  13. #include "defs.h"
  14. #include DEF_MPERS_TYPE(msqid_ds_t)
  15. #include "ipc_defs.h"
  16. #include MSG_H_PROVIDER
  17. typedef struct NAME_OF_STRUCT_MSQID_DS msqid_ds_t;
  18. #include MPERS_DEFS
  19. #include "xlat/msgctl_flags.h"
  20. static void
  21. print_msqid_ds(struct tcb *const tcp, const kernel_ulong_t addr, int cmd)
  22. {
  23. /* TODO: We don't properly decode old compat ipc calls. */
  24. if (cmd & IPC_64)
  25. cmd &= ~IPC_64;
  26. msqid_ds_t msqid_ds;
  27. switch (cmd) {
  28. case IPC_SET:
  29. case IPC_STAT:
  30. if (umove_or_printaddr(tcp, addr, &msqid_ds))
  31. return;
  32. tprints("{msg_perm={");
  33. printuid("uid=", msqid_ds.msg_perm.uid);
  34. printuid(", gid=", msqid_ds.msg_perm.gid);
  35. tprints(", mode=");
  36. print_numeric_umode_t(msqid_ds.msg_perm.mode);
  37. if (cmd != IPC_STAT) {
  38. tprints("}, ...}");
  39. break;
  40. }
  41. tprintf(", key=%u",
  42. (unsigned) msqid_ds.msg_perm.NAME_OF_STRUCT_IPC_PERM_KEY);
  43. printuid(", cuid=", msqid_ds.msg_perm.cuid);
  44. printuid(", cgid=", msqid_ds.msg_perm.cgid);
  45. tprints("}");
  46. tprintf(", msg_stime=%u", (unsigned) msqid_ds.msg_stime);
  47. tprintf(", msg_rtime=%u", (unsigned) msqid_ds.msg_rtime);
  48. tprintf(", msg_ctime=%u", (unsigned) msqid_ds.msg_ctime);
  49. tprintf(", msg_qnum=%u", (unsigned) msqid_ds.msg_qnum);
  50. tprintf(", msg_qbytes=%u", (unsigned) msqid_ds.msg_qbytes);
  51. tprintf(", msg_lspid=%u", (unsigned) msqid_ds.msg_lspid);
  52. tprintf(", msg_lrpid=%u", (unsigned) msqid_ds.msg_lrpid);
  53. tprints("}");
  54. break;
  55. default:
  56. printaddr(addr);
  57. break;
  58. }
  59. }
  60. SYS_FUNC(msgctl)
  61. {
  62. if (entering(tcp)) {
  63. tprintf("%d, ", (int) tcp->u_arg[0]);
  64. PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
  65. tprints(", ");
  66. } else {
  67. const kernel_ulong_t addr = tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2];
  68. print_msqid_ds(tcp, addr, tcp->u_arg[1]);
  69. }
  70. return 0;
  71. }