1.2: Init A custom init can make your distro feel particullarly lightweight and yours,
that requires some low-level coding tho.

Showcase of a simple C-Init:
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/mount.h>

int main(){
mount("tmpfs", "/tmp", "tmpfs",0,0);
mount("proc", "/proc", "proc",0,0);
mount("devtmpfs", "/dev", "devtmpfs",0,0);
mount("sysfs", "/sys", "sysfs",0,0);

int stdio = open("/dev/console", O_RDWR);
if(stdio > 0){
dup2(stdio, 0);
dup2(stdio, 1);
dup2(stdio, 2);
if(stdio > 2){ close(stdio); }
}else{
printf("XSUnit: ERR: Cannot find STDIO, STDIN, STDERR in /dev/console\n");
}

int pnum = 0;
char *shell = "/bin/busybox";

printf("XSUnit: PNUM: %d\n", pnum++);
pid_t shellprocess = fork();
if(shellprocess == 0){

//if you wish to use a diffrent shell than busybox, change the command
//and the char *shell = "/bin/yourshell"
execl(shell, "busybox", "sh", (char *)NULL);

printf("XSUnit: ERR: Something stopped %s\n", shell);
while(1){ sleep(10); }
}
if(shellprocess > 0){
printf("XSUnit: PROCEED: Correct\n");
while(1){ sleep(10); }
}
}

, To compile this with GCC, use the -static flag
gcc -static init.c -o init

Make a root filesystem directory.
mkdir -p ~/lfz/rootfs

And put it in your work folder
cp init ~/lfz/rootfs/


Next page...