There's no need to allocate new file descriptor through ioctl and no need to use ioctls to run a ktap program: write() on the ktap device should be enough to upload a ktap program. Signed-off-by: Yann Droneaud <ydroneaud@xxxxxxxxxx> --- include/ktap_types.h | 8 -------- interpreter/ktap.c | 45 --------------------------------------------- 2 files changed, 53 deletions(-) diff --git a/include/ktap_types.h b/include/ktap_types.h index 5c35afe..3c84ee2 100644 --- a/include/ktap_types.h +++ b/include/ktap_types.h @@ -27,14 +27,6 @@ typedef struct ktap_parm { int print_timestamp; } ktap_parm; -/* - * Ioctls that can be done on a ktap fd: - * todo: use _IO macro in include/uapi/asm-generic/ioctl.h - */ -#define KTAP_CMD_IOC_VERSION ('$' + 0) -#define KTAP_CMD_IOC_RUN ('$' + 1) -#define KTAP_CMD_IOC_EXIT ('$' + 3) - #define KTAP_ENV "_ENV" #define KTAP_VERSION_MAJOR "0" diff --git a/interpreter/ktap.c b/interpreter/ktap.c index 1cbcba1..f517fc1 100644 --- a/interpreter/ktap.c +++ b/interpreter/ktap.c @@ -45,7 +45,6 @@ #include <linux/fcntl.h> #include <linux/sched.h> #include <linux/poll.h> -#include <linux/anon_inodes.h> #include <linux/debugfs.h> #include <linux/vmalloc.h> #include "../include/ktap.h" @@ -167,56 +166,12 @@ static ssize_t ktapvm_write(struct file *filp, const char __user *buf, size_t co return size; } -static long ktap_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - ktap_parm parm; - int ret; - - switch (cmd) { - case KTAP_CMD_IOC_VERSION: - print_version(); - return 0; - case KTAP_CMD_IOC_RUN: - ret = copy_from_user(&parm, (void __user *)arg, - sizeof(ktap_parm)); - if (ret < 0) - return -EFAULT; - - return ktap_main(file, &parm); - default: - return -EINVAL; - }; - - return 0; -} - -static const struct file_operations ktap_fops = { - .llseek = no_llseek, - .unlocked_ioctl = ktap_ioctl, -}; - -static long ktapvm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - int new_fd; - - if (arg & ~(unsigned long)(O_ACCMODE | O_CLOEXEC)) - return -EINVAL; - - new_fd = anon_inode_getfd("[ktap]", &ktap_fops, NULL, (int) arg)); - if (new_fd < 0) { - return new_fd; - } - - return new_fd; -} - static const struct file_operations ktapvm_fops = { .owner = THIS_MODULE, .open = ktapvm_open, .write = ktapvm_write, .release = ktapvm_release, .llseek = no_llseek, - .unlocked_ioctl = ktapvm_ioctl, }; unsigned int kp_stub_exit_instr; -- 1.8.3.1