I have a kernel module that has this structure:
struct test {
int a;
int b;
.....
}
I created an array of instances of this structure as:
struct test foo[8];
I want to export this structure or the "foo" array using EXPORT_SYMBOLand access foo[0].ain another kernel module.
I tried EXPORT_SYMBOL(foo);from the provider module and extern struct test * foo;in the receiver module, but I cannot access the variable. Indicate where I am mistaken.
Here is another code:
Kernel Module 1:
#include <....>
#include "test_config.h"
....
MODULE_LICENSE("GPL");
struct test {
int a;
int b;
.....
}
test_t foo[8];
int init_module(void)
{
printk(KERN_INFO "Hello World\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye Cruel World\n");
}
Kerne 2 module:
#include <linux/module.h>
#include <linux/kernel.h>
#include "test_config.h"
int init_module(void)
{
test_t foo[8];
printk ("Value of foo is :: %d\n", foo[0].a);
foo[0].a++;
printk(KERN_INFO "Hello Again World\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye Again Cruel World\n");
}
Here is the header file with the structure definition:
#ifndef __TEST_CONFIG
#define __TEST_CONFIG
typedef struct test
{
int a;
int b
int c;
int d;
float e;
}test_t;
#endif
source
share