[dahdi-commits] tzafrir: linux/trunk r7769 - /linux/trunk/drivers/dahdi/dahdi-base.c
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Wed Jan 6 13:16:56 CST 2010
Author: tzafrir
Date: Wed Jan 6 13:16:52 2010
New Revision: 7769
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7769
Log:
Use unlocked_ioctl and compat_ioctl instead of ioctl.
* dahdi-base needs compat_ioctl in order to allow 32-bit userspace
applications to call the DAHDI ioctls in a 64-bit kernel.
* add a separate dahdi_ioctl_compat() to handle functions whose parameters
will need some tweaks (currently: only reject DAHDI_SFCONFIG).
(closes issue #14808)
* 0002-dahdi-base-Use-unlocked_ioctl-and-compat_ioctl-inste.patch uploaded
by sruffell (license 456)
* 0003-add-a-separate-dahdi_ioctl_compat.patch uploaded by tzafrir
(license 46)
Tested by: sruffell, tzafrir
Modified:
linux/trunk/drivers/dahdi/dahdi-base.c
Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=7769&r1=7768&r2=7769
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Wed Jan 6 13:16:52 2010
@@ -47,6 +47,10 @@
#include <linux/moduleparam.h>
#include <linux/sched.h>
#include <linux/list.h>
+
+#ifdef HAVE_UNLOCKED_IOCTL
+#include <linux/smp_lock.h>
+#endif
#include <linux/ppp_defs.h>
@@ -5628,47 +5632,80 @@
return 0;
}
-static int dahdi_ioctl(struct file *file, unsigned int cmd, unsigned long data)
+#ifdef HAVE_UNLOCKED_IOCTL
+static long dahdi_ioctl(struct file *file, unsigned int cmd, unsigned long data)
+#else
+static int dahdi_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long data)
+#endif
{
int unit = UNIT(file);
struct dahdi_chan *chan;
struct dahdi_timer *timer;
-
- if (!unit)
- return dahdi_ctl_ioctl(file, cmd, data);
+ int ret;
+
+#ifdef HAVE_UNLOCKED_IOCTL
+ lock_kernel();
+#endif
+
+ if (!unit) {
+ ret = dahdi_ctl_ioctl(file, cmd, data);
+ goto unlock_exit;
+ }
if (unit == 250) {
/* dahdi_transcode should have updated the file_operations on
* this file object on open, so we shouldn't be here. */
WARN_ON(1);
- return -EFAULT;
+ ret = -EFAULT;
+ goto unlock_exit;
}
if (unit == 253) {
timer = file->private_data;
if (timer)
- return dahdi_timer_ioctl(file, cmd, data, timer);
+ ret = dahdi_timer_ioctl(file, cmd, data, timer);
else
- return -EINVAL;
+ ret = -EINVAL;
+ goto unlock_exit;
}
if (unit == 254) {
chan = file->private_data;
if (chan)
- return dahdi_chan_ioctl(file, cmd, data, chan->channo);
+ ret = dahdi_chan_ioctl(file, cmd, data, chan->channo);
else
- return dahdi_prechan_ioctl(file, cmd, data, unit);
+ ret = dahdi_prechan_ioctl(file, cmd, data, unit);
+ goto unlock_exit;
}
if (unit == 255) {
chan = file->private_data;
if (!chan) {
module_printk(KERN_NOTICE, "No pseudo channel structure to read?\n");
- return -EINVAL;
- }
- return dahdi_chanandpseudo_ioctl(file, cmd, data, chan->channo);
- }
- return dahdi_chan_ioctl(file, cmd, data, unit);
-}
-
+ ret = -EINVAL;
+ goto unlock_exit;
+ }
+ ret = dahdi_chanandpseudo_ioctl(file, cmd, data, chan->channo);
+ goto unlock_exit;
+ }
+ ret = dahdi_chan_ioctl(file, cmd, data, unit);
+
+unlock_exit:
+#ifdef HAVE_UNLOCKED_IOCTL
+ unlock_kernel();
+#endif
+ return ret;
+}
+
+#ifdef HAVE_COMPAT_IOCTL
+static long dahdi_ioctl_compat(struct file *file, unsigned int cmd,
+ unsigned long data)
+{
+ if (cmd == DAHDI_SFCONFIG)
+ return -ENOTTY; /* Not supported yet */
+
+ return dahdi_ioctl(file, cmd, data);
+}
+#endif
/**
* dahdi_register() - unregister a new DAHDI span
@@ -8334,17 +8371,20 @@
static struct file_operations dahdi_fops = {
.owner = THIS_MODULE,
- .llseek = NULL,
.open = dahdi_open,
.release = dahdi_release,
+#ifdef HAVE_UNLOCKED_IOCTL
+ .unlocked_ioctl = dahdi_ioctl,
+#ifdef HAVE_COMPAT_IOCTL
+ .compat_ioctl = dahdi_ioctl_compat,
+#endif
+#else
.ioctl = dahdi_ioctl,
+#endif
.read = dahdi_read,
.write = dahdi_write,
.poll = dahdi_poll,
.mmap = dahdi_mmap,
- .flush = NULL,
- .fsync = NULL,
- .fasync = NULL,
};
#ifdef CONFIG_DAHDI_WATCHDOG
More information about the dahdi-commits
mailing list