Skip to contentSkip to conversation

Add compat_ioctl to SG

PATCH In review Andi Kleen 2 participants 3 messages Jan 18, 2005

Subsystems (2)
lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 Add compat_ioctl to SG

Add compat_ioctl forwarder to SG.

drivers/scsi/sg.c renamed from drivers/scsi/sg.c-o +26 -0
diff -u linux-2.6.11-rc1-bk4/drivers/scsi/sg.c-o linux-2.6.11-rc1-bk4/drivers/scsi/sg.c
@@ -1037,6 +1037,29 @@
 	}
 }
 
+#ifdef CONFIG_COMPAT
+static long sg_compat_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
+{
+	Sg_device *sdp;
+	Sg_fd *sfp;
+	struct scsi_device *sdev;
+
+	if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
+		return -ENXIO;
+
+	sdev = sdp->device;
+	if (sdev->host->hostt->compat_ioctl) { 
+		int ret;
+
+		ret = sdev->host->hostt->compat_ioctl(sdev, cmd_in, (void __user *)arg);
+
+		return ret;
+	}
+	
+	return -ENOIOCTLCMD;
+}
+#endif
+
 static unsigned int
 sg_poll(struct file *filp, poll_table * wait)
 {
@@ -1343,6 +1366,9 @@
 	.write = sg_write,
 	.poll = sg_poll,
 	.ioctl = sg_ioctl,
+#ifdef CONFIG_COMPAT
+	.ioctl = sg_compat_ioctl,
+#endif
 	.open = sg_open,
 	.mmap = sg_mmap,
 	.release = sg_release,
#1 lore raw

Andi Kleen wrote:
<snip>

drivers/scsi/sg.c line 1371

Quoted 7 lines
drivers/scsi/sg.c renamed from drivers/scsi/sg.c-o +3 -0
@@ -1343,6 +1366,9 @@
 	.write = sg_write,
 	.poll = sg_poll,
 	.ioctl = sg_ioctl,
+#ifdef CONFIG_COMPAT
+	.ioctl = sg_compat_ioctl,
+#endif

Andi,
Two initializations of ".ioctl" looks wrongs.
Comparing with the patch to sd should that be:
+ .compat_ioctl = sg_compat_ioctl,
??

Doug Gilbert

author
#2 lore raw
Quoted 14 lines · Douglas Gilbert

Andi Kleen wrote:
<snip>

Review line 1371

Quoted 7 lines
(quoted diff) +3 -0
@@ -1343,6 +1366,9 @@
 	.write = sg_write,
 	.poll = sg_poll,
 	.ioctl = sg_ioctl,
+#ifdef CONFIG_COMPAT
+	.ioctl = sg_compat_ioctl,
+#endif

Andi,
Two initializations of ".ioctl" looks wrongs.
Comparing with the patch to sd should that be:
+ .compat_ioctl = sg_compat_ioctl,

Yep, you're right. Thanks for catching it. #$@#!-compiler doesn't warn about that. Here's a corrected patch.

-Andi

Add compat_ioctl to SG driver

drivers/scsi/sg.c renamed from drivers/scsi/sg.c-o +26 -0
diff -u linux-2.6.11-rc1-bk4/drivers/scsi/sg.c-o linux-2.6.11-rc1-bk4/drivers/scsi/sg.c
@@ -1037,6 +1037,29 @@
 	}
 }
 
+#ifdef CONFIG_COMPAT
+static long sg_compat_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
+{
+	Sg_device *sdp;
+	Sg_fd *sfp;
+	struct scsi_device *sdev;
+
+	if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
+		return -ENXIO;
+
+	sdev = sdp->device;
+	if (sdev->host->hostt->compat_ioctl) { 
+		int ret;
+
+		ret = sdev->host->hostt->compat_ioctl(sdev, cmd_in, (void __user *)arg);
+
+		return ret;
+	}
+	
+	return -ENOIOCTLCMD;
+}
+#endif
+
 static unsigned int
 sg_poll(struct file *filp, poll_table * wait)
 {
@@ -1343,6 +1366,9 @@
 	.write = sg_write,
 	.poll = sg_poll,
 	.ioctl = sg_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl = sg_compat_ioctl,
+#endif
 	.open = sg_open,
 	.mmap = sg_mmap,
 	.release = sg_release,