2009-01-25 04:57:54

by Satish Eerpini

[permalink] [raw]
Subject: building custom module on 2.6.28 fails

Hi everyone,

I tried to compile build the following sample kernel module on 2.6.28 :

______________________________________________________________________
#include <linux/module.h>
/* Defines the license for this LKM */
MODULE_LICENSE("GPL");
/* Init function called on module entry */

int my_module_init( void )
{
printk(KERN_INFO "my_module_init called. Module is now loaded.\n");
return 0;
}

/* Cleanup function called on module exit */
void my_module_cleanup( void )
{
printk(KERN_INFO "my_module_cleanup called. Module is now unloaded.\n");
return;
}

/* Declare entry and exit functions */
module_init( my_module_init );
module_exit( my_module_cleanup );
____________________________________________________________________

but it fails with the following error :

_____________________________________________________________________
make -C /lib/modules/`uname -r`/build
SUBDIRS=/home/satish/prog/kernel/modules modules
make[1]: Entering directory `/usr/src/kernels/linux-2.6.28'
CC [M] /home/satish/prog/kernel/modules/simple-mod.o
In file included from include/linux/gfp.h:4,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from /home/satish/prog/kernel/modules/simple-mod.c:1:
include/linux/mmzone.h:18:26: error: linux/bounds.h: No such file or directory
include/linux/mmzone.h:256:5: warning: "MAX_NR_ZONES" is not defined
In file included from include/linux/gfp.h:4,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from /home/satish/prog/kernel/modules/simple-mod.c:1:
include/linux/mmzone.h:277: error: 'MAX_NR_ZONES' undeclared here (not
in a function)
make[2]: *** [/home/satish/prog/kernel/modules/simple-mod.o] Error 1
make[1]: *** [_module_/home/satish/prog/kernel/modules] Error 2
make[1]: Leaving directory `/usr/src/kernels/linux-2.6.28'
make: *** [all] Error 2
__________________________________________________________________

any hints what could be wrong ?


Thanks
Satish

--
http://satish.playdrupal.com


2009-01-25 06:49:48

by Jaswinder Singh Rajput

[permalink] [raw]
Subject: Re: building custom module on 2.6.28 fails

On Sun, 2009-01-25 at 10:27 +0530, Satish Eerpini wrote:
> include/linux/mmzone.h:18:26: error: linux/bounds.h: No such file or directory
> include/linux/mmzone.h:256:5: warning: "MAX_NR_ZONES" is not defined
> In file included from include/linux/gfp.h:4,
> from include/linux/kmod.h:22,
> from include/linux/module.h:13,
> from /home/satish/prog/kernel/modules/simple-mod.c:1:
> include/linux/mmzone.h:277: error: 'MAX_NR_ZONES' undeclared here (not
> in a function)
> make[2]: *** [/home/satish/prog/kernel/modules/simple-mod.o] Error 1
> make[1]: *** [_module_/home/satish/prog/kernel/modules] Error 2
> make[1]: Leaving directory `/usr/src/kernels/linux-2.6.28'
> make: *** [all] Error 2
> __________________________________________________________________
>
> any hints what could be wrong ?
>

what is the output of:

ls -l /usr/src/kernels/linux-2.6.28/include/linux/bo*

--
JSR

2009-01-25 08:37:41

by Satish Eerpini

[permalink] [raw]
Subject: Re: building custom module on 2.6.28 fails

-rw-r--r-- 1 root root 4848 2008-10-10 03:43
/usr/src/kernels/linux-2.6.28/include/linux/bootmem.h
-rw-r--r-- 1 root root 261 2008-10-10 03:43
/usr/src/kernels/linux-2.6.28/include/linux/bottom_half.h
-rw-r--r-- 1 root root 224 2009-01-25 14:09
/usr/src/kernels/linux-2.6.28/include/linux/bounds.h


On 1/25/09, Jaswinder Singh Rajput <[email protected]> wrote:
> On Sun, 2009-01-25 at 10:27 +0530, Satish Eerpini wrote:
>> include/linux/mmzone.h:18:26: error: linux/bounds.h: No such file or
>> directory
>> include/linux/mmzone.h:256:5: warning: "MAX_NR_ZONES" is not defined
>> In file included from include/linux/gfp.h:4,
>> from include/linux/kmod.h:22,
>> from include/linux/module.h:13,
>> from /home/satish/prog/kernel/modules/simple-mod.c:1:
>> include/linux/mmzone.h:277: error: 'MAX_NR_ZONES' undeclared here (not
>> in a function)
>> make[2]: *** [/home/satish/prog/kernel/modules/simple-mod.o] Error 1
>> make[1]: *** [_module_/home/satish/prog/kernel/modules] Error 2
>> make[1]: Leaving directory `/usr/src/kernels/linux-2.6.28'
>> make: *** [all] Error 2
>> __________________________________________________________________
>>
>> any hints what could be wrong ?
>>
>
> what is the output of:
>
> ls -l /usr/src/kernels/linux-2.6.28/include/linux/bo*
>
> --
> JSR
>
>


--
http://satish.playdrupal.com

2009-01-25 10:31:00

by Jaswinder Singh Rajput

[permalink] [raw]
Subject: Re: building custom module on 2.6.28 fails


On Sun, 2009-01-25 at 14:07 +0530, Satish Eerpini wrote:
> -rw-r--r-- 1 root root 4848 2008-10-10 03:43
> /usr/src/kernels/linux-2.6.28/include/linux/bootmem.h
> -rw-r--r-- 1 root root 261 2008-10-10 03:43
> /usr/src/kernels/linux-2.6.28/include/linux/bottom_half.h
> -rw-r--r-- 1 root root 224 2009-01-25 14:09
> /usr/src/kernels/linux-2.6.28/include/linux/bounds.h
>
>
> On 1/25/09, Jaswinder Singh Rajput <[email protected]> wrote:
> > On Sun, 2009-01-25 at 10:27 +0530, Satish Eerpini wrote:
> >> include/linux/mmzone.h:18:26: error: linux/bounds.h: No such file or
> >> directory

It seems you run "make clean" or "make distclean" in your kernel sources

run "make prepare" in your kernel sources then you will not get this error.

--
JSR

2009-01-25 10:41:57

by Jaswinder Singh Rajput

[permalink] [raw]
Subject: Re: building custom module on 2.6.28 fails

Hello Andrew, Sam,

On Sun, 2009-01-25 at 16:00 +0530, Jaswinder Singh Rajput wrote:
> On Sun, 2009-01-25 at 14:07 +0530, Satish Eerpini wrote:
> > -rw-r--r-- 1 root root 4848 2008-10-10 03:43
> > /usr/src/kernels/linux-2.6.28/include/linux/bootmem.h
> > -rw-r--r-- 1 root root 261 2008-10-10 03:43
> > /usr/src/kernels/linux-2.6.28/include/linux/bottom_half.h
> > -rw-r--r-- 1 root root 224 2009-01-25 14:09
> > /usr/src/kernels/linux-2.6.28/include/linux/bounds.h
> >
> >
> > On 1/25/09, Jaswinder Singh Rajput <[email protected]> wrote:
> > > On Sun, 2009-01-25 at 10:27 +0530, Satish Eerpini wrote:
> > >> include/linux/mmzone.h:18:26: error: linux/bounds.h: No such file or
> > >> directory
>
> It seems you run "make clean" or "make distclean" in your kernel sources
>
> run "make prepare" in your kernel sources then you will not get this error.

Many people are facing similar problems like this.

In this case linux/bounds.h is generated by Kbuild and leads to error
for modules if we do "make clean" or "make distclean"

Can we take benefits from __GENERATING_BOUNDS_H

Do you have some better plans.

--
JSR

2009-01-25 11:19:26

by Satish Eerpini

[permalink] [raw]
Subject: Re: building custom module on 2.6.28 fails

>> It seems you run "make clean" or "make distclean" in your kernel sources
>>
>> run "make prepare" in your kernel sources then you will not get this
>> error.
>

I ran make clean and then make prepare but it gives an error saying
"no such file or directory : modpost ", ....
Then i ran make( in the kernel source tree) , and terminated it after
a few files were compiled and then again tried to compile my module,
this time it worked without any errors, ....... any particular reason
for this ??

Thanks
Satish
--
http://satish.playdrupal.com

2009-01-25 13:45:42

by Sam Ravnborg

[permalink] [raw]
Subject: Re: building custom module on 2.6.28 fails

On Sun, Jan 25, 2009 at 04:49:16PM +0530, Satish Eerpini wrote:
> >> It seems you run "make clean" or "make distclean" in your kernel sources
> >>
> >> run "make prepare" in your kernel sources then you will not get this
> >> error.
> >
>
> I ran make clean and then make prepare but it gives an error saying
> "no such file or directory : modpost ", ....
> Then i ran make( in the kernel source tree) , and terminated it after
> a few files were compiled and then again tried to compile my module,
> this time it worked without any errors, ....... any particular reason
> for this ??
We are currently lacking a dependency on "scripts" so doing:
make scripts
make prepare
is needed today.

Sam

2009-01-25 14:28:34

by Jaswinder Singh Rajput

[permalink] [raw]
Subject: Re: building custom module on 2.6.28 fails

On Sun, 2009-01-25 at 14:47 +0100, Sam Ravnborg wrote:
> On Sun, Jan 25, 2009 at 04:49:16PM +0530, Satish Eerpini wrote:
> > >> It seems you run "make clean" or "make distclean" in your kernel sources
> > >>
> > >> run "make prepare" in your kernel sources then you will not get this
> > >> error.
> > >
> >
> > I ran make clean and then make prepare but it gives an error saying
> > "no such file or directory : modpost ", ....
> > Then i ran make( in the kernel source tree) , and terminated it after
> > a few files were compiled and then again tried to compile my module,
> > this time it worked without any errors, ....... any particular reason
> > for this ??
> We are currently lacking a dependency on "scripts" so doing:
> make scripts
> make prepare
> is needed today.

As per makefile:
# make clean Delete most generated files
# Leave enough to build external modules

So is this OK to delete include/linux/bounds.h by 'make clean'.

--
JSR

2009-01-25 15:51:55

by Satish Eerpini

[permalink] [raw]
Subject: Re: building custom module on 2.6.28 fails

> We are currently lacking a dependency on "scripts" so doing:
> make scripts
> make prepare
> is needed today.
>

Just to confirm, ... doing the above works fine and I am able to
compile the module.


Thanks
Satish

--
http://satish.playdrupal.com

2009-01-25 19:16:41

by Sam Ravnborg

[permalink] [raw]
Subject: Re: building custom module on 2.6.28 fails

On Sun, Jan 25, 2009 at 07:57:37PM +0530, Jaswinder Singh Rajput wrote:
> On Sun, 2009-01-25 at 14:47 +0100, Sam Ravnborg wrote:
> > On Sun, Jan 25, 2009 at 04:49:16PM +0530, Satish Eerpini wrote:
> > > >> It seems you run "make clean" or "make distclean" in your kernel sources
> > > >>
> > > >> run "make prepare" in your kernel sources then you will not get this
> > > >> error.
> > > >
> > >
> > > I ran make clean and then make prepare but it gives an error saying
> > > "no such file or directory : modpost ", ....
> > > Then i ran make( in the kernel source tree) , and terminated it after
> > > a few files were compiled and then again tried to compile my module,
> > > this time it worked without any errors, ....... any particular reason
> > > for this ??
> > We are currently lacking a dependency on "scripts" so doing:
> > make scripts
> > make prepare
> > is needed today.
>
> As per makefile:
> # make clean Delete most generated files
> # Leave enough to build external modules
>
> So is this OK to delete include/linux/bounds.h by 'make clean'.
No - only mrproper and distclean should delete it.

Sam

2009-01-25 19:32:40

by Jaswinder Singh

[permalink] [raw]
Subject: Re: building custom module on 2.6.28 fails

On Mon, Jan 26, 2009 at 12:48 AM, Sam Ravnborg <[email protected]> wrote:
> On Sun, Jan 25, 2009 at 07:57:37PM +0530, Jaswinder Singh Rajput wrote:
>> On Sun, 2009-01-25 at 14:47 +0100, Sam Ravnborg wrote:
>> > On Sun, Jan 25, 2009 at 04:49:16PM +0530, Satish Eerpini wrote:
>> > > >> It seems you run "make clean" or "make distclean" in your kernel sources
>> > > >>
>> > > >> run "make prepare" in your kernel sources then you will not get this
>> > > >> error.
>> > > >
>> > >
>> > > I ran make clean and then make prepare but it gives an error saying
>> > > "no such file or directory : modpost ", ....
>> > > Then i ran make( in the kernel source tree) , and terminated it after
>> > > a few files were compiled and then again tried to compile my module,
>> > > this time it worked without any errors, ....... any particular reason
>> > > for this ??
>> > We are currently lacking a dependency on "scripts" so doing:
>> > make scripts
>> > make prepare
>> > is needed today.
>>
>> As per makefile:
>> # make clean Delete most generated files
>> # Leave enough to build external modules
>>
>> So is this OK to delete include/linux/bounds.h by 'make clean'.
> No - only mrproper and distclean should delete it.
>

[jsr@jaswinder linux-2.6-tip]$ ls -l include/linux/bo*
-rw-rw-r-- 1 jsr jsr 4848 2008-08-21 19:55 include/linux/bootmem.h
-rw-rw-r-- 1 jsr jsr 224 2008-12-08 11:35 include/linux/bottom_half.h
-rw-rw-r-- 1 jsr jsr 224 2009-01-17 20:31 include/linux/bounds.h
[jsr@jaswinder linux-2.6-tip]$ make clean
CLEAN arch/x86/boot/compressed
CLEAN arch/x86/boot
CLEAN /home/jsr/jaswinder-git/linux-2.6-tip
CLEAN arch/x86/kernel/acpi/realmode
CLEAN arch/x86/kernel/cpu
CLEAN arch/x86/kernel
CLEAN arch/x86/vdso
CLEAN drivers/char
CLEAN drivers/scsi/aic7xxx
CLEAN drivers/video/logo
CLEAN firmware
CLEAN init
CLEAN kernel
CLEAN lib
CLEAN usr
CLEAN .tmp_versions
CLEAN vmlinux System.map .tmp_kallsyms0.o .tmp_kallsyms0.S
.tmp_kallsyms1.o .tmp_kallsyms1.S .tmp_kallsyms2.o .tmp_kallsyms2.S
.tmp_kallsyms3.o .tmp_kallsyms3.S .tmp_vmlinux0 .tmp_vmlinux0.stripped
.tmp_vmlinux1 .tmp_vmlinux1.stripped .tmp_vmlinux2
.tmp_vmlinux2.stripped .tmp_vmlinux3 .tmp_vmlinux3.stripped
.tmp_System.map
[jsr@jaswinder linux-2.6-tip]$ ls -l include/linux/bo*
-rw-rw-r-- 1 jsr jsr 4848 2008-08-21 19:55 include/linux/bootmem.h
-rw-rw-r-- 1 jsr jsr 224 2008-12-08 11:35 include/linux/bottom_half.h
[jsr@jaswinder linux-2.6-tip]$

--
JSR