* tests/ioctl_inotify.c (sys_ioctl): New function.
(main): Use sys_ioctl for ioctl calls with oversized arguments.
* tests/ioctl_loop.c: Likewise.
* tests/ioctl_perf.c: Likewise.
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
-
+#include <unistd.h>
+#include <asm/unistd.h>
#include <linux/ioctl.h>
-#include <sys/ioctl.h>
-#include <sys/sysmacros.h>
-
#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)
{
(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 ?
_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),
(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);
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
+#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/sysmacros.h>
+#include <asm/unistd.h>
#include <linux/ioctl.h>
#include <linux/loop.h>
#include "print_fields.h"
# 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,
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 ?
_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),
(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);
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);
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);
# include <inttypes.h>
# include <stdio.h>
# include <string.h>
+# include <unistd.h>
# include <sys/ioctl.h>
+# include <asm/unistd.h>
# include <linux/perf_event.h>
/*
# 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)
{
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 ?
_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),
"= -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);
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);
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);