mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
Rm useless init.sh, init_hello and poweroff are not init specific, so rename them more generically
This commit is contained in:
@@ -264,11 +264,16 @@ Is the default BusyBox `/init` too bloated for you, minimalism freak?
|
||||
|
||||
No problem, just use the `init` kernel boot parameter:
|
||||
|
||||
./runqemu -e 'init=/init_hello.out'
|
||||
./runqemu -e 'init=/sleep_forever.out'
|
||||
|
||||
Remember that shell scripts can also be used for `init` <https://unix.stackexchange.com/questions/174062/init-as-a-shell-script/395375#395375>:
|
||||
|
||||
./runqemu -e 'init=/init.sh'
|
||||
./runqemu -e 'init=/count.sh'
|
||||
|
||||
Also remember that if your init returns, the kernel will panic, there are just two non-panic possibilities:
|
||||
|
||||
- run forever in a loop or long sleep
|
||||
- `poweroff` the machine
|
||||
|
||||
## Debugging
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ These programs can also be compiled and used on host.
|
||||
1. [usermem](usermem.c)
|
||||
1. [pagemap_dump](pagemap_dump.c)
|
||||
1. inits
|
||||
1. [init_hello](init_hello.c)
|
||||
1. [init_poweroff](init_poweroff.c)
|
||||
1. [sleep_forever](sleep_forever.c)
|
||||
1. [poweroff](poweroff.c)
|
||||
1. [uio_read](uio_read.c)
|
||||
1. Module tests
|
||||
1. [anonymous_inode](anonymous_inode.c)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
/* Replacement init example for when we feel like running
|
||||
* a single non-interactive single executable Linux distro. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(void) {
|
||||
puts(__FILE__);
|
||||
while (1)
|
||||
sleep(0xFFFFFFFF);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/* Userspace is for the weak. Die.
|
||||
* https://stackoverflow.com/questions/28812514/how-to-shutdown-linux-using-c-or-qt-without-call-to-system */
|
||||
* https://stackoverflow.com/questions/28812514/how-to-shutdown-linux-using-c-or-qt-without-call-to-system
|
||||
* BusyBox's /sbin/poweroff is under init/halt.c, but it does extra crap like killing init, so I don't trust it. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/reboot.h>
|
||||
10
kernel_module/user/sleep_forever.c
Normal file
10
kernel_module/user/sleep_forever.c
Normal file
@@ -0,0 +1,10 @@
|
||||
/* Sleeping beauty, your prince is called Ctrl + C. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(void) {
|
||||
puts(__FILE__);
|
||||
while (1)
|
||||
sleep(0xFFFFFFFF);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Can init be a sh script? Yes.
|
||||
# Sure, why not: https://unix.stackexchange.com/questions/174062/init-as-a-shell-script/395375#395375
|
||||
echo 'hello init.sh'
|
||||
while true; do
|
||||
sleep 1
|
||||
done
|
||||
Reference in New Issue
Block a user