]> granicus.if.org Git - strace/blobdiff - ipc_msgctl.c
io: change size types from unsigned long to kernel_ureg_t
[strace] / ipc_msgctl.c
index a97dd1a1f6b01875eaf7a31d7a47192b6c56fb46..9ad101f17249cd3a66f33f91db7890d02b148be6 100644 (file)
  */
 
 #include "defs.h"
-#include "ipc_defs.h"
 
-#include <sys/msg.h>
 #include DEF_MPERS_TYPE(msqid_ds_t)
+
+#include "ipc_defs.h"
+
+#ifdef HAVE_SYS_MSG_H
+/* The C library generally exports the struct the current kernel expects. */
+# include <sys/msg.h>
 typedef struct msqid_ds msqid_ds_t;
+#elif defined HAVE_LINUX_MSG_H
+/* The linux header might provide the right struct. */
+# include <linux/msg.h>
+typedef struct msqid64_ds msqid_ds_t;
+#endif
+
 #include MPERS_DEFS
 
 #include "xlat/msgctl_flags.h"
 
 static void
-print_msqid_ds(struct tcb *tcp, const long addr, int cmd)
+print_msqid_ds(struct tcb *const tcp, const kernel_ureg_t addr, int cmd)
 {
+       /* TODO: We don't properly decode old compat ipc calls. */
        if (cmd & IPC_64)
                cmd &= ~IPC_64;
        msqid_ds_t msqid_ds;
@@ -56,7 +67,7 @@ print_msqid_ds(struct tcb *tcp, const long addr, int cmd)
                printuid("uid=", msqid_ds.msg_perm.uid);
                printuid(", gid=", msqid_ds.msg_perm.gid);
                tprints(", mode=");
-               tprints(sprintmode(msqid_ds.msg_perm.mode));
+               print_numeric_umode_t(msqid_ds.msg_perm.mode);
 
                if (cmd != IPC_STAT) {
                        tprints("}, ...}");
@@ -86,11 +97,11 @@ print_msqid_ds(struct tcb *tcp, const long addr, int cmd)
 SYS_FUNC(msgctl)
 {
        if (entering(tcp)) {
-               tprintf("%lu, ", tcp->u_arg[0]);
+               tprintf("%d, ", (int) tcp->u_arg[0]);
                PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
                tprints(", ");
        } else {
-               const long addr = tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2];
+               const kernel_ureg_t addr = tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2];
                print_msqid_ds(tcp, addr, tcp->u_arg[1]);
        }
        return 0;