]> granicus.if.org Git - strace/blob - print_mq_attr.c
netlink: add a basic rtnetlink parser of nsid messages
[strace] / print_mq_attr.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-2017 The strace developers.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #include "defs.h"
31
32 #include DEF_MPERS_TYPE(mq_attr_t)
33
34 #ifdef HAVE_MQUEUE_H
35 # include <mqueue.h>
36 typedef struct mq_attr mq_attr_t;
37 #elif defined HAVE_LINUX_MQUEUE_H
38 # include <linux/types.h>
39 # include <linux/mqueue.h>
40 typedef struct mq_attr mq_attr_t;
41 #endif
42
43 #include "xlat/mq_attr_flags.h"
44
45 #include MPERS_DEFS
46
47 MPERS_PRINTER_DECL(void, printmqattr, struct tcb *const tcp,
48                    const kernel_ulong_t addr, const bool decode_flags)
49 {
50 #if defined HAVE_MQUEUE_H || defined HAVE_LINUX_MQUEUE_H
51         mq_attr_t attr;
52         if (umove_or_printaddr(tcp, addr, &attr))
53                 return;
54         tprints("{mq_flags=");
55         if (decode_flags)
56                 printflags64(mq_attr_flags,
57                              zero_extend_signed_to_ull(attr.mq_flags),
58                              "O_???");
59         else
60                 tprintf("%#llx", zero_extend_signed_to_ull(attr.mq_flags));
61         tprintf(", mq_maxmsg=%lld, mq_msgsize=%lld, mq_curmsgs=%lld}",
62                 sign_extend_unsigned_to_ll(attr.mq_maxmsg),
63                 sign_extend_unsigned_to_ll(attr.mq_msgsize),
64                 sign_extend_unsigned_to_ll(attr.mq_curmsgs));
65 #else
66         printaddr(addr);
67 #endif
68 }