aboutsummaryrefslogtreecommitdiff
path: root/init/init.c
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-04-28 00:18:56 +0000
committerErik Andersen <andersen@codepoet.org>2000-04-28 00:18:56 +0000
commit4f3f757d56fbf420ea5030dcf7ea971b3da3ab47 (patch)
treed986e9bb9f03bf1f83465c274c35c0d58ed544e4 /init/init.c
parent227a59b05d6df9b4be5990915646249d6f548822 (diff)
downloadbusybox-w32-4f3f757d56fbf420ea5030dcf7ea971b3da3ab47.tar.gz
busybox-w32-4f3f757d56fbf420ea5030dcf7ea971b3da3ab47.tar.bz2
busybox-w32-4f3f757d56fbf420ea5030dcf7ea971b3da3ab47.zip
Latest and greatest. Some effort at libc5 (aiming towards newlib)
compatability. -Erik
Diffstat (limited to 'init/init.c')
-rw-r--r--init/init.c61
1 files changed, 43 insertions, 18 deletions
diff --git a/init/init.c b/init/init.c
index af10f98f0..29d8f48f9 100644
--- a/init/init.c
+++ b/init/init.c
@@ -28,31 +28,50 @@
28*/ 28*/
29 29
30#include "internal.h" 30#include "internal.h"
31#include <asm/types.h> 31#include <stdio.h>
32#include <stdlib.h>
32#include <errno.h> 33#include <errno.h>
33#include <linux/serial.h> /* for serial_struct */
34#include <linux/version.h>
35#include <paths.h> 34#include <paths.h>
36#include <signal.h> 35#include <signal.h>
37#include <stdarg.h> 36#include <stdarg.h>
38#include <stdio.h>
39#include <stdlib.h>
40#include <string.h> 37#include <string.h>
38#include <termios.h>
39#include <unistd.h>
40#include <asm/types.h>
41#include <linux/serial.h> /* for serial_struct */
42#include <linux/version.h>
43#include <linux/reboot.h>
44#include <linux/unistd.h>
45#include <sys/sysinfo.h> /* For check_free_memory() */
41#include <sys/fcntl.h> 46#include <sys/fcntl.h>
42#include <sys/ioctl.h> 47#include <sys/ioctl.h>
43#include <sys/kdaemon.h>
44#include <sys/mount.h> 48#include <sys/mount.h>
45#include <sys/reboot.h>
46#include <sys/sysinfo.h> /* For check_free_memory() */
47#ifdef BB_SYSLOGD
48# include <sys/syslog.h>
49#endif
50#include <sys/sysmacros.h> 49#include <sys/sysmacros.h>
51#include <sys/types.h> 50#include <sys/types.h>
52#include <sys/vt.h> /* for vt_stat */ 51#include <sys/vt.h> /* for vt_stat */
53#include <sys/wait.h> 52#include <sys/wait.h>
54#include <termios.h> 53#ifdef BB_SYSLOGD
55#include <unistd.h> 54# include <sys/syslog.h>
55#endif
56
57
58#ifndef RB_HALT_SYSTEM
59#define RB_HALT_SYSTEM 0xcdef0123
60#define RB_ENABLE_CAD 0x89abcdef
61#define RB_DISABLE_CAD 0
62#define RB_POWER_OFF 0x4321fedc
63#define RB_AUTOBOOT 0x01234567
64#if defined(__GLIBC__)
65#include <sys/reboot.h>
66 #define init_reboot(magic) reboot(magic)
67#else
68 #define init_reboot(magic) reboot(0xfee1dead, 672274793, magic)
69#endif
70#endif
71
72#ifndef _PATH_STDPATH
73#define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
74#endif
56 75
57 76
58#if defined BB_FEATURE_INIT_COREDUMPS 77#if defined BB_FEATURE_INIT_COREDUMPS
@@ -71,6 +90,12 @@
71#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 90#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
72#endif 91#endif
73 92
93#if defined(__GLIBC__)
94#include <sys/kdaemon.h>
95#else
96_syscall2(int, bdflush, int, func, int, data);
97#endif /* __GLIBC__ */
98
74 99
75#define VT_PRIMARY "/dev/tty1" /* Primary virtual console */ 100#define VT_PRIMARY "/dev/tty1" /* Primary virtual console */
76#define VT_SECONDARY "/dev/tty2" /* Virtual console */ 101#define VT_SECONDARY "/dev/tty2" /* Virtual console */
@@ -510,7 +535,7 @@ static void shutdown_system(void)
510 signal(SIGHUP, SIG_DFL); 535 signal(SIGHUP, SIG_DFL);
511 536
512 /* Allow Ctrl-Alt-Del to reboot system. */ 537 /* Allow Ctrl-Alt-Del to reboot system. */
513 reboot(RB_ENABLE_CAD); 538 init_reboot(RB_ENABLE_CAD);
514 539
515 message(CONSOLE|LOG, "\r\nThe system is going down NOW !!\r\n"); 540 message(CONSOLE|LOG, "\r\nThe system is going down NOW !!\r\n");
516 sync(); 541 sync();
@@ -550,10 +575,10 @@ static void halt_signal(int sig)
550 575
551#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) 576#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
552 if (sig == SIGUSR2) 577 if (sig == SIGUSR2)
553 reboot(RB_POWER_OFF); 578 init_reboot(RB_POWER_OFF);
554 else 579 else
555#endif 580#endif
556 reboot(RB_HALT_SYSTEM); 581 init_reboot(RB_HALT_SYSTEM);
557 exit(0); 582 exit(0);
558} 583}
559 584
@@ -566,7 +591,7 @@ static void reboot_signal(int sig)
566 /* allow time for last message to reach serial console */ 591 /* allow time for last message to reach serial console */
567 sleep(2); 592 sleep(2);
568 593
569 reboot(RB_AUTOBOOT); 594 init_reboot(RB_AUTOBOOT);
570 exit(0); 595 exit(0);
571} 596}
572 597
@@ -852,7 +877,7 @@ extern int init_main(int argc, char **argv)
852 877
853 /* Turn off rebooting via CTL-ALT-DEL -- we get a 878 /* Turn off rebooting via CTL-ALT-DEL -- we get a
854 * SIGINT on CAD so we can shut things down gracefully... */ 879 * SIGINT on CAD so we can shut things down gracefully... */
855 reboot(RB_DISABLE_CAD); 880 init_reboot(RB_DISABLE_CAD);
856#endif 881#endif
857 882
858 /* Figure out what kernel this is running */ 883 /* Figure out what kernel this is running */