First complete buildable version (may have bugs)

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
Claudio Matsuoka committed 2007-12-30 12:09:39 -02:00
1 parent 5aceab8526
commit a1b91e7191
2 files changed
+17 -12

No files matched your search

+3 -1
View File
@@ -1,5 +1,5 @@
CC = gcc CC = gcc
CFLAGS = -Os CFLAGS = -Os -Wall -mno-push-args -fomit-frame-pointer
LD = gcc LD = gcc
LDFLAGS = LDFLAGS =
LIBS = LIBS =
@@ -16,3 +16,5 @@ finit: finit.o
clean: clean:
rm -f *.o core *~ rm -f *.o core *~
finit.o: finit.c Makefile
+14 -11
View File
@@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@@ -9,9 +10,10 @@
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <unistd.h>
#include <sys/reboot.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/reboot.h>
/* From sysvinit */ /* From sysvinit */
@@ -36,7 +38,7 @@ void dummy()
} }
int main(int argv, char **argc) int main()
{ {
int i; int i;
FILE *f; FILE *f;
@@ -49,6 +51,7 @@ int main(int argv, char **argc)
char hline[1024]; char hline[1024];
char *x; char *x;
sigset_t nmask, nmask1, nmask2; sigset_t nmask, nmask1, nmask2;
struct stat buf;
chdir("/"); chdir("/");
umask(022); umask(022);
@@ -76,7 +79,7 @@ int main(int argv, char **argc)
sigaddset(&nmask, SIGCHLD); sigaddset(&nmask, SIGCHLD);
sigprocmask(SIG_BLOCK, &nmask, NULL); sigprocmask(SIG_BLOCK, &nmask, NULL);
reboot(LINUX_REBOOT_CMD_CAD_OFF); reboot(RB_DISABLE_CAD);
/* /*
* Parse kernel parameters * Parse kernel parameters
@@ -141,9 +144,11 @@ int main(int argv, char **argc)
fgets(hline, 1023, f); fgets(hline, 1023, f);
if ((x = strchr(hline, 0x0a)) != NULL) if ((x = strchr(hline, 0x0a)) != NULL)
*x = 0; *x = 0;
}
/* ... */ sethostname(hline, strlen(hline));
fclose(f);
}
system("/sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0 up > /dev/null"); system("/sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0 up > /dev/null");
@@ -192,7 +197,7 @@ int main(int argv, char **argc)
touch("/tmp/nologin"); touch("/tmp/nologin");
if (stat("/tmp/shutdown", NULL) < 0) if (stat("/tmp/shutdown", &buf) < 0)
system("su -c startx -l user &> /dev/null"); system("su -c startx -l user &> /dev/null");
exit(0); exit(0);
@@ -203,10 +208,8 @@ int main(int argv, char **argc)
system("/usr/sbin/services.sh &> /dev/null &"); system("/usr/sbin/services.sh &> /dev/null &");
while (1) { while (1) {
/* sigemptyset(&nmask);
sigemptyset(...); pselect(0, NULL, NULL, NULL, NULL, &nmask);
pselect(0, NULL, NULL, NULL, ...);
*/
} }
} }
@@ -238,7 +241,7 @@ void shutdown(char *t)
ret = system("/sbin/unionctl.static / --remove / > /dev/null 2>&1"); ret = system("/sbin/unionctl.static / --remove / > /dev/null 2>&1");
if (ret == 2 && ret == 10) if (ret == 2 && ret == 10)
reboot(LINUX_REBOOT_CMD_RESTART); reboot(RB_AUTOBOOT);
if ((fd = open("/proc/acpi/sleep", O_WRONLY)) >= 0) { if ((fd = open("/proc/acpi/sleep", O_WRONLY)) >= 0) {
write(fd, "5", 1); write(fd, "5", 1);