From 1d7266d3b59be361763dab61f680103bbb70f3e9 Mon Sep 17 00:00:00 2001
From: Jeremie Koenig
Date: Mon, 19 Jul 2010 00:44:56 +0200
Subject: mark Linux-specific configuration options
PLATFORM_LINUX is used as a dependency for applets or features
which require Linux-specific interfaces.
Signed-off-by: Jeremie Koenig
Signed-off-by: Denys Vlasenko
---
init/Config.src | 2 ++
init/bootchartd.c | 1 +
2 files changed, 3 insertions(+)
(limited to 'init')
diff --git a/init/Config.src b/init/Config.src
index 590e29890..a5e76be6a 100644
--- a/init/Config.src
+++ b/init/Config.src
@@ -10,6 +10,7 @@ INSERT
config INIT
bool "init"
default y
+ depends on PLATFORM_LINUX
select FEATURE_SYSLOG
help
init is the first program run when the system boots.
@@ -92,6 +93,7 @@ config FEATURE_INITRD
config HALT
bool "poweroff, halt, and reboot"
default y
+ depends on PLATFORM_LINUX
help
Stop all processes and either halt, reboot, or power off the system.
diff --git a/init/bootchartd.c b/init/bootchartd.c
index dae2fe6e9..a1c01641b 100644
--- a/init/bootchartd.c
+++ b/init/bootchartd.c
@@ -6,6 +6,7 @@
//config:config BOOTCHARTD
//config: bool "bootchartd"
//config: default y
+//config: depends on PLATFORM_LINUX
//config: help
//config: bootchartd is commonly used to profile the boot process
//config: for the purpose of speeding it up. In this case, it is started
--
cgit v1.2.3-55-g6feb
From f812eace1863feeac64dc8af27f4ab0f98119618 Mon Sep 17 00:00:00 2001
From: Jeremie Koenig
Date: Thu, 27 May 2010 15:37:32 +0200
Subject: init,loginutils: termios portability fixes
Signed-off-by: Jeremie Koenig
Signed-off-by: Denys Vlasenko
---
init/init.c | 17 ++++++++++++++++-
loginutils/Config.src | 2 --
loginutils/getty.c | 27 ++++++++++++++-------------
loginutils/login.c | 2 +-
4 files changed, 31 insertions(+), 17 deletions(-)
(limited to 'init')
diff --git a/init/init.c b/init/init.c
index 2eb8f1a54..1388c75cc 100644
--- a/init/init.c
+++ b/init/init.c
@@ -14,11 +14,19 @@
#include
#include
#include
+#ifdef __linux__
#include
+#endif
#if ENABLE_FEATURE_UTMP
# include /* DEAD_PROCESS */
#endif
+/* Used only for sanitizing purposes in set_sane_term() below. On systems where
+ * the baud rate is stored in a separate field, we can safely disable them. */
+#ifndef CBAUD
+# define CBAUD 0
+# define CBAUDEX 0
+#endif
/* Was a CONFIG_xxx option. A lot of people were building
* not fully functional init by switching it on! */
@@ -166,7 +174,9 @@ static void message(int where, const char *fmt, ...)
static void console_init(void)
{
+#ifdef VT_OPENQRY
int vtno;
+#endif
char *s;
s = getenv("CONSOLE");
@@ -190,6 +200,7 @@ static void console_init(void)
}
s = getenv("TERM");
+#ifdef VT_OPENQRY
if (ioctl(STDIN_FILENO, VT_OPENQRY, &vtno) != 0) {
/* Not a linux terminal, probably serial console.
* Force the TERM setting to vt102
@@ -198,7 +209,9 @@ static void console_init(void)
putenv((char*)"TERM=vt102");
if (!ENABLE_FEATURE_INIT_SYSLOG)
log_console = NULL;
- } else if (!s)
+ } else
+#endif
+ if (!s)
putenv((char*)"TERM=linux");
}
@@ -220,8 +233,10 @@ static void set_sane_term(void)
tty.c_cc[VSTOP] = 19; /* C-s */
tty.c_cc[VSUSP] = 26; /* C-z */
+#ifdef __linux__
/* use line discipline 0 */
tty.c_line = 0;
+#endif
/* Make it be sane */
tty.c_cflag &= CBAUD | CBAUDEX | CSIZE | CSTOPB | PARENB | PARODD;
diff --git a/loginutils/Config.src b/loginutils/Config.src
index 425d041b9..6ec289355 100644
--- a/loginutils/Config.src
+++ b/loginutils/Config.src
@@ -179,7 +179,6 @@ config DELUSER
config GETTY
bool "getty"
default y
- depends on PLATFORM_LINUX
select FEATURE_SYSLOG
help
getty lets you log in on a tty, it is normally invoked by init.
@@ -187,7 +186,6 @@ config GETTY
config LOGIN
bool "login"
default y
- depends on PLATFORM_LINUX
select FEATURE_SUID
select FEATURE_SYSLOG
help
diff --git a/loginutils/getty.c b/loginutils/getty.c
index a5e8e906a..7f04d33fb 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -282,10 +282,8 @@ static void termios_init(struct termios *tp, int speed, struct options *op)
* reads will be done in raw mode anyway. Errors will be dealt with
* later on.
*/
-#ifdef __linux__
/* flush input and output queues, important for modems! */
- ioctl(0, TCFLSH, TCIOFLUSH); /* tcflush(0, TCIOFLUSH)? - same */
-#endif
+ tcflush(0, TCIOFLUSH);
ispeed = ospeed = speed;
if (speed == B0) {
/* Speed was specified as "0" on command line.
@@ -299,10 +297,13 @@ static void termios_init(struct termios *tp, int speed, struct options *op)
cfsetispeed(tp, ispeed);
cfsetospeed(tp, ospeed);
- tp->c_iflag = tp->c_lflag = tp->c_line = 0;
+ tp->c_iflag = tp->c_lflag = 0;
tp->c_oflag = OPOST | ONLCR;
tp->c_cc[VMIN] = 1;
tp->c_cc[VTIME] = 0;
+#ifdef __linux__
+ tp->c_line = 0;
+#endif
/* Optionally enable hardware flow control */
#ifdef CRTSCTS
@@ -360,10 +361,8 @@ static void auto_baud(char *buf, unsigned size_buf, struct termios *tp)
for (bp = buf; bp < buf + nread; bp++) {
if (isdigit(*bp)) {
speed = bcode(bp);
- if (speed > 0) {
- tp->c_cflag &= ~CBAUD;
- tp->c_cflag |= speed;
- }
+ if (speed > 0)
+ cfsetspeed(tp, speed);
break;
}
}
@@ -417,7 +416,7 @@ static char *get_logname(char *logname, unsigned size_logname,
/* Flush pending input (esp. after parsing or switching the baud rate). */
sleep(1);
- ioctl(0, TCFLSH, TCIFLUSH); /* tcflush(0, TCIOFLUSH)? - same */
+ tcflush(0, TCIOFLUSH);
/* Prompt for and read a login name. */
logname[0] = '\0';
@@ -526,7 +525,9 @@ static void termios_final(struct options *op, struct termios *tp, struct chardat
tp->c_cc[VQUIT] = DEF_QUIT; /* default quit */
tp->c_cc[VEOF] = DEF_EOF; /* default EOF character */
tp->c_cc[VEOL] = DEF_EOL;
+#ifdef VSWTC
tp->c_cc[VSWTC] = DEF_SWITCH; /* default switch character */
+#endif
/* Account for special characters seen in input. */
if (cp->eol == CR) {
@@ -572,8 +573,8 @@ static void termios_final(struct options *op, struct termios *tp, struct chardat
#endif
/* Finally, make the new settings effective */
- /* It's tcsetattr_stdin_TCSANOW() + error check */
- ioctl_or_perror_and_die(0, TCSETS, tp, "%s: TCSETS", op->tty);
+ if (tcsetattr_stdin_TCSANOW(tp) < 0)
+ bb_perror_msg_and_die("%s: tcsetattr", op->tty);
}
int getty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -650,8 +651,8 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
* by patching the SunOS kernel variable "zsadtrlow" to a larger value;
* 5 seconds seems to be a good value.
*/
- /* tcgetattr() + error check */
- ioctl_or_perror_and_die(0, TCGETS, &termios, "%s: TCGETS", options.tty);
+ if (tcgetattr(0, &termios) < 0)
+ bb_perror_msg_and_die("%s: tcgetattr", options.tty);
pid = getpid();
#ifdef __linux__
diff --git a/loginutils/login.c b/loginutils/login.c
index 88ed0af78..10012486f 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -264,7 +264,7 @@ int login_main(int argc UNUSED_PARAM, char **argv)
while (1) {
/* flush away any type-ahead (as getty does) */
- ioctl(0, TCFLSH, TCIFLUSH);
+ tcflush(0, TCIFLUSH);
if (!username[0])
get_username_or_die(username, sizeof(username));
--
cgit v1.2.3-55-g6feb
From 714674e4da3d92c5dd14e00ab30794a895b91eb4 Mon Sep 17 00:00:00 2001
From: Jeremie Koenig
Date: Thu, 27 May 2010 15:38:44 +0200
Subject: init,halt: portability improvements
* make init and halt use the same RB_* constants for reboot()
* conditionalize the Linux-specific code
Inspired by init.init.diff from the Debian kFreeBSD patches at:
http://svn.debian.org/viewsvn/d-i/people/slackydeb/kfreebsd/busybox/1.14/debian
Signed-off-by: Jeremie Koenig
Signed-off-by: Denys Vlasenko
---
init/Config.src | 2 --
init/halt.c | 14 +-------------
init/init.c | 16 ++++++++--------
init/reboot.h | 31 +++++++++++++++++++++++++++++++
4 files changed, 40 insertions(+), 23 deletions(-)
create mode 100644 init/reboot.h
(limited to 'init')
diff --git a/init/Config.src b/init/Config.src
index a5e76be6a..590e29890 100644
--- a/init/Config.src
+++ b/init/Config.src
@@ -10,7 +10,6 @@ INSERT
config INIT
bool "init"
default y
- depends on PLATFORM_LINUX
select FEATURE_SYSLOG
help
init is the first program run when the system boots.
@@ -93,7 +92,6 @@ config FEATURE_INITRD
config HALT
bool "poweroff, halt, and reboot"
default y
- depends on PLATFORM_LINUX
help
Stop all processes and either halt, reboot, or power off the system.
diff --git a/init/halt.c b/init/halt.c
index f1bb2c4a8..abd801fda 100644
--- a/init/halt.c
+++ b/init/halt.c
@@ -8,7 +8,7 @@
*/
#include "libbb.h"
-#include
+#include "reboot.h"
#if ENABLE_FEATURE_WTMP
#include
@@ -36,18 +36,6 @@ static void write_wtmp(void)
#define write_wtmp() ((void)0)
#endif
-#ifndef RB_HALT_SYSTEM
-#define RB_HALT_SYSTEM RB_HALT
-#endif
-
-#ifndef RB_POWERDOWN
-/* Stop system and switch power off if possible. */
-# define RB_POWERDOWN 0x4321fedc
-#endif
-#ifndef RB_POWER_OFF
-# define RB_POWER_OFF RB_POWERDOWN
-#endif
-
int halt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int halt_main(int argc UNUSED_PARAM, char **argv)
diff --git a/init/init.c b/init/init.c
index 1388c75cc..d8bf15894 100644
--- a/init/init.c
+++ b/init/init.c
@@ -12,7 +12,6 @@
#include "libbb.h"
#include
#include
-#include
#include
#ifdef __linux__
#include
@@ -20,6 +19,7 @@
#if ENABLE_FEATURE_UTMP
# include /* DEAD_PROCESS */
#endif
+#include "reboot.h" /* reboot() constants */
/* Used only for sanitizing purposes in set_sane_term() below. On systems where
* the baud rate is stored in a separate field, we can safely disable them. */
@@ -97,13 +97,6 @@ static const char *log_console = VC_5;
enum {
L_LOG = 0x1,
L_CONSOLE = 0x2,
-#ifndef RB_HALT_SYSTEM
- RB_HALT_SYSTEM = 0xcdef0123, /* FIXME: this overflows enum */
- RB_ENABLE_CAD = 0x89abcdef,
- RB_DISABLE_CAD = 0,
- RB_POWER_OFF = 0x4321fedc,
- RB_AUTOBOOT = 0x01234567,
-#endif
};
/* Print a message to the specified device.
@@ -724,10 +717,12 @@ static void restart_handler(int sig UNUSED_PARAM)
run_shutdown_and_kill_processes();
+#ifdef RB_ENABLE_CAD
/* Allow Ctrl-Alt-Del to reboot the system.
* This is how kernel sets it up for init, we follow suit.
*/
reboot(RB_ENABLE_CAD); /* misnomer */
+#endif
if (open_stdio_to_tty(a->terminal)) {
dbg_message(L_CONSOLE, "Trying to re-exec %s", a->command);
@@ -870,9 +865,11 @@ int init_main(int argc UNUSED_PARAM, char **argv)
) {
bb_show_usage();
}
+#ifdef RB_DISABLE_CAD
/* Turn off rebooting via CTL-ALT-DEL - we get a
* SIGINT on CAD so we can shut things down gracefully... */
reboot(RB_DISABLE_CAD); /* misnomer */
+#endif
}
/* Figure out where the default console should be */
@@ -895,6 +892,8 @@ int init_main(int argc UNUSED_PARAM, char **argv)
message(L_CONSOLE | L_LOG, "init started: %s", bb_banner);
#endif
+/* struct sysinfo is linux-specific */
+#ifdef __linux__
/* Make sure there is enough memory to do something useful. */
if (ENABLE_SWAPONOFF) {
struct sysinfo info;
@@ -910,6 +909,7 @@ int init_main(int argc UNUSED_PARAM, char **argv)
run_actions(SYSINIT); /* wait and removing */
}
}
+#endif
/* Check if we are supposed to be in single user mode */
if (argv[1]
diff --git a/init/reboot.h b/init/reboot.h
new file mode 100644
index 000000000..ff045fdd1
--- /dev/null
+++ b/init/reboot.h
@@ -0,0 +1,31 @@
+/*
+ * Definitions related to the reboot() system call,
+ * shared between init.c and halt.c.
+ */
+
+#include
+
+#ifndef RB_HALT_SYSTEM
+# if defined(__linux__)
+# define RB_HALT_SYSTEM 0xcdef0123
+# define RB_ENABLE_CAD 0x89abcdef
+# define RB_DISABLE_CAD 0
+# define RB_POWER_OFF 0x4321fedc
+# define RB_AUTOBOOT 0x01234567
+# elif defined(RB_HALT)
+# define RB_HALT_SYSTEM RB_HALT
+# endif
+#endif
+
+/* Stop system and switch power off if possible. */
+#ifndef RB_POWER_OFF
+# if defined(RB_POWERDOWN)
+# define RB_POWER_OFF RB_POWERDOWN
+# elif defined(__linux__)
+# define RB_POWER_OFF 0x4321fedc
+# else
+# warning "poweroff unsupported, using halt as fallback"
+# define RB_POWER_OFF RB_HALT_SYSTEM
+# endif
+#endif
+
--
cgit v1.2.3-55-g6feb
From 1c05303fdc302725093294eb0305adc003d52bcb Mon Sep 17 00:00:00 2001
From: Jeremie Koenig
Date: Thu, 27 May 2010 15:46:07 +0200
Subject: init: make the initial $TERM value configurable
Signed-off-by: Jeremie Koenig
Signed-off-by: Denys Vlasenko
---
init/Config.src | 12 ++++++++++++
init/init.c | 2 +-
2 files changed, 13 insertions(+), 1 deletion(-)
(limited to 'init')
diff --git a/init/Config.src b/init/Config.src
index 590e29890..2cac3573e 100644
--- a/init/Config.src
+++ b/init/Config.src
@@ -89,6 +89,18 @@ config FEATURE_INITRD
This does not apply to initramfs, which runs /init as PID 1 and
requires no special support.
+config INIT_TERMINAL_TYPE
+ string "Initial terminal type"
+ default "linux"
+ depends on INIT
+ help
+ This is the initial value set by init for the TERM environment
+ variable. This variable is used by programs which make use of
+ extended terminal capabilities.
+
+ Note that on Linux, init attempts to detect serial terminal and
+ sets TERM to "vt102" if one is found.
+
config HALT
bool "poweroff, halt, and reboot"
default y
diff --git a/init/init.c b/init/init.c
index d8bf15894..fa1af6d7c 100644
--- a/init/init.c
+++ b/init/init.c
@@ -205,7 +205,7 @@ static void console_init(void)
} else
#endif
if (!s)
- putenv((char*)"TERM=linux");
+ putenv((char*)"TERM=" CONFIG_INIT_TERMINAL_TYPE);
}
/* Set terminal settings to reasonable defaults.
--
cgit v1.2.3-55-g6feb
From ba2dcccd799963ac74ee92300df494947820608b Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Mon, 26 Jul 2010 01:49:12 +0200
Subject: *: trailing empty lines removed
Signed-off-by: Denys Vlasenko
---
archival/libunarchive/unxz/README | 1 -
debianutils/Config.src | 1 -
docs/busybox_footer.pod | 1 -
docs/cgi/cl.html | 2 +-
docs/cgi/env.html | 2 +-
docs/cgi/in.html | 2 +-
docs/cgi/interface.html | 2 +-
docs/cgi/out.html | 2 +-
docs/contributing.txt | 2 --
docs/posix_conformance.txt | 1 -
e2fsprogs/old_e2fsprogs/e2fsck.h | 2 --
e2fsprogs/old_e2fsprogs/e2p/ostype.c | 2 --
examples/bootfloppy/display.txt | 1 -
examples/bootfloppy/etc/fstab | 1 -
examples/bootfloppy/etc/inittab | 1 -
examples/bootfloppy/etc/profile | 1 -
examples/bootfloppy/mkrootfs.sh | 1 -
examples/inittab | 1 -
init/reboot.h | 1 -
libbb/README | 1 -
libbb/selinux_common.c | 1 -
networking/libiproute/ll_proto.c | 1 -
scripts/Makefile.host | 1 -
scripts/Makefile.lib | 2 --
scripts/basic/docproc.c | 1 -
scripts/find_stray_empty_lines | 10 ++++++++++
scripts/kconfig/check.sh | 1 -
scripts/kconfig/lex.zconf.c_shipped | 1 -
scripts/kconfig/menu.c | 1 -
scripts/kconfig/util.c | 1 -
scripts/kconfig/zconf.hash.c_shipped | 1 -
scripts/kconfig/zconf.tab.c_shipped | 2 --
scripts/showasm | 1 -
selinux/Config.src | 1 -
shell/hush_test/hush-misc/break1.tests | 1 -
sysklogd/Config.src | 1 -
testsuite/basename/basename-works | 1 -
testsuite/dirname/dirname-works | 1 -
testsuite/expr/expr-works | 1 -
testsuite/ln/ln-preserves-soft-links | 1 -
testsuite/readlink.tests | 1 -
testsuite/uptime/uptime-works | 1 -
42 files changed, 15 insertions(+), 46 deletions(-)
(limited to 'init')
diff --git a/archival/libunarchive/unxz/README b/archival/libunarchive/unxz/README
index f79b0a404..c5972f6b8 100644
--- a/archival/libunarchive/unxz/README
+++ b/archival/libunarchive/unxz/README
@@ -133,4 +133,3 @@ Specifying the calling convention
For example, on Windows, you may make all functions use the stdcall
calling convention by defining XZ_FUNC=__stdcall when building and
using the functions from XZ Embedded.
-
diff --git a/debianutils/Config.src b/debianutils/Config.src
index 838d8f00c..cbc09b5ce 100644
--- a/debianutils/Config.src
+++ b/debianutils/Config.src
@@ -83,4 +83,3 @@ config WHICH
print out their pathnames.
endmenu
-
diff --git a/docs/busybox_footer.pod b/docs/busybox_footer.pod
index 5ed937991..47eabaeeb 100644
--- a/docs/busybox_footer.pod
+++ b/docs/busybox_footer.pod
@@ -253,4 +253,3 @@ Tito Ragusa
devfsd and size optimizations in strings, openvt and deallocvt.
=cut
-
diff --git a/docs/cgi/cl.html b/docs/cgi/cl.html
index 5779d623e..4f8faae9f 100644
--- a/docs/cgi/cl.html
+++ b/docs/cgi/cl.html
@@ -43,4 +43,4 @@ CGI - Common Gateway Interface
cgi@ncsa.uiuc.edu
-