On 3/24/07, Ismael Luceno <[EMAIL PROTECTED]> wrote:
> I don't know how to elegantly implement a "reboot hook" in the general
> case. But if I only want to run kexec, it seems a simple matter of
> adding system("kexec -e") in the right place and recompiling. Can you
> tell me what is the "right place"?
>
You should use the kexec system call directly, the file that you need
to edit is src/initng_main.c.
Good luck ;).
Thank you. I will study the kexec system call. Since I am not sure about
what "kexec -e" does before calling the system call, I think I will read the
kexec (the userland program) source code. I hope it is small!
Slightly changing the topic, allow me to report what happened on my Gentoo
system.
I was reading the "TIP kexec" at the Gentoo Wiki, and it told me that I had
to issue /etc/init.d/kexec start.
It would load the kernel image, so the system could later reboot by invoking
said image.
I thought that /etc/init.d/kexec was a a shell script, so I thought that I
could execute it even though I was running initng. The result was very, very
weird: I saw messages in my xterm that made it seem like my computer was
being put in single mode (including the "Enter password for maintenance"
message). But X was still runnning! When I dismissed the prompt to enter
password (I don't remember now if I pressed ESC, control-D or control-C), my
computer rebooted, without umounting partitions first.
When I read the /etc/init.d/kexec script, I realized that the function I
called should not reboot the computer (it merely loaded the kernel image,
without invoking it). I then realized the #!/sbin/runscript at the top.
"Oh... this thing is not a shell script. This thing probably thought that I
was running under Sys V init and made something really crazy...".
So nothing inside the script made the computer reboot. It was a weird
consequence of running a /etc/init.d script in a system that booted with
Initng.
Of course, I should not have called /etc/init.d/kexec start. My bad.
But can't we make the system fail in a more graceful manner than rebooting,
when a clueless user executes a script in /etc/init.d?
--
Software is like sex: it is better when it is free.
--
_______________________________________________
Initng mailing list
[email protected]
http://jw.dyndns.org/mailman/listinfo/initng