]> granicus.if.org Git - strace/blob - mq.c
tests: add ioctl_evdev-success* test binaries to .gitignore
[strace] / mq.c
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-2019 The strace developers.
5  * All rights reserved.
6  *
7  * SPDX-License-Identifier: LGPL-2.1-or-later
8  */
9
10 #include "defs.h"
11 #include <fcntl.h>
12
13 SYS_FUNC(mq_open)
14 {
15         printpath(tcp, tcp->u_arg[0]);
16         tprints(", ");
17         /* flags */
18         tprint_open_modes(tcp->u_arg[1]);
19         if (tcp->u_arg[1] & O_CREAT) {
20                 /* mode */
21                 tprints(", ");
22                 print_numeric_umode_t(tcp->u_arg[2]);
23                 tprints(", ");
24                 printmqattr(tcp, tcp->u_arg[3], false);
25         }
26         return RVAL_DECODED | RVAL_FD;
27 }
28
29 static int
30 do_mq_timedsend(struct tcb *const tcp, const print_obj_by_addr_fn print_ts)
31 {
32         printfd(tcp, tcp->u_arg[0]);
33         tprints(", ");
34         printstrn(tcp, tcp->u_arg[1], tcp->u_arg[2]);
35         tprintf(", %" PRI_klu ", %u, ", tcp->u_arg[2],
36                 (unsigned int) tcp->u_arg[3]);
37         print_ts(tcp, tcp->u_arg[4]);
38         return RVAL_DECODED;
39 }
40
41 #if HAVE_ARCH_TIME32_SYSCALLS
42 SYS_FUNC(mq_timedsend_time32)
43 {
44         return do_mq_timedsend(tcp, print_timespec32);
45 }
46 #endif
47
48 SYS_FUNC(mq_timedsend_time64)
49 {
50         return do_mq_timedsend(tcp, print_timespec64);
51 }
52
53 static int
54 do_mq_timedreceive(struct tcb *const tcp, const print_obj_by_addr_fn print_ts)
55 {
56         if (entering(tcp)) {
57                 printfd(tcp, tcp->u_arg[0]);
58                 tprints(", ");
59         } else {
60                 if (syserror(tcp))
61                         printaddr(tcp->u_arg[1]);
62                 else
63                         printstrn(tcp, tcp->u_arg[1], tcp->u_rval);
64                 tprintf(", %" PRI_klu ", ", tcp->u_arg[2]);
65                 printnum_int(tcp, tcp->u_arg[3], "%u");
66                 tprints(", ");
67                 /*
68                  * Since the timeout parameter is read by the kernel
69                  * on entering syscall, it has to be decoded the same way
70                  * whether the syscall has failed or not.
71                  */
72                 temporarily_clear_syserror(tcp);
73                 print_ts(tcp, tcp->u_arg[4]);
74                 restore_cleared_syserror(tcp);
75         }
76         return 0;
77 }
78
79 #if HAVE_ARCH_TIME32_SYSCALLS
80 SYS_FUNC(mq_timedreceive_time32)
81 {
82         return do_mq_timedreceive(tcp, print_timespec32);
83 }
84 #endif
85
86 SYS_FUNC(mq_timedreceive_time64)
87 {
88         return do_mq_timedreceive(tcp, print_timespec64);
89 }
90
91 SYS_FUNC(mq_notify)
92 {
93         printfd(tcp, tcp->u_arg[0]);
94         tprints(", ");
95         print_sigevent(tcp, tcp->u_arg[1]);
96         return RVAL_DECODED;
97 }
98
99 SYS_FUNC(mq_getsetattr)
100 {
101         if (entering(tcp)) {
102                 printfd(tcp, tcp->u_arg[0]);
103                 tprints(", ");
104                 printmqattr(tcp, tcp->u_arg[1], true);
105                 tprints(", ");
106         } else {
107                 printmqattr(tcp, tcp->u_arg[2], true);
108         }
109         return 0;
110 }