From fe4cbf0f49d96cd2278740b08c1da0c9f0db2514 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Fri, 16 Jun 2017 08:13:52 +0100 Subject: [PATCH] fops owner --- bibliography.md | 1 + kernel_module/anonymous_inode.c | 1 + kernel_module/character_device.c | 1 + kernel_module/fops.c | 3 +++ kernel_module/ioctl.c | 1 + kernel_module/poll.c | 1 + 6 files changed, 8 insertions(+) diff --git a/bibliography.md b/bibliography.md index 5e8e09b..a6e64f2 100644 --- a/bibliography.md +++ b/bibliography.md @@ -4,3 +4,4 @@ - - - +- you will fall here a lot when the hard Google queries start popping diff --git a/kernel_module/anonymous_inode.c b/kernel_module/anonymous_inode.c index 3b962c9..77eb7ef 100644 --- a/kernel_module/anonymous_inode.c +++ b/kernel_module/anonymous_inode.c @@ -66,6 +66,7 @@ static long unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long ar } static const struct file_operations fops_ioctl = { + .owner = THIS_MODULE, .unlocked_ioctl = unlocked_ioctl }; diff --git a/kernel_module/character_device.c b/kernel_module/character_device.c index 14b7448..3587499 100644 --- a/kernel_module/character_device.c +++ b/kernel_module/character_device.c @@ -49,6 +49,7 @@ static ssize_t read(struct file *filp, char __user *buf, size_t len, loff_t *off } static const struct file_operations fops = { + .owner = THIS_MODULE, .read = read, }; diff --git a/kernel_module/fops.c b/kernel_module/fops.c index d7c5c6d..c309df9 100644 --- a/kernel_module/fops.c +++ b/kernel_module/fops.c @@ -129,6 +129,9 @@ static loff_t llseek(struct file *filp, loff_t off, int whence) } static const struct file_operations fops = { + /* Prevents rmmod while fops are running. + * Try removing this for poll, which waits a lot. */ + .owner = THIS_MODULE, .llseek = llseek, .open = open, .read = read, diff --git a/kernel_module/ioctl.c b/kernel_module/ioctl.c index aead6b4..378a385 100644 --- a/kernel_module/ioctl.c +++ b/kernel_module/ioctl.c @@ -67,6 +67,7 @@ static long unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long ar } static const struct file_operations fops = { + .owner = THIS_MODULE, .unlocked_ioctl = unlocked_ioctl }; diff --git a/kernel_module/poll.c b/kernel_module/poll.c index 38e80e1..6f34a7c 100644 --- a/kernel_module/poll.c +++ b/kernel_module/poll.c @@ -65,6 +65,7 @@ static int kthread_func(void *data) } static const struct file_operations fops = { + .owner = THIS_MODULE, .read = read, .poll = poll };