how to Call my C code at start of kernel?
hello,
Whenever a Linux machine started it loads all drivers. Then ups Network interfaces eth0,eth1... and then sends ARP packets on its Internal networks Right? Now what i want is to load my C program executable as soon as network card ups but before it queries for ARP or try to send any packet? How to do that in RH9? regards, cranium. |
You could just start your C program early on in the init phase.
|
you could also try making your program a kernel module.. but the init process would be easier, look in /etc/init.d/rc.d directory for all services available, and rc.x for each runlevel's services
|
The init process idea, by the way, assumes that you are not using any kernel-space IP Autoconfiguration.
|
Is there any palce on RH9 where i can put path to my program to be executed as soon as NIC Interfaces are up by kernel?
Or I have to write a new service in rc3.d directory for that? |
i would start at the /etc/init.d/rc.d/network shell script, perhaps you could modify that to run your program within the network service startup process, /etc/init.d/rcX.d contains links to the actual scripts
|
hello,
In /etc/rc.d/rc3.d/S10network I add my C program executable /home/cranium/test before following lines as shown /home/cranium/test # If this is a final shutdown/halt, check for network FS, # and unmount them even if the user didn't turn on netfs But the program is not executed? why? I am using RH9 |
Well, are the permissions set properly?
|
hello,
I copied my executable to /root/bin which is in shell path. Now i am able to run it from any directory oce i got console prompt. But same is not called in /etc/rc.d/rc3.d/S10network when i place a statement in it /root/bin/test Is there anything required me to modify? Because after adding rebooting kernel my executable is not executed automatically ? |
Is your system really booting in runlevel 3? Are other statements in the file being executed properly?
|
Ofcourse, ITs saying at bootup that enting in runlevel 3 and as i am getting stable console promt that mean i am bootin g in level3 so that no graphical problem to my linux installation. also i already set it in GRUB also to boot in level 3.
What else required to boot in level3? Other statement in file S10networks are executing properly with no error message. Now what else i do to add my executable in boot up procedure? |
That should be all you need. Please post the contents of S10networks.
|
hello,
I have did all things and its booting in level 3. Take a look at S10network that i modifies by adding my executable. Code:
|
Your stuff appears to be under the stop) option in the case statement, so it will only be run when "service network stop" is run. You want your program to run when the network is started, not when it's stopped, so put it under the start) option of the case and that should do it.
|
Thanks all :)
Thanks btmiller and Matir and frieza for their assistence my problem is solved.
Thanks :) |
All times are GMT -5. The time now is 08:29 AM. |