Reputation: 321
extern unsigned long current_rx_time;
EXPORT_SYMBOL(current_rx_time);
int netif_rx(struct sk_buff *skb)
{
current_rx_time = jiffies;
}
I modified the kernel source code in dev.c as shown above. Later I am creating a loadable kernel module in procfs and using the currentrx_time to send it to user space as shown below :
static int my_proc_show(struct seq_file *m, void *v)
{
//I AM JUST PRINTING THAT VALUE BELOW
seq_printf(m, "%lu\n", current_rx_time *1000/HZ);
return 0;
}
but I am getting a error when I compile my module above as current_rx_time
is undeclared. Could someone tell me how to solve this problem?
Upvotes: 1
Views: 219
Reputation: 400159
The second code needs to declare the external variable, so the linker can know that it's coming from the outside:
extern unsigned long current_rx_time;
Upvotes: 0
Reputation: 27240
First you need to declare your variable and then you can EXPORT it.
so just declare it as in dev.c
unsigned long current_rx_time;
then export it as in dev.c
EXPORT_SYMBOL(current_rx_time);
and in other loadable module where you want to use it (let's say in temp2.c)...
extern unsigned long current_rx_time;
Now make sure when you going to compile temp2.c at that time dev.c is also getting compile.
Upvotes: 2