linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: linux-kernel@vger.kernel.org, davem@davemloft.net, hch@lst.de,
	Al Viro <viro@ftp.linux.org.uk>
Subject: [patch 5/9] compat_ioctl: move BLKPG handling to block/compat_ioctl.c
Date: Sat, 06 Oct 2007 20:19:07 +0200	[thread overview]
Message-ID: <20071006182343.208790435@arndb.de> (raw)
In-Reply-To: 20071006181902.141862534@arndb.de

[-- Attachment #1: compat-blkpg.diff --]
[-- Type: text/plain, Size: 3272 bytes --]

BLKPG is common to all block devices, so it should be handled
by common code.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Index: linux-2.6/block/compat_ioctl.c
===================================================================
--- linux-2.6.orig/block/compat_ioctl.c
+++ linux-2.6/block/compat_ioctl.c
@@ -92,6 +92,35 @@ static int compat_hdio_ioctl(struct inod
 	return error;
 }
 
+struct compat_blkpg_ioctl_arg {
+	compat_int_t op;
+	compat_int_t flags;
+	compat_int_t datalen;
+	compat_caddr_t data;
+};
+
+static int compat_blkpg_ioctl(struct inode *inode, struct file *file,
+		unsigned int cmd, struct compat_blkpg_ioctl_arg __user *ua32)
+{
+	struct blkpg_ioctl_arg __user *a = compat_alloc_user_space(sizeof(*a));
+	compat_caddr_t udata;
+	compat_int_t n;
+	int err;
+
+	err = get_user(n, &ua32->op);
+	err |= put_user(n, &a->op);
+	err |= get_user(n, &ua32->flags);
+	err |= put_user(n, &a->flags);
+	err |= get_user(n, &ua32->datalen);
+	err |= put_user(n, &a->datalen);
+	err |= get_user(udata, &ua32->data);
+	err |= put_user(compat_ptr(udata), &a->data);
+	if (err)
+		return err;
+
+	return blkdev_ioctl(inode, file, cmd, (unsigned long)a);
+}
+
 #define BLKBSZGET_32		_IOR(0x12, 112, int)
 #define BLKBSZSET_32		_IOW(0x12, 113, int)
 #define BLKGETSIZE64_32		_IOR(0x12, 114, int)
@@ -350,6 +379,8 @@ long compat_blkdev_ioctl(struct file *fi
 	case BLKBSZSET_32:
 		return blkdev_ioctl(inode, file, BLKBSZSET,
 				(unsigned long)compat_ptr(arg));
+	case BLKPG:
+		return compat_blkpg_ioctl(inode, file, cmd, compat_ptr(arg));
 	}
 
 	lock_kernel();
Index: linux-2.6/fs/compat_ioctl.c
===================================================================
--- linux-2.6.orig/fs/compat_ioctl.c
+++ linux-2.6/fs/compat_ioctl.c
@@ -47,7 +47,6 @@
 #include <linux/netdevice.h>
 #include <linux/raw.h>
 #include <linux/smb_fs.h>
-#include <linux/blkpg.h>
 #include <linux/blkdev.h>
 #include <linux/elevator.h>
 #include <linux/rtc.h>
@@ -1487,37 +1486,6 @@ ret_einval(unsigned int fd, unsigned int
 	return -EINVAL;
 }
 
-#ifdef CONFIG_BLOCK
-struct blkpg_ioctl_arg32 {
-	compat_int_t op;
-	compat_int_t flags;
-	compat_int_t datalen;
-	compat_caddr_t data;
-};
-
-static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-	struct blkpg_ioctl_arg32 __user *ua32 = compat_ptr(arg);
-	struct blkpg_ioctl_arg __user *a = compat_alloc_user_space(sizeof(*a));
-	compat_caddr_t udata;
-	compat_int_t n;
-	int err;
-	
-	err = get_user(n, &ua32->op);
-	err |= put_user(n, &a->op);
-	err |= get_user(n, &ua32->flags);
-	err |= put_user(n, &a->flags);
-	err |= get_user(n, &ua32->datalen);
-	err |= put_user(n, &a->datalen);
-	err |= get_user(udata, &ua32->data);
-	err |= put_user(compat_ptr(udata), &a->data);
-	if (err)
-		return err;
-
-	return sys_ioctl(fd, cmd, (unsigned long)a);
-}
-#endif
-
 static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
 	return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
@@ -3160,7 +3128,6 @@ HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
 HANDLE_IOCTL(SIOCGSTAMPNS, do_siocgstampns)
 #endif
 #ifdef CONFIG_BLOCK
-HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
 HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans)
 HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans)
 HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans)

-- 


  parent reply	other threads:[~2007-10-06 18:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-06 18:19 [patch 0/9] compat_ioctl: introduce block/compat_ioctl.c Arnd Bergmann
2007-10-06 18:19 ` [patch 1/9] compat_ioctl: move common block ioctls to compat_blkdev_ioctl Arnd Bergmann
2007-10-06 18:55   ` Christoph Hellwig
2007-10-06 23:44     ` Arnd Bergmann
2007-10-06 18:19 ` [patch 2/9] compat_ioctl: add compat_blkdev_driver_ioctl() Arnd Bergmann
2007-10-06 18:19 ` [patch 3/9] compat_ioctl: handle blk_trace ioctls Arnd Bergmann
2007-10-06 18:19 ` [patch 4/9] compat_ioctl: move hdio calls to block/compat_ioctl.c Arnd Bergmann
2007-10-06 18:19 ` Arnd Bergmann [this message]
2007-10-06 18:19 ` [patch 6/9] compat_ioctl: move cdrom handlers " Arnd Bergmann
2007-10-06 18:19 ` [patch 7/9] compat_ioctl: move floppy " Arnd Bergmann
2007-10-06 18:19 ` [patch 8/9] compat_ioctl: call disk->fops->compat_ioctl without BKL Arnd Bergmann
2007-10-07  9:53   ` Al Viro
2007-10-07 11:02     ` Arnd Bergmann
2007-10-06 18:19 ` [patch 9/9] compat_ioctl: fix compat_fd_ioctl pointer access Arnd Bergmann
2007-10-07  9:59   ` Al Viro
2007-10-08  5:12 ` [patch 0/9] compat_ioctl: introduce block/compat_ioctl.c Al Viro
2007-10-08  6:04   ` David Miller
2007-10-08  6:38     ` [PATCHv2 1/9] compat_ioctl: move common block ioctls to compat_blkdev_ioctl Arnd Bergmann
2007-10-09 11:24 ` [patch 0/9] compat_ioctl: introduce block/compat_ioctl.c Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071006182343.208790435@arndb.de \
    --to=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=hch@lst.de \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ftp.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).