diff --git a/Makefile b/Makefile index ddd7479..4b6f1ff 100644 --- a/Makefile +++ b/Makefile @@ -10,10 +10,10 @@ KMODVER=$(shell git describe HEAD 2>/dev/null || git rev-parse --short HEAD) endif all: - make -C /lib/modules/$(KVER)/build M=$(PWD) EXTRA_CFLAGS=-DKMODVER=\\\"$(KMODVER)\\\" modules + make -C /usr/src/kernels/$(KVER)/ M=$(PWD) EXTRA_CFLAGS=-DKMODVER=\\\"$(KMODVER)\\\" modules gcc -o spkut ./simple-procfs-kmod-userspace-tool.c clean: - make -C /lib/modules/$(KVER)/build M=$(PWD) clean + make -C /usr/src/kernels/$(KVER)/ M=$(PWD) clean rm -f spkut install: install -v -m 755 spkut /bin/ diff --git a/simple-procfs-kmod.c b/simple-procfs-kmod.c index fef17fe..3b96bf4 100644 --- a/simple-procfs-kmod.c +++ b/simple-procfs-kmod.c @@ -9,6 +9,7 @@ #include #include #include +#include #define BUFSIZE 100 #define PROCFS_NAME "simple-procfs-kmod" @@ -60,12 +61,27 @@ static ssize_t myread(struct file *file, char __user *ubuf,size_t count, loff_t return len; } +// the api for procfs changed with the 5.6 kernel to use the proc_ops struct rather than file_operations +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) +static loff_t proc_lseek(struct file *file, loff_t offset, int i) +{ + file->f_pos = offset; + return offset; +} +static struct proc_ops myops = +{ + .proc_read = myread, + .proc_write = mywrite, + .proc_lseek = proc_lseek, +}; +#else static struct file_operations myops = { .owner = THIS_MODULE, .read = myread, .write = mywrite, }; +#endif static int simple_init(void) {