From c4356304e5277c5476d16222770917f9eb6cf3d3 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Tue, 16 Sep 2014 16:58:44 -0500 Subject: [PATCH] dahdi: Fix failure to read / write on kernel 3.16+ Kernel version 3.16+, since upstream commit (7f7f25e82d54870d "replace checking for ->read/->aio_read presence with check in ->f_mode" )[1], does not like it when dahdi changes the set of allowed file operations on a file descriptor outside of the context of an open() system call. DAHDI changes the available file operations when a channel is opened by first opening /dev/dahdi/channel and then calling the DAHDI_SPECIFY ioctl to bind it to a particular DAHDI channel. Until DAHDI_SPECIFY is called there weren't any read()/write() callbacks implemented and therefore after the initial open, the kernel was setting not setting FMODE_CAN_{WRITE,READ} on the file descriptor indicating that those operations were not allowed. Now define empty shell functions on the general dahdi_fops so the vfs layer will not mark a file descriptor as unwritteable or unreadable on open. [1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=7f7f25e82d54870df24d415a7007fbd327da027b Internal-Issue-ID: DAHLIN-340 Reported-and-tested-by: Thomas B. Clark Signed-off-by: Shaun Ruffell Signed-off-by: Russ Meyerriecks (cherry picked from commit b9a8000bbd1b6120f22627c105a2c2194dcc793d) --- drivers/dahdi/dahdi-base.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index d46d7eb..0892734 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -10284,6 +10284,18 @@ MODULE_PARM_DESC(auto_assign_spans, "channel numbers assigned by the driver. If 0, user space " "will need to assign them via /sys/bus/dahdi_devices."); + +static ssize_t dahdi_no_read(struct file *file, char __user *usrbuf, + size_t count, loff_t *ppos) +{ + return -ENOSYS; +} +static ssize_t dahdi_no_write(struct file *file, const char __user *usrbuf, + size_t count, loff_t *ppos) +{ + return -ENOSYS; +} + static const struct file_operations dahdi_fops = { .owner = THIS_MODULE, .open = dahdi_open, @@ -10297,6 +10309,8 @@ static const struct file_operations dahdi_fops = { .ioctl = dahdi_ioctl, #endif .poll = dahdi_poll, + .read = dahdi_no_read, + .write = dahdi_no_write, }; static const struct file_operations dahdi_timer_fops = { @@ -10311,6 +10325,8 @@ static const struct file_operations dahdi_timer_fops = { .ioctl = dahdi_timer_ioctl, #endif .poll = dahdi_timer_poll, + .read = dahdi_no_read, + .write = dahdi_no_write, }; /*