diff --git a/tests/ioctl_inotify.c b/tests/ioctl_inotify.c index 88bd3b12..0650c624 100644 --- a/tests/ioctl_inotify.c +++ b/tests/ioctl_inotify.c @@ -32,16 +32,20 @@ #include #include #include - +#include +#include #include -#include -#include - #ifndef INOTIFY_IOC_SETNEXTWD # define INOTIFY_IOC_SETNEXTWD _IOW('I', 0, int32_t) #endif +static long +sys_ioctl(kernel_long_t fd, kernel_ulong_t cmd, kernel_ulong_t arg) +{ + return syscall(__NR_ioctl, fd, cmd, arg); +} + int main(void) { @@ -51,7 +55,7 @@ main(void) (kernel_ulong_t) 0xdeadbeefbadc0dedULL; /* Unknown inotify commands */ - ioctl(-1, unknown_inotify_cmd, magic); + sys_ioctl(-1, unknown_inotify_cmd, magic); printf("ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE%s, 0x49, %#x, %#x), " "%#lx) = -1 EBADF (%m)\n", _IOC_DIR((unsigned int) unknown_inotify_cmd) & _IOC_NONE ? @@ -60,7 +64,7 @@ main(void) _IOC_SIZE((unsigned int) unknown_inotify_cmd), (unsigned long) magic); - ioctl(-1, INOTIFY_IOC_SETNEXTWD + 1, magic); + sys_ioctl(-1, INOTIFY_IOC_SETNEXTWD + 1, magic); printf("ioctl(-1, _IOC(_IOC_WRITE, 0x49, %#x, %#x), %#lx)" " = -1 EBADF (%m)\n", (unsigned int) _IOC_NR(INOTIFY_IOC_SETNEXTWD + 1), @@ -68,7 +72,7 @@ main(void) (unsigned long) magic); /* INOTIFY_IOC_SETNEXTWD */ - ioctl(-1, INOTIFY_IOC_SETNEXTWD, magic); + sys_ioctl(-1, INOTIFY_IOC_SETNEXTWD, magic); printf("ioctl(-1, INOTIFY_IOC_SETNEXTWD, %d) = -1 EBADF (%m)\n", (int) magic); diff --git a/tests/ioctl_loop.c b/tests/ioctl_loop.c index bafbd378..10b7dc34 100644 --- a/tests/ioctl_loop.c +++ b/tests/ioctl_loop.c @@ -34,8 +34,10 @@ #include #include #include +#include #include #include +#include #include #include #include "print_fields.h" @@ -45,6 +47,12 @@ # define ABBREV 0 #endif +static long +sys_ioctl(kernel_long_t fd, kernel_ulong_t cmd, kernel_ulong_t arg) +{ + return syscall(__NR_ioctl, fd, cmd, arg); +} + static void print_loop_info(struct loop_info * const info, bool print_encrypt, const char *encrypt_type, const char *encrypt_key, @@ -178,7 +186,7 @@ main(void) TAIL_ALLOC_OBJECT_CONST_PTR(struct loop_info64, info64); /* Unknown loop commands */ - ioctl(-1, unknown_loop_cmd, magic); + sys_ioctl(-1, unknown_loop_cmd, magic); printf("ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE%s, 0x4c, %#x, %#x), " "%#lx) = -1 EBADF (%m)\n", _IOC_DIR((unsigned int) unknown_loop_cmd) & _IOC_NONE ? @@ -187,14 +195,14 @@ main(void) _IOC_SIZE((unsigned int) unknown_loop_cmd), (unsigned long) magic); - ioctl(-1, LOOP_SET_BLOCK_SIZE + 1, magic); + sys_ioctl(-1, LOOP_SET_BLOCK_SIZE + 1, magic); printf("ioctl(-1, _IOC(0, 0x4c, %#x, %#x), %#lx) = " "-1 EBADF (%m)\n", _IOC_NR(LOOP_SET_BLOCK_SIZE + 1), _IOC_SIZE(LOOP_SET_BLOCK_SIZE + 1), (unsigned long) magic); - ioctl(-1, LOOP_CTL_GET_FREE + 1, magic); + sys_ioctl(-1, LOOP_CTL_GET_FREE + 1, magic); printf("ioctl(-1, _IOC(0, 0x4c, %#x, %#x), %#lx) = " "-1 EBADF (%m)\n", _IOC_NR(LOOP_CTL_GET_FREE + 1), @@ -202,7 +210,7 @@ main(void) (unsigned long) magic); /* LOOP_SET_FD */ - ioctl(-1, LOOP_SET_FD, magic); + sys_ioctl(-1, LOOP_SET_FD, magic); printf("ioctl(-1, LOOP_SET_FD, %d) = -1 EBADF (%m)\n", (unsigned int) magic); @@ -289,7 +297,7 @@ main(void) printf("ioctl(-1, LOOP_GET_STATUS64, %p) = -1 EBADF (%m)\n", info64); /* LOOP_CHANGE_FD */ - ioctl(-1, LOOP_CHANGE_FD, magic); + sys_ioctl(-1, LOOP_CHANGE_FD, magic); printf("ioctl(-1, LOOP_CHANGE_FD, %d) = -1 EBADF (%m)\n", (unsigned int) magic); @@ -298,22 +306,22 @@ main(void) printf("ioctl(-1, LOOP_SET_CAPACITY) = -1 EBADF (%m)\n"); /* LOOP_SET_DIRECT_IO */ - ioctl(-1, LOOP_SET_DIRECT_IO, magic); + sys_ioctl(-1, LOOP_SET_DIRECT_IO, magic); printf("ioctl(-1, LOOP_SET_DIRECT_IO, %lu) = -1 EBADF (%m)\n", (unsigned long) magic); /* LOOP_SET_BLOCK_SIZE */ - ioctl(-1, LOOP_SET_BLOCK_SIZE, magic); + sys_ioctl(-1, LOOP_SET_BLOCK_SIZE, magic); printf("ioctl(-1, LOOP_SET_BLOCK_SIZE, %lu) = -1 EBADF (%m)\n", (unsigned long) magic); /* LOOP_CTL_ADD */ - ioctl(-1, LOOP_CTL_ADD, magic); + sys_ioctl(-1, LOOP_CTL_ADD, magic); printf("ioctl(-1, LOOP_CTL_ADD, %d) = -1 EBADF (%m)\n", (unsigned int) magic); /* LOOP_CTL_REMOVE */ - ioctl(-1, LOOP_CTL_REMOVE, magic); + sys_ioctl(-1, LOOP_CTL_REMOVE, magic); printf("ioctl(-1, LOOP_CTL_REMOVE, %d) = -1 EBADF (%m)\n", (unsigned int) magic); diff --git a/tests/ioctl_perf.c b/tests/ioctl_perf.c index 2fbc753d..7db01dbc 100644 --- a/tests/ioctl_perf.c +++ b/tests/ioctl_perf.c @@ -34,7 +34,9 @@ # include # include # include +# include # include +# include # include /* @@ -51,6 +53,12 @@ # define STR16 "0123456789abcdef" +static long +sys_ioctl(kernel_long_t fd, kernel_ulong_t cmd, kernel_ulong_t arg) +{ + return syscall(__NR_ioctl, fd, cmd, arg); +} + int main(void) { @@ -82,7 +90,7 @@ main(void) fill_memory_ex(pea_ptr, sizeof(*pea_ptr), 0xaa, 0x55); /* Unknown perf commands */ - ioctl(-1, unknown_perf_cmd, magic); + sys_ioctl(-1, unknown_perf_cmd, magic); printf("ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE%s, 0x24, %#x, %#x), " "%#lx) = -1 EBADF (%m)\n", _IOC_DIR((unsigned int) unknown_perf_cmd) & _IOC_NONE ? @@ -91,7 +99,7 @@ main(void) _IOC_SIZE((unsigned int) unknown_perf_cmd), (unsigned long) magic); - ioctl(-1, PERF_EVENT_IOC_MODIFY_ATTRIBUTES + 1, magic); + sys_ioctl(-1, PERF_EVENT_IOC_MODIFY_ATTRIBUTES + 1, magic); printf("ioctl(-1, _IOC(_IOC_WRITE, 0x24, %#x, %#x), %#lx)" " = -1 EBADF (%m)\n", (unsigned int) _IOC_NR(PERF_EVENT_IOC_MODIFY_ATTRIBUTES + 1), @@ -112,14 +120,14 @@ main(void) "= -1 EBADF (%m)\n", flag_iocs[i].str); - ioctl(-1, flag_iocs[i].cmd, magic); + sys_ioctl(-1, flag_iocs[i].cmd, magic); printf("ioctl(-1, %s, PERF_IOC_FLAG_GROUP|%#x) " "= -1 EBADF (%m)\n", flag_iocs[i].str, (unsigned int) magic & ~1U); } /* PERF_EVENT_IOC_REFRESH */ - ioctl(-1, PERF_EVENT_IOC_REFRESH, magic); + sys_ioctl(-1, PERF_EVENT_IOC_REFRESH, magic); printf("ioctl(-1, PERF_EVENT_IOC_REFRESH, %d) = -1 EBADF (%m)\n", (int) magic); @@ -137,7 +145,7 @@ main(void) magic64); /* PERF_EVENT_IOC_SET_OUTPUT */ - ioctl(-1, PERF_EVENT_IOC_SET_OUTPUT, magic); + sys_ioctl(-1, PERF_EVENT_IOC_SET_OUTPUT, magic); printf("ioctl(-1, PERF_EVENT_IOC_SET_OUTPUT, %d) = -1 EBADF (%m)\n", (int) magic); @@ -178,12 +186,12 @@ main(void) u64_ptr); /* PERF_EVENT_IOC_SET_BPF */ - ioctl(-1, PERF_EVENT_IOC_SET_BPF, magic); + sys_ioctl(-1, PERF_EVENT_IOC_SET_BPF, magic); printf("ioctl(-1, PERF_EVENT_IOC_SET_BPF, %d) = -1 EBADF (%m)\n", (int) magic); /* PERF_EVENT_IOC_PAUSE_OUTPUT */ - ioctl(-1, PERF_EVENT_IOC_PAUSE_OUTPUT, magic); + sys_ioctl(-1, PERF_EVENT_IOC_PAUSE_OUTPUT, magic); printf("ioctl(-1, PERF_EVENT_IOC_PAUSE_OUTPUT, %lu) = -1 EBADF (%m)\n", (unsigned long) magic);