hi!
I am facing problem in compiling an LKM. It seems Inclusion of
<sys/stat.h> conflicts with definitions in time.h.
My linux kernal version is 2.4.21-4.EL
#include <linux/kernel.h>
#include <linux/module.h>
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include <linux/modversions.h>
#endif
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) ((a)*65536+(b)*256+(c))
#endif
#include <linux/slab.h>
#include <asm/uaccess.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#define CALLOFF 500
MODULE_LICENSE("GPL");
......
......
Inclusion of header file "sys/stat.h" gives variable redefinition error
during compilation.
........
In file included from /usr/include/sys/stat.h:37,
from venky.c:18:
/usr/include/time.h:119: redefinition of `struct timespec'
In file included from /usr/include/sys/stat.h:105,
from venky.c:18:
/usr/include/bits/stat.h:37: redefinition of `struct stat'
......
The Compile string is ::
gcc -O2 -DMODULE -D__KERNEL__ -W -Wall -Wstrict-prototypes
-Wmissing-prototypes -isystem /lib/modules/`uname -r`/build/include -I../ -c
-o test.o test.c
Similar redefinition error message are there when trying to include header
files like sys/types.h
It would be very helpfull if someone would point me in right direction.
Thanks
_________________________________________________________________
Tuff to bluff! Get Abhishek before he gets you! Enter the contest
http://utv.movie-talkies.com/bluffmaster/contest.html
On Thu, Dec 29, 2005 at 04:21:49PM +0530, pretorious . wrote:
> hi!
> I am facing problem in compiling an LKM. It seems Inclusion of
> <sys/stat.h> conflicts with definitions in time.h.
That's because you do not use libc headers for non-userland code...
On Thu, 2005-12-29 at 16:21 +0530, pretorious . wrote:
> hi!
> I am facing problem in compiling an LKM. It seems Inclusion of
> <sys/stat.h> conflicts with definitions in time.h.
>
>
> My linux kernal version is 2.4.21-4.EL
>
>
> #include <linux/kernel.h>
> #include <linux/module.h>
>
> #if CONFIG_MODVERSIONS==1
> #define MODVERSIONS
> #include <linux/modversions.h>
> #endif
this is broken btw
>
> #ifndef KERNEL_VERSION
> #define KERNEL_VERSION(a,b,c) ((a)*65536+(b)*256+(c))
> #endif
>
> #include <linux/slab.h>
> #include <asm/uaccess.h>
> #include <sys/syscall.h>
>
> #include <sys/stat.h>
you cannot use glibc headers in kernel modules. anything in sys/ is a
glibc header.
and.. why on earth would you need sys/syscall.h ?? (or sys/stat.h for
that matter)
>
>and.. why on earth would you need sys/syscall.h ?? (or sys/stat.h for
>that matter)
>
>
Trying to override certain syscalls (mknod ...)
>From: Arjan van de Ven <[email protected]>
>To: "pretorious ." <[email protected]>
>CC: [email protected]
>Subject: Re: Redefinition error while compiling LKM
>Date: Thu, 29 Dec 2005 12:02:09 +0100
>
>On Thu, 2005-12-29 at 16:21 +0530, pretorious . wrote:
> > hi!
> > I am facing problem in compiling an LKM. It seems Inclusion of
> > <sys/stat.h> conflicts with definitions in time.h.
> >
> >
> > My linux kernal version is 2.4.21-4.EL
> >
> >
> > #include <linux/kernel.h>
> > #include <linux/module.h>
> >
> > #if CONFIG_MODVERSIONS==1
> > #define MODVERSIONS
> > #include <linux/modversions.h>
> > #endif
>
>this is broken btw
> >
> > #ifndef KERNEL_VERSION
> > #define KERNEL_VERSION(a,b,c) ((a)*65536+(b)*256+(c))
> > #endif
> >
> > #include <linux/slab.h>
> > #include <asm/uaccess.h>
> > #include <sys/syscall.h>
> >
> > #include <sys/stat.h>
>
>
>you cannot use glibc headers in kernel modules. anything in sys/ is a
>glibc header.
>
>and.. why on earth would you need sys/syscall.h ?? (or sys/stat.h for
>that matter)
>
>
_________________________________________________________________
Spice up your IM conversations. New, colorful and animated emoticons. Get
chatting! http://server1.msn.co.in/SP05/emoticons/
On 12/29/05, pretorious . <[email protected]> wrote:
> >
> >and.. why on earth would you need sys/syscall.h ?? (or sys/stat.h for
> >that matter)
> >
> >
>
> Trying to override certain syscalls (mknod ...)
You do not intercept syscalls.
You do not intercept syscalls from a kernel module.
You do not include libc headers in the kernel code.
--
I am free of all prejudices. I hate every one equally.
On Thu, 2005-12-29 at 16:51 +0530, pretorious . wrote:
> >
> >and.. why on earth would you need sys/syscall.h ?? (or sys/stat.h for
> >that matter)
> >
> >
>
> Trying to override certain syscalls (mknod ...)
eeppp why??
really don't do that!
(overriding syscalls from modules really shouldn't be done.. there's a
reason the syscall table isn't exported!)
On 12/29/05, Arjan van de Ven <[email protected]> wrote:
> On Thu, 2005-12-29 at 16:51 +0530, pretorious . wrote:
> > >
> > >and.. why on earth would you need sys/syscall.h ?? (or sys/stat.h for
> > >that matter)
> > >
> > >
> >
> > Trying to override certain syscalls (mknod ...)
>
> eeppp why??
> really don't do that!
>
> (overriding syscalls from modules really shouldn't be done.. there's a
> reason the syscall table isn't exported!)
Perhaps during the 2.4.21 old days sys_call_table was still exported
and there were plenty of 'How to intrecept a syscall in 10 minutes'
documents in the wild.
--
I am free of all prejudices. I hate every one equally.
On Thu, 2005-12-29 at 15:14 +0300, Alexander Shishckin wrote:
> On 12/29/05, Arjan van de Ven <[email protected]> wrote:
> > On Thu, 2005-12-29 at 16:51 +0530, pretorious . wrote:
> > > >
> > > >and.. why on earth would you need sys/syscall.h ?? (or sys/stat.h for
> > > >that matter)
> > > >
> > > >
> > >
> > > Trying to override certain syscalls (mknod ...)
> >
> > eeppp why??
> > really don't do that!
> >
> > (overriding syscalls from modules really shouldn't be done.. there's a
> > reason the syscall table isn't exported!)
>
> Perhaps during the 2.4.21 old days sys_call_table was still exported
not in the RHEL3 kernel though.