[Devel] [PATCH rh7] aio: Enumerate ioctl numbers right

Kirill Tkhai ktkhai at virtuozzo.com
Thu Feb 18 05:30:49 PST 2016


Do not use common used numbers, use custom.
Also, make error codes different.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 fs/aio.c            |    6 +++---
 include/linux/aio.h |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/aio.c b/fs/aio.c
index 7c8158f..0a22b24 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1860,7 +1860,7 @@ static int ve_aio_set_tail(struct kioctx *ctx, unsigned tail)
 	mutex_lock(&ctx->ring_lock);
 	spin_lock_irq(&ctx->completion_lock);
 
-	ret = -EINVAL;
+	ret = -E2BIG;
 	if (tail >= ctx->nr_events)
 		goto out;
 
@@ -1901,14 +1901,14 @@ int ve_aio_ioctl(struct task_struct *task, unsigned int cmd, unsigned long arg)
 	int ret;
 
 	if (task != current)
-		return -EINVAL;
+		return -EBADF;
 
 	if (copy_from_user(&karg, (void *)arg, sizeof(karg)))
 		return -EFAULT;
 
 	ioctx = lookup_ioctx(karg.ctx_id);
 	if (!ioctx)
-		return -EINVAL;;
+		return -ESRCH;;
 
 	switch (cmd) {
 		case VE_AIO_IOC_SET_TAIL:
diff --git a/include/linux/aio.h b/include/linux/aio.h
index f40a32b..371fb82 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -16,15 +16,15 @@ struct kiocb;
 
 #define AIO_MAX_NR_DEFAULT	0x10000
 
-#define VE_AIO_IOC_SET_TAIL	1
-#define VE_AIO_IOC_WAIT_ACTIVE	2
-
 struct ve_ioc_arg
 {
 	aio_context_t	ctx_id;
 	unsigned	val;
 };
 
+#define VE_AIO_IOC_SET_TAIL	_IOW('a',  0, struct ve_ioc_arg)
+#define VE_AIO_IOC_WAIT_ACTIVE	_IOW('a',  1, struct ve_ioc_arg)
+
 /*
  * We use ki_cancel == KIOCB_CANCELLED to indicate that a kiocb has been either
  * cancelled or completed (this makes a certain amount of sense because



More information about the Devel mailing list