Hi,
I am need to use one global variable in two files.
One is ~/net/ipv6/tcp_ipv6.c where I have defined the global variable as extern int global_fd;
Second is my custom system call code. Its code is as follows
__________
#include<linux/linkage.h>
#include<linux/kernel.h>
int global_fd;
asmlinkage int sys_mycall(int fd)
{
global_fd = fd;
return fd;
}
___________
Now I am still getting the follwing error
___________________________
CHK include/linux/version.h
CHK include/linux/utsrelease.h
Building modules, stage 2.
MODPOST
WARNING: drivers/atm/he.o - Section mismatch: reference to .init.text: from .text between 'he_start' (at offset 0x2074) and 'he_service_tbrq'
WARNING: "global_fd" [net/ipv6/ipv6.ko] undefined!
WARNING: "sys_write" [net/ipv6/ipv6.ko] undefined!
[root@localhost linux-2.6.18.2]#
________________
Anther thing that I want to ask about sys_write . Can I use it in kernel code other than kernel module. and how can I solve the undefined problem of sys_write even I have also added the syscalls.h header file.
Regards,
Irfan
I am need to use one global variable in two files.
One is ~/net/ipv6/tcp_ipv6.c where I have defined the global variable as extern int global_fd;
Second is my custom system call code. Its code is as follows
__________
#include<linux/linkage.h>
#include<linux/kernel.h>
int global_fd;
asmlinkage int sys_mycall(int fd)
{
global_fd = fd;
return fd;
}
___________
Now I am still getting the follwing error
___________________________
CHK include/linux/version.h
CHK include/linux/utsrelease.h
Building modules, stage 2.
MODPOST
WARNING: drivers/atm/he.o - Section mismatch: reference to .init.text: from .text between 'he_start' (at offset 0x2074) and 'he_service_tbrq'
WARNING: "global_fd" [net/ipv6/ipv6.ko] undefined!
WARNING: "sys_write" [net/ipv6/ipv6.ko] undefined!
[root@localhost linux-2.6.18.2]#
________________
Anther thing that I want to ask about sys_write . Can I use it in kernel code other than kernel module. and how can I solve the undefined problem of sys_write even I have also added the syscalls.h header file.
Regards,
Irfan
----- Original Message ----
From: Naveed Latif <kernelmail.naveed@xxxxxxxxx>
To: Irfan Ahmed <ahm_irf@xxxxxxxxx>
Sent: Thursday, May 3, 2007 3:39:26 AM
Subject: Re: Where should I declare the global variable
From: Naveed Latif <kernelmail.naveed@xxxxxxxxx>
To: Irfan Ahmed <ahm_irf@xxxxxxxxx>
Sent: Thursday, May 3, 2007 3:39:26 AM
Subject: Re: Where should I declare the global variable
On 5/3/07, Irfan Ahmed <ahm_irf@xxxxxxxxx> wrote:
hope for the best
Hi,
I have added a new system call that is used to initialize a global variable through userspace program. After initialization, I need to use that global variable in ~/net/ipv6/tcp_ipv6.c file. let say printing the value of that global variable.
So where should I declare that global variable.
Right now I have declare it in system call but the following error occured
I think u are doing 2 mistakes
1) you have to use EXPORT_SYMBOL(my_variable) macro to export variable in other modules
2) in ~/net/ipv6/tcp_ipv6.c file variable should be like this
extern int my_variable;
extern int my_variable;
hope for the best
Naveed Latif
_______________________________________________________
CC [M] net/ipv6/tcp_ipv6.o
net/ipv6/tcp_ipv6.c: In function 'tcp_v6_rcv':
net/ipv6/tcp_ipv6.c:1313: error: 'global_fd' undeclared (first use in this function)
net/ipv6/tcp_ipv6.c:1313: error: (Each undeclared identifier is reported only once
net/ipv6/tcp_ipv6.c:1313: error: for each function it appears in.)
make[2]: *** [net/ipv6/tcp_ipv6.o] Error 1
make[1]: *** [net/ipv6] Error 2
make: *** [net] Error 2
__________________________________
Regards,
Irfan
Send instant messages to your online friends http://uk.messenger.yahoo.com
Send instant messages to your online friends http://uk.messenger.yahoo.com