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 <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
(cherry picked from commit b9a8000bbd)
This commit is contained in:
Shaun Ruffell 2014-09-16 16:58:44 -05:00 committed by Russ Meyerriecks
parent 54893b93aa
commit c4356304e5

View File

@ -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,
};
/*