Linux Kernel Module - Creating a proc file - proc_root uneclared error

I copy and paste the code from this URL to create and read / write the proc file using the kernel module and receive an error that proc_root does not report. The same example is on several sites, so I assume that it works. Any ideas why I get this error? My makefile needs something else. Below is also my makefile:

Sample code for creating the base proc file (direct copy and paste to run the initial test): http://tldp.org/LDP/lkmpg/2.6/html/lkmpg.html#AEN769

Makefile I use:

obj-m    := counter.o

KDIR    := /MY/LINUX/SRC

PWD    := $(shell pwd)

default:
 $(MAKE) ARCH=um -C $(KDIR) SUBDIRS=$(PWD) modules
+5
source share
2

. API NULL procfs.

, create_proc_entry proc_create() const struct file_operations *.

+12

proc. http://pointer-overloading.blogspot.in/2013/09/linux-creating-entry-in-proc-file.html

"hello_proc" :

#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>

static int hello_proc_show(struct seq_file *m, void *v) {
  seq_printf(m, "Hello proc!\n");
  return 0;
}

static int hello_proc_open(struct inode *inode, struct  file *file) {
  return single_open(file, hello_proc_show, NULL);
}

static const struct file_operations hello_proc_fops = {
  .owner = THIS_MODULE,
  .open = hello_proc_open,
  .read = seq_read,
  .llseek = seq_lseek,
  .release = single_release,
};

static int __init hello_proc_init(void) {
  proc_create("hello_proc", 0, NULL, &hello_proc_fops);
  return 0;
}

static void __exit hello_proc_exit(void) {
  remove_proc_entry("hello_proc", NULL);
}

MODULE_LICENSE("GPL");
module_init(hello_proc_init);
module_exit(hello_proc_exit);
+6

All Articles