Re: linux/module.h does not exist

2010-08-23 Thread Hemanth Kumar
  LD [M]  /home/praval/cprog/lkm/misc/tapas.ko make[1]: Leaving directory `/usr/src/kernels/2.6.27.25-78.2.56.fc9.i686' it is #include not #include --- On Mon, 23/8/10, Tapas Mishra wrote: From: Tapas Mishra Subject: Re: linux/module.h does not exist To: "SPK" Cc: k

Re: linux/module.h does not exist

2010-08-23 Thread Tapas Mishra
Sharad you are right. It did worked I got a warning in it. make -C /lib/modules/2.6.28-11-generic/build M=/home/tapas/LKP/pandora/temp/sample2 modules make[1]: Entering directory `/usr/src/linux-headers-2.6.28-11-generic' CC [M] /home/tapas/LKP/pandora/temp/sample2/sample21.o /home/tapas/LKP/p

Re: linux/module.h does not exist

2010-08-23 Thread SPK
On Mon, Aug 23, 2010 at 9:59 PM, Tapas Mishra wrote: > No It did not worked I tried what you said. > Here is the new program. > If possible just copy paste the program and try to run. > > #include > #include > #include > #include > extern void *sys_table[]; > asmlinkage int(*main_sys_exit)(int

Re: linux/module.h does not exist

2010-08-23 Thread Tapas Mishra
No It did not worked I tried what you said. Here is the new program. If possible just copy paste the program and try to run. #include #include #include #include extern void *sys_table[]; asmlinkage int(*main_sys_exit)(int); asmlinkage int alt_exit_function(int err_code) { printk("Sys_e

Re: linux/module.h does not exist

2010-08-22 Thread SPK
On Sun, Aug 22, 2010 at 11:58 PM, Tapas Mishra wrote: > On Sun, Aug 22, 2010 at 8:49 PM, arshad hussain > wrote: > > Ok. So you included linux/syscalls.h instead of sys/syscalls.h > > and still it cannot find > Yes this is what happened > >"__NR_exit" symbol. Right? Or it > > compiled successfull

Re: linux/module.h does not exist

2010-08-22 Thread Tapas Mishra
On Sun, Aug 22, 2010 at 8:49 PM, arshad hussain wrote: > Ok. So you included linux/syscalls.h instead of sys/syscalls.h > and still it cannot find Yes this is what happened >"__NR_exit" symbol. Right? Or it > compiled successfully but did not load. Not reached here. -- Tapas http://mightydrea

Re: linux/module.h does not exist

2010-08-22 Thread arshad hussain
On 8/22/2010 12:39 PM, Tapas Mishra wrote: He he tried what you said. I wont 2 cents :) It did not worked Ok. So you included linux/syscalls.h instead of sys/syscalls.h and still it cannot find "__NR_exit" symbol. Right? Or it compiled successfully but did not load. --snip-- sys/syscall

Re: linux/module.h does not exist

2010-08-22 Thread Tapas Mishra
Ok I corrected the make file there should have been a blank space here is the new make file for the program ifeq ($(KERNELRELEASE),) KERNELDIR ?= /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) .PHONY: build clean build: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules clean: rm -

Re: linux/module.h does not exist

2010-08-22 Thread Tapas Mishra
On Sun, Aug 22, 2010 at 6:11 PM, Robert P. J. Day wrote: > >  i'm just catching up with this thread and, if i read it correctly, > the goal is to build a loadable kernel module using the proper > incantation and options on the gcc command line, is that correct? Yes yes right >but > i'm not sure i

Re: linux/module.h does not exist

2010-08-22 Thread Robert P. J. Day
On Sun, 22 Aug 2010, Mulyadi Santosa wrote: > On Sun, Aug 22, 2010 at 12:41, Tapas Mishra wrote: > > > > Following is the program for which it was Makefile I am mentioning it > > here for the sake of clarity so that you dont have to read first post > > > > #include > > #include > > #include >

Re: linux/module.h does not exist

2010-08-22 Thread Tapas Mishra
On Sun, Aug 22, 2010 at 1:48 PM, Mulyadi Santosa wrote: > > uhum? AFAIK sys call table is not exported in 2.6.x so even if > your code is perfectly compiled and produced valid .ko kernel module, > I doubt it will work. > Unless I missed something in recent development > > Regarding the m

Re: linux/module.h does not exist

2010-08-22 Thread Mulyadi Santosa
On Sun, Aug 22, 2010 at 12:41, Tapas Mishra wrote: > > Following is the program for which it was Makefile I am mentioning it > here for the sake of clarity so that you dont have to read first post > > #include > #include > #include > extern void *sys_table[]; ^^^ uhum? AFAIK sys call table is

Re: linux/module.h does not exist

2010-08-22 Thread Tapas Mishra
He he tried what you said. I wont 2 cents :) It did not worked Following is new program #include #include #include extern void *sys_table[]; asmlinkage int(*main_sys_exit)(int); asmlinkage int alt_exit_function(int err_code) { printk("Sys_exit called with err_code=%d\n",err_code);

Re: linux/module.h does not exist

2010-08-21 Thread arshad hussain
On 8/22/2010 11:11 AM, Tapas Mishra wrote: /home/tapas/LKP/pandora/temp/sample2/sample2.c:2:25: error: sys/syscall.h: No such file or directory My 2 cents ... #includehttp://lxr.linux.no/linux+*/include/linux/syscalls.h>> , try this include. Thanks

Re: linux/module.h does not exist

2010-08-21 Thread Tapas Mishra
Ok I did try what you suggested. From http://tldp.org/LDP/lkmpg/2.6/html/x181.html#AEN189 here is my Makefile obj-m += sample2.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 but I got same err

Re: linux/module.h does not exist

2010-08-21 Thread Mulyadi Santosa
On Sat, Aug 21, 2010 at 13:59, Tapas Mishra wrote: > Upto this point I have tried > > Step1) gcc -Wall -DMODULE -D__KERNEL__ -DLINUX -c sample2.c > Step2) added -I to gcc flag > gcc -Wall -DMODULE -D__KERNEL -DLINUX -I > /usr/src/linux-headers-2.6.28- 11/include/ -c sample2.c I've just realized t

Re: linux/module.h does not exist

2010-08-21 Thread Tapas Mishra
Upto this point I have tried Step1) gcc -Wall -DMODULE -D__KERNEL__ -DLINUX -c sample2.c Step2) added -I to gcc flag gcc -Wall -DMODULE -D__KERNEL -DLINUX -I /usr/src/linux-headers-2.6.28- 11/include/ -c sample2.c Step3) added one more -I with asm in path gcc -I /usr/src/linux-headers-2.6.28-11/a

Re: linux/module.h does not exist

2010-08-21 Thread Dave Hylands
Hi Tapas, On Fri, Aug 20, 2010 at 10:35 PM, Tapas Mishra wrote: > Ok I did > > gcc -I /usr/src/linux-headers-2.6.28-11/arch/x86/include/ -I > /usr/src/linux-headers-2.6.28-11/include/ -c sample2.c I tried a few other variants and couldn't get them to work either. The only thing I've been able t

Re: linux/module.h does not exist

2010-08-20 Thread Dave Hylands
Hi Tapas, On Fri, Aug 20, 2010 at 10:24 PM, Tapas Mishra wrote: > Ya you were right I tried the following this time > gcc -I /usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/ -I > /usr/src/linux-headers-2.6.28-11/include/linux/ -c sample2.c Almost there. why did you modify your original pat

Re: linux/module.h does not exist

2010-08-20 Thread Dave Hylands
Hi Tapas, On Fri, Aug 20, 2010 at 10:27 PM, Dave Hylands wrote: > Hi Tapas, > > On Fri, Aug 20, 2010 at 10:24 PM, Tapas Mishra wrote: >> Ya you were right I tried the following this time >> gcc -I /usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/ -I >> /usr/src/linux-headers-2.6.28-11/inclu

Re: linux/module.h does not exist

2010-08-20 Thread Tapas Mishra
Apart from what you said I notice adding /linux to reduces the errors. So when I tried gcc -I /usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/ -I /usr/src/linux-headers-2.6.28-11/include/linux/ -c sample2.c got less errors sample2.c:3:26: error: linux/module.h: No such file or directory sam

Re: linux/module.h does not exist

2010-08-20 Thread Dave Hylands
Hi Tapas, On Fri, Aug 20, 2010 at 9:34 PM, Tapas Mishra wrote: > Ohh Ok now it becomes a bit clear, > > > On Sat, Aug 21, 2010 at 8:51 AM, Dave Hylands wrote: >> >> This one: >> /usr/src/linux-headers-2.6.28-11/include/linux/module.h >> >> I suspect that you'll also need to add >> /usr/src//usr/

Re: linux/module.h does not exist

2010-08-20 Thread Tapas Mishra
Ohh Ok now it becomes a bit clear, On Sat, Aug 21, 2010 at 8:51 AM, Dave Hylands wrote: > > This one: > /usr/src/linux-headers-2.6.28-11/include/linux/module.h > > I suspect that you'll also need to add > /usr/src//usr/src/linux-headers-2.6.28-11/arch/x86/include/asm to your > search path. Ok is

Re: linux/module.h does not exist

2010-08-20 Thread Dave Hylands
Hi Tapas, Replying to all this time... On Fri, Aug 20, 2010 at 6:07 PM, Tapas Mishra wrote: > Also I did a find on module.h which of them among here should I include? This one: /usr/src/linux-headers-2.6.28-11/include/linux/module.h I suspect that you'll also need to add /usr/src//usr/src/linu

Re: linux/module.h does not exist

2010-08-20 Thread Tapas Mishra
Also I did a find on module.h which of them among here should I include? As some one pointed out to use -I flag /usr/src/linux-headers-2.6.28-11-generic/include/linux/module.h /usr/src/linux-headers-2.6.28-11/arch/alpha/include/asm/module.h /usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/mod

Re: linux/module.h does not exist

2010-08-20 Thread Tapas Mishra
Yes you were right I had missed one line following. asmlinkage int alt_exit_function(int err_code) I have added this line so the program becomes now #include #include #include extern void *sys_table[]; asmlinkage int(*main_sys_exit)(int); asmlinkage int alt_exit_function(int err_code) {

Re: linux/module.h does not exist

2010-08-20 Thread Dave Hylands
Hi Tapas, Replying to all this time... On Fri, Aug 20, 2010 at 12:52 AM, Tapas Mishra wrote: > Hi Dave I could not understand your reply. > Go back to page 48 of the PDF, and look at the example. And then look at the code you posted. It's missing a line in the spot I indicated. -- Dave Hylands

Re: linux/module.h does not exist

2010-08-20 Thread Tapas Mishra
> GCC does not have information about compiling the kernel. The > information that you were suggested to read it how to configure GCC so > it can find the kernel headers. I checked these 2 documents http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1124.pdf http://gcc.gnu.org/onlinedocs/gcc-4.4.4/g

Re: linux/module.h does not exist

2010-08-20 Thread Mulyadi Santosa
On Fri, Aug 20, 2010 at 15:29, Wouter Simons wrote: > Your compiler should be told where to find the header files that are in > the kernel sources. Which is exactly I suggest Tapas to check the -I ("i" capital, no "el") :) -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blo

Re: linux/module.h does not exist

2010-08-20 Thread Wouter Simons
On 08/20/2010 01:53 AM, Tapas Mishra wrote: > Ok > I looked at man page of gcc and searched for > DMODULE D__KERNEL and DLINUX got following > > Pattern not found (press RETURN) GCC does not have information about compiling the kernel. The information that you were suggested to read it how to co

Re: linux/module.h does not exist

2010-08-20 Thread Tapas Mishra
Hi Dave I could not understand your reply. -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ

Re: linux/module.h does not exist

2010-08-19 Thread Dave Hylands
Hi Tapas, On Wed, Aug 18, 2010 at 9:12 AM, Tapas Mishra wrote: > I wrote following program in my home directory. > > #include > #include > #include > extern void *sys_table[]; > asmlinkage int(*main_sys_exit)(int); You seem to be missing the line of code that goes here > { >        print

Re: linux/module.h does not exist

2010-08-19 Thread Tapas Mishra
Ok I looked at man page of gcc and searched for DMODULE D__KERNEL and DLINUX got following Pattern not found (press RETURN) -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ

Re: linux/module.h does not exist

2010-08-19 Thread Mulyadi Santosa
Hi... On Wed, Aug 18, 2010 at 23:12, Tapas Mishra wrote: > When I compiled it as > > > gcc -Wall -DMODULE -D__KERNEL__  -DLINUX -c sample2.c[/code] > > I got following error > > > sample2.c:3:26: error: linux/module.h: No such file or directory IMO it's because you forgot to tell gcc on where to

Re: linux/module.h does not exist

2010-08-19 Thread Tapas Mishra
I was able to write my first module and saw that in syslog. I am trying this code from here https://docs.google.com/fileview?id=0B2A4urYOAf6POTI1OGE1MjctM2UyMC00OGUzLThlNDUtZDBhOWFjY2Y1MDUz&hl=en page 48 left hand section. Headers are installed. sudo apt-get install linux-headers-generic [sudo]

Re: linux/module.h does not exist

2010-08-18 Thread Dave Hylands
Hi Taps, On Wed, Aug 18, 2010 at 9:12 AM, Tapas Mishra wrote: > I wrote following program in my home directory. ...snip... gcc -Wall -DMODULE -D__KERNEL__ -DLINUX -c sample2.c[/code] ...snip... > What is the above error and why is it coming? > I did all this in my home directory. You're trying

linux/module.h does not exist

2010-08-18 Thread Tapas Mishra
I wrote following program in my home directory. #include #include #include extern void *sys_table[]; asmlinkage int(*main_sys_exit)(int); { printk("Sys_exit called with err_code=%d\n",err_code); return main_sys_exit(err_code); } int init_module() { main_sys_exit=sys_t