From: Jens Axboe Date: Wed, 27 Oct 2010 15:23:47 +0000 (-0600) Subject: Fixup ioctls X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;ds=sidebyside;p=binject.git Fixup ioctls Signed-off-by: Jens Axboe --- diff --git a/binject.h b/binject.h index 1e73820..67db5ed 100644 --- a/binject.h +++ b/binject.h @@ -23,6 +23,10 @@ struct b_ioctl_cmd { int minor; }; +#define BINJECT_IOCTL_CHR 'J' +#define B_IOCTL_ADD _IOWR(BINJECT_IOCTL_CHR, 1, struct b_ioctl_cmd) +#define B_IOCTL_DEL _IOWR(BINJECT_IOCTL_CHR, 2, struct b_ioctl_cmd) + enum { B_TYPE_READ = 0, B_TYPE_WRITE, diff --git a/main.c b/main.c index 0981b36..296cbfe 100644 --- a/main.c +++ b/main.c @@ -736,21 +736,21 @@ static long b_misc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return -EFAULT; switch (cmd) { - case 0: + case B_IOCTL_ADD: ret = b_add_dev(&bic); if (!ret && copy_to_user(uarg, &bic, sizeof(bic))) { b_del_dev(&bic); ret = -EFAULT; } break; - case 1: + case B_IOCTL_DEL: ret = b_del_dev(&bic); break; default: break; } - return -ENOTTY; + return ret; } static const struct file_operations b_misc_fops = { diff --git a/tools/bbind.c b/tools/bbind.c index 78803a1..9617a8f 100644 --- a/tools/bbind.c +++ b/tools/bbind.c @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) bic.fd = fd; - if (ioctl(fdb, 0, &bic) < 0) { + if (ioctl(fdb, B_IOCTL_ADD, &bic) < 0) { perror("ioctl"); return 1; } diff --git a/tools/bdel.c b/tools/bdel.c index 5e8116d..fbcd51b 100644 --- a/tools/bdel.c +++ b/tools/bdel.c @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) bic.minor = minor(sb.st_rdev); printf("will delete minor %d\n", bic.minor); - if (ioctl(fd, 1, &bic) < 0) + if (ioctl(fd, B_IOCTL_DEL, &bic) < 0) perror("ioctl"); close(fd);