From 15f5a963376d7d4a0541873d4ef54e7e4fc0de44 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+ Since upstream commit (7f7f25e82d54870d "replace checking for ->read/->aio_read presence with check in ->f_mode" )[1] the capability of a dahdi file descriptor to read / write was determined when the file is first opened. Since not all dahdi file descriptors define read or write, this would cause errors with -EINVAL returned from read() or write() when DAHDI_SPECIFY ioctl is used to open a channel through the /dev/dahdi/master file. We now define empty shell functions on the general dahdi_fops so the vfs layer will not mark a file descriptor as unwritteable or readable on open. I also add the dummy operations to the timer file_operations even though it may not be completely necessary. Those file operations are updated in the context of the open call, and not through an ioctl and I believe the FMODE_CAN_READ and FMODE_CAN_WRITE flags are set at the end of the open call. Internal-Issue-ID: DAHLIN-340 https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=7f7f25e82d54870df24d415a7007fbd327da027b --- 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..7dac228 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_read(struct file *file, char __user *usrbuf, + size_t count, loff_t *ppos) +{ + return -ENOSYS; +} + +static ssize_t dahdi_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, @@ -10296,6 +10308,8 @@ static const struct file_operations dahdi_fops = { #else .ioctl = dahdi_ioctl, #endif + .read = dahdi_read, + .write = dahdi_write, .poll = dahdi_poll, }; @@ -10311,6 +10325,8 @@ static const struct file_operations dahdi_timer_fops = { .ioctl = dahdi_timer_ioctl, #endif .poll = dahdi_timer_poll, + .read = dahdi_read, + .write = dahdi_write, }; /* -- 2.0.4