2 * Copyright (c) 2012 Mike Frysinger <vapier@gentoo.org>
3 * Copyright (c) 2012-2018 The strace developers.
5 * SPDX-License-Identifier: LGPL-2.1-or-later
10 #ifdef HAVE_STRUCT_UBI_ATTACH_REQ_MAX_BEB_PER1024
12 # include <linux/ioctl.h>
13 # include <mtd/ubi-user.h>
15 # include "xlat/ubi_volume_types.h"
16 # include "xlat/ubi_volume_props.h"
19 ubi_ioctl(struct tcb *const tcp, const unsigned int code,
20 const kernel_ulong_t arg)
28 struct ubi_mkvol_req mkvol;
31 if (umove_or_printaddr(tcp, arg, &mkvol))
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=",
41 print_quoted_cstring(mkvol.name,
42 CLAMP(mkvol.name_len, 0,
43 UBI_MAX_VOLUME_NAME));
49 printnum_int(tcp, arg, "%d");
54 struct ubi_rsvol_req rsvol;
57 if (umove_or_printaddr(tcp, arg, &rsvol))
60 tprintf("{vol_id=%" PRIi32 ", bytes=%" PRIi64 "}",
61 rsvol.vol_id, (int64_t)rsvol.bytes);
66 struct ubi_rnvol_req rnvol;
70 if (umove_or_printaddr(tcp, arg, &rnvol))
73 tprintf("{count=%" PRIi32 ", ents=[", rnvol.count);
74 for (c = 0; c < CLAMP(rnvol.count, 0, UBI_MAX_RNVOL); ++c) {
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));
90 struct ubi_leb_change_req leb;
93 if (umove_or_printaddr(tcp, arg, &leb))
96 tprintf("{lnum=%d, bytes=%d}", leb.lnum, leb.bytes);
102 struct ubi_attach_req attach;
105 if (umove_or_printaddr(tcp, arg, &attach))
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);
115 if (!syserror(tcp)) {
117 printnum_int(tcp, arg, "%d");
122 struct ubi_map_req map;
125 if (umove_or_printaddr(tcp, arg, &map))
128 tprintf("{lnum=%" PRIi32 ", dtype=%" PRIi8 "}",
129 map.lnum, map.dtype);
133 case UBI_IOCSETVOLPROP: {
134 struct ubi_set_vol_prop_req prop;
137 if (umove_or_printaddr(tcp, arg, &prop))
140 tprints("{property=");
141 printxval(ubi_volume_props, prop.property, "UBI_VOL_PROP_???");
142 tprintf(", value=%#" PRIx64 "}", (uint64_t)prop.value);
149 printnum_int64(tcp, arg, "%" PRIi64);
158 printnum_int(tcp, arg, "%d");
161 # ifdef UBI_IOCVOLCRBLK
162 case UBI_IOCVOLCRBLK:
164 # ifdef UBI_IOCVOLRMBLK
165 case UBI_IOCVOLRMBLK:
174 return RVAL_IOCTL_DECODED;
177 #endif /* HAVE_STRUCT_UBI_ATTACH_REQ_MAX_BEB_PER1024 */