Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise proc_ops creation logic in ch2 proc kernel module exercise #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ch2/hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Operating System Concepts - 10th Edition
* Copyright John Wiley & Sons - 2018
*/

#include <linux/version.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
Expand All @@ -26,11 +26,19 @@
*/
static ssize_t proc_read(struct file *file, char *buf, size_t count, loff_t *pos);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
#define HAVE_PROC_OPS
#endif
#ifdef HAVE_PROC_OPS
static const struct proc_ops proc_ops = {
.proc_read = proc_read
};
#else
static struct file_operations proc_ops = {
.owner = THIS_MODULE,
.read = proc_read,
};

#endif

/* This function is called when the module is loaded. */
static int proc_init(void)
Expand Down