how to insert a module in kernel through a user defined service
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how to insert a module in kernel through a user defined service
Hi everybody,
I have created a c program which will insert a module in kernel. I converted this program into a service so that when I start it, it should insert the module in kernel & vice versa.
By default the service takes this module from root( / ) for insertion. But when I put this module in my home directory(say /home/sharad), the service is unable to find the module (It will search it in / only).
So how to load the module in kernel from my home directory using a service?
When you say that the program is a "service", do you mean it's running as a daemon? How does the user communicate with the daemon? Whatever communication method you use, why don't you just allow the user to specify the full path to whatever module that they want to load?
While we're on the topic, issuing command: depmod -a, will that only apply to the /lib/modules directory or modules system wide, as modules with udev have .ko extension.
Can not insert a module through a service running as a daemon
Quote:
Originally Posted by btmiller
When you say that the program is a "service", do you mean it's running as a daemon? How does the user communicate with the daemon? Whatever communication method you use, why don't you just allow the user to specify the full path to whatever module that they want to load?
Yes, the service is running as a daemon. From the C code I am invoking a system() function as follows.
e.g,
system("insmod module.ko");
Also I tried with the absolute path, but it is not working.
Junior Hacker: According to the man page for depmod on my system it only looks at modules in /lib/modules`uname -r` but you can give it other directories with the -b option.
sharad: I've used insmod with the full path before with no problem, and AFAIK it should work. Are you sure you passed it the correct path? Maybe there was some other problem inserting the module -- e.g. a missing symbol or somesuch (just guessing here). Can you post the exact error message you're getting?
Well
I feel kind of like a fool here, that was a question for both of us but I ended up forcing you to read up on it. But we both gained some knowledge I guess.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.