All of lore.kernel.org
 help / color / mirror / Atom feed
* [uml-user] [PATCH 00/12] move compat_ioctl handling into drivers
@ 2009-11-16  0:26 ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  0:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, user-mode-linux-user, Neil Brown, H. Peter Anvin,
	Paul Clements, Andre Noll, Pavel Machek, linux-i2c, Jens Axboe,
	Jan Blunck, Ian Kent, Nick Piggin, user-mode-linux-devel,
	linux-scsi, Kay Sievers, Alon Bar-Lev, Alan Stern,
	KOSAKI Motohiro, Doug Gilbert, David Vrabel, Alexey Dobriyan,
	Arnd Bergmann, Jeff Dike, Oliver Neukum, linux-raid, Tejun

This is the second series of patches on compat_ioctl handling,
moving compat handlers into more drivers. Most of these
patches consist on a part that adds a compat_ioctl method
in one driver and another part removing the respective
section from fs/compat_ioctl.c. The fs/compat_ioctl.c
portion depends on other patches[1], but the driver code can
be applied independently.

If some of you feel responsible for the code I patched, please
look at my changes and if they are ok, either take them into
your tree or give me an Acked-by for them.

I have tested the patches for sg, usbdevfs and autofs, which
was easily done in qemu, but I'm lacking test cases for
most of the other ones.

	Arnd <><

Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Alon Bar-Lev <alon.barlev@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andre Noll <maan@systemlinux.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: autofs@linux.kernel.org
Cc: "Ben Dooks (embedded platforms)" <ben-linux@fluff.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: David Vrabel <david.vrabel@csr.com>
Cc: Doug Gilbert <dgilbert@interlog.com>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ian Kent <raven@themaw.net>
Cc: James E.J. Bottomley <James.Bottomley@suse.de>
Cc: Jan Blunck <jblunck@suse.de>
Cc: "Jean Delvare (PC drivers, core)" <khali@linux-fr.org>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: linux-i2c@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-raid@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Neil Brown <neilb@suse.de>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Oliver Neukum <oliver@neukum.org>
Cc: Paul Clements <Paul.Clements@steeleye.com>
Cc: Pavel Machek <pavel@suse.cz>
Cc: Tejun Heo <tj@kernel.org>
Cc: user-mode-linux-devel@lists.sourceforge.net
Cc: user-mode-linux-user@lists.sourceforge.net
Cc: Wolfram Sang <w.sang@pengutronix.de>

Arnd Bergmann (12):
  arch/um: handle compat_ioctl in tty line driver
  scsi/sg: move compat_ioctl handling into sg driver
  autofs/autofs4: move compat_ioctl handling into fs
  raw: partly fix compat_ioctl handling on non-x86
  nbd: add compat_ioctl method
  smbfs: do compat_ioctl handling in place
  i2cdev: move compat_ioctl handling into driver
  md: move compat_ioctl handling into md.c
  lp: move compat_ioctl handling into lp.c
  usbdevfs: move compat_ioctl handling to devio.c
  hamradio/mkiss: fix typo in compat_ioctl
  compat_ioctl: remove unused handlers

 arch/um/drivers/line.c          |    6 +
 arch/um/drivers/ssl.c           |    1 +
 arch/um/drivers/stdio_console.c |    1 +
 arch/um/include/shared/line.h   |    2 +
 drivers/block/nbd.c             |    7 +-
 drivers/char/lp.c               |  115 +++++++--
 drivers/char/raw.c              |  157 ++++++++++---
 drivers/i2c/i2c-dev.c           |  117 +++++++++
 drivers/md/md.c                 |   23 ++
 drivers/net/hamradio/mkiss.c    |    2 +-
 drivers/scsi/sg.c               |  182 ++++++++++++++-
 drivers/usb/core/devio.c        |  110 ++++++++-
 fs/autofs/root.c                |   67 +++++-
 fs/autofs4/root.c               |   69 +++++-
 fs/compat_ioctl.c               |  504 +--------------------------------------
 fs/smbfs/dir.c                  |    5 +-
 fs/smbfs/file.c                 |    3 +-
 fs/smbfs/ioctl.c                |   48 ++++-
 fs/smbfs/proto.h                |    3 +-
 include/linux/auto_fs.h         |    1 +
 include/linux/usbdevice_fs.h    |   26 ++
 kernel/trace/blktrace.c         |    1 +
 22 files changed, 856 insertions(+), 594 deletions(-)

[1] http://patchwork.kernel.org/bundle/arnd/compat-ioctl-cleanup/?state=*

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [uml-devel] [PATCH 00/12] move compat_ioctl handling into drivers
@ 2009-11-16  0:26 ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  0:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, user-mode-linux-user, Neil Brown, H. Peter Anvin,
	Paul Clements, Andre Noll, Pavel Machek, linux-i2c, Jens Axboe,
	Jan Blunck, Ian Kent, Nick Piggin, user-mode-linux-devel,
	linux-scsi, Kay Sievers, Alon Bar-Lev, Alan Stern,
	KOSAKI Motohiro, Doug Gilbert, David Vrabel, Alexey Dobriyan,
	Arnd Bergmann, Jeff Dike, Oliver Neukum, linux-raid, Tejun Heo,
	James E.J. Bottomley, Al Viro, Ben Dooks (embedded platforms),
	autofs, Martin K. Petersen, Greg Kroah-Hartman, Wolfram Sang,
	FUJITA Tomonori, Jean Delvare (PC drivers, core),
	Andrew Morton, David S. Miller

This is the second series of patches on compat_ioctl handling,
moving compat handlers into more drivers. Most of these
patches consist on a part that adds a compat_ioctl method
in one driver and another part removing the respective
section from fs/compat_ioctl.c. The fs/compat_ioctl.c
portion depends on other patches[1], but the driver code can
be applied independently.

If some of you feel responsible for the code I patched, please
look at my changes and if they are ok, either take them into
your tree or give me an Acked-by for them.

I have tested the patches for sg, usbdevfs and autofs, which
was easily done in qemu, but I'm lacking test cases for
most of the other ones.

	Arnd <><

Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Alon Bar-Lev <alon.barlev@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andre Noll <maan@systemlinux.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: autofs@linux.kernel.org
Cc: "Ben Dooks (embedded platforms)" <ben-linux@fluff.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: David Vrabel <david.vrabel@csr.com>
Cc: Doug Gilbert <dgilbert@interlog.com>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ian Kent <raven@themaw.net>
Cc: James E.J. Bottomley <James.Bottomley@suse.de>
Cc: Jan Blunck <jblunck@suse.de>
Cc: "Jean Delvare (PC drivers, core)" <khali@linux-fr.org>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: linux-i2c@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-raid@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Neil Brown <neilb@suse.de>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Oliver Neukum <oliver@neukum.org>
Cc: Paul Clements <Paul.Clements@steeleye.com>
Cc: Pavel Machek <pavel@suse.cz>
Cc: Tejun Heo <tj@kernel.org>
Cc: user-mode-linux-devel@lists.sourceforge.net
Cc: user-mode-linux-user@lists.sourceforge.net
Cc: Wolfram Sang <w.sang@pengutronix.de>

Arnd Bergmann (12):
  arch/um: handle compat_ioctl in tty line driver
  scsi/sg: move compat_ioctl handling into sg driver
  autofs/autofs4: move compat_ioctl handling into fs
  raw: partly fix compat_ioctl handling on non-x86
  nbd: add compat_ioctl method
  smbfs: do compat_ioctl handling in place
  i2cdev: move compat_ioctl handling into driver
  md: move compat_ioctl handling into md.c
  lp: move compat_ioctl handling into lp.c
  usbdevfs: move compat_ioctl handling to devio.c
  hamradio/mkiss: fix typo in compat_ioctl
  compat_ioctl: remove unused handlers

 arch/um/drivers/line.c          |    6 +
 arch/um/drivers/ssl.c           |    1 +
 arch/um/drivers/stdio_console.c |    1 +
 arch/um/include/shared/line.h   |    2 +
 drivers/block/nbd.c             |    7 +-
 drivers/char/lp.c               |  115 +++++++--
 drivers/char/raw.c              |  157 ++++++++++---
 drivers/i2c/i2c-dev.c           |  117 +++++++++
 drivers/md/md.c                 |   23 ++
 drivers/net/hamradio/mkiss.c    |    2 +-
 drivers/scsi/sg.c               |  182 ++++++++++++++-
 drivers/usb/core/devio.c        |  110 ++++++++-
 fs/autofs/root.c                |   67 +++++-
 fs/autofs4/root.c               |   69 +++++-
 fs/compat_ioctl.c               |  504 +--------------------------------------
 fs/smbfs/dir.c                  |    5 +-
 fs/smbfs/file.c                 |    3 +-
 fs/smbfs/ioctl.c                |   48 ++++-
 fs/smbfs/proto.h                |    3 +-
 include/linux/auto_fs.h         |    1 +
 include/linux/usbdevice_fs.h    |   26 ++
 kernel/trace/blktrace.c         |    1 +
 22 files changed, 856 insertions(+), 594 deletions(-)

[1] http://patchwork.kernel.org/bundle/arnd/compat-ioctl-cleanup/?state=*

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 01/12] arch/um: handle compat_ioctl in tty line driver
  2009-11-16  0:26 ` [uml-devel] " Arnd Bergmann
  (?)
@ 2009-11-16  0:26 ` Arnd Bergmann
  -1 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  0:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Jeff Dike, Alexey Dobriyan, user-mode-linux-devel,
	user-mode-linux-user

This pushes the handling of VT specific ioctls down to the
UML specific drivers so we can remove it from the common
compat_ioctl.c file.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: user-mode-linux-devel@lists.sourceforge.net
Cc: user-mode-linux-user@lists.sourceforge.net
---
 arch/um/drivers/line.c          |    6 ++++++
 arch/um/drivers/ssl.c           |    1 +
 arch/um/drivers/stdio_console.c |    1 +
 arch/um/include/shared/line.h   |    2 ++
 4 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index cf8a97f..e819d9b 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -315,6 +315,12 @@ int line_ioctl(struct tty_struct *tty, struct file * file,
 	return ret;
 }
 
+long line_compat_ioctl(struct tty_struct *tty, struct file * file,
+	       unsigned int cmd, unsigned long arg)
+{
+	return line_ioctl(tty, file, cmd, arg);
+}
+
 void line_throttle(struct tty_struct *tty)
 {
 	struct line *line = tty->driver_data;
diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c
index f1786e6..eccf14a 100644
--- a/arch/um/drivers/ssl.c
+++ b/arch/um/drivers/ssl.c
@@ -137,6 +137,7 @@ static const struct tty_operations ssl_ops = {
 	.flush_chars 		= line_flush_chars,
 	.set_termios 		= line_set_termios,
 	.ioctl 	 		= line_ioctl,
+	.compat_ioctl 	 	= line_compat_ioctl,
 	.throttle 		= line_throttle,
 	.unthrottle 		= line_unthrottle,
 #if 0
diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
index 49266f6..2cb1f04 100644
--- a/arch/um/drivers/stdio_console.c
+++ b/arch/um/drivers/stdio_console.c
@@ -120,6 +120,7 @@ static const struct tty_operations console_ops = {
 	.flush_chars 		= line_flush_chars,
 	.set_termios 		= line_set_termios,
 	.ioctl 	 		= line_ioctl,
+	.compat_ioctl 	 	= line_compat_ioctl,
 	.throttle 		= line_throttle,
 	.unthrottle 		= line_unthrottle,
 };
diff --git a/arch/um/include/shared/line.h b/arch/um/include/shared/line.h
index 311a0d3..6ef62e4 100644
--- a/arch/um/include/shared/line.h
+++ b/arch/um/include/shared/line.h
@@ -79,6 +79,8 @@ extern void line_flush_chars(struct tty_struct *tty);
 extern int line_write_room(struct tty_struct *tty);
 extern int line_ioctl(struct tty_struct *tty, struct file * file,
 		      unsigned int cmd, unsigned long arg);
+extern long line_compat_ioctl(struct tty_struct *tty, struct file * file,
+		      unsigned int cmd, unsigned long arg);
 extern void line_throttle(struct tty_struct *tty);
 extern void line_unthrottle(struct tty_struct *tty);
 
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 02/12] scsi/sg: move compat_ioctl handling into sg driver
  2009-11-16  0:26 ` [uml-devel] " Arnd Bergmann
  (?)
  (?)
@ 2009-11-16  0:26 ` Arnd Bergmann
  -1 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  0:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Doug Gilbert, James E.J. Bottomley,
	FUJITA Tomonori, Jens Axboe, linux-scsi

This moves the handling of SG_GET_REQUEST_TABLE from fs/compat_ioctl.c
into the sg driver, which is the only user.

There was no emulation for BLKTRACE so far in the sg driver, because
it does not get accessed through the block layer. Fix that by
adding emulation for BLKTRACESETUP and passthrough for the other
ioctls as well.

Since we're already touching the ioctl function, make it use
unlocked_ioctl now, to also push down the big kernel lock into
the driver.

BLKTRACESETUP32 emulation and the straight calling of compatible
ioctls apparently work fine now, but I could not find a test case
for SG_GET_REQUEST_TABLE in sg3-utils or elsewhere.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Doug Gilbert <dgilbert@interlog.com>
Cc: James E.J. Bottomley <James.Bottomley@suse.de>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: linux-scsi@vger.kernel.org
---
 drivers/scsi/sg.c       |  182 +++++++++++++++++++++++++++++++++++++++++++++--
 fs/compat_ioctl.c       |   50 -------------
 kernel/trace/blktrace.c |    1 +
 3 files changed, 176 insertions(+), 57 deletions(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 040f751..31a65cf 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -49,6 +49,7 @@ static int sg_version_num = 30534;	/* 2 digits for each component */
 #include <linux/delay.h>
 #include <linux/blktrace_api.h>
 #include <linux/smp_lock.h>
+#include <linux/compat.h>
 
 #include "scsi.h"
 #include <scsi/scsi_dbg.h>
@@ -757,9 +758,8 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
 	return 0;
 }
 
-static int
-sg_ioctl(struct inode *inode, struct file *filp,
-	 unsigned int cmd_in, unsigned long arg)
+static long
+sg_locked_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
 {
 	void __user *p = (void __user *)arg;
 	int __user *ip = p;
@@ -1078,27 +1078,195 @@ sg_ioctl(struct inode *inode, struct file *filp,
 	}
 }
 
+static long
+sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
+{
+	int ret;
+	lock_kernel();
+	ret = sg_locked_ioctl(filp, cmd_in, arg);
+	unlock_kernel();
+	return ret;
+}
+
 #ifdef CONFIG_COMPAT
-static long sg_compat_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
+
+typedef struct sg_compat_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
+    char req_state;     /* 0 -> not used, 1 -> written, 2 -> ready to read */
+    char orphan;        /* 0 -> normal request, 1 -> from interruped SG_IO */
+    char sg_io_owned;   /* 0 -> complete with read(), 1 -> owned by SG_IO */
+    char problem;       /* 0 -> no problem detected, 1 -> error to report */
+    int pack_id;        /* pack_id associated with request */
+    compat_uptr_t usr_ptr; /* user provided pointer (in new interface) */
+    unsigned int duration; /* millisecs elapsed since written (req_state==1)
+			      or request duration (req_state==2) */
+    int unused;
+} sg_compat_req_info_t; /* 20 bytes long on i386 */
+#define SZ_SG_COMPAT_REQ_INFO sizeof(sg_compat_req_info_t)
+
+struct compat_blk_user_trace_setup {
+	char name[32];
+	u16 act_mask;
+	u32 buf_size;
+	u32 buf_nr;
+	compat_u64 start_lba;
+	compat_u64 end_lba;
+	u32 pid;
+};
+#define BLKTRACESETUP32 _IOWR(0x12, 115, struct compat_blk_user_trace_setup)
+
+static long sg_compat_locked_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
 {
 	Sg_device *sdp;
 	Sg_fd *sfp;
 	struct scsi_device *sdev;
+	void __user *p = compat_ptr(arg);
+	Sg_request *srp;
+	unsigned long iflags;
+	struct blk_user_trace_setup buts;
+	struct compat_blk_user_trace_setup cbuts;
+	int ret, val;
 
 	if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
 		return -ENXIO;
 
+	switch (cmd_in) {
+	/* SG_IO comes back after conversion on fs/compat_ioctl.c */
+	case SG_IO:
+		return -ENOIOCTLCMD;
+
+	/* These are all compatible */
+	case SG_SET_TIMEOUT:
+	case SG_GET_TIMEOUT:
+	case SG_SET_FORCE_LOW_DMA:
+	case SG_GET_LOW_DMA:
+	case SG_GET_SCSI_ID:
+	case SG_SET_FORCE_PACK_ID:
+	case SG_GET_PACK_ID:
+	case SG_GET_NUM_WAITING:
+	case SG_GET_SG_TABLESIZE:
+	case SG_SET_RESERVED_SIZE:
+	case SG_GET_RESERVED_SIZE:
+	case SG_SET_COMMAND_Q:
+	case SG_GET_COMMAND_Q:
+	case SG_SET_KEEP_ORPHAN:
+	case SG_GET_KEEP_ORPHAN:
+	case SG_NEXT_CMD_LEN:
+	case SG_GET_VERSION_NUM:
+	case SG_GET_ACCESS_COUNT:
+	case SG_EMULATED_HOST:
+	case SG_SCSI_RESET:
+	case SCSI_IOCTL_SEND_COMMAND:
+	case SG_SET_DEBUG:
+	case SCSI_IOCTL_GET_IDLUN:
+	case SCSI_IOCTL_GET_BUS_NUMBER:
+	case SCSI_IOCTL_PROBE_HOST:
+	case SG_GET_TRANSFORM:
+	case BLKSECTGET:
+	case BLKTRACESTART:
+	case BLKTRACESTOP:
+	case BLKTRACETEARDOWN:
+		return sg_locked_ioctl(filp, cmd_in,
+				(unsigned long)compat_ptr(arg));
+	}
+
+	SCSI_LOG_TIMEOUT(3, printk("sg_compat_ioctl: %s, cmd=0x%x\n",
+				   sdp->disk->disk_name, (int) cmd_in));
+
+	switch (cmd_in) {
+	case SG_GET_REQUEST_TABLE:
+		if (!access_ok(VERIFY_WRITE, p, SZ_SG_REQ_INFO * SG_MAX_QUEUE))
+			return -EFAULT;
+		else {
+			sg_compat_req_info_t *rinfo;
+			unsigned int ms;
+
+			rinfo = kmalloc(SZ_SG_COMPAT_REQ_INFO * SG_MAX_QUEUE,
+								GFP_KERNEL);
+			if (!rinfo)
+				return -ENOMEM;
+			read_lock_irqsave(&sfp->rq_list_lock, iflags);
+			for (srp = sfp->headrp, val = 0; val < SG_MAX_QUEUE;
+			     ++val, srp = srp ? srp->nextrp : srp) {
+				memset(&rinfo[val], 0, SZ_SG_COMPAT_REQ_INFO);
+				if (srp) {
+					rinfo[val].req_state = srp->done + 1;
+					rinfo[val].problem =
+					    srp->header.masked_status &
+					    srp->header.host_status &
+					    srp->header.driver_status;
+					if (srp->done)
+						rinfo[val].duration =
+							srp->header.duration;
+					else {
+						ms = jiffies_to_msecs(jiffies);
+						rinfo[val].duration =
+						    (ms > srp->header.duration) ?
+						    (ms - srp->header.duration) : 0;
+					}
+					rinfo[val].orphan = srp->orphan;
+					rinfo[val].sg_io_owned =
+							srp->sg_io_owned;
+					rinfo[val].pack_id =
+							srp->header.pack_id;
+					rinfo[val].usr_ptr = (compat_uptr_t)
+					   (unsigned long) srp->header.usr_ptr;
+				}
+			}
+			read_unlock_irqrestore(&sfp->rq_list_lock, iflags);
+			ret = __copy_to_user(p, rinfo,
+						SZ_SG_COMPAT_REQ_INFO * SG_MAX_QUEUE);
+			ret = ret ? -EFAULT : 0;
+			kfree(rinfo);
+			return ret;
+		}
+	case BLKTRACESETUP32:
+		if (copy_from_user(&cbuts, p, sizeof(cbuts)))
+			return -EFAULT;
+
+		buts = (struct blk_user_trace_setup) {
+			.act_mask = cbuts.act_mask,
+			.buf_size = cbuts.buf_size,
+			.buf_nr = cbuts.buf_nr,
+			.start_lba = cbuts.start_lba,
+			.end_lba = cbuts.end_lba,
+			.pid = cbuts.pid,
+		};
+		memcpy(&buts.name, &cbuts.name, 32);
+
+		ret = do_blk_trace_setup(sdp->device->request_queue,
+					       sdp->disk->disk_name,
+					       MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
+					       NULL,
+					       &buts);
+		if (ret)
+			return ret;
+
+		if (copy_to_user(p, &buts.name, 32))
+			return -EFAULT;
+
+		return 0;
+	}
+
 	sdev = sdp->device;
-	if (sdev->host->hostt->compat_ioctl) { 
+	if (sdev->host->hostt->compat_ioctl) {
 		int ret;
 
 		ret = sdev->host->hostt->compat_ioctl(sdev, cmd_in, (void __user *)arg);
 
 		return ret;
 	}
-	
+
 	return -ENOIOCTLCMD;
 }
+
+static long sg_compat_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
+{
+	int ret;
+	lock_kernel();
+	ret = sg_compat_locked_ioctl(filp, cmd_in, arg);
+	unlock_kernel();
+	return ret;
+}
 #endif
 
 static unsigned int
@@ -1322,7 +1490,7 @@ static const struct file_operations sg_fops = {
 	.read = sg_read,
 	.write = sg_write,
 	.poll = sg_poll,
-	.ioctl = sg_ioctl,
+	.unlocked_ioctl = sg_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = sg_compat_ioctl,
 #endif
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 716788f..219a117 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -380,39 +380,6 @@ static int sg_ioctl_trans(unsigned int fd, unsigned int cmd,
 	return err;
 }
 
-struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
-	char req_state;
-	char orphan;
-	char sg_io_owned;
-	char problem;
-	int pack_id;
-	compat_uptr_t usr_ptr;
-	unsigned int duration;
-	int unused;
-};
-
-static int sg_grt_trans(unsigned int fd, unsigned int cmd, struct
-			compat_sg_req_info __user *o)
-{
-	int err, i;
-	sg_req_info_t __user *r;
-	r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE);
-	err = sys_ioctl(fd,cmd,(unsigned long)r);
-	if (err < 0)
-		return err;
-	for (i = 0; i < SG_MAX_QUEUE; i++) {
-		void __user *ptr;
-		int d;
-
-		if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) ||
-		    get_user(ptr, &r[i].usr_ptr) ||
-		    get_user(d, &r[i].duration) ||
-		    put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) ||
-		    put_user(d, &o[i].duration))
-			return -EFAULT;
-	}
-	return err;
-}
 #endif /* CONFIG_BLOCK */
 
 struct sock_fprog32 {
@@ -1159,25 +1126,12 @@ IGNORE_IOCTL(LOOP_CLR_FD)
 COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
 COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
 COMPATIBLE_IOCTL(SG_EMULATED_HOST)
-COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
 COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
 COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
-COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
-COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
-COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
-COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
-COMPATIBLE_IOCTL(SG_GET_PACK_ID)
-COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
-COMPATIBLE_IOCTL(SG_SET_DEBUG)
-COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
 COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
 COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
 COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
-COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
 COMPATIBLE_IOCTL(SG_SCSI_RESET)
-COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
-COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
-COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
 #endif
 /* PPP stuff */
 COMPATIBLE_IOCTL(PPPIOCGFLAGS)
@@ -1685,8 +1639,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
 #ifdef CONFIG_BLOCK
 	case SG_IO:
 		return sg_ioctl_trans(fd, cmd, argp);
-	case SG_GET_REQUEST_TABLE:
-		return sg_grt_trans(fd, cmd, argp);
 	case MTIOCGET32:
 	case MTIOCPOS32:
 		return mt_ioctl_trans(fd, cmd, argp);
@@ -1763,8 +1715,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
 	case KDSKBMETA:
 	case KDSKBLED:
 	case KDSETLED:
-	/* SG stuff */
-	case SG_SET_TRANSFORM:
 	/* AUTOFS */
 	case AUTOFS_IOC_READY:
 	case AUTOFS_IOC_FAIL:
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index d9d6206..96bc047 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -524,6 +524,7 @@ err:
 	blk_trace_free(bt);
 	return ret;
 }
+EXPORT_SYMBOL_GPL(do_blk_trace_setup);
 
 int blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
 		    struct block_device *bdev,
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 03/12] autofs/autofs4: move compat_ioctl handling into fs
  2009-11-16  0:26 ` [uml-devel] " Arnd Bergmann
                   ` (2 preceding siblings ...)
  (?)
@ 2009-11-16  0:26 ` Arnd Bergmann
  -1 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  0:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, H. Peter Anvin, Al Viro, Ian Kent, autofs

Handling of autofs ioctl numbers does not need to be generic
and can easily be done directly in autofs itself.

This also pushes the BKL into autofs and autofs4 ioctl
methods.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Ian Kent <raven@themaw.net>
Cc: autofs@linux.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 fs/autofs/root.c        |   67 +++++++++++++++++++++++++++++++++++++++++++--
 fs/autofs4/root.c       |   69 ++++++++++++++++++++++++++++++++++++++++++++--
 fs/compat_ioctl.c       |   36 ------------------------
 include/linux/auto_fs.h |    1 +
 4 files changed, 131 insertions(+), 42 deletions(-)

diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 4a1401c..ad8d240 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -15,6 +15,7 @@
 #include <linux/stat.h>
 #include <linux/param.h>
 #include <linux/time.h>
+#include <linux/compat.h>
 #include <linux/smp_lock.h>
 #include "autofs_i.h"
 
@@ -24,12 +25,16 @@ static int autofs_root_symlink(struct inode *,struct dentry *,const char *);
 static int autofs_root_unlink(struct inode *,struct dentry *);
 static int autofs_root_rmdir(struct inode *,struct dentry *);
 static int autofs_root_mkdir(struct inode *,struct dentry *,int);
-static int autofs_root_ioctl(struct inode *, struct file *,unsigned int,unsigned long);
+static long autofs_root_ioctl(struct file *,unsigned int,unsigned long);
+static long autofs_root_compat_ioctl(struct file *,unsigned int,unsigned long);
 
 const struct file_operations autofs_root_operations = {
 	.read		= generic_read_dir,
 	.readdir	= autofs_root_readdir,
-	.ioctl		= autofs_root_ioctl,
+	.unlocked_ioctl	= autofs_root_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= autofs_root_compat_ioctl,
+#endif
 };
 
 const struct inode_operations autofs_root_inode_operations = {
@@ -490,6 +495,25 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 }
 
 /* Get/set timeout ioctl() operation */
+#ifdef CONFIG_COMPAT
+static inline int autofs_compat_get_set_timeout(struct autofs_sb_info *sbi,
+					 unsigned int __user *p)
+{
+	unsigned long ntimeout;
+
+	if (get_user(ntimeout, p) ||
+	    put_user(sbi->exp_timeout / HZ, p))
+		return -EFAULT;
+
+	if (ntimeout > UINT_MAX/HZ)
+		sbi->exp_timeout = 0;
+	else
+		sbi->exp_timeout = ntimeout * HZ;
+
+	return 0;
+}
+#endif
+
 static inline int autofs_get_set_timeout(struct autofs_sb_info *sbi,
 					 unsigned long __user *p)
 {
@@ -544,7 +568,7 @@ static inline int autofs_expire_run(struct super_block *sb,
  * ioctl()'s on the root directory is the chief method for the daemon to
  * generate kernel reactions
  */
-static int autofs_root_ioctl(struct inode *inode, struct file *filp,
+static int autofs_do_root_ioctl(struct inode *inode, struct file *filp,
 			     unsigned int cmd, unsigned long arg)
 {
 	struct autofs_sb_info *sbi = autofs_sbi(inode->i_sb);
@@ -569,6 +593,10 @@ static int autofs_root_ioctl(struct inode *inode, struct file *filp,
 		return 0;
 	case AUTOFS_IOC_PROTOVER: /* Get protocol version */
 		return autofs_get_protover(argp);
+#ifdef CONFIG_COMPAT
+	case AUTOFS_IOC_SETTIMEOUT32:
+		return autofs_compat_get_set_timeout(sbi, argp);
+#endif
 	case AUTOFS_IOC_SETTIMEOUT:
 		return autofs_get_set_timeout(sbi, argp);
 	case AUTOFS_IOC_EXPIRE:
@@ -577,4 +605,37 @@ static int autofs_root_ioctl(struct inode *inode, struct file *filp,
 	default:
 		return -ENOSYS;
 	}
+
+}
+
+static long autofs_root_ioctl(struct file *filp,
+			     unsigned int cmd, unsigned long arg)
+{
+	int ret;
+
+	lock_kernel();
+	ret = autofs_do_root_ioctl(filp->f_path.dentry->d_inode,
+				   filp, cmd, arg);
+	unlock_kernel();
+
+	return ret;
+}
+
+#ifdef CONFIG_COMPAT
+static long autofs_root_compat_ioctl(struct file *filp,
+			     unsigned int cmd, unsigned long arg)
+{
+	struct inode *inode = filp->f_path.dentry->d_inode;
+	int ret;
+
+	lock_kernel();
+	if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL)
+		ret = autofs_do_root_ioctl(inode, filp, cmd, arg);
+	else
+		ret = autofs_do_root_ioctl(inode, filp, cmd,
+			(unsigned long)compat_ptr(arg));
+	unlock_kernel();
+
+	return ret;
 }
+#endif
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index b96a3c5..ff00dfc 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -17,13 +17,17 @@
 #include <linux/stat.h>
 #include <linux/param.h>
 #include <linux/time.h>
+#include <linux/compat.h>
+#include <linux/smp_lock.h>
+
 #include "autofs_i.h"
 
 static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *);
 static int autofs4_dir_unlink(struct inode *,struct dentry *);
 static int autofs4_dir_rmdir(struct inode *,struct dentry *);
 static int autofs4_dir_mkdir(struct inode *,struct dentry *,int);
-static int autofs4_root_ioctl(struct inode *, struct file *,unsigned int,unsigned long);
+static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long);
+static long autofs4_root_compat_ioctl(struct file *,unsigned int,unsigned long);
 static int autofs4_dir_open(struct inode *inode, struct file *file);
 static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *);
 static void *autofs4_follow_link(struct dentry *, struct nameidata *);
@@ -37,7 +41,10 @@ const struct file_operations autofs4_root_operations = {
 	.read		= generic_read_dir,
 	.readdir	= dcache_readdir,
 	.llseek		= dcache_dir_lseek,
-	.ioctl		= autofs4_root_ioctl,
+	.unlocked_ioctl	= autofs4_root_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= autofs4_root_compat_ioctl,
+#endif
 };
 
 const struct file_operations autofs4_dir_operations = {
@@ -807,6 +814,26 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 }
 
 /* Get/set timeout ioctl() operation */
+#ifdef CONFIG_COMPAT
+static inline int autofs4_compat_get_set_timeout(struct autofs_sb_info *sbi,
+					 compat_ulong_t __user *p)
+{
+	int rv;
+	unsigned long ntimeout;
+
+	if ((rv = get_user(ntimeout, p)) ||
+	     (rv = put_user(sbi->exp_timeout/HZ, p)))
+		return rv;
+
+	if (ntimeout > UINT_MAX/HZ)
+		sbi->exp_timeout = 0;
+	else
+		sbi->exp_timeout = ntimeout * HZ;
+
+	return 0;
+}
+#endif
+
 static inline int autofs4_get_set_timeout(struct autofs_sb_info *sbi,
 					 unsigned long __user *p)
 {
@@ -870,7 +897,7 @@ int is_autofs4_dentry(struct dentry *dentry)
  * ioctl()'s on the root directory is the chief method for the daemon to
  * generate kernel reactions
  */
-static int autofs4_root_ioctl(struct inode *inode, struct file *filp,
+static int autofs4_do_root_ioctl(struct inode *inode, struct file *filp,
 			     unsigned int cmd, unsigned long arg)
 {
 	struct autofs_sb_info *sbi = autofs4_sbi(inode->i_sb);
@@ -900,6 +927,10 @@ static int autofs4_root_ioctl(struct inode *inode, struct file *filp,
 		return autofs4_get_protosubver(sbi, p);
 	case AUTOFS_IOC_SETTIMEOUT:
 		return autofs4_get_set_timeout(sbi, p);
+#ifdef CONFIG_COMPAT
+	case AUTOFS_IOC_SETTIMEOUT32:
+		return autofs4_compat_get_set_timeout(sbi, p);
+#endif
 
 	case AUTOFS_IOC_ASKUMOUNT:
 		return autofs4_ask_umount(filp->f_path.mnt, p);
@@ -915,3 +946,35 @@ static int autofs4_root_ioctl(struct inode *inode, struct file *filp,
 		return -ENOSYS;
 	}
 }
+
+static long autofs4_root_ioctl(struct file *filp,
+			       unsigned int cmd, unsigned long arg)
+{
+	int ret;
+
+	lock_kernel();
+	ret = autofs4_do_root_ioctl(filp->f_path.dentry->d_inode,
+				    filp, cmd, arg);
+	unlock_kernel();
+
+	return ret;
+}
+
+#ifdef CONFIG_COMPAT
+static long autofs4_root_compat_ioctl(struct file *filp,
+			     unsigned int cmd, unsigned long arg)
+{
+	struct inode *inode = filp->f_path.dentry->d_inode;
+	int ret;
+
+	lock_kernel();
+	if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL)
+		ret = autofs4_do_root_ioctl(inode, filp, cmd, arg);
+	else
+		ret = autofs4_do_root_ioctl(inode, filp, cmd,
+			(unsigned long)compat_ptr(arg));
+	unlock_kernel();
+
+	return ret;
+}
+#endif
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 219a117..ed3f23c 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -132,23 +132,6 @@ static int w_long(unsigned int fd, unsigned int cmd,
 	return err;
 }
 
-static int rw_long(unsigned int fd, unsigned int cmd,
-		compat_ulong_t __user *argp)
-{
-	mm_segment_t old_fs = get_fs();
-	int err;
-	unsigned long val;
-
-	if(get_user(val, argp))
-		return -EFAULT;
-	set_fs (KERNEL_DS);
-	err = sys_ioctl(fd, cmd, (unsigned long)&val);
-	set_fs (old_fs);
-	if (!err && put_user(val, argp))
-		return -EFAULT;
-	return err;
-}
-
 struct compat_video_event {
 	int32_t		type;
 	compat_time_t	timestamp;
@@ -556,12 +539,6 @@ static int do_smb_getmountuid(unsigned int fd, unsigned int cmd,
 	return err;
 }
 
-static int ioc_settimeout(unsigned int fd, unsigned int cmd,
-		compat_ulong_t __user *argp)
-{
-	return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, argp);
-}
-
 /* Bluetooth ioctls */
 #define HCIUARTSETPROTO	_IOW('U', 200, int)
 #define HCIUARTGETPROTO	_IOR('U', 201, int)
@@ -1348,13 +1325,6 @@ COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
 COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
 COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
 COMPATIBLE_IOCTL(OSS_GETVERSION)
-/* AUTOFS */
-COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
-COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
-COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
-COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI)
-COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOSUBVER)
-COMPATIBLE_IOCTL(AUTOFS_IOC_ASKUMOUNT)
 /* Raw devices */
 COMPATIBLE_IOCTL(RAW_SETBIND)
 COMPATIBLE_IOCTL(RAW_GETBIND)
@@ -1647,9 +1617,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
 	case RAW_GETBIND:
 		return raw_ioctl(fd, cmd, argp);
 #endif
-#define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
-	case AUTOFS_IOC_SETTIMEOUT32:
-		return ioc_settimeout(fd, cmd, argp);
 	/* One SMB ioctl needs translations. */
 #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
 	case SMB_IOC_GETMOUNTUID_32:
@@ -1715,9 +1682,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
 	case KDSKBMETA:
 	case KDSKBLED:
 	case KDSETLED:
-	/* AUTOFS */
-	case AUTOFS_IOC_READY:
-	case AUTOFS_IOC_FAIL:
 	/* NBD */
 	case NBD_SET_SOCK:
 	case NBD_SET_BLKSIZE:
diff --git a/include/linux/auto_fs.h b/include/linux/auto_fs.h
index 7b09c83..da64e15 100644
--- a/include/linux/auto_fs.h
+++ b/include/linux/auto_fs.h
@@ -79,6 +79,7 @@ struct autofs_packet_expire {
 #define AUTOFS_IOC_FAIL       _IO(0x93,0x61)
 #define AUTOFS_IOC_CATATONIC  _IO(0x93,0x62)
 #define AUTOFS_IOC_PROTOVER   _IOR(0x93,0x63,int)
+#define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,compat_ulong_t)
 #define AUTOFS_IOC_SETTIMEOUT _IOWR(0x93,0x64,unsigned long)
 #define AUTOFS_IOC_EXPIRE     _IOR(0x93,0x65,struct autofs_packet_expire)
 
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 04/12] raw: partly fix compat_ioctl handling on non-x86
  2009-11-16  0:26 ` [uml-devel] " Arnd Bergmann
                   ` (3 preceding siblings ...)
  (?)
@ 2009-11-16  0:26 ` Arnd Bergmann
  -1 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  0:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Kay Sievers, Jens Axboe,
	Jan Blunck, Martin K. Petersen

The (compat_ioctl handling for the) raw driver is broken in
multiple ways. The RAW_SETBIND and RAW_GETBIND ioctls are
compatible between 32 and 64 bit on most architectures
but not on x86-64 and ia64 because of the different alignment
on 64 bit variables.
Defining the data structure in terms of compat_u64 rather than
using __attribute__((packed)) solves this.

Another problem is the handling of ioctl passthrough to
block devices, which is not implemented for the compat_ioctl
case and has been broken for ages. This patch does not
fix the problem but prints a diagnostic message in case
someone hits it.

Also move the conversion code into the raw driver itself
to clean up the common fs/compat_ioctl implementation.

Finally, push the big kernel lock into the ioctl functions,
since I'm touching them anyway.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Jan Blunck <jblunck@suse.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
---
 drivers/char/raw.c |  157 +++++++++++++++++++++++++++++++++++++++++-----------
 fs/compat_ioctl.c  |   68 ----------------------
 2 files changed, 125 insertions(+), 100 deletions(-)

diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 64acd05..7ccf1c1 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -20,6 +20,7 @@
 #include <linux/device.h>
 #include <linux/mutex.h>
 #include <linux/smp_lock.h>
+#include <linux/compat.h>
 
 #include <asm/uaccess.h>
 
@@ -120,9 +121,8 @@ static int raw_release(struct inode *inode, struct file *filp)
 /*
  * Forward ioctls to the underlying block device.
  */
-static int
-raw_ioctl(struct inode *inode, struct file *filp,
-		  unsigned int command, unsigned long arg)
+static long
+raw_ioctl(struct file *filp, unsigned int command, unsigned long arg)
 {
 	struct block_device *bdev = filp->private_data;
 
@@ -140,10 +140,9 @@ static void bind_device(struct raw_config_request *rq)
  * Deal with ioctls against the raw-device control interface, to bind
  * and unbind other raw devices.
  */
-static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
-			unsigned int command, unsigned long arg)
+static int do_raw_ctl_ioctl(struct file *filp,
+			unsigned int command, struct raw_config_request *rq)
 {
-	struct raw_config_request rq;
 	struct raw_device_data *rawdev;
 	int err = 0;
 
@@ -152,17 +151,11 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
 	case RAW_GETBIND:
 
 		/* First, find out which raw minor we want */
-
-		if (copy_from_user(&rq, (void __user *) arg, sizeof(rq))) {
-			err = -EFAULT;
-			goto out;
-		}
-
-		if (rq.raw_minor <= 0 || rq.raw_minor >= MAX_RAW_MINORS) {
+		if (rq->raw_minor <= 0 || rq->raw_minor >= MAX_RAW_MINORS) {
 			err = -EINVAL;
 			goto out;
 		}
-		rawdev = &raw_devices[rq.raw_minor];
+		rawdev = &raw_devices[rq->raw_minor];
 
 		if (command == RAW_SETBIND) {
 			dev_t dev;
@@ -183,10 +176,10 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
 			 * major/minor numbers make sense.
 			 */
 
-			dev = MKDEV(rq.block_major, rq.block_minor);
-			if ((rq.block_major == 0 && rq.block_minor != 0) ||
-					MAJOR(dev) != rq.block_major ||
-					MINOR(dev) != rq.block_minor) {
+			dev = MKDEV(rq->block_major, rq->block_minor);
+			if ((rq->block_major == 0 && rq->block_minor != 0) ||
+					MAJOR(dev) != rq->block_major ||
+					MINOR(dev) != rq->block_minor) {
 				err = -EINVAL;
 				goto out;
 			}
@@ -201,18 +194,18 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
 				bdput(rawdev->binding);
 				module_put(THIS_MODULE);
 			}
-			if (rq.block_major == 0 && rq.block_minor == 0) {
+			if (rq->block_major == 0 && rq->block_minor == 0) {
 				/* unbind */
 				rawdev->binding = NULL;
 				device_destroy(raw_class,
-						MKDEV(RAW_MAJOR, rq.raw_minor));
+						MKDEV(RAW_MAJOR, rq->raw_minor));
 			} else {
 				rawdev->binding = bdget(dev);
 				if (rawdev->binding == NULL)
 					err = -ENOMEM;
 				else {
 					__module_get(THIS_MODULE);
-					bind_device(&rq);
+					bind_device(rq);
 				}
 			}
 			mutex_unlock(&raw_mutex);
@@ -222,16 +215,12 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
 			mutex_lock(&raw_mutex);
 			bdev = rawdev->binding;
 			if (bdev) {
-				rq.block_major = MAJOR(bdev->bd_dev);
-				rq.block_minor = MINOR(bdev->bd_dev);
+				rq->block_major = MAJOR(bdev->bd_dev);
+				rq->block_minor = MINOR(bdev->bd_dev);
 			} else {
-				rq.block_major = rq.block_minor = 0;
+				rq->block_major = rq->block_minor = 0;
 			}
 			mutex_unlock(&raw_mutex);
-			if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) {
-				err = -EFAULT;
-				goto out;
-			}
 		}
 		break;
 	default:
@@ -242,6 +231,108 @@ out:
 	return err;
 }
 
+
+static long raw_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+	struct raw_config_request rq;
+	int err = -EINVAL;
+
+        switch (cmd) {
+        case RAW_SETBIND:
+        case RAW_GETBIND:
+		if (copy_from_user(&rq, (void __user *)arg, sizeof(rq))) {
+			err = -EFAULT;
+			break;
+		}
+
+		lock_kernel();
+                err = do_raw_ctl_ioctl(file, cmd, &rq);
+		unlock_kernel();
+
+		if (!err && cmd == RAW_GETBIND) {
+			if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) {
+				err = -EFAULT;
+			}
+		}
+                break;
+        }
+        return err;
+}
+
+#ifdef CONFIG_COMPAT
+struct compat_raw_config_request {
+	compat_int_t	raw_minor;
+	compat_u64	block_major;
+	compat_u64	block_minor;
+};
+
+static int get_raw32_request(struct raw_config_request *req,
+			     struct compat_raw_config_request __user * user_req)
+{
+	int err;
+
+	if (!access_ok (VERIFY_READ, user_req,
+			sizeof(struct compat_raw_config_request)))
+		return -EFAULT;
+
+	err  = __get_user(req->raw_minor, &user_req->raw_minor);
+	err |= __get_user(req->block_major, &user_req->block_major);
+	err |= __get_user(req->block_minor, &user_req->block_minor);
+
+	return err ? -EFAULT : 0;
+}
+
+static int set_raw32_request(struct raw_config_request *req,
+			     struct compat_raw_config_request __user * user_req)
+{
+	int err;
+
+	if (!access_ok(VERIFY_WRITE, user_req,
+			sizeof(struct compat_raw_config_request)))
+		return -EFAULT;
+
+	err  = __put_user(req->raw_minor, &user_req->raw_minor);
+	err |= __put_user(req->block_major, &user_req->block_major);
+	err |= __put_user(req->block_minor, &user_req->block_minor);
+
+	return err ? -EFAULT : 0;
+}
+
+static long raw_ctl_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg)
+{
+	struct raw_config_request req;
+	struct compat_raw_config_request __user *user_req;
+	int err = -EINVAL;
+
+	user_req = compat_ptr(arg);
+	switch (cmd) {
+	case RAW_SETBIND:
+	case RAW_GETBIND:
+		if ((err = get_raw32_request(&req, user_req)))
+			return err;
+
+		lock_kernel();
+		err = do_raw_ctl_ioctl(file, cmd, &req);
+		unlock_kernel();
+
+		if ((!err) && (cmd == RAW_GETBIND)) {
+			err = set_raw32_request(&req, user_req);
+		}
+		break;
+	}
+	return err;
+}
+
+static long
+raw_compat_ioctl(struct file *filp, unsigned int command, unsigned long arg)
+{
+	/* FIXME: should pass through ioctls */
+	compat_printk("%s: no support for block ioctls\n", __func__);
+
+	return -ENOIOCTLCMD;
+}
+#endif /* CONFIG_COMPAT */
+
 static const struct file_operations raw_fops = {
 	.read	=	do_sync_read,
 	.aio_read = 	generic_file_aio_read,
@@ -249,14 +340,16 @@ static const struct file_operations raw_fops = {
 	.aio_write =	blkdev_aio_write,
 	.open	=	raw_open,
 	.release=	raw_release,
-	.ioctl	=	raw_ioctl,
+	.unlocked_ioctl	= raw_ioctl,
+	.compat_ioctl = raw_compat_ioctl,
 	.owner	=	THIS_MODULE,
 };
 
 static const struct file_operations raw_ctl_fops = {
-	.ioctl	=	raw_ctl_ioctl,
-	.open	=	raw_open,
-	.owner	=	THIS_MODULE,
+	.unlocked_ioctl	= raw_ctl_ioctl,
+	.compat_ioctl	= raw_ctl_compat_ioctl,
+	.open		= raw_open,
+	.owner		= THIS_MODULE,
 };
 
 static struct cdev raw_cdev;
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index ed3f23c..80f1a92 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -558,70 +558,6 @@ static int do_smb_getmountuid(unsigned int fd, unsigned int cmd,
 #define HIDPGETCONNLIST	_IOR('H', 210, int)
 #define HIDPGETCONNINFO	_IOR('H', 211, int)
 
-#ifdef CONFIG_BLOCK
-struct raw32_config_request
-{
-        compat_int_t    raw_minor;
-        __u64   block_major;
-        __u64   block_minor;
-} __attribute__((packed));
-
-static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
-{
-        int ret;
-
-        if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request)))
-                return -EFAULT;
-
-        ret = __get_user(req->raw_minor, &user_req->raw_minor);
-        ret |= __get_user(req->block_major, &user_req->block_major);
-        ret |= __get_user(req->block_minor, &user_req->block_minor);
-
-        return ret ? -EFAULT : 0;
-}
-
-static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
-{
-	int ret;
-
-        if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request)))
-                return -EFAULT;
-
-        ret = __put_user(req->raw_minor, &user_req->raw_minor);
-        ret |= __put_user(req->block_major, &user_req->block_major);
-        ret |= __put_user(req->block_minor, &user_req->block_minor);
-
-        return ret ? -EFAULT : 0;
-}
-
-static int raw_ioctl(unsigned fd, unsigned cmd,
-		struct raw32_config_request __user *user_req)
-{
-        int ret;
-
-        switch (cmd) {
-        case RAW_SETBIND:
-        case RAW_GETBIND: {
-                struct raw_config_request req;
-                mm_segment_t oldfs = get_fs();
-
-                if ((ret = get_raw32_request(&req, user_req)))
-                        return ret;
-
-                set_fs(KERNEL_DS);
-                ret = sys_ioctl(fd,cmd,(unsigned long)&req);
-                set_fs(oldfs);
-
-                if ((!ret) && (cmd == RAW_GETBIND)) {
-                        ret = set_raw32_request(&req, user_req);
-                }
-                break;
-        }
-        }
-        return ret;
-}
-#endif /* CONFIG_BLOCK */
-
 struct serial_struct32 {
         compat_int_t    type;
         compat_int_t    line;
@@ -1612,10 +1548,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
 	case MTIOCGET32:
 	case MTIOCPOS32:
 		return mt_ioctl_trans(fd, cmd, argp);
-	/* Raw devices */
-	case RAW_SETBIND:
-	case RAW_GETBIND:
-		return raw_ioctl(fd, cmd, argp);
 #endif
 	/* One SMB ioctl needs translations. */
 #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 05/12] nbd: add compat_ioctl method
  2009-11-16  0:26 ` [uml-devel] " Arnd Bergmann
                   ` (4 preceding siblings ...)
  (?)
@ 2009-11-16  0:27 ` Arnd Bergmann
  -1 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  0:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Paul Clements, Jens Axboe, Andrew Morton,
	Pavel Machek, Tejun Heo

The nbd driver needs a special case for its compat_ioctl
handling, because it treats the ioctl argument as an
integer instead of a pointer.

Move that handling into the nbd driver itself from
fs/compat_ioctl.c in order to keep it local.

Push down the BKL into the ioctl method at the
same time.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Paul Clements <Paul.Clements@steeleye.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Pavel Machek <pavel@suse.cz>
Cc: Tejun Heo <tj@kernel.org>
---
 drivers/block/nbd.c |    7 ++++++-
 fs/compat_ioctl.c   |   11 -----------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index cc923a5..758b75d 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -30,6 +30,8 @@
 #include <net/sock.h>
 #include <linux/net.h>
 #include <linux/kthread.h>
+#include <linux/smp_lock.h>
+#include <linux/compat.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -715,9 +717,11 @@ static int nbd_ioctl(struct block_device *bdev, fmode_t mode,
 	dprintk(DBG_IOCTL, "%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n",
 			lo->disk->disk_name, ioctl_cmd_to_ascii(cmd), cmd, arg);
 
+	lock_kernel();
 	mutex_lock(&lo->tx_lock);
 	error = __nbd_ioctl(bdev, lo, cmd, arg);
 	mutex_unlock(&lo->tx_lock);
+	unlock_kernel();
 
 	return error;
 }
@@ -725,7 +729,8 @@ static int nbd_ioctl(struct block_device *bdev, fmode_t mode,
 static const struct block_device_operations nbd_fops =
 {
 	.owner =	THIS_MODULE,
-	.locked_ioctl =	nbd_ioctl,
+	.ioctl =	nbd_ioctl,
+	.compat_ioctl =	nbd_ioctl,
 };
 
 /*
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 80f1a92..376d907 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1362,12 +1362,6 @@ COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32)
 COMPATIBLE_IOCTL(USBDEVFS_REAPURB32)
 COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32)
 COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
-/* NBD */
-COMPATIBLE_IOCTL(NBD_DO_IT)
-COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
-COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
-COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
-COMPATIBLE_IOCTL(NBD_DISCONNECT)
 /* i2c */
 COMPATIBLE_IOCTL(I2C_SLAVE)
 COMPATIBLE_IOCTL(I2C_SLAVE_FORCE)
@@ -1614,11 +1608,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
 	case KDSKBMETA:
 	case KDSKBLED:
 	case KDSETLED:
-	/* NBD */
-	case NBD_SET_SOCK:
-	case NBD_SET_BLKSIZE:
-	case NBD_SET_SIZE:
-	case NBD_SET_SIZE_BLOCKS:
 		return do_vfs_ioctl(file, fd, cmd, arg);
 	}
 
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 06/12] smbfs: do compat_ioctl handling in place
  2009-11-16  0:26 ` [uml-devel] " Arnd Bergmann
                   ` (5 preceding siblings ...)
  (?)
@ 2009-11-16  0:27 ` Arnd Bergmann
  -1 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  0:27 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, KOSAKI Motohiro, Andrew Morton, Nick Piggin

Handling SMB_IOC_GETMOUNTUID emulation directly in smbfs avoids
extra code in fs/compat_ioctl.c and can be optimized away by
the compiler in architectures where SMB_IOC_GETMOUNTUID and
COMPAT_SMB_IOC_GETMOUNTUID are identical.

As a positive side-effect, this pushes the BKL into the
ioctl method.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Piggin <npiggin@suse.de>
---
 fs/compat_ioctl.c |   25 -------------------------
 fs/smbfs/dir.c    |    5 ++++-
 fs/smbfs/file.c   |    3 ++-
 fs/smbfs/ioctl.c  |   48 ++++++++++++++++++++++++++++++++++++++++++++----
 fs/smbfs/proto.h  |    3 ++-
 5 files changed, 52 insertions(+), 32 deletions(-)

diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 376d907..a762fb1 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -520,25 +520,6 @@ static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, void __user *argp)
 
 #endif /* CONFIG_BLOCK */
 
-static int do_smb_getmountuid(unsigned int fd, unsigned int cmd,
-			compat_uid_t __user *argp)
-{
-	mm_segment_t old_fs = get_fs();
-	__kernel_uid_t kuid;
-	int err;
-
-	cmd = SMB_IOC_GETMOUNTUID;
-
-	set_fs(KERNEL_DS);
-	err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
-	set_fs(old_fs);
-
-	if (err >= 0)
-		err = put_user(kuid, argp);
-
-	return err;
-}
-
 /* Bluetooth ioctls */
 #define HCIUARTSETPROTO	_IOW('U', 200, int)
 #define HCIUARTGETPROTO	_IOR('U', 201, int)
@@ -1264,8 +1245,6 @@ COMPATIBLE_IOCTL(OSS_GETVERSION)
 /* Raw devices */
 COMPATIBLE_IOCTL(RAW_SETBIND)
 COMPATIBLE_IOCTL(RAW_GETBIND)
-/* SMB ioctls which do not need any translations */
-COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
 /* Watchdog */
 COMPATIBLE_IOCTL(WDIOC_GETSUPPORT)
 COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
@@ -1543,10 +1522,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
 	case MTIOCPOS32:
 		return mt_ioctl_trans(fd, cmd, argp);
 #endif
-	/* One SMB ioctl needs translations. */
-#define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
-	case SMB_IOC_GETMOUNTUID_32:
-		return do_smb_getmountuid(fd, cmd, argp);
 	/* Serial */
 	case TIOCGSERIAL:
 	case TIOCSSERIAL:
diff --git a/fs/smbfs/dir.c b/fs/smbfs/dir.c
index 3e4803b..9607ff1 100644
--- a/fs/smbfs/dir.c
+++ b/fs/smbfs/dir.c
@@ -39,7 +39,10 @@ const struct file_operations smb_dir_operations =
 {
 	.read		= generic_read_dir,
 	.readdir	= smb_readdir,
-	.ioctl		= smb_ioctl,
+	.unlocked_ioctl	= smb_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= smb_ioctl,
+#endif
 	.open		= smb_dir_open,
 };
 
diff --git a/fs/smbfs/file.c b/fs/smbfs/file.c
index 92d5e8f..02f2bf8 100644
--- a/fs/smbfs/file.c
+++ b/fs/smbfs/file.c
@@ -438,7 +438,8 @@ const struct file_operations smb_file_operations =
 	.aio_read	= smb_file_aio_read,
 	.write		= do_sync_write,
 	.aio_write	= smb_file_aio_write,
-	.ioctl		= smb_ioctl,
+	.unlocked_ioctl	= smb_ioctl,
+	.compat_ioctl	= smb_ioctl,
 	.mmap		= smb_file_mmap,
 	.open		= smb_file_open,
 	.release	= smb_file_release,
diff --git a/fs/smbfs/ioctl.c b/fs/smbfs/ioctl.c
index dbae1f8..0c28305 100644
--- a/fs/smbfs/ioctl.c
+++ b/fs/smbfs/ioctl.c
@@ -14,6 +14,8 @@
 #include <linux/mm.h>
 #include <linux/highuid.h>
 #include <linux/net.h>
+#include <linux/smp_lock.h>
+#include <linux/compat.h>
 
 #include <linux/smb_fs.h>
 #include <linux/smb_mount.h>
@@ -22,11 +24,9 @@
 
 #include "proto.h"
 
-int
-smb_ioctl(struct inode *inode, struct file *filp,
-	  unsigned int cmd, unsigned long arg)
+static long
+smb_locked_ioctl(struct smb_sb_info *server, unsigned int cmd, void __user *arg)
 {
-	struct smb_sb_info *server = server_from_inode(inode);
 	struct smb_conn_opt opt;
 	int result = -EINVAL;
 
@@ -65,3 +65,43 @@ smb_ioctl(struct inode *inode, struct file *filp,
 
 	return result;
 }
+
+long
+smb_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+	struct smb_sb_info *server;
+	int ret;
+
+	lock_kernel();
+	server = server_from_inode(filp->f_path.dentry->d_inode);
+	ret = smb_locked_ioctl(server, cmd, (void __user *)arg);
+	unlock_kernel();
+
+	return ret;
+}
+
+#ifdef CONFIG_COMPAT
+#define COMPAT_SMB_IOC_GETMOUNTUID _IOR('u', 1, compat_uid_t)
+long
+smb_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+	struct smb_sb_info *server;
+	void __user *argp = compat_ptr(arg);
+	int ret;
+
+	lock_kernel();
+	server = server_from_inode(filp->f_path.dentry->d_inode);
+	if (cmd == COMPAT_SMB_IOC_GETMOUNTUID &&
+	    sizeof (compat_uid_t) < sizeof (__kernel_old_uid_t)) {
+		uid_t uid = server->mnt->mounted_uid;
+		if (uid > 65535)
+			uid = (compat_uid_t)overflowuid;
+		ret = put_user(uid, (compat_uid_t __user *) argp);
+	} else {
+		ret = smb_locked_ioctl(server, cmd, argp);
+	}
+	unlock_kernel();
+
+	return ret;
+}
+#endif
diff --git a/fs/smbfs/proto.h b/fs/smbfs/proto.h
index 03f456c..34bc708 100644
--- a/fs/smbfs/proto.h
+++ b/fs/smbfs/proto.h
@@ -67,7 +67,8 @@ extern const struct address_space_operations smb_file_aops;
 extern const struct file_operations smb_file_operations;
 extern const struct inode_operations smb_file_inode_operations;
 /* ioctl.c */
-extern int smb_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);
+extern long smb_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+extern long smb_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
 /* smbiod.c */
 extern void smbiod_wake_up(void);
 extern int smbiod_register_server(struct smb_sb_info *server);
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 07/12] i2cdev: move compat_ioctl handling into driver
  2009-11-16  0:26 ` [uml-devel] " Arnd Bergmann
                   ` (6 preceding siblings ...)
  (?)
@ 2009-11-16  0:27 ` Arnd Bergmann
  2009-12-14 14:23     ` Jean Delvare
  -1 siblings, 1 reply; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  0:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Jean Delvare (PC drivers, core),
	Ben Dooks (embedded platforms),
	Wolfram Sang, linux-i2c

Doing all the compat_ioctl handling in the i2c driver itself
removes special cases from fs/compat_ioctl.c and makes it possible
to optimize this case better.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: "Jean Delvare (PC drivers, core)" <khali@linux-fr.org>
Cc: "Ben Dooks (embedded platforms)" <ben-linux@fluff.org>
Cc: Wolfram Sang <w.sang@pengutronix.de>
Cc: linux-i2c@vger.kernel.org
---
 drivers/i2c/i2c-dev.c |  117 ++++++++++++++++++++++++++++++++++++++++++++++++
 fs/compat_ioctl.c     |  119 -------------------------------------------------
 2 files changed, 117 insertions(+), 119 deletions(-)

diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 7e13d2d..fde0c9e 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -35,6 +35,7 @@
 #include <linux/i2c.h>
 #include <linux/i2c-dev.h>
 #include <linux/smp_lock.h>
+#include <linux/compat.h>
 #include <linux/jiffies.h>
 #include <asm/uaccess.h>
 
@@ -439,6 +440,119 @@ static long i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	return 0;
 }
 
+#ifdef CONFIG_COMPAT
+struct i2c_msg32 {
+	u16 addr;
+	u16 flags;
+	u16 len;
+	compat_caddr_t buf;
+};
+
+struct i2c_rdwr_ioctl_data32 {
+	compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
+	u32 nmsgs;
+};
+
+struct i2c_smbus_ioctl_data32 {
+	u8 read_write;
+	u8 command;
+	u32 size;
+	compat_caddr_t data; /* union i2c_smbus_data *data */
+};
+
+struct i2c_rdwr_aligned {
+	struct i2c_rdwr_ioctl_data cmd;
+	struct i2c_msg msgs[0];
+};
+
+static int compat_i2c_rdwr_ioctl(struct file *filp, unsigned int cmd,
+			struct i2c_rdwr_ioctl_data32    __user *udata)
+{
+	struct i2c_rdwr_aligned		__user *tdata;
+	struct i2c_msg			__user *tmsgs;
+	struct i2c_msg32		__user *umsgs;
+	compat_caddr_t			datap;
+	int				nmsgs, i;
+
+	if (get_user(nmsgs, &udata->nmsgs))
+		return -EFAULT;
+	if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
+		return -EINVAL;
+
+	if (get_user(datap, &udata->msgs))
+		return -EFAULT;
+	umsgs = compat_ptr(datap);
+
+	tdata = compat_alloc_user_space(sizeof(*tdata) +
+				      nmsgs * sizeof(struct i2c_msg));
+	tmsgs = &tdata->msgs[0];
+
+	if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
+	    put_user(tmsgs, &tdata->cmd.msgs))
+		return -EFAULT;
+
+	for (i = 0; i < nmsgs; i++) {
+		if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
+			return -EFAULT;
+		if (get_user(datap, &umsgs[i].buf) ||
+		    put_user(compat_ptr(datap), &tmsgs[i].buf))
+			return -EFAULT;
+	}
+	return i2cdev_ioctl(filp, cmd, (unsigned long)tdata);
+}
+
+static int compat_i2c_smbus_ioctl(struct file *filp, unsigned int cmd,
+			struct i2c_smbus_ioctl_data32   __user *udata)
+{
+	struct i2c_smbus_ioctl_data	__user *tdata;
+	compat_caddr_t			datap;
+
+	tdata = compat_alloc_user_space(sizeof(*tdata));
+	if (tdata == NULL)
+		return -ENOMEM;
+	if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
+		return -EFAULT;
+
+	if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
+		return -EFAULT;
+
+	if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
+		return -EFAULT;
+	if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
+		return -EFAULT;
+	if (__get_user(datap, &udata->data) ||
+	    __put_user(compat_ptr(datap), &tdata->data))
+		return -EFAULT;
+
+	return i2cdev_ioctl(filp, cmd, (unsigned long)tdata);
+}
+
+static int compat_i2c_funcs(struct file *filp, unsigned int cmd,
+			compat_ulong_t __user *argp)
+{
+	struct i2c_client *client = filp->private_data;
+	compat_ulong_t funcs;
+	funcs = i2c_get_functionality(client->adapter);
+	return put_user(funcs, argp);
+}
+
+static long i2cdev_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+	void __user *argp = compat_ptr(arg);
+
+	switch (cmd) {
+	case I2C_FUNCS:
+		return compat_i2c_funcs(filp, cmd, argp);
+	case I2C_RDWR:
+		return compat_i2c_rdwr_ioctl(filp, cmd, argp);
+	case I2C_SMBUS:
+		return compat_i2c_smbus_ioctl(filp, cmd, argp);
+	}
+
+	return i2cdev_ioctl(filp, cmd, arg);
+}
+#endif /* CONFIG_COMPAT */
+
 static int i2cdev_open(struct inode *inode, struct file *file)
 {
 	unsigned int minor = iminor(inode);
@@ -501,6 +615,9 @@ static const struct file_operations i2cdev_fops = {
 	.read		= i2cdev_read,
 	.write		= i2cdev_write,
 	.unlocked_ioctl	= i2cdev_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= i2cdev_compat_ioctl,
+#endif
 	.open		= i2cdev_open,
 	.release	= i2cdev_release,
 };
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index a762fb1..b419459 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -117,21 +117,6 @@
 #include <asm/fbio.h>
 #endif
 
-static int w_long(unsigned int fd, unsigned int cmd,
-		compat_ulong_t __user *argp)
-{
-	mm_segment_t old_fs = get_fs();
-	int err;
-	unsigned long val;
-
-	set_fs (KERNEL_DS);
-	err = sys_ioctl(fd, cmd, (unsigned long)&val);
-	set_fs (old_fs);
-	if (!err && put_user(val, argp))
-		return -EFAULT;
-	return err;
-}
-
 struct compat_video_event {
 	int32_t		type;
 	compat_time_t	timestamp;
@@ -691,96 +676,6 @@ static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd,
         return err;
 }
 
-/*
- * I2C layer ioctls
- */
-
-struct i2c_msg32 {
-	u16 addr;
-	u16 flags;
-	u16 len;
-	compat_caddr_t buf;
-};
-
-struct i2c_rdwr_ioctl_data32 {
-	compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
-	u32 nmsgs;
-};
-
-struct i2c_smbus_ioctl_data32 {
-	u8 read_write;
-	u8 command;
-	u32 size;
-	compat_caddr_t data; /* union i2c_smbus_data *data */
-};
-
-struct i2c_rdwr_aligned {
-	struct i2c_rdwr_ioctl_data cmd;
-	struct i2c_msg msgs[0];
-};
-
-static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
-			struct i2c_rdwr_ioctl_data32    __user *udata)
-{
-	struct i2c_rdwr_aligned		__user *tdata;
-	struct i2c_msg			__user *tmsgs;
-	struct i2c_msg32		__user *umsgs;
-	compat_caddr_t			datap;
-	int				nmsgs, i;
-
-	if (get_user(nmsgs, &udata->nmsgs))
-		return -EFAULT;
-	if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
-		return -EINVAL;
-
-	if (get_user(datap, &udata->msgs))
-		return -EFAULT;
-	umsgs = compat_ptr(datap);
-
-	tdata = compat_alloc_user_space(sizeof(*tdata) +
-				      nmsgs * sizeof(struct i2c_msg));
-	tmsgs = &tdata->msgs[0];
-
-	if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
-	    put_user(tmsgs, &tdata->cmd.msgs))
-		return -EFAULT;
-
-	for (i = 0; i < nmsgs; i++) {
-		if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
-			return -EFAULT;
-		if (get_user(datap, &umsgs[i].buf) ||
-		    put_user(compat_ptr(datap), &tmsgs[i].buf))
-			return -EFAULT;
-	}
-	return sys_ioctl(fd, cmd, (unsigned long)tdata);
-}
-
-static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd,
-			struct i2c_smbus_ioctl_data32   __user *udata)
-{
-	struct i2c_smbus_ioctl_data	__user *tdata;
-	compat_caddr_t			datap;
-
-	tdata = compat_alloc_user_space(sizeof(*tdata));
-	if (tdata == NULL)
-		return -ENOMEM;
-	if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
-		return -EFAULT;
-
-	if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
-		return -EFAULT;
-
-	if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
-		return -EFAULT;
-	if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
-		return -EFAULT;
-	if (__get_user(datap, &udata->data) ||
-	    __put_user(compat_ptr(datap), &tdata->data))
-		return -EFAULT;
-
-	return sys_ioctl(fd, cmd, (unsigned long)tdata);
-}
-
 #define RTC_IRQP_READ32		_IOR('p', 0x0b, compat_ulong_t)
 #define RTC_IRQP_SET32		_IOW('p', 0x0c, compat_ulong_t)
 #define RTC_EPOCH_READ32	_IOR('p', 0x0d, compat_ulong_t)
@@ -1341,13 +1236,6 @@ COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32)
 COMPATIBLE_IOCTL(USBDEVFS_REAPURB32)
 COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32)
 COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
-/* i2c */
-COMPATIBLE_IOCTL(I2C_SLAVE)
-COMPATIBLE_IOCTL(I2C_SLAVE_FORCE)
-COMPATIBLE_IOCTL(I2C_TENBIT)
-COMPATIBLE_IOCTL(I2C_PEC)
-COMPATIBLE_IOCTL(I2C_RETRIES)
-COMPATIBLE_IOCTL(I2C_TIMEOUT)
 /* hiddev */
 COMPATIBLE_IOCTL(HIDIOCGVERSION)
 COMPATIBLE_IOCTL(HIDIOCAPPLICATION)
@@ -1533,13 +1421,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
 		return do_usbdevfs_bulk(fd, cmd, argp);
 	case USBDEVFS_DISCSIGNAL32:
 		return do_usbdevfs_discsignal(fd, cmd, argp);
-	/* i2c */
-	case I2C_FUNCS:
-		return w_long(fd, cmd, argp);
-	case I2C_RDWR:
-		return do_i2c_rdwr_ioctl(fd, cmd, argp);
-	case I2C_SMBUS:
-		return do_i2c_smbus_ioctl(fd, cmd, argp);
 	/* Not implemented in the native kernel */
 	case RTC_IRQP_READ32:
 	case RTC_IRQP_SET32:
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 08/12] md: move compat_ioctl handling into md.c
  2009-11-16  0:26 ` [uml-devel] " Arnd Bergmann
                   ` (7 preceding siblings ...)
  (?)
@ 2009-11-16  0:27 ` Arnd Bergmann
  2009-11-16  8:39   ` Andre Noll
  -1 siblings, 1 reply; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  0:27 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, Neil Brown, Andre Noll, linux-raid

The RAID ioctls are only implemented in md.c, so the
handling for them should also be moved there from
fs/compat_ioctl.c.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Neil Brown <neilb@suse.de>
Cc: Andre Noll <maan@systemlinux.org>
Cc: linux-raid@vger.kernel.org
---
 drivers/md/md.c   |   23 +++++++++++++++++++++++
 fs/compat_ioctl.c |   23 -----------------------
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index e64c971..e4eebaf 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -44,6 +44,7 @@
 #include <linux/random.h>
 #include <linux/reboot.h>
 #include <linux/file.h>
+#include <linux/compat.h>
 #include <linux/delay.h>
 #include <linux/raid/md_p.h>
 #include <linux/raid/md_u.h>
@@ -5503,6 +5504,25 @@ done:
 abort:
 	return err;
 }
+#ifdef CONFIG_COMPAT
+static int md_compat_ioctl(struct block_device *bdev, fmode_t mode,
+		    unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+	case HOT_REMOVE_DISK:
+	case HOT_ADD_DISK:
+	case SET_DISK_FAULTY:
+	case SET_BITMAP_FILE:
+		/* These take in integer arg, do not convert */
+		break;
+	default:
+		arg = (unsigned long)compat_ptr(arg);
+		break;
+	}
+
+	return md_ioctl(bdev, mode, cmd, arg);
+}
+#endif /* CONFIG_COMPAT */
 
 static int md_open(struct block_device *bdev, fmode_t mode)
 {
@@ -5568,6 +5588,9 @@ static const struct block_device_operations md_fops =
 	.open		= md_open,
 	.release	= md_release,
 	.ioctl		= md_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= md_compat_ioctl,
+#endif
 	.getgeo		= md_getgeo,
 	.media_changed	= md_media_changed,
 	.revalidate_disk= md_revalidate,
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index b419459..8adfc08 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -837,24 +837,6 @@ COMPATIBLE_IOCTL(FIGETBSZ)
 /* 'X' - originally XFS but some now in the VFS */
 COMPATIBLE_IOCTL(FIFREEZE)
 COMPATIBLE_IOCTL(FITHAW)
-/* RAID */
-COMPATIBLE_IOCTL(RAID_VERSION)
-COMPATIBLE_IOCTL(GET_ARRAY_INFO)
-COMPATIBLE_IOCTL(GET_DISK_INFO)
-COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
-COMPATIBLE_IOCTL(RAID_AUTORUN)
-COMPATIBLE_IOCTL(CLEAR_ARRAY)
-COMPATIBLE_IOCTL(ADD_NEW_DISK)
-COMPATIBLE_IOCTL(SET_ARRAY_INFO)
-COMPATIBLE_IOCTL(SET_DISK_INFO)
-COMPATIBLE_IOCTL(WRITE_RAID_INFO)
-COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
-COMPATIBLE_IOCTL(PROTECT_ARRAY)
-COMPATIBLE_IOCTL(RUN_ARRAY)
-COMPATIBLE_IOCTL(STOP_ARRAY)
-COMPATIBLE_IOCTL(STOP_ARRAY_RO)
-COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
-COMPATIBLE_IOCTL(GET_BITMAP_FILE)
 COMPATIBLE_IOCTL(KDGETKEYCODE)
 COMPATIBLE_IOCTL(KDSETKEYCODE)
 COMPATIBLE_IOCTL(KDGKBTYPE)
@@ -1450,11 +1432,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
 	case TCSBRKP:
 	case TIOCMIWAIT:
 	case TIOCSCTTY:
-	/* RAID */
-	case HOT_REMOVE_DISK:
-	case HOT_ADD_DISK:
-	case SET_DISK_FAULTY:
-	case SET_BITMAP_FILE:
 	/* Big K */
 	case KDSIGACCEPT:
 	case KIOCSOUND:
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 09/12] lp: move compat_ioctl handling into lp.c
  2009-11-16  0:26 ` [uml-devel] " Arnd Bergmann
                   ` (8 preceding siblings ...)
  (?)
@ 2009-11-16  0:27 ` Arnd Bergmann
  2009-11-17  1:38   ` Greg KH
  -1 siblings, 1 reply; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  0:27 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, Greg Kroah-Hartman

Handling for LPSETTIMEOUT can easily be done in lp_ioctl, which
is the only user. As a positive side-effect, push the BKL
into the ioctl methods.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/char/lp.c |  115 +++++++++++++++++++++++++++++++++++++++++------------
 fs/compat_ioctl.c |   33 ---------------
 2 files changed, 89 insertions(+), 59 deletions(-)

diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index e444c2d..938a3a2 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -127,6 +127,7 @@
 #include <linux/wait.h>
 #include <linux/jiffies.h>
 #include <linux/smp_lock.h>
+#include <linux/compat.h>
 
 #include <linux/parport.h>
 #undef LP_STATS
@@ -571,13 +572,11 @@ static int lp_release(struct inode * inode, struct file * file)
 	return 0;
 }
 
-static int lp_ioctl(struct inode *inode, struct file *file,
-		    unsigned int cmd, unsigned long arg)
+static int lp_do_ioctl(unsigned int minor, unsigned int cmd,
+	unsigned long arg, void __user *argp)
 {
-	unsigned int minor = iminor(inode);
 	int status;
 	int retval = 0;
-	void __user *argp = (void __user *)arg;
 
 #ifdef LP_DEBUG
 	printk(KERN_DEBUG "lp%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
@@ -587,9 +586,6 @@ static int lp_ioctl(struct inode *inode, struct file *file,
 	if ((LP_F(minor) & LP_EXIST) == 0)
 		return -ENODEV;
 	switch ( cmd ) {
-		struct timeval par_timeout;
-		long to_jiffies;
-
 		case LPTIME:
 			LP_TIME(minor) = arg * HZ/100;
 			break;
@@ -652,34 +648,101 @@ static int lp_ioctl(struct inode *inode, struct file *file,
 				return -EFAULT;
 			break;
 
-		case LPSETTIMEOUT:
-			if (copy_from_user (&par_timeout, argp,
-					    sizeof (struct timeval))) {
-				return -EFAULT;
-			}
-			/* Convert to jiffies, place in lp_table */
-			if ((par_timeout.tv_sec < 0) ||
-			    (par_timeout.tv_usec < 0)) {
-				return -EINVAL;
-			}
-			to_jiffies = DIV_ROUND_UP(par_timeout.tv_usec, 1000000/HZ);
-			to_jiffies += par_timeout.tv_sec * (long) HZ;
-			if (to_jiffies <= 0) {
-				return -EINVAL;
-			}
-			lp_table[minor].timeout = to_jiffies;
-			break;
-
 		default:
 			retval = -EINVAL;
 	}
 	return retval;
 }
 
+static int lp_set_timeout(unsigned int minor, struct timeval *par_timeout)
+{
+	long to_jiffies;
+
+	/* Convert to jiffies, place in lp_table */
+	if ((par_timeout->tv_sec < 0) ||
+	    (par_timeout->tv_usec < 0)) {
+		return -EINVAL;
+	}
+	to_jiffies = DIV_ROUND_UP(par_timeout->tv_usec, 1000000/HZ);
+	to_jiffies += par_timeout->tv_sec * (long) HZ;
+	if (to_jiffies <= 0) {
+		return -EINVAL;
+	}
+	lp_table[minor].timeout = to_jiffies;
+	return 0;
+}
+
+static long lp_ioctl(struct file *file, unsigned int cmd,
+			unsigned long arg)
+{
+	unsigned int minor;
+	struct timeval par_timeout;
+	int ret;
+
+	minor = iminor(file->f_path.dentry->d_inode);
+	lock_kernel();
+	switch (cmd) {
+	case LPSETTIMEOUT:
+		if (copy_from_user(&par_timeout, (void __user *)arg,
+					sizeof (struct timeval))) {
+			ret = -EFAULT;
+			break;
+		}
+		ret = lp_set_timeout(minor, &par_timeout);
+		break;
+	default:
+		ret = lp_do_ioctl(minor, cmd, arg, (void __user *)arg);
+		break;
+	}
+	unlock_kernel();
+
+	return ret;
+}
+
+#ifdef CONFIG_COMPAT
+static long lp_compat_ioctl(struct file *file, unsigned int cmd,
+			unsigned long arg)
+{
+	unsigned int minor;
+	struct timeval par_timeout;
+	struct compat_timeval __user *tc;
+	int ret;
+
+	minor = iminor(file->f_path.dentry->d_inode);
+	lock_kernel();
+	switch (cmd) {
+	case LPSETTIMEOUT:
+		tc = compat_ptr(arg);
+		if (get_user(par_timeout.tv_sec, &tc->tv_sec) ||
+		    get_user(par_timeout.tv_usec, &tc->tv_usec)) {
+			ret = -EFAULT;
+			break;
+		}
+		ret = lp_set_timeout(minor, &par_timeout);
+		break;
+#ifdef LP_STATS
+	case LPGETSTATS:
+		/* FIXME: add an implementation if you set LP_STATS */
+		ret = -EINVAL;
+		break;
+#endif
+	default:
+		ret = lp_do_ioctl(minor, cmd, arg, compat_ptr(arg));
+		break;
+	}
+	unlock_kernel();
+
+	return ret;
+}
+#endif
+
 static const struct file_operations lp_fops = {
 	.owner		= THIS_MODULE,
 	.write		= lp_write,
-	.ioctl		= lp_ioctl,
+	.unlocked_ioctl	= lp_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= lp_compat_ioctl,
+#endif
 	.open		= lp_open,
 	.release	= lp_release,
 #ifdef CONFIG_PARPORT_1284
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 8adfc08..68929a2 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -709,20 +709,6 @@ static int rtc_ioctl(unsigned fd, unsigned cmd, void __user *argp)
 	return -ENOIOCTLCMD;
 }
 
-static int
-lp_timeout_trans(unsigned int fd, unsigned int cmd,
-			struct compat_timeval __user *tc)
-{
-	struct timeval __user *tn = compat_alloc_user_space(sizeof(struct timeval));
-	struct timeval ts;
-	if (get_user(ts.tv_sec, &tc->tv_sec) ||
-	    get_user(ts.tv_usec, &tc->tv_usec) ||
-	    put_user(ts.tv_sec, &tn->tv_sec) ||
-	    put_user(ts.tv_usec, &tn->tv_usec))
-		return -EFAULT;
-	return sys_ioctl(fd, cmd, (unsigned long)tn);
-}
-
 /* on ia32 l_start is on a 32-bit boundary */
 #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
 struct space_resv_32 {
@@ -937,8 +923,6 @@ COMPATIBLE_IOCTL(PPPIOCGCHAN)
 /* PPPOX */
 COMPATIBLE_IOCTL(PPPOEIOCSFWD)
 COMPATIBLE_IOCTL(PPPOEIOCDFWD)
-/* LP */
-COMPATIBLE_IOCTL(LPGETSTATUS)
 /* ppdev */
 COMPATIBLE_IOCTL(PPSETMODE)
 COMPATIBLE_IOCTL(PPRSTATUS)
@@ -1326,19 +1310,6 @@ COMPATIBLE_IOCTL(TIOCSTOP)
 /* Usbdevfs */
 COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
 
-/* parport */
-COMPATIBLE_IOCTL(LPTIME)
-COMPATIBLE_IOCTL(LPCHAR)
-COMPATIBLE_IOCTL(LPABORTOPEN)
-COMPATIBLE_IOCTL(LPCAREFUL)
-COMPATIBLE_IOCTL(LPWAIT)
-COMPATIBLE_IOCTL(LPSETIRQ)
-COMPATIBLE_IOCTL(LPGETSTATUS)
-COMPATIBLE_IOCTL(LPGETSTATUS)
-COMPATIBLE_IOCTL(LPRESET)
-/*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/
-COMPATIBLE_IOCTL(LPGETFLAGS)
-
 /* fat 'r' ioctls. These are handled by fat with ->compat_ioctl,
    but we don't want warnings on other file systems. So declare
    them as compatible here. */
@@ -1417,10 +1388,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
 		return do_video_stillpicture(fd, cmd, argp);
 	case VIDEO_SET_SPU_PALETTE:
 		return do_video_set_spu_palette(fd, cmd, argp);
-
-	/* lp */
-	case LPSETTIMEOUT:
-		return lp_timeout_trans(fd, cmd, argp);
 	}
 
 	/*
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 10/12] usbdevfs: move compat_ioctl handling to devio.c
  2009-11-16  0:26 ` [uml-devel] " Arnd Bergmann
                   ` (9 preceding siblings ...)
  (?)
@ 2009-11-16  0:27 ` Arnd Bergmann
  2009-11-17  1:38   ` Greg KH
  -1 siblings, 1 reply; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  0:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Alan Stern, Oliver Neukum,
	Alon Bar-Lev, David Vrabel, linux-usb

Half the compat_ioctl handling is in devio.c, the other
half is in fs/compat_ioctl.c. This moves everything into
one place for consistency.

As a positive side-effect, push down the BKL into the
ioctl methods.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Oliver Neukum <oliver@neukum.org>
Cc: Alon Bar-Lev <alon.barlev@gmail.com>
Cc: David Vrabel <david.vrabel@csr.com>
Cc: linux-usb@vger.kernel.org
---
 drivers/usb/core/devio.c     |  110 ++++++++++++++++++++++++++++++++++++----
 fs/compat_ioctl.c            |  113 +-----------------------------------------
 include/linux/usbdevice_fs.h |   26 ++++++++++
 3 files changed, 126 insertions(+), 123 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 181f78c..6e8bcdf 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1388,6 +1388,46 @@ static int proc_reapurbnonblock(struct dev_state *ps, void __user *arg)
 }
 
 #ifdef CONFIG_COMPAT
+static int proc_control_compat(struct dev_state *ps,
+				struct usbdevfs_ctrltransfer32 __user *p32)
+{
+        struct usbdevfs_ctrltransfer __user *p;
+        __u32 udata;
+        p = compat_alloc_user_space(sizeof(*p));
+        if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
+            get_user(udata, &p32->data) ||
+	    put_user(compat_ptr(udata), &p->data))
+		return -EFAULT;
+        return proc_control(ps, p);
+}
+
+static int proc_bulk_compat(struct dev_state *ps,
+			struct usbdevfs_bulktransfer32 __user *p32)
+{
+        struct usbdevfs_bulktransfer __user *p;
+        compat_uint_t n;
+        compat_caddr_t addr;
+
+        p = compat_alloc_user_space(sizeof(*p));
+
+        if (get_user(n, &p32->ep) || put_user(n, &p->ep) ||
+            get_user(n, &p32->len) || put_user(n, &p->len) ||
+            get_user(n, &p32->timeout) || put_user(n, &p->timeout) ||
+            get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data))
+                return -EFAULT;
+
+        return proc_bulk(ps, p);
+}
+static int proc_disconnectsignal_compat(struct dev_state *ps, void __user *arg)
+{
+	struct usbdevfs_disconnectsignal32 ds;
+
+	if (copy_from_user(&ds, arg, sizeof(ds)))
+		return -EFAULT;
+	ps->discsignr = ds.signr;
+	ps->disccontext = compat_ptr(ds.context);
+	return 0;
+}
 
 static int get_urb32(struct usbdevfs_urb *kurb,
 		     struct usbdevfs_urb32 __user *uurb)
@@ -1482,6 +1522,7 @@ static int proc_reapurbnonblock_compat(struct dev_state *ps, void __user *arg)
 	return processcompl_compat(as, (void __user * __user *)arg);
 }
 
+
 #endif
 
 static int proc_disconnectsignal(struct dev_state *ps, void __user *arg)
@@ -1648,12 +1689,12 @@ static int proc_release_port(struct dev_state *ps, void __user *arg)
  * are assuming that somehow the configuration has been prevented from
  * changing.  But there's no mechanism to ensure that...
  */
-static int usbdev_ioctl(struct inode *inode, struct file *file,
-			unsigned int cmd, unsigned long arg)
+static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
+				void __user *p)
 {
 	struct dev_state *ps = file->private_data;
+	struct inode *inode = file->f_path.dentry->d_inode;
 	struct usb_device *dev = ps->dev;
-	void __user *p = (void __user *)arg;
 	int ret = -ENOTTY;
 
 	if (!(file->f_mode & FMODE_WRITE))
@@ -1726,6 +1767,24 @@ static int usbdev_ioctl(struct inode *inode, struct file *file,
 		break;
 
 #ifdef CONFIG_COMPAT
+	case USBDEVFS_CONTROL32:
+		snoop(&dev->dev, "%s: CONTROL32\n", __func__);
+		ret = proc_control_compat(ps, p);
+		if (ret >= 0)
+			inode->i_mtime = CURRENT_TIME;
+		break;
+
+	case USBDEVFS_BULK32:
+		snoop(&dev->dev, "%s: BULK32\n", __func__);
+		ret = proc_bulk_compat(ps, p);
+		if (ret >= 0)
+			inode->i_mtime = CURRENT_TIME;
+		break;
+
+	case USBDEVFS_DISCSIGNAL32:
+		snoop(&dev->dev, "%s: DISCSIGNAL32\n", __func__);
+		ret = proc_disconnectsignal_compat(ps, p);
+		break;
 
 	case USBDEVFS_SUBMITURB32:
 		snoop(&dev->dev, "%s: SUBMITURB32\n", __func__);
@@ -1745,7 +1804,7 @@ static int usbdev_ioctl(struct inode *inode, struct file *file,
 		break;
 
 	case USBDEVFS_IOCTL32:
-		snoop(&dev->dev, "%s: IOCTL\n", __func__);
+		snoop(&dev->dev, "%s: IOCTL32\n", __func__);
 		ret = proc_ioctl_compat(ps, ptr_to_compat(p));
 		break;
 #endif
@@ -1801,6 +1860,32 @@ static int usbdev_ioctl(struct inode *inode, struct file *file,
 	return ret;
 }
 
+static long usbdev_ioctl(struct file *file, unsigned int cmd,
+			unsigned long arg)
+{
+	int ret;
+
+	lock_kernel();
+	ret = usbdev_do_ioctl(file, cmd, (void __user *)arg);
+	unlock_kernel();
+
+	return ret;
+}
+
+#ifdef CONFIG_COMPAT
+static long usbdev_compat_ioctl(struct file *file, unsigned int cmd,
+			unsigned long arg)
+{
+	int ret;
+
+	lock_kernel();
+	ret = usbdev_do_ioctl(file, cmd, compat_ptr(arg));
+	unlock_kernel();
+
+	return ret;
+}
+#endif
+
 /* No kernel lock - fine */
 static unsigned int usbdev_poll(struct file *file,
 				struct poll_table_struct *wait)
@@ -1817,13 +1902,16 @@ static unsigned int usbdev_poll(struct file *file,
 }
 
 const struct file_operations usbdev_file_operations = {
-	.owner = 	THIS_MODULE,
-	.llseek =	usbdev_lseek,
-	.read =		usbdev_read,
-	.poll =		usbdev_poll,
-	.ioctl =	usbdev_ioctl,
-	.open =		usbdev_open,
-	.release =	usbdev_release,
+	.owner =	  THIS_MODULE,
+	.llseek =	  usbdev_lseek,
+	.read =		  usbdev_read,
+	.poll =		  usbdev_poll,
+	.unlocked_ioctl = usbdev_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl =   usbdev_compat_ioctl,
+#endif
+	.open =		  usbdev_open,
+	.release =	  usbdev_release,
 };
 
 static void usbdev_remove(struct usb_device *udev)
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 68929a2..1fef181 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -588,94 +588,6 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
         return err;
 }
 
-struct usbdevfs_ctrltransfer32 {
-        u8 bRequestType;
-        u8 bRequest;
-        u16 wValue;
-        u16 wIndex;
-        u16 wLength;
-        u32 timeout;  /* in milliseconds */
-        compat_caddr_t data;
-};
-
-#define USBDEVFS_CONTROL32           _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
-
-static int do_usbdevfs_control(unsigned int fd, unsigned int cmd,
-			struct usbdevfs_ctrltransfer32 __user *p32)
-{
-        struct usbdevfs_ctrltransfer __user *p;
-        __u32 udata;
-        p = compat_alloc_user_space(sizeof(*p));
-        if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
-            get_user(udata, &p32->data) ||
-	    put_user(compat_ptr(udata), &p->data))
-		return -EFAULT;
-        return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p);
-}
-
-
-struct usbdevfs_bulktransfer32 {
-        compat_uint_t ep;
-        compat_uint_t len;
-        compat_uint_t timeout; /* in milliseconds */
-        compat_caddr_t data;
-};
-
-#define USBDEVFS_BULK32              _IOWR('U', 2, struct usbdevfs_bulktransfer32)
-
-static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd,
-			struct usbdevfs_bulktransfer32 __user *p32)
-{
-        struct usbdevfs_bulktransfer __user *p;
-        compat_uint_t n;
-        compat_caddr_t addr;
-
-        p = compat_alloc_user_space(sizeof(*p));
-
-        if (get_user(n, &p32->ep) || put_user(n, &p->ep) ||
-            get_user(n, &p32->len) || put_user(n, &p->len) ||
-            get_user(n, &p32->timeout) || put_user(n, &p->timeout) ||
-            get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data))
-                return -EFAULT;
-
-        return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p);
-}
-
-
-/*
- *  USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY
- *  are handled in usbdevfs core.			-Christopher Li
- */
-
-struct usbdevfs_disconnectsignal32 {
-        compat_int_t signr;
-        compat_caddr_t context;
-};
-
-#define USBDEVFS_DISCSIGNAL32      _IOR('U', 14, struct usbdevfs_disconnectsignal32)
-
-static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd,
-			struct usbdevfs_disconnectsignal32 __user *udis)
-{
-        struct usbdevfs_disconnectsignal kdis;
-        mm_segment_t old_fs;
-        u32 uctx;
-        int err;
-
-        if (get_user(kdis.signr, &udis->signr) ||
-            __get_user(uctx, &udis->context))
-                return -EFAULT;
-
-        kdis.context = compat_ptr(uctx);
-
-        old_fs = get_fs();
-        set_fs(KERNEL_DS);
-        err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
-        set_fs(old_fs);
-
-        return err;
-}
-
 #define RTC_IRQP_READ32		_IOR('p', 0x0b, compat_ulong_t)
 #define RTC_IRQP_SET32		_IOW('p', 0x0c, compat_ulong_t)
 #define RTC_EPOCH_READ32	_IOR('p', 0x0d, compat_ulong_t)
@@ -1187,21 +1099,6 @@ COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
 COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
 COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
 COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
-/* USB */
-COMPATIBLE_IOCTL(USBDEVFS_RESETEP)
-COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE)
-COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION)
-COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER)
-COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB)
-COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE)
-COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE)
-COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO)
-COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO)
-COMPATIBLE_IOCTL(USBDEVFS_RESET)
-COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32)
-COMPATIBLE_IOCTL(USBDEVFS_REAPURB32)
-COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32)
-COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
 /* hiddev */
 COMPATIBLE_IOCTL(HIDIOCGVERSION)
 COMPATIBLE_IOCTL(HIDIOCAPPLICATION)
@@ -1307,8 +1204,6 @@ COMPATIBLE_IOCTL(TIOCSLTC)
 COMPATIBLE_IOCTL(TIOCSTART)
 COMPATIBLE_IOCTL(TIOCSTOP)
 #endif
-/* Usbdevfs */
-COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
 
 /* fat 'r' ioctls. These are handled by fat with ->compat_ioctl,
    but we don't want warnings on other file systems. So declare
@@ -1367,13 +1262,7 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
 	case TIOCGSERIAL:
 	case TIOCSSERIAL:
 		return serial_struct_ioctl(fd, cmd, argp);
-	/* Usbdevfs */
-	case USBDEVFS_CONTROL32:
-		return do_usbdevfs_control(fd, cmd, argp);
-	case USBDEVFS_BULK32:
-		return do_usbdevfs_bulk(fd, cmd, argp);
-	case USBDEVFS_DISCSIGNAL32:
-		return do_usbdevfs_discsignal(fd, cmd, argp);
+
 	/* Not implemented in the native kernel */
 	case RTC_IRQP_READ32:
 	case RTC_IRQP_SET32:
diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h
index b2a7d8b..15591d2 100644
--- a/include/linux/usbdevice_fs.h
+++ b/include/linux/usbdevice_fs.h
@@ -128,6 +128,29 @@ struct usbdevfs_hub_portinfo {
 #ifdef __KERNEL__
 #ifdef CONFIG_COMPAT
 #include <linux/compat.h>
+
+struct usbdevfs_ctrltransfer32 {
+        u8 bRequestType;
+        u8 bRequest;
+        u16 wValue;
+        u16 wIndex;
+        u16 wLength;
+        u32 timeout;  /* in milliseconds */
+        compat_caddr_t data;
+};
+
+struct usbdevfs_bulktransfer32 {
+        compat_uint_t ep;
+        compat_uint_t len;
+        compat_uint_t timeout; /* in milliseconds */
+        compat_caddr_t data;
+};
+
+struct usbdevfs_disconnectsignal32 {
+        compat_int_t signr;
+        compat_caddr_t context;
+};
+
 struct usbdevfs_urb32 {
 	unsigned char type;
 	unsigned char endpoint;
@@ -153,7 +176,9 @@ struct usbdevfs_ioctl32 {
 #endif /* __KERNEL__ */
 
 #define USBDEVFS_CONTROL           _IOWR('U', 0, struct usbdevfs_ctrltransfer)
+#define USBDEVFS_CONTROL32           _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
 #define USBDEVFS_BULK              _IOWR('U', 2, struct usbdevfs_bulktransfer)
+#define USBDEVFS_BULK32              _IOWR('U', 2, struct usbdevfs_bulktransfer32)
 #define USBDEVFS_RESETEP           _IOR('U', 3, unsigned int)
 #define USBDEVFS_SETINTERFACE      _IOR('U', 4, struct usbdevfs_setinterface)
 #define USBDEVFS_SETCONFIGURATION  _IOR('U', 5, unsigned int)
@@ -166,6 +191,7 @@ struct usbdevfs_ioctl32 {
 #define USBDEVFS_REAPURBNDELAY     _IOW('U', 13, void *)
 #define USBDEVFS_REAPURBNDELAY32   _IOW('U', 13, __u32)
 #define USBDEVFS_DISCSIGNAL        _IOR('U', 14, struct usbdevfs_disconnectsignal)
+#define USBDEVFS_DISCSIGNAL32      _IOR('U', 14, struct usbdevfs_disconnectsignal32)
 #define USBDEVFS_CLAIMINTERFACE    _IOR('U', 15, unsigned int)
 #define USBDEVFS_RELEASEINTERFACE  _IOR('U', 16, unsigned int)
 #define USBDEVFS_CONNECTINFO       _IOW('U', 17, struct usbdevfs_connectinfo)
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 11/12] hamradio/mkiss: fix typo in compat_ioctl
  2009-11-16  0:26 ` [uml-devel] " Arnd Bergmann
                   ` (10 preceding siblings ...)
  (?)
@ 2009-11-16  0:27 ` Arnd Bergmann
  2009-11-16  5:13   ` David Miller
  -1 siblings, 1 reply; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  0:27 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, David S. Miller

My last commit introduced an typo causing the
compat_ioctl function to do nothing useful.
The obvious way for an ioctl function to work
is to look at the command, not the argument first.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: David S. Miller <davem@davemloft.net>
---
 drivers/net/hamradio/mkiss.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index fc9c578..7db0a1c 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -903,7 +903,7 @@ static int mkiss_ioctl(struct tty_struct *tty, struct file *file,
 static long mkiss_compat_ioctl(struct tty_struct *tty, struct file *file,
 	unsigned int cmd, unsigned long arg)
 {
-	switch (arg) {
+	switch (cmd) {
 	case SIOCGIFNAME:
 	case SIOCGIFENCAP:
 	case SIOCSIFENCAP:
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 12/12] compat_ioctl: remove unused handlers
  2009-11-16  0:26 ` [uml-devel] " Arnd Bergmann
                   ` (11 preceding siblings ...)
  (?)
@ 2009-11-16  0:27 ` Arnd Bergmann
  -1 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  0:27 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann

These handlers were moved into the respective drivers and can
now be deleted from common code.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/compat_ioctl.c |   26 --------------------------
 1 files changed, 0 insertions(+), 26 deletions(-)

diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 1fef181..5ae4fde 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -735,21 +735,6 @@ COMPATIBLE_IOCTL(FIGETBSZ)
 /* 'X' - originally XFS but some now in the VFS */
 COMPATIBLE_IOCTL(FIFREEZE)
 COMPATIBLE_IOCTL(FITHAW)
-COMPATIBLE_IOCTL(KDGETKEYCODE)
-COMPATIBLE_IOCTL(KDSETKEYCODE)
-COMPATIBLE_IOCTL(KDGKBTYPE)
-COMPATIBLE_IOCTL(KDGETMODE)
-COMPATIBLE_IOCTL(KDGKBMODE)
-COMPATIBLE_IOCTL(KDGKBMETA)
-COMPATIBLE_IOCTL(KDGKBENT)
-COMPATIBLE_IOCTL(KDSKBENT)
-COMPATIBLE_IOCTL(KDGKBSENT)
-COMPATIBLE_IOCTL(KDSKBSENT)
-COMPATIBLE_IOCTL(KDGKBDIACR)
-COMPATIBLE_IOCTL(KDSKBDIACR)
-COMPATIBLE_IOCTL(KDKBDREP)
-COMPATIBLE_IOCTL(KDGKBLED)
-COMPATIBLE_IOCTL(KDGETLED)
 #ifdef CONFIG_BLOCK
 /* Big S */
 COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
@@ -1277,26 +1262,15 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
 		return do_video_stillpicture(fd, cmd, argp);
 	case VIDEO_SET_SPU_PALETTE:
 		return do_video_set_spu_palette(fd, cmd, argp);
-	}
 
 	/*
 	 * These take an integer instead of a pointer as 'arg',
 	 * so we must not do a compat_ptr() translation.
 	 */
-	switch (cmd) {
 	/* Big T */
 	case TCSBRKP:
 	case TIOCMIWAIT:
 	case TIOCSCTTY:
-	/* Big K */
-	case KDSIGACCEPT:
-	case KIOCSOUND:
-	case KDMKTONE:
-	case KDSETMODE:
-	case KDSKBMODE:
-	case KDSKBMETA:
-	case KDSKBLED:
-	case KDSETLED:
 		return do_vfs_ioctl(file, fd, cmd, arg);
 	}
 
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* Re: [uml-user] [PATCH 00/12] move compat_ioctl handling into drivers
  2009-11-16  0:26 ` [uml-devel] " Arnd Bergmann
  (?)
@ 2009-11-16  0:57   ` Neil Brown
  -1 siblings, 0 replies; 29+ messages in thread
From: Neil Brown @ 2009-11-16  0:57 UTC (permalink / raw)
  Cc: linux-usb, user-mode-linux-user, H. Peter Anvin, Paul Clements,
	Wolfram Sang, Andre Noll, Pavel Machek, linux-i2c, Jens Axboe,
	Jan Blunck, Ian Kent, Nick Piggin, user-mode-linux-devel,
	linux-scsi, Kay Sievers, Alon Bar-Lev, Alan Stern,
	KOSAKI Motohiro, Doug Gilbert, David Vrabel, Alexey Dobriyan,
	Arnd Bergmann, Jeff Dike, Oliver Neukum, linux-raid

On Mon, 16 Nov 2009 00:26:55 +0000
Arnd Bergmann <arnd@arndb.de> wrote:

> This is the second series of patches on compat_ioctl handling,
> moving compat handlers into more drivers. Most of these
> patches consist on a part that adds a compat_ioctl method
> in one driver and another part removing the respective
> section from fs/compat_ioctl.c. The fs/compat_ioctl.c
> portion depends on other patches[1], but the driver code can
> be applied independently.
> 
> If some of you feel responsible for the code I patched, please
> look at my changes and if they are ok, either take them into
> your tree or give me an Acked-by for them.

I would take the md ones into my tree, but I suspect that if
everyone did that we would end up with lots of conflicts in
fs/compat_ioctl.c.

So how about I just take the changes to md.c, and give you an:

   Acked-by: NeilBrown <neilb@suse.de>

for the changes to fs/compat_ioctl.c
??

NeilBrown

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [uml-devel] [PATCH 00/12] move compat_ioctl handling into drivers
@ 2009-11-16  0:57   ` Neil Brown
  0 siblings, 0 replies; 29+ messages in thread
From: Neil Brown @ 2009-11-16  0:57 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-usb, user-mode-linux-user, H. Peter Anvin, Paul Clements,
	Wolfram Sang, Andre Noll, Pavel Machek, linux-i2c, Jens Axboe,
	Jan Blunck, Ian Kent, Nick Piggin, user-mode-linux-devel,
	linux-scsi, Kay Sievers, Alon Bar-Lev, Alan Stern,
	KOSAKI Motohiro, Doug Gilbert, David Vrabel, Alexey Dobriyan,
	Arnd Bergmann, Jeff Dike, Oliver Neukum, linux-raid, Tejun Heo,
	James E.J. Bottomley, Al Viro, Ben Dooks (embedded platforms),
	autofs, Martin K. Petersen, Greg Kroah-Hartman, linux-kernel,
	FUJITA Tomonori, Jean Delvare (PC drivers, core),
	Andrew Morton, David S. Miller

On Mon, 16 Nov 2009 00:26:55 +0000
Arnd Bergmann <arnd@arndb.de> wrote:

> This is the second series of patches on compat_ioctl handling,
> moving compat handlers into more drivers. Most of these
> patches consist on a part that adds a compat_ioctl method
> in one driver and another part removing the respective
> section from fs/compat_ioctl.c. The fs/compat_ioctl.c
> portion depends on other patches[1], but the driver code can
> be applied independently.
> 
> If some of you feel responsible for the code I patched, please
> look at my changes and if they are ok, either take them into
> your tree or give me an Acked-by for them.

I would take the md ones into my tree, but I suspect that if
everyone did that we would end up with lots of conflicts in
fs/compat_ioctl.c.

So how about I just take the changes to md.c, and give you an:

   Acked-by: NeilBrown <neilb@suse.de>

for the changes to fs/compat_ioctl.c
??

NeilBrown

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [uml-user] [PATCH 00/12] move compat_ioctl handling into drivers
@ 2009-11-16  0:57   ` Neil Brown
  0 siblings, 0 replies; 29+ messages in thread
From: Neil Brown @ 2009-11-16  0:57 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-usb, user-mode-linux-user, H. Peter Anvin, Paul Clements,
	Wolfram Sang, Andre Noll, Pavel Machek, linux-i2c, Jens Axboe,
	Jan Blunck, Ian Kent, Nick Piggin, user-mode-linux-devel,
	linux-scsi, Kay Sievers, Alon Bar-Lev, Alan Stern,
	KOSAKI Motohiro, Doug Gilbert, David Vrabel, Alexey Dobriyan,
	Arnd Bergmann, Jeff Dike, Oliver Neukum, linux-raid

On Mon, 16 Nov 2009 00:26:55 +0000
Arnd Bergmann <arnd@arndb.de> wrote:

> This is the second series of patches on compat_ioctl handling,
> moving compat handlers into more drivers. Most of these
> patches consist on a part that adds a compat_ioctl method
> in one driver and another part removing the respective
> section from fs/compat_ioctl.c. The fs/compat_ioctl.c
> portion depends on other patches[1], but the driver code can
> be applied independently.
> 
> If some of you feel responsible for the code I patched, please
> look at my changes and if they are ok, either take them into
> your tree or give me an Acked-by for them.

I would take the md ones into my tree, but I suspect that if
everyone did that we would end up with lots of conflicts in
fs/compat_ioctl.c.

So how about I just take the changes to md.c, and give you an:

   Acked-by: NeilBrown <neilb@suse.de>

for the changes to fs/compat_ioctl.c
??

NeilBrown

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [uml-user] [PATCH 00/12] move compat_ioctl handling into drivers
  2009-11-16  0:57   ` [uml-devel] " Neil Brown
  (?)
@ 2009-11-16  1:02     ` Arnd Bergmann
  -1 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  1:02 UTC (permalink / raw)
  To: Neil Brown
  Cc: linux-usb, user-mode-linux-user, H. Peter Anvin, Paul Clements,
	Wolfram Sang, Andre Noll, Pavel Machek, linux-i2c, Jens Axboe,
	Jan Blunck, Ian Kent, Nick Piggin, linux-scsi, Kay Sievers,
	Alon Bar-Lev, Alan Stern, KOSAKI Motohiro, Doug Gilbert,
	David Vrabel, Alexey Dobriyan, user-mode-linux-devel, Jeff Dike,
	Oliver Neukum, linux-raid, Tejun Heo

On Monday 16 November 2009, Neil Brown wrote:
> I would take the md ones into my tree, but I suspect that if
> everyone did that we would end up with lots of conflicts in
> fs/compat_ioctl.c.
> 
> So how about I just take the changes to md.c, and give you an:
> 
>    Acked-by: NeilBrown <neilb@suse.de>
> 
> for the changes to fs/compat_ioctl.c
> ??

Yes, that is exactly what I was trying to suggest. Thanks,

	Arnd <><

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [uml-devel] [PATCH 00/12] move compat_ioctl handling into drivers
@ 2009-11-16  1:02     ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  1:02 UTC (permalink / raw)
  To: Neil Brown
  Cc: linux-usb, user-mode-linux-user, H. Peter Anvin, Paul Clements,
	Wolfram Sang, Andre Noll, Pavel Machek, linux-i2c, Jens Axboe,
	Jan Blunck, Ian Kent, Nick Piggin, linux-scsi, Kay Sievers,
	Alon Bar-Lev, Alan Stern, KOSAKI Motohiro, Doug Gilbert,
	David Vrabel, Alexey Dobriyan, user-mode-linux-devel, Jeff Dike,
	Oliver Neukum, linux-raid, Tejun Heo, James E.J. Bottomley,
	Al Viro, Ben Dooks (embedded platforms),
	autofs, Martin K. Petersen, Greg Kroah-Hartman, linux-kernel,
	FUJITA Tomonori, Jean Delvare (PC drivers, core),
	Andrew Morton, David S. Miller

On Monday 16 November 2009, Neil Brown wrote:
> I would take the md ones into my tree, but I suspect that if
> everyone did that we would end up with lots of conflicts in
> fs/compat_ioctl.c.
> 
> So how about I just take the changes to md.c, and give you an:
> 
>    Acked-by: NeilBrown <neilb@suse.de>
> 
> for the changes to fs/compat_ioctl.c
> ??

Yes, that is exactly what I was trying to suggest. Thanks,

	Arnd <><

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [uml-user] [PATCH 00/12] move compat_ioctl handling into drivers
@ 2009-11-16  1:02     ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2009-11-16  1:02 UTC (permalink / raw)
  To: Neil Brown
  Cc: linux-usb, user-mode-linux-user, H. Peter Anvin, Paul Clements,
	Wolfram Sang, Andre Noll, Pavel Machek, linux-i2c, Jens Axboe,
	Jan Blunck, Ian Kent, Nick Piggin, linux-scsi, Kay Sievers,
	Alon Bar-Lev, Alan Stern, KOSAKI Motohiro, Doug Gilbert,
	David Vrabel, Alexey Dobriyan, user-mode-linux-devel, Jeff Dike,
	Oliver Neukum, linux-raid, Tejun Heo, Ja

On Monday 16 November 2009, Neil Brown wrote:
> I would take the md ones into my tree, but I suspect that if
> everyone did that we would end up with lots of conflicts in
> fs/compat_ioctl.c.
> 
> So how about I just take the changes to md.c, and give you an:
> 
>    Acked-by: NeilBrown <neilb@suse.de>
> 
> for the changes to fs/compat_ioctl.c
> ??

Yes, that is exactly what I was trying to suggest. Thanks,

	Arnd <><

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 11/12] hamradio/mkiss: fix typo in compat_ioctl
  2009-11-16  0:27 ` [PATCH 11/12] hamradio/mkiss: fix typo in compat_ioctl Arnd Bergmann
@ 2009-11-16  5:13   ` David Miller
  0 siblings, 0 replies; 29+ messages in thread
From: David Miller @ 2009-11-16  5:13 UTC (permalink / raw)
  To: arnd; +Cc: linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 16 Nov 2009 00:27:06 +0000

> My last commit introduced an typo causing the
> compat_ioctl function to do nothing useful.
> The obvious way for an ioctl function to work
> is to look at the command, not the argument first.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, but please CC: netdev on all networking patches so that
they get properly tracked in patchwork.

Thanks.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 08/12] md: move compat_ioctl handling into md.c
  2009-11-16  0:27 ` [PATCH 08/12] md: move compat_ioctl handling into md.c Arnd Bergmann
@ 2009-11-16  8:39   ` Andre Noll
  0 siblings, 0 replies; 29+ messages in thread
From: Andre Noll @ 2009-11-16  8:39 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel, Neil Brown, linux-raid

[-- Attachment #1: Type: text/plain, Size: 658 bytes --]

On 00:27, Arnd Bergmann wrote:
> The RAID ioctls are only implemented in md.c, so the
> handling for them should also be moved there from
> fs/compat_ioctl.c.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Cc: Neil Brown <neilb@suse.de>
> Cc: Andre Noll <maan@systemlinux.org>
> Cc: linux-raid@vger.kernel.org
> ---
>  drivers/md/md.c   |   23 +++++++++++++++++++++++
>  fs/compat_ioctl.c |   23 -----------------------
>  2 files changed, 23 insertions(+), 23 deletions(-)

Looks good to me.

Acked-by: Andre Noll <maan@systemlinux.org>

Thanks
Andre
-- 
The only person who always got his work done by Friday was Robinson Crusoe

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 10/12] usbdevfs: move compat_ioctl handling to devio.c
  2009-11-16  0:27 ` [PATCH 10/12] usbdevfs: move compat_ioctl handling to devio.c Arnd Bergmann
@ 2009-11-17  1:38   ` Greg KH
  0 siblings, 0 replies; 29+ messages in thread
From: Greg KH @ 2009-11-17  1:38 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-kernel, Alan Stern, Oliver Neukum, Alon Bar-Lev,
	David Vrabel, linux-usb

On Mon, Nov 16, 2009 at 12:27:05AM +0000, Arnd Bergmann wrote:
> Half the compat_ioctl handling is in devio.c, the other
> half is in fs/compat_ioctl.c. This moves everything into
> one place for consistency.
> 
> As a positive side-effect, push down the BKL into the
> ioctl methods.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Oliver Neukum <oliver@neukum.org>
> Cc: Alon Bar-Lev <alon.barlev@gmail.com>
> Cc: David Vrabel <david.vrabel@csr.com>
> Cc: linux-usb@vger.kernel.org

Acked-by: Greg Kroah-Hartman <gregkh@suse.de>

thanks for doing this.

greg k-h

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 09/12] lp: move compat_ioctl handling into lp.c
  2009-11-16  0:27 ` [PATCH 09/12] lp: move compat_ioctl handling into lp.c Arnd Bergmann
@ 2009-11-17  1:38   ` Greg KH
  0 siblings, 0 replies; 29+ messages in thread
From: Greg KH @ 2009-11-17  1:38 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel

On Mon, Nov 16, 2009 at 12:27:04AM +0000, Arnd Bergmann wrote:
> Handling for LPSETTIMEOUT can easily be done in lp_ioctl, which
> is the only user. As a positive side-effect, push the BKL
> into the ioctl methods.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>

Acked-by: Greg Kroah-Hartman <gregkh@suse.de>

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 07/12] i2cdev: move compat_ioctl handling into driver
@ 2009-12-14 14:23     ` Jean Delvare
  0 siblings, 0 replies; 29+ messages in thread
From: Jean Delvare @ 2009-12-14 14:23 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-kernel, Ben Dooks (embedded platforms), Wolfram Sang, linux-i2c

Hi Arnd,

On Mon, 16 Nov 2009 00:27:02 +0000, Arnd Bergmann wrote:
> Doing all the compat_ioctl handling in the i2c driver itself
> removes special cases from fs/compat_ioctl.c and makes it possible
> to optimize this case better.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Cc: "Jean Delvare (PC drivers, core)" <khali@linux-fr.org>
> Cc: "Ben Dooks (embedded platforms)" <ben-linux@fluff.org>
> Cc: Wolfram Sang <w.sang@pengutronix.de>
> Cc: linux-i2c@vger.kernel.org
> ---
>  drivers/i2c/i2c-dev.c |  117 ++++++++++++++++++++++++++++++++++++++++++++++++
>  fs/compat_ioctl.c     |  119 -------------------------------------------------
>  2 files changed, 117 insertions(+), 119 deletions(-)

This patch no longer applies so I can't test it. I do not have any
objection about it though.

I'm also not sure what I am supposed to comment on. As far as I can
see, most of this patch is merely moving code from one file to another,
so there's little point in reviewing that code. Is there any part in
particular which needs my attention?

If you want to test your patch yourself, it is fairly easy using the
i2c-stub driver, which is a software-only i2c bus driver. Install the
i2c-tools package on your system, and then:

# modprobe i2c-stub chip_addr=0x6d
# modprobe i2c-dev
# i2cdetect -l
# i2cbus=$(i2cdetect -l | grep stub | cut -f1 | cut -d- -f2)
# i2cdetect -F $i2cbus
Functionalities implemented by /dev/i2c-x:
I2C                              no
SMBus Quick Command              yes
SMBus Send Byte                  yes
SMBus Receive Byte               yes
SMBus Write Byte                 yes
SMBus Read Byte                  yes
SMBus Write Word                 yes
SMBus Read Word                  yes
SMBus Process Call               no
SMBus Block Write                no
SMBus Block Read                 no
SMBus Block Process Call         no
SMBus PEC                        no
I2C Block Write                  no
I2C Block Read                   no
# i2cset -y $i2cbus 0x6d 0x00 0x42 b
Value 0x42 written, readback matched
# i2cget -y $i2cbus 0x6d 0x00 b
0x42
#

The last 3 commands will generate i2c-dev ioctls.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 07/12] i2cdev: move compat_ioctl handling into driver
@ 2009-12-14 14:23     ` Jean Delvare
  0 siblings, 0 replies; 29+ messages in thread
From: Jean Delvare @ 2009-12-14 14:23 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	Ben Dooks (embedded platforms),
	Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA

Hi Arnd,

On Mon, 16 Nov 2009 00:27:02 +0000, Arnd Bergmann wrote:
> Doing all the compat_ioctl handling in the i2c driver itself
> removes special cases from fs/compat_ioctl.c and makes it possible
> to optimize this case better.
> 
> Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
> Cc: "Jean Delvare (PC drivers, core)" <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
> Cc: "Ben Dooks (embedded platforms)" <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
> Cc: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> ---
>  drivers/i2c/i2c-dev.c |  117 ++++++++++++++++++++++++++++++++++++++++++++++++
>  fs/compat_ioctl.c     |  119 -------------------------------------------------
>  2 files changed, 117 insertions(+), 119 deletions(-)

This patch no longer applies so I can't test it. I do not have any
objection about it though.

I'm also not sure what I am supposed to comment on. As far as I can
see, most of this patch is merely moving code from one file to another,
so there's little point in reviewing that code. Is there any part in
particular which needs my attention?

If you want to test your patch yourself, it is fairly easy using the
i2c-stub driver, which is a software-only i2c bus driver. Install the
i2c-tools package on your system, and then:

# modprobe i2c-stub chip_addr=0x6d
# modprobe i2c-dev
# i2cdetect -l
# i2cbus=$(i2cdetect -l | grep stub | cut -f1 | cut -d- -f2)
# i2cdetect -F $i2cbus
Functionalities implemented by /dev/i2c-x:
I2C                              no
SMBus Quick Command              yes
SMBus Send Byte                  yes
SMBus Receive Byte               yes
SMBus Write Byte                 yes
SMBus Read Byte                  yes
SMBus Write Word                 yes
SMBus Read Word                  yes
SMBus Process Call               no
SMBus Block Write                no
SMBus Block Read                 no
SMBus Block Process Call         no
SMBus PEC                        no
I2C Block Write                  no
I2C Block Read                   no
# i2cset -y $i2cbus 0x6d 0x00 0x42 b
Value 0x42 written, readback matched
# i2cget -y $i2cbus 0x6d 0x00 b
0x42
#

The last 3 commands will generate i2c-dev ioctls.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 07/12] i2cdev: move compat_ioctl handling into driver
@ 2009-12-14 15:31       ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2009-12-14 15:31 UTC (permalink / raw)
  To: Jean Delvare
  Cc: linux-kernel, Ben Dooks (embedded platforms), Wolfram Sang, linux-i2c

On Monday 14 December 2009, Jean Delvare wrote:
> This patch no longer applies so I can't test it. I do not have any
> objection about it though.

The patch is part of a longer series of patches moving code out
of fs/compat_ioctl.c. If you want to test it, you can just apply the
half adding it to i2c-dev.c and that version will be used.

That part has gained a trivial conflict against an #include cleanup.

> I'm also not sure what I am supposed to comment on. As far as I can
> see, most of this patch is merely moving code from one file to another,
> so there's little point in reviewing that code. Is there any part in
> particular which needs my attention?

No, nothing particular. I was just running the whole series by the
maintainers (or the closest approximation of that) in order to
collect Acked-by and/or have people include the patches in their
trees, especially the ones that I didn't have a test case for.
The patches I got an Ack for were merged now, and I'll repost
the rest after -rc1 to prepare them for the next merge window.

A good way to avoid conflicts would be if you take the i2c-dev.c
parts into a tree of yours and let me follow up with removing the
code from fs/compat_ioctl.c once your tree is merged.

If everyone does that, I can just remove half of fs/compat_ioctl.c
at once.

> If you want to test your patch yourself, it is fairly easy using the
> i2c-stub driver, which is a software-only i2c bus driver. Install the
> i2c-tools package on your system, and then:
> 
> # modprobe i2c-stub chip_addr=0x6d
> # modprobe i2c-dev
> # i2cdetect -l
> # i2cbus=$(i2cdetect -l | grep stub | cut -f1 | cut -d- -f2)
> # i2cdetect -F $i2cbus
> Functionalities implemented by /dev/i2c-x:
> I2C                              no
> SMBus Quick Command              yes
> SMBus Send Byte                  yes
> SMBus Receive Byte               yes
> SMBus Write Byte                 yes
> SMBus Read Byte                  yes
> SMBus Write Word                 yes
> SMBus Read Word                  yes
> SMBus Process Call               no
> SMBus Block Write                no
> SMBus Block Read                 no
> SMBus Block Process Call         no
> SMBus PEC                        no
> I2C Block Write                  no
> I2C Block Read                   no
> # i2cset -y $i2cbus 0x6d 0x00 0x42 b
> Value 0x42 written, readback matched
> # i2cget -y $i2cbus 0x6d 0x00 b
> 0x42
> #
> 
> The last 3 commands will generate i2c-dev ioctls.

Ok, I'll try that, thanks!

	Arnd <><

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 07/12] i2cdev: move compat_ioctl handling into driver
@ 2009-12-14 15:31       ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2009-12-14 15:31 UTC (permalink / raw)
  To: Jean Delvare
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	Ben Dooks (embedded platforms),
	Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA

On Monday 14 December 2009, Jean Delvare wrote:
> This patch no longer applies so I can't test it. I do not have any
> objection about it though.

The patch is part of a longer series of patches moving code out
of fs/compat_ioctl.c. If you want to test it, you can just apply the
half adding it to i2c-dev.c and that version will be used.

That part has gained a trivial conflict against an #include cleanup.

> I'm also not sure what I am supposed to comment on. As far as I can
> see, most of this patch is merely moving code from one file to another,
> so there's little point in reviewing that code. Is there any part in
> particular which needs my attention?

No, nothing particular. I was just running the whole series by the
maintainers (or the closest approximation of that) in order to
collect Acked-by and/or have people include the patches in their
trees, especially the ones that I didn't have a test case for.
The patches I got an Ack for were merged now, and I'll repost
the rest after -rc1 to prepare them for the next merge window.

A good way to avoid conflicts would be if you take the i2c-dev.c
parts into a tree of yours and let me follow up with removing the
code from fs/compat_ioctl.c once your tree is merged.

If everyone does that, I can just remove half of fs/compat_ioctl.c
at once.

> If you want to test your patch yourself, it is fairly easy using the
> i2c-stub driver, which is a software-only i2c bus driver. Install the
> i2c-tools package on your system, and then:
> 
> # modprobe i2c-stub chip_addr=0x6d
> # modprobe i2c-dev
> # i2cdetect -l
> # i2cbus=$(i2cdetect -l | grep stub | cut -f1 | cut -d- -f2)
> # i2cdetect -F $i2cbus
> Functionalities implemented by /dev/i2c-x:
> I2C                              no
> SMBus Quick Command              yes
> SMBus Send Byte                  yes
> SMBus Receive Byte               yes
> SMBus Write Byte                 yes
> SMBus Read Byte                  yes
> SMBus Write Word                 yes
> SMBus Read Word                  yes
> SMBus Process Call               no
> SMBus Block Write                no
> SMBus Block Read                 no
> SMBus Block Process Call         no
> SMBus PEC                        no
> I2C Block Write                  no
> I2C Block Read                   no
> # i2cset -y $i2cbus 0x6d 0x00 0x42 b
> Value 0x42 written, readback matched
> # i2cget -y $i2cbus 0x6d 0x00 b
> 0x42
> #
> 
> The last 3 commands will generate i2c-dev ioctls.

Ok, I'll try that, thanks!

	Arnd <><

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 07/12] i2cdev: move compat_ioctl handling into driver
  2009-12-14 15:31       ` Arnd Bergmann
  (?)
@ 2010-06-03 12:31       ` Jean Delvare
  -1 siblings, 0 replies; 29+ messages in thread
From: Jean Delvare @ 2010-06-03 12:31 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-kernel, Ben Dooks (embedded platforms), Wolfram Sang, linux-i2c

Hi Arnd,

On Mon, 14 Dec 2009 16:31:45 +0100, Arnd Bergmann wrote:
> On Monday 14 December 2009, Jean Delvare wrote:
> > This patch no longer applies so I can't test it. I do not have any
> > objection about it though.
> 
> The patch is part of a longer series of patches moving code out
> of fs/compat_ioctl.c. If you want to test it, you can just apply the
> half adding it to i2c-dev.c and that version will be used.
> 
> That part has gained a trivial conflict against an #include cleanup.

It was long ago, there are even more conflicts now.

> > I'm also not sure what I am supposed to comment on. As far as I can
> > see, most of this patch is merely moving code from one file to another,
> > so there's little point in reviewing that code. Is there any part in
> > particular which needs my attention?
> 
> No, nothing particular. I was just running the whole series by the
> maintainers (or the closest approximation of that) in order to
> collect Acked-by and/or have people include the patches in their
> trees, especially the ones that I didn't have a test case for.
> The patches I got an Ack for were merged now, and I'll repost
> the rest after -rc1 to prepare them for the next merge window.
> 
> A good way to avoid conflicts would be if you take the i2c-dev.c
> parts into a tree of yours and let me follow up with removing the
> code from fs/compat_ioctl.c once your tree is merged.
> 
> If everyone does that, I can just remove half of fs/compat_ioctl.c
> at once.
> 
> > If you want to test your patch yourself, it is fairly easy using the
> > i2c-stub driver, which is a software-only i2c bus driver. Install the
> > i2c-tools package on your system, and then:
> > 
> > # modprobe i2c-stub chip_addr=0x6d
> > # modprobe i2c-dev
> > # i2cdetect -l
> > # i2cbus=$(i2cdetect -l | grep stub | cut -f1 | cut -d- -f2)
> > # i2cdetect -F $i2cbus
> > Functionalities implemented by /dev/i2c-x:
> > I2C                              no
> > SMBus Quick Command              yes
> > SMBus Send Byte                  yes
> > SMBus Receive Byte               yes
> > SMBus Write Byte                 yes
> > SMBus Read Byte                  yes
> > SMBus Write Word                 yes
> > SMBus Read Word                  yes
> > SMBus Process Call               no
> > SMBus Block Write                no
> > SMBus Block Read                 no
> > SMBus Block Process Call         no
> > SMBus PEC                        no
> > I2C Block Write                  no
> > I2C Block Read                   no
> > # i2cset -y $i2cbus 0x6d 0x00 0x42 b
> > Value 0x42 written, readback matched
> > # i2cget -y $i2cbus 0x6d 0x00 b
> > 0x42
> > #
> > 
> > The last 3 commands will generate i2c-dev ioctls.
> 
> Ok, I'll try that, thanks!

Were you able to perform your tests? What's the status of your patch? I
can't do much without a patch which at least applies and builds.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2010-06-03 12:31 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-16  0:26 [uml-user] [PATCH 00/12] move compat_ioctl handling into drivers Arnd Bergmann
2009-11-16  0:26 ` [uml-devel] " Arnd Bergmann
2009-11-16  0:26 ` [PATCH 01/12] arch/um: handle compat_ioctl in tty line driver Arnd Bergmann
2009-11-16  0:26 ` [PATCH 02/12] scsi/sg: move compat_ioctl handling into sg driver Arnd Bergmann
2009-11-16  0:26 ` [PATCH 03/12] autofs/autofs4: move compat_ioctl handling into fs Arnd Bergmann
2009-11-16  0:26 ` [PATCH 04/12] raw: partly fix compat_ioctl handling on non-x86 Arnd Bergmann
2009-11-16  0:27 ` [PATCH 05/12] nbd: add compat_ioctl method Arnd Bergmann
2009-11-16  0:27 ` [PATCH 06/12] smbfs: do compat_ioctl handling in place Arnd Bergmann
2009-11-16  0:27 ` [PATCH 07/12] i2cdev: move compat_ioctl handling into driver Arnd Bergmann
2009-12-14 14:23   ` Jean Delvare
2009-12-14 14:23     ` Jean Delvare
2009-12-14 15:31     ` Arnd Bergmann
2009-12-14 15:31       ` Arnd Bergmann
2010-06-03 12:31       ` Jean Delvare
2009-11-16  0:27 ` [PATCH 08/12] md: move compat_ioctl handling into md.c Arnd Bergmann
2009-11-16  8:39   ` Andre Noll
2009-11-16  0:27 ` [PATCH 09/12] lp: move compat_ioctl handling into lp.c Arnd Bergmann
2009-11-17  1:38   ` Greg KH
2009-11-16  0:27 ` [PATCH 10/12] usbdevfs: move compat_ioctl handling to devio.c Arnd Bergmann
2009-11-17  1:38   ` Greg KH
2009-11-16  0:27 ` [PATCH 11/12] hamradio/mkiss: fix typo in compat_ioctl Arnd Bergmann
2009-11-16  5:13   ` David Miller
2009-11-16  0:27 ` [PATCH 12/12] compat_ioctl: remove unused handlers Arnd Bergmann
2009-11-16  0:57 ` [uml-user] [PATCH 00/12] move compat_ioctl handling into drivers Neil Brown
2009-11-16  0:57   ` Neil Brown
2009-11-16  0:57   ` [uml-devel] " Neil Brown
2009-11-16  1:02   ` [uml-user] " Arnd Bergmann
2009-11-16  1:02     ` Arnd Bergmann
2009-11-16  1:02     ` [uml-devel] " Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.