@@ -281,6 +281,23 @@ dm_decode_string(const struct dm_ioctl *ioc, const char *extra,
}
}
+static inline bool
+dm_ioctl_has_params(const unsigned int code)
+{
+ switch (code) {
+ case DM_VERSION:
+ case DM_REMOVE_ALL:
+ case DM_DEV_CREATE:
+ case DM_DEV_REMOVE:
+ case DM_DEV_SUSPEND:
+ case DM_DEV_STATUS:
+ case DM_TABLE_CLEAR:
+ return false;
+ }
+
+ return true;
+}
+
static int
dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg)
{
@@ -336,8 +353,10 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg)
goto skip;
}
- tprintf(", data_size=%u, data_start=%u",
- ioc->data_size, ioc->data_start);
+ tprintf(", data_size=%u", ioc->data_size);
+
+ if (dm_ioctl_has_params(code))
+ tprintf(", data_start=%u", ioc->data_start);
if (ioc->data_size < (sizeof(*ioc) - sizeof(ioc->data))) {
tprints(", /* Incorrect data_size */ ...");
@@ -348,7 +367,7 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg)
dm_decode_values(tcp, code, ioc);
dm_decode_flags(ioc);
- if (ioc->data_size > sizeof(ioc)) {
+ if (dm_ioctl_has_params(code) && (ioc->data_size > sizeof(ioc))) {
extra = malloc(ioc->data_size);
if (extra) {
extra_size = ioc->data_size;
@@ -40,7 +40,7 @@ main(void)
init_s(&s.ioc, sizeof(s.ioc), 0);
ioctl(-1, DM_VERSION, &s);
printf("ioctl(-1, DM_VERSION, "
- "{version=4.1.2, data_size=%zu, data_start=0, "
+ "{version=4.1.2, data_size=%zu, "
"dev=makedev(18, 52), name=\"nnn\", uuid=\"uuu\", flags=0}) = "
"-1 EBADF (%m)\n", sizeof(s.ioc));