0

I've written three kernel modules. A, B, C. B needs some functions from A and C also. How to achieve this. Please be code specific. Any help is appreciated.

1 Answer 1

1

Below the function implementation in A, export it:

#include "moduleA_header.h"

int foo(void)
{
    printk(KERN_NOTICE "Hi there!\n");
}
EXPORT_SYMBOL(foo);

Make sure that the prototype of your function is declared in a header file that you can include in module B. Also, make sure module A gets loaded before module B.

Just make sure that your include has the path right to the moduleA_header.h file.

Sign up to request clarification or add additional context in comments.

6 Comments

Could you please show me the directory structure. Should these modules be in same directory (and also header file too)?
@mahesh The modules don't need to be in the same directory. All you need for that to work is to be able to include the definition of int foo() into the code of your module B.
How to return character arrays? While compiling it says return address of local variable.
@mahesh I am afraid your last comment is beyond the scope of the original question.
So should I ask another question?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.