Skip to content

Comments

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

Open
LSKhappychild wants to merge 1 commit intogreggagne:masterfrom
LSKhappychild:master
Open

Revise proc_ops creation logic in ch2 proc kernel module exercise#6
LSKhappychild wants to merge 1 commit intogreggagne:masterfrom
LSKhappychild:master

Conversation

@LSKhappychild
Copy link

Currently I'm using Linux kernel version 5.15.0 with ubuntu 22.04.1 LTS.
In chapter 2, exercise for creating proc file system kernel module,
provided source code generates following error :

error: passing argument 4 of ‘proc_create’ from incompatible pointer type [-Werror=incompatible-pointer-types] 50 | proc_create(PROC_NAME, 0, NULL, &proc_ops); | ^~~~~~~~~ | | | struct file_operations * In file included from /home/lskhappychild/Desktop/Systems/Linux/ch2/hello.c:16: ./include/linux/proc_fs.h:110:122: note: expected ‘const struct proc_ops *’ but argument is of type ‘struct file_operations *’ 110 | t char *name, umode_t mode, struct proc_dir_entry *parent, const struct proc_ops *proc_ops); | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

And this seems to happen due to Linux version compatibility.

So added part needed for compatibility with higher version linux kernel.

@qqwqqw689
Copy link

Yes, I encounter the same problem.It need some fix I think

@jpstayfocus
Copy link

Here's how to fix it

proc_create(PROC_NAME, 0666, NULL, (const struct proc_ops *) &proc_ops);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants