summaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-07-08 18:55:24 +0000
committerEric Andersen <andersen@codepoet.org>2000-07-08 18:55:24 +0000
commitbd22ed806782eec76929bcd2ec556717e79d24c7 (patch)
treee225367aaef198eacec8ed0b530d36a9d888d92f /init
parent877a71bbf0b8386add4631c08f7101259ad2dc07 (diff)
downloadbusybox-w32-bd22ed806782eec76929bcd2ec556717e79d24c7.tar.gz
busybox-w32-bd22ed806782eec76929bcd2ec556717e79d24c7.tar.bz2
busybox-w32-bd22ed806782eec76929bcd2ec556717e79d24c7.zip
Update files to reduce dependance on kernel version...
-Erik
Diffstat (limited to 'init')
-rw-r--r--init/init.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/init/init.c b/init/init.c
index 35f2255b5..b368c00ed 100644
--- a/init/init.c
+++ b/init/init.c
@@ -37,12 +37,6 @@
37#include <string.h> 37#include <string.h>
38#include <termios.h> 38#include <termios.h>
39#include <unistd.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 <linux/vt.h> /* for vt_stat */
46#include <sys/fcntl.h> 40#include <sys/fcntl.h>
47#include <sys/ioctl.h> 41#include <sys/ioctl.h>
48#include <sys/mount.h> 42#include <sys/mount.h>
@@ -52,6 +46,33 @@
52# include <sys/syslog.h> 46# include <sys/syslog.h>
53#endif 47#endif
54 48
49/* From <linux/vt.h> */
50struct vt_stat {
51 unsigned short v_active; /* active vt */
52 unsigned short v_signal; /* signal to send */
53 unsigned short v_state; /* vt bitmask */
54};
55#define VT_GETSTATE 0x5603 /* get global vt state info */
56
57/* From <linux/serial.h> */
58struct serial_struct {
59 int type;
60 int line;
61 int port;
62 int irq;
63 int flags;
64 int xmit_fifo_size;
65 int custom_divisor;
66 int baud_base;
67 unsigned short close_delay;
68 char reserved_char[2];
69 int hub6;
70 unsigned short closing_wait; /* time to wait before closing */
71 unsigned short closing_wait2; /* no longer used... */
72 int reserved[4];
73};
74
75
55 76
56#ifndef RB_HALT_SYSTEM 77#ifndef RB_HALT_SYSTEM
57#define RB_HALT_SYSTEM 0xcdef0123 78#define RB_HALT_SYSTEM 0xcdef0123
@@ -84,13 +105,12 @@
84#include <sys/time.h> 105#include <sys/time.h>
85#endif 106#endif
86 107
87#ifndef KERNEL_VERSION
88#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 108#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
89#endif
90 109
91#if defined(__GLIBC__) 110#if defined(__GLIBC__)
92#include <sys/kdaemon.h> 111#include <sys/kdaemon.h>
93#else 112#else
113#include <linux/unistd.h> /* for _syscall() macro */
94static _syscall2(int, bdflush, int, func, int, data); 114static _syscall2(int, bdflush, int, func, int, data);
95#endif /* __GLIBC__ */ 115#endif /* __GLIBC__ */
96 116
@@ -568,7 +588,7 @@ static void shutdown_system(void)
568 run_lastAction(); 588 run_lastAction();
569 589
570 sync(); 590 sync();
571 if (kernelVersion > 0 && kernelVersion <= 2 * 65536 + 2 * 256 + 11) { 591 if (kernelVersion > 0 && kernelVersion <= KERNEL_VERSION(2,2,11)) {
572 /* bdflush, kupdate not needed for kernels >2.2.11 */ 592 /* bdflush, kupdate not needed for kernels >2.2.11 */
573 bdflush(1, 0); 593 bdflush(1, 0);
574 sync(); 594 sync();
@@ -587,11 +607,9 @@ static void halt_signal(int sig)
587 /* allow time for last message to reach serial console */ 607 /* allow time for last message to reach serial console */
588 sleep(2); 608 sleep(2);
589 609
590#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) 610 if (sig == SIGUSR2 && kernelVersion >= KERNEL_VERSION(2,2,0))
591 if (sig == SIGUSR2)
592 init_reboot(RB_POWER_OFF); 611 init_reboot(RB_POWER_OFF);
593 else 612 else
594#endif
595 init_reboot(RB_HALT_SYSTEM); 613 init_reboot(RB_HALT_SYSTEM);
596 exit(0); 614 exit(0);
597} 615}