fixup! ioctl: decode ioctl type

This commit is contained in:
Eugene Syromyatnikov 2018-09-24 03:58:51 +02:00
parent c8dc2208eb
commit 452bb1c4b9
8 changed files with 28 additions and 27 deletions

View File

@ -208,18 +208,19 @@ main(void)
/* Incorrect operation */
ioctl(-1, _IOW(DM_IOCTL, 0xde, int), dm_arg);
printf("ioctl(-1, _IOC(_IOC_WRITE, %#x, 0xde, %#zx), %p) = "
"-1 EBADF (%m)\n",
DM_IOCTL, sizeof(int), dm_arg);
printf("ioctl(-1, _IOC(_IOC_WRITE, DM_IOCTL, 0xde, %#zx), %p)"
" = -1 EBADF (%m)\n",
sizeof(int), dm_arg);
ioctl(-1, dummy_dm_ioctl1, 0);
printf("ioctl(-1, _IOC(_IOC_READ, %#x, 0, %#x), 0) = -1 EBADF (%m)\n",
DM_IOCTL, (unsigned int) _IOC_SIZE(dummy_dm_ioctl1));
printf("ioctl(-1, _IOC(_IOC_READ, DM_IOCTL, 0, %#x), 0)"
" = -1 EBADF (%m)\n",
(unsigned int) _IOC_SIZE(dummy_dm_ioctl1));
ioctl(-1, dummy_dm_ioctl2, dummy_dm_arg);
printf("ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE, %#x, %#x, 0), %#lx) = "
"-1 EBADF (%m)\n",
DM_IOCTL, (unsigned int) _IOC_NR(dummy_dm_ioctl2),
printf("ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE, DM_IOCTL, %#x, 0), %#lx)"
" = -1 EBADF (%m)\n",
(unsigned int) _IOC_NR(dummy_dm_ioctl2),
(unsigned long) dummy_dm_arg);

View File

@ -283,19 +283,19 @@ main(void)
ioctl(-1, _IOC(_IOC_READ, 0x45, 0x1, 0xff), lmagic);
printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
"_IOC(_IOC_READ, 0x45, 0x1, 0xff)", lmagic);
"_IOC(_IOC_READ, 'E', 0x1, 0xff)", lmagic);
ioctl(-1, _IOC(_IOC_WRITE, 0x45, 0x1, 0xff), lmagic);
printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
"_IOC(_IOC_WRITE, 0x45, 0x1, 0xff)", lmagic);
"_IOC(_IOC_WRITE, 'E', 0x1, 0xff)", lmagic);
ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE, 0x45, 0xfe, 0xff), lmagic);
printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
"_IOC(_IOC_READ|_IOC_WRITE, 0x45, 0xfe, 0xff)", lmagic);
"_IOC(_IOC_READ|_IOC_WRITE, 'E', 0xfe, 0xff)", lmagic);
ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE, 0x45, 0, 0), lmagic);
printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
"_IOC(_IOC_READ|_IOC_WRITE, 0x45, 0, 0)", lmagic);
"_IOC(_IOC_READ|_IOC_WRITE, 'E', 0, 0)", lmagic);
puts("+++ exited with 0 +++");
return 0;

View File

@ -56,7 +56,7 @@ main(void)
/* Unknown inotify commands */
sys_ioctl(-1, unknown_inotify_cmd, magic);
printf("ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE%s, 0x49, %#x, %#x), "
printf("ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE%s, 'I', %#x, %#x), "
"%#lx) = -1 EBADF (%m)\n",
_IOC_DIR((unsigned int) unknown_inotify_cmd) & _IOC_NONE ?
"|_IOC_NONE" : "",
@ -65,7 +65,7 @@ main(void)
(unsigned long) magic);
sys_ioctl(-1, INOTIFY_IOC_SETNEXTWD + 1, magic);
printf("ioctl(-1, _IOC(_IOC_WRITE, 0x49, %#x, %#x), %#lx)"
printf("ioctl(-1, _IOC(_IOC_WRITE, 'I', %#x, %#x), %#lx)"
" = -1 EBADF (%m)\n",
(unsigned int) _IOC_NR(INOTIFY_IOC_SETNEXTWD + 1),
(unsigned int) _IOC_SIZE(INOTIFY_IOC_SETNEXTWD + 1),

View File

@ -187,7 +187,7 @@ main(void)
/* Unknown loop commands */
sys_ioctl(-1, unknown_loop_cmd, magic);
printf("ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE%s, 0x4c, %#x, %#x), "
printf("ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE%s, 'L', %#x, %#x), "
"%#lx) = -1 EBADF (%m)\n",
_IOC_DIR((unsigned int) unknown_loop_cmd) & _IOC_NONE ?
"|_IOC_NONE" : "",
@ -196,14 +196,14 @@ main(void)
(unsigned long) magic);
sys_ioctl(-1, LOOP_SET_BLOCK_SIZE + 1, magic);
printf("ioctl(-1, _IOC(0, 0x4c, %#x, %#x), %#lx) = "
printf("ioctl(-1, _IOC(0, 'L', %#x, %#x), %#lx) = "
"-1 EBADF (%m)\n",
_IOC_NR(LOOP_SET_BLOCK_SIZE + 1),
_IOC_SIZE(LOOP_SET_BLOCK_SIZE + 1),
(unsigned long) magic);
sys_ioctl(-1, LOOP_CTL_GET_FREE + 1, magic);
printf("ioctl(-1, _IOC(0, 0x4c, %#x, %#x), %#lx) = "
printf("ioctl(-1, _IOC(0, 'L', %#x, %#x), %#lx) = "
"-1 EBADF (%m)\n",
_IOC_NR(LOOP_CTL_GET_FREE + 1),
_IOC_SIZE(LOOP_CTL_GET_FREE + 1),

View File

@ -189,9 +189,9 @@ main(void)
(unsigned long long) wr->usr_data,
(unsigned long long) wr->usr_oob);
ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE, 0x4d, 0xfe, 0xff), lmagic);
ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE, 'M', 0xfe, 0xff), lmagic);
printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
"_IOC(_IOC_READ|_IOC_WRITE, 0x4d, 0xfe, 0xff)", lmagic);
"_IOC(_IOC_READ|_IOC_WRITE, 'M', 0xfe, 0xff)", lmagic);
puts("+++ exited with 0 +++");
return 0;

View File

@ -91,7 +91,7 @@ main(void)
/* Unknown perf commands */
sys_ioctl(-1, unknown_perf_cmd, magic);
printf("ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE%s, 0x24, %#x, %#x), "
printf("ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE%s, '$', %#x, %#x), "
"%#lx) = -1 EBADF (%m)\n",
_IOC_DIR((unsigned int) unknown_perf_cmd) & _IOC_NONE ?
"|_IOC_NONE" : "",
@ -100,7 +100,7 @@ main(void)
(unsigned long) magic);
sys_ioctl(-1, PERF_EVENT_IOC_MODIFY_ATTRIBUTES + 1, magic);
printf("ioctl(-1, _IOC(_IOC_WRITE, 0x24, %#x, %#x), %#lx)"
printf("ioctl(-1, _IOC(_IOC_WRITE, '$', %#x, %#x), %#lx)"
" = -1 EBADF (%m)\n",
(unsigned int) _IOC_NR(PERF_EVENT_IOC_MODIFY_ATTRIBUTES + 1),
(unsigned int) _IOC_SIZE(PERF_EVENT_IOC_MODIFY_ATTRIBUTES + 1),

View File

@ -106,13 +106,13 @@ test_no_device(void)
/* unrecognized */
ioctl(-1, _IOC(_IOC_READ, PTP_CLK_MAGIC, 0xff, 0xfe), 0);
printf("ioctl(-1, _IOC(_IOC_READ, %#x, 0xff, 0xfe), 0)"
" = -1 EBADF (%m)\n", PTP_CLK_MAGIC);
printf("ioctl(-1, _IOC(_IOC_READ, PTP_CLK_MAGIC, 0xff, 0xfe), 0)"
" = -1 EBADF (%m)\n");
const unsigned long arg = (unsigned long) 0xfacefeeddeadbeefULL;
ioctl(-1, _IOC(_IOC_WRITE, PTP_CLK_MAGIC, 0xfd, 0xfc), arg);
printf("ioctl(-1, _IOC(_IOC_WRITE, %#x, 0xfd, 0xfc), %#lx)"
" = -1 EBADF (%m)\n", PTP_CLK_MAGIC, arg);
printf("ioctl(-1, _IOC(_IOC_WRITE, PTP_CLK_MAGIC, 0xfd, 0xfc), %#lx)"
" = -1 EBADF (%m)\n", arg);
}
int

View File

@ -137,12 +137,12 @@ main(void)
"SG_SCSI_RESET");
ioctl(-1, 0x22ff, 0);
printf("ioctl(-1, _IOC(0, 0x22, 0xff, 0), 0) = -1 EBADF (%m)\n");
printf("ioctl(-1, _IOC(0, '\"', 0xff, 0), 0) = -1 EBADF (%m)\n");
static const unsigned long magic =
(unsigned long) 0xdeadbeeffacefeedULL;
ioctl(-1, 0x22ff, magic);
printf("ioctl(-1, _IOC(0, 0x22, 0xff, 0), %#lx) = -1 EBADF (%m)\n",
printf("ioctl(-1, _IOC(0, '\"', 0xff, 0), %#lx) = -1 EBADF (%m)\n",
magic);
puts("+++ exited with 0 +++");