1

The functions you write to provide procfs interfaces is just code that is part of your LKM source.

http://linux.die.net/lkmpg/x769.html has a simple example using procfs, reproduced here:

I copied the code from above link - You'll find a tutorial for building kernel modules at http://www.cyberciti.biz/tips/compiling-linux-kernel-module.html. The summary of that is:

1) Ensure you have kernel source installed in /usr/src.

2) Create a makefile that looks like:

obj-m = procfs2.o
KVERSION = $(shell uname -r)
all:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean

3) build the module with the command make 4) load the module into memory with the command insmod procfs2.ko (do this as the root user)

I copied the code and created the MAKEFILE and later if I give the make command from the console then it is showing as : make: nothing to be done for all. could someone please tell me what could be the error ??

user3458454
  • 291
  • 1
  • 4
  • 20

1 Answers1

5

Here is an example of a Makefile for a kernel module.

the important thing here to note is that the dots shown below must be replaced by a TAB, replacing them by spaces will cause Makefile to malfunction.

obj-m += hello.o

all:
.......make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
.......make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
Jayesh Bhoi
  • 24,694
  • 15
  • 58
  • 73
  • could you please answer this : http://stackoverflow.com/questions/23101224/how-to-send-the-kernel-data-to-the-user-the-space-using-procfs – user3458454 Apr 16 '14 at 06:13
  • please can I have your email id ?? I need some suggestions. – user3458454 Apr 16 '14 at 06:14
  • I am getting some errors when I run the make command : error: proc_root undeclared error: struct proc_dir_entry has no member named 'owner' – user3458454 Apr 16 '14 at 06:26
  • @user3458454 look http://stackoverflow.com/questions/2531730/linux-kernel-module-creating-proc-file-proc-root-undeclared-error – Jayesh Bhoi Apr 16 '14 at 06:33
  • to perform a procfile_read function from kernel to user then I should create a file operations structure used to define file manipulation callbacks for our pseudo-file. but If i give .read = procfile_read, (I am giving within the structure then showing error as procfile_read is undeclared here) – user3458454 Apr 16 '14 at 07:37
  • if I use this link : http://pointer-overloading.blogspot.in/2013/09/linux-creating-entry-in-proc-file.html if I want to perform procfile_read function as shown in the code above then how to specify it in the file operation structure ? – user3458454 Apr 16 '14 at 07:54