mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-26 19:51:35 +01:00
modules: rename packages/kernel_modules to packages/lkmc
Then inside, split packages/lkmc into kernel_modules and userland, to keep userland out of the kernel_modules parent path, which makes no sense. Copy built modules and userland to the output rootfs overlay. Document Linux distro tradeoffs.
This commit is contained in:
43
packages/lkmc/kernel_modules/procfs.c
Normal file
43
packages/lkmc/kernel_modules/procfs.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#procfs */
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h> /* seq_read, seq_lseek, single_open, single_release */
|
||||
#include <uapi/linux/stat.h> /* S_IRUSR */
|
||||
|
||||
static const char *filename = "lkmc_procfs";
|
||||
|
||||
static int show(struct seq_file *m, void *v)
|
||||
{
|
||||
seq_printf(m, "abcd\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, show, NULL);
|
||||
}
|
||||
|
||||
static const struct file_operations fops = {
|
||||
.llseek = seq_lseek,
|
||||
.open = open,
|
||||
.owner = THIS_MODULE,
|
||||
.read = seq_read,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
static int myinit(void)
|
||||
{
|
||||
proc_create(filename, 0, NULL, &fops);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void myexit(void)
|
||||
{
|
||||
remove_proc_entry(filename, NULL);
|
||||
}
|
||||
|
||||
module_init(myinit)
|
||||
module_exit(myexit)
|
||||
MODULE_LICENSE("GPL");
|
||||
Reference in New Issue
Block a user