]> granicus.if.org Git - strace/blob - netlink_kobject_uevent.c
tests: fix format warnings on x32
[strace] / netlink_kobject_uevent.c
1 /*
2  * Copyright (c) 2018 Harsha Sharma <harshasharmaiitr@gmail.com>
3  * Copyright (c) 2018 The strace developers.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: LGPL-2.1-or-later
7  */
8
9 #include "defs.h"
10 #include "print_fields.h"
11 #include "netlink_kobject_uevent.h"
12
13 #include <arpa/inet.h>
14
15 void
16 decode_netlink_kobject_uevent(struct tcb *tcp, kernel_ulong_t addr,
17                               kernel_ulong_t len)
18 {
19         struct udev_monitor_netlink_header uh;
20         const char *prefix = "libudev";
21         unsigned int offset = sizeof(uh);
22
23         if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)) ||
24             !addr || len < offset || umove(tcp, addr, &uh) ||
25             strcmp(uh.prefix, prefix) != 0) {
26                 printstrn(tcp, addr, len);
27                 return;
28         }
29
30         PRINT_FIELD_CSTRING("{{", uh, prefix);
31         tprintf(", magic=htonl(%#x)", ntohl(uh.magic));
32         PRINT_FIELD_U(", ", uh, header_size);
33         PRINT_FIELD_U(", ", uh, properties_off);
34         PRINT_FIELD_U(", ", uh, properties_len);
35         tprintf(", filter_subsystem_hash=htonl(%#x)", ntohl(uh.filter_subsystem_hash));
36         tprintf(", filter_devtype_hash=htonl(%#x)", ntohl(uh.filter_devtype_hash));
37         tprintf(", filter_tag_bloom_hi=htonl(%#x)", ntohl(uh.filter_tag_bloom_hi));
38         tprintf(", filter_tag_bloom_lo=htonl(%#x)", ntohl(uh.filter_tag_bloom_lo));
39         tprints("}");
40         if (len > offset) {
41                 tprints(", ");
42                 printstrn(tcp, addr + offset, len - offset);
43         }
44         tprints("}");
45 }