]> granicus.if.org Git - strace/blob - ubi.c
rtnl_link: print pad field in the struct ifla_port_vsi decoder
[strace] / ubi.c
1 /*
2  * Copyright (c) 2012 Mike Frysinger <vapier@gentoo.org>
3  * Copyright (c) 2012-2018 The strace developers.
4  *
5  * SPDX-License-Identifier: LGPL-2.1-or-later
6  */
7
8 #include "defs.h"
9
10 #ifdef HAVE_STRUCT_UBI_ATTACH_REQ_MAX_BEB_PER1024
11
12 # include <linux/ioctl.h>
13 # include <mtd/ubi-user.h>
14
15 # include "xlat/ubi_volume_types.h"
16 # include "xlat/ubi_volume_props.h"
17
18 int
19 ubi_ioctl(struct tcb *const tcp, const unsigned int code,
20           const kernel_ulong_t arg)
21 {
22         if (!verbose(tcp))
23                 return RVAL_DECODED;
24
25         switch (code) {
26         case UBI_IOCMKVOL:
27                 if (entering(tcp)) {
28                         struct ubi_mkvol_req mkvol;
29
30                         tprints(", ");
31                         if (umove_or_printaddr(tcp, arg, &mkvol))
32                                 break;
33
34                         tprintf("{vol_id=%" PRIi32 ", alignment=%" PRIi32
35                                 ", bytes=%" PRIi64 ", vol_type=", mkvol.vol_id,
36                                 mkvol.alignment, (int64_t)mkvol.bytes);
37                         printxval(ubi_volume_types,
38                                     (uint8_t) mkvol.vol_type, "UBI_???_VOLUME");
39                         tprintf(", name_len=%" PRIi16 ", name=",
40                                 mkvol.name_len);
41                         print_quoted_cstring(mkvol.name,
42                                         CLAMP(mkvol.name_len, 0,
43                                               UBI_MAX_VOLUME_NAME));
44                         tprints("}");
45                         return 0;
46                 }
47                 if (!syserror(tcp)) {
48                         tprints(" => ");
49                         printnum_int(tcp, arg, "%d");
50                 }
51                 break;
52
53         case UBI_IOCRSVOL: {
54                 struct ubi_rsvol_req rsvol;
55
56                 tprints(", ");
57                 if (umove_or_printaddr(tcp, arg, &rsvol))
58                         break;
59
60                 tprintf("{vol_id=%" PRIi32 ", bytes=%" PRIi64 "}",
61                         rsvol.vol_id, (int64_t)rsvol.bytes);
62                 break;
63         }
64
65         case UBI_IOCRNVOL: {
66                 struct ubi_rnvol_req rnvol;
67                 int c;
68
69                 tprints(", ");
70                 if (umove_or_printaddr(tcp, arg, &rnvol))
71                         break;
72
73                 tprintf("{count=%" PRIi32 ", ents=[", rnvol.count);
74                 for (c = 0; c < CLAMP(rnvol.count, 0, UBI_MAX_RNVOL); ++c) {
75                         if (c)
76                                 tprints(", ");
77                         tprintf("{vol_id=%" PRIi32 ", name_len=%" PRIi16
78                                 ", name=", rnvol.ents[c].vol_id,
79                                 rnvol.ents[c].name_len);
80                         print_quoted_cstring(rnvol.ents[c].name,
81                                         CLAMP(rnvol.ents[c].name_len, 0,
82                                               UBI_MAX_VOLUME_NAME));
83                         tprints("}");
84                 }
85                 tprints("]}");
86                 break;
87         }
88
89         case UBI_IOCEBCH: {
90                 struct ubi_leb_change_req leb;
91
92                 tprints(", ");
93                 if (umove_or_printaddr(tcp, arg, &leb))
94                         break;
95
96                 tprintf("{lnum=%d, bytes=%d}", leb.lnum, leb.bytes);
97                 break;
98         }
99
100         case UBI_IOCATT:
101                 if (entering(tcp)) {
102                         struct ubi_attach_req attach;
103
104                         tprints(", ");
105                         if (umove_or_printaddr(tcp, arg, &attach))
106                                 break;
107
108                         tprintf("{ubi_num=%" PRIi32 ", mtd_num=%" PRIi32
109                                 ", vid_hdr_offset=%" PRIi32
110                                 ", max_beb_per1024=%" PRIi16 "}",
111                                 attach.ubi_num, attach.mtd_num,
112                                 attach.vid_hdr_offset, attach.max_beb_per1024);
113                         return 0;
114                 }
115                 if (!syserror(tcp)) {
116                         tprints(" => ");
117                         printnum_int(tcp, arg, "%d");
118                 }
119                 break;
120
121         case UBI_IOCEBMAP: {
122                 struct ubi_map_req map;
123
124                 tprints(", ");
125                 if (umove_or_printaddr(tcp, arg, &map))
126                         break;
127
128                 tprintf("{lnum=%" PRIi32 ", dtype=%" PRIi8 "}",
129                         map.lnum, map.dtype);
130                 break;
131         }
132
133         case UBI_IOCSETVOLPROP: {
134                 struct ubi_set_vol_prop_req prop;
135
136                 tprints(", ");
137                 if (umove_or_printaddr(tcp, arg, &prop))
138                         break;
139
140                 tprints("{property=");
141                 printxval(ubi_volume_props, prop.property, "UBI_VOL_PROP_???");
142                 tprintf(", value=%#" PRIx64 "}", (uint64_t)prop.value);
143                 break;
144         }
145
146
147         case UBI_IOCVOLUP:
148                 tprints(", ");
149                 printnum_int64(tcp, arg, "%" PRIi64);
150                 break;
151
152         case UBI_IOCDET:
153         case UBI_IOCEBER:
154         case UBI_IOCEBISMAP:
155         case UBI_IOCEBUNMAP:
156         case UBI_IOCRMVOL:
157                 tprints(", ");
158                 printnum_int(tcp, arg, "%d");
159                 break;
160
161 # ifdef UBI_IOCVOLCRBLK
162         case UBI_IOCVOLCRBLK:
163 # endif
164 # ifdef UBI_IOCVOLRMBLK
165         case UBI_IOCVOLRMBLK:
166 # endif
167                 /* no arguments */
168                 break;
169
170         default:
171                 return RVAL_DECODED;
172         }
173
174         return RVAL_IOCTL_DECODED;
175 }
176
177 #endif /* HAVE_STRUCT_UBI_ATTACH_REQ_MAX_BEB_PER1024 */