b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From 6126f8efebf659708245ba99df6b85d7c1260668 Mon Sep 17 00:00:00 2001 |
| 2 | From: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> |
| 3 | Date: Sun, 31 Jan 2021 20:53:32 -0800 |
| 4 | Subject: [PATCH] mrm_ctlfile.c: compatibility with linux >= 5.6 |
| 5 | |
| 6 | Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> |
| 7 | --- |
| 8 | kernelmod/mrm_ctlfile.c | 13 ++++++++++++- |
| 9 | 1 file changed, 12 insertions(+), 1 deletion(-) |
| 10 | |
| 11 | --- a/kernelmod/mrm_ctlfile.c |
| 12 | +++ b/kernelmod/mrm_ctlfile.c |
| 13 | @@ -13,6 +13,7 @@ |
| 14 | #include "./macremapper_ioctl.h" |
| 15 | #include "./bufprintf.h" |
| 16 | |
| 17 | +#include <linux/version.h> |
| 18 | #include <linux/proc_fs.h> |
| 19 | #include <linux/uaccess.h> |
| 20 | #include <linux/mutex.h> |
| 21 | @@ -80,13 +81,14 @@ mrm_handle_read(struct file *f, char __u |
| 22 | } |
| 23 | |
| 24 | static long |
| 25 | -mrm_handle_ioctl(struct file *f, unsigned int type, void __user *param) { |
| 26 | +mrm_handle_ioctl(struct file *f, unsigned int type, unsigned long arg) { |
| 27 | union { |
| 28 | struct mrm_filter_config filt_conf; |
| 29 | struct mrm_remap_entry remap_entry; |
| 30 | unsigned count; |
| 31 | } u; |
| 32 | int rv; |
| 33 | + void __user *param = (void __user *)arg; |
| 34 | |
| 35 | mutex_lock(&_ctrl_mutex); |
| 36 | |
| 37 | @@ -159,6 +161,14 @@ fail_fault: |
| 38 | } |
| 39 | |
| 40 | |
| 41 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) |
| 42 | +static const struct proc_ops _fops = { |
| 43 | + .proc_open = mrm_handle_open, |
| 44 | + .proc_release = mrm_handle_release, |
| 45 | + .proc_read = mrm_handle_read, |
| 46 | + .proc_ioctl = mrm_handle_ioctl, |
| 47 | +}; |
| 48 | +#else |
| 49 | static const struct file_operations _fops = { |
| 50 | owner: THIS_MODULE, |
| 51 | open: &mrm_handle_open, |
| 52 | @@ -166,6 +176,7 @@ static const struct file_operations _fop |
| 53 | read: &mrm_handle_read, |
| 54 | unlocked_ioctl: (void*)&mrm_handle_ioctl, |
| 55 | }; |
| 56 | +#endif |
| 57 | |
| 58 | int mrm_init_ctlfile( void ) { |
| 59 | struct proc_dir_entry *pde; |