From 5d26df6497505e8ed486bf3e3ba65d0d6f0daa15 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Fri, 16 Jul 2010 15:31:38 +0200
Subject: tweak defconfig
Signed-off-by: Denys Vlasenko
---
archival/Config.src | 2 +-
libbb/Config.src | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/archival/Config.src b/archival/Config.src
index f64b3347b..9a84fd6c6 100644
--- a/archival/Config.src
+++ b/archival/Config.src
@@ -39,7 +39,7 @@ config FEATURE_SEAMLESS_Z
config AR
bool "ar"
- default y
+ default n # needs to be improved to be able to replace binutils ar
help
ar is an archival utility program used to create, modify, and
extract contents from archives. An archive is a single file holding
diff --git a/libbb/Config.src b/libbb/Config.src
index 80b1e0d21..09bf89246 100644
--- a/libbb/Config.src
+++ b/libbb/Config.src
@@ -98,7 +98,7 @@ config FEATURE_USERNAME_COMPLETION
config FEATURE_EDITING_FANCY_PROMPT
bool "Fancy shell prompts"
- default n
+ default y
depends on FEATURE_EDITING
help
Setting this option allows for prompts to use things like \w and
--
cgit v1.2.3-55-g6feb
From 51ca7761a3579f3c3f7e771b39019e6e248a5171 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Fri, 16 Jul 2010 17:16:40 +0200
Subject: cttyhack: move build system bits into cttyhack.c, no code changes
Signed-off-by: Denys Vlasenko
---
include/applets.src.h | 1 -
include/usage.src.h | 11 -----------
shell/Config.src | 36 -----------------------------------
shell/Kbuild.src | 1 -
shell/ash.c | 1 +
shell/cttyhack.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 53 insertions(+), 49 deletions(-)
diff --git a/include/applets.src.h b/include/applets.src.h
index 6ca0c3230..195598fee 100644
--- a/include/applets.src.h
+++ b/include/applets.src.h
@@ -104,7 +104,6 @@ IF_CPIO(APPLET(cpio, _BB_DIR_BIN, _BB_SUID_DROP))
IF_CROND(APPLET(crond, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
IF_CRONTAB(APPLET(crontab, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE))
IF_CRYPTPW(APPLET(cryptpw, _BB_DIR_USR_BIN, _BB_SUID_DROP))
-IF_CTTYHACK(APPLET(cttyhack, _BB_DIR_BIN, _BB_SUID_DROP))
IF_CUT(APPLET_NOEXEC(cut, cut, _BB_DIR_USR_BIN, _BB_SUID_DROP, cut))
IF_DATE(APPLET(date, _BB_DIR_BIN, _BB_SUID_DROP))
IF_DC(APPLET(dc, _BB_DIR_USR_BIN, _BB_SUID_DROP))
diff --git a/include/usage.src.h b/include/usage.src.h
index 46d64c135..9b326eebb 100644
--- a/include/usage.src.h
+++ b/include/usage.src.h
@@ -678,17 +678,6 @@ INSERT
"\n -S SALT" \
) \
-#define cttyhack_trivial_usage \
- "PROG ARGS"
-#define cttyhack_full_usage "\n\n" \
- "Give PROG a controlling tty if possible." \
- "\nExample for /etc/inittab (for busybox init):" \
- "\n ::respawn:/bin/cttyhack /bin/sh" \
- "\nGiving controlling tty to shell running with PID 1:" \
- "\n $ exec cttyhack sh" \
- "\nStarting interactive shell from boot shell script:" \
- "\n setsid cttyhack sh" \
-
#define cut_trivial_usage \
"[OPTIONS] [FILE]..."
#define cut_full_usage "\n\n" \
diff --git a/shell/Config.src b/shell/Config.src
index 6389d943a..f6f0b6c94 100644
--- a/shell/Config.src
+++ b/shell/Config.src
@@ -158,40 +158,4 @@ config FEATURE_SH_NOFORK
This feature is relatively new. Use with care.
-config CTTYHACK
- bool "cttyhack"
- default y
- help
- One common problem reported on the mailing list is "can't access tty;
- job control turned off" error message which typically appears when
- one tries to use shell with stdin/stdout opened to /dev/console.
- This device is special - it cannot be a controlling tty.
-
- Proper solution is to use correct device instead of /dev/console.
-
- cttyhack provides "quick and dirty" solution to this problem.
- It analyzes stdin with various ioctls, trying to determine whether
- it is a /dev/ttyN or /dev/ttySN (virtual terminal or serial line).
- If it detects one, it closes stdin/out/err and reopens that device.
- Then it executes given program. Opening the device will make
- that device a controlling tty. This may require cttyhack
- to be a session leader.
-
- Example for /etc/inittab (for busybox init):
-
- ::respawn:/bin/cttyhack /bin/sh
-
- Starting an interactive shell from boot shell script:
-
- setsid cttyhack sh
-
- Giving controlling tty to shell running with PID 1:
-
- # exec cttyhack sh
-
- Without cttyhack, you need to know exact tty name,
- and do something like this:
-
- # exec setsid sh -c 'exec sh /dev/tty1 2>&1'
-
endmenu
diff --git a/shell/Kbuild.src b/shell/Kbuild.src
index bce99240f..a669bdfb0 100644
--- a/shell/Kbuild.src
+++ b/shell/Kbuild.src
@@ -8,5 +8,4 @@ lib-y:=
INSERT
-lib-$(CONFIG_CTTYHACK) += cttyhack.o
lib-$(CONFIG_SH_MATH_SUPPORT) += math.o
diff --git a/shell/ash.c b/shell/ash.c
index 9b33e78ec..fd119fa51 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -179,6 +179,7 @@
//config: "PS#" may contain volatile content, such as backquote commands.
//config: This option recreates the prompt string from the environment
//config: variable each time it is displayed.
+//config:
//usage:#define ash_trivial_usage NOUSAGE_STR
//usage:#define ash_full_usage ""
diff --git a/shell/cttyhack.c b/shell/cttyhack.c
index 67736ad62..7af13fdfd 100644
--- a/shell/cttyhack.c
+++ b/shell/cttyhack.c
@@ -6,6 +6,58 @@
*/
#include "libbb.h"
+//applet:IF_CTTYHACK(APPLET(cttyhack, _BB_DIR_BIN, _BB_SUID_DROP))
+
+//kbuild:lib-$(CONFIG_CTTYHACK) += cttyhack.o
+
+//config:config CTTYHACK
+//config: bool "cttyhack"
+//config: default y
+//config: help
+//config: One common problem reported on the mailing list is "can't access tty;
+//config: job control turned off" error message which typically appears when
+//config: one tries to use shell with stdin/stdout opened to /dev/console.
+//config: This device is special - it cannot be a controlling tty.
+//config:
+//config: Proper solution is to use correct device instead of /dev/console.
+//config:
+//config: cttyhack provides "quick and dirty" solution to this problem.
+//config: It analyzes stdin with various ioctls, trying to determine whether
+//config: it is a /dev/ttyN or /dev/ttySN (virtual terminal or serial line).
+//config: If it detects one, it closes stdin/out/err and reopens that device.
+//config: Then it executes given program. Opening the device will make
+//config: that device a controlling tty. This may require cttyhack
+//config: to be a session leader.
+//config:
+//config: Example for /etc/inittab (for busybox init):
+//config:
+//config: ::respawn:/bin/cttyhack /bin/sh
+//config:
+//config: Starting an interactive shell from boot shell script:
+//config:
+//config: setsid cttyhack sh
+//config:
+//config: Giving controlling tty to shell running with PID 1:
+//config:
+//config: # exec cttyhack sh
+//config:
+//config: Without cttyhack, you need to know exact tty name,
+//config: and do something like this:
+//config:
+//config: # exec setsid sh -c 'exec sh /dev/tty1 2>&1'
+//config:
+
+//usage:#define cttyhack_trivial_usage
+//usage: "PROG ARGS"
+//usage:#define cttyhack_full_usage "\n\n"
+//usage: "Give PROG a controlling tty if possible."
+//usage: "\nExample for /etc/inittab (for busybox init):"
+//usage: "\n ::respawn:/bin/cttyhack /bin/sh"
+//usage: "\nGiving controlling tty to shell running with PID 1:"
+//usage: "\n $ exec cttyhack sh"
+//usage: "\nStarting interactive shell from boot shell script:"
+//usage: "\n setsid cttyhack sh"
+
/* From */
struct vt_stat {
unsigned short v_active; /* active vt */
--
cgit v1.2.3-55-g6feb
From 6adf2aad38cf2f5a056f9014955807607bcb41b2 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Fri, 16 Jul 2010 19:26:38 +0200
Subject: hush: move msh/lash config into hush.c, no code changes
Signed-off-by: Denys Vlasenko
---
shell/Config.src | 23 -----------------------
shell/hush.c | 14 ++++++++++++++
2 files changed, 14 insertions(+), 23 deletions(-)
diff --git a/shell/Config.src b/shell/Config.src
index f6f0b6c94..c9c2439e7 100644
--- a/shell/Config.src
+++ b/shell/Config.src
@@ -62,29 +62,6 @@ config FEATURE_BASH_IS_NONE
endchoice
-config LASH
- bool "lash (deprecated: aliased to hush)"
- default n
- select HUSH
- help
- lash is deprecated and will be removed, please migrate to hush.
-
-config MSH
- bool "msh (deprecated: please use hush)"
- default n
- select HUSH
- help
- msh is deprecated and will be removed, please migrate to hush.
- If there is a feature msh has but hush does not, please let us know.
-
-# The minix shell (adds just 30k) is quite complete and handles things
-# like for/do/done, case/esac and all the things you expect a Bourne
-# shell to do. It is not always pedantically correct about Bourne
-# shell grammar (try running the shell testscript "tests/sh.testcases"
-# on it and compare vs bash) but for most things it works quite well.
-# It uses only vfork, so it can be used on uClinux systems.
-
-
config SH_MATH_SUPPORT
bool "POSIX math support"
default y
diff --git a/shell/hush.c b/shell/hush.c
index 56a3f4b14..9208ec497 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -224,6 +224,20 @@
//config: This instructs hush to print commands before execution.
//config: Adds ~300 bytes.
//config:
+//config:config LASH
+//config: bool "lash (deprecated: aliased to hush)"
+//config: default n
+//config: select HUSH
+//config: help
+//config: lash is deprecated and will be removed, please migrate to hush.
+//config:
+//config:config MSH
+//config: bool "msh (deprecated: aliased to hush)"
+//config: default n
+//config: select HUSH
+//config: help
+//config: msh is deprecated and will be removed, please migrate to hush.
+//config:
//usage:#define hush_trivial_usage NOUSAGE_STR
//usage:#define hush_full_usage ""
--
cgit v1.2.3-55-g6feb
From d1516c4d628dbded9e1abefaacc1535aaecef418 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Sat, 17 Jul 2010 22:43:42 +0200
Subject: dos2unix: fix the case w/o parameters
Signed-off-by: Denys Vlasenko
---
coreutils/dos2unix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c
index 1911f5319..e06ecc4e0 100644
--- a/coreutils/dos2unix.c
+++ b/coreutils/dos2unix.c
@@ -92,7 +92,7 @@ int dos2unix_main(int argc UNUSED_PARAM, char **argv)
do {
/* might be convert(NULL) if there is no filename given */
convert(*argv, conv_type);
- } while (*++argv);
+ } while (*argv && *++argv);
return 0;
}
--
cgit v1.2.3-55-g6feb
From 4cab7f3e63ff850bc478f96d0589a01dec878a00 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Sun, 18 Jul 2010 17:41:17 +0200
Subject: depmod: generate "new-style" modules.dep with relative paths.
function old new delta
parse_module 384 379 -5
depmod_main 590 559 -31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-36) Total: -36 bytes
Signed-off-by: Denys Vlasenko
---
modutils/depmod.c | 76 ++++++++++++++++++++++++++++++++++---------------------
1 file changed, 47 insertions(+), 29 deletions(-)
diff --git a/modutils/depmod.c b/modutils/depmod.c
index c734f142b..694f9ea5a 100644
--- a/modutils/depmod.c
+++ b/modutils/depmod.c
@@ -28,16 +28,6 @@ typedef struct module_info {
struct module_info *dnext, *dprev;
} module_info;
-enum {
- ARG_a = (1<<0), /* All modules, ignore mods in argv */
- ARG_A = (1<<1), /* Only emit .ko that are newer than modules.dep file */
- ARG_b = (1<<2), /* base directory when modules are in staging area */
- ARG_e = (1<<3), /* with -F, print unresolved symbols */
- ARG_F = (1<<4), /* System.map that contains the symbols */
- ARG_n = (1<<5), /* dry-run, print to stdout only */
- ARG_r = (1<<6) /* Compat dummy. Linux Makefile uses it */
-};
-
static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARAM,
void *data, int depth UNUSED_PARAM)
{
@@ -58,7 +48,7 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA
*first = info;
info->dnext = info->dprev = info;
- info->name = xasprintf("/%s", fname);
+ info->name = xstrdup(fname + 2); /* skip "./" */
info->modname = xstrdup(filename2modname(fname, modname));
for (ptr = image; ptr < image + len - 10; ptr++) {
if (strncmp(ptr, "depends=", 8) == 0) {
@@ -134,10 +124,44 @@ static void xfreopen_write(const char *file, FILE *f)
bb_perror_msg_and_die("can't open '%s'", file);
}
+/* Usage:
+ * [-aAenv] [-C FILE or DIR] [-b BASE] [-F System.map] [VERSION] [MODFILES]...
+ * -a --all
+ * Probe all modules. Default if no MODFILES.
+ * -A --quick
+ * Check modules.dep's mtime against module files' mtimes.
+ * -b --basedir BASE
+ * Use $BASE/lib/modules/VERSION
+ * -C --config FILE or DIR
+ * Path to /etc/depmod.conf or /etc/depmod.d/
+ * -e --errsyms
+ * When combined with the -F option, this reports any symbols which
+ * which are not supplied by other modules or kernel.
+ * -F --filesyms System.map
+ * -n --dry-run
+ * Print modules.dep etc to standard output
+ * -v --verbose
+ * Print to stdout all the symbols each module depends on
+ * and the module's file name which provides that symbol.
+ * -r No-op
+ *
+ * So far we only support: [-rn] [-b BASE] [VERSION] [MODFILES]...
+ * -aAeF are accepted but ignored. -vC are not accepted.
+ */
+enum {
+ //OPT_a = (1 << 0), /* All modules, ignore mods in argv */
+ //OPT_A = (1 << 1), /* Only emit .ko that are newer than modules.dep file */
+ OPT_b = (1 << 2), /* base directory when modules are in staging area */
+ //OPT_e = (1 << 3), /* with -F, print unresolved symbols */
+ //OPT_F = (1 << 4), /* System.map that contains the symbols */
+ OPT_n = (1 << 5), /* dry-run, print to stdout only */
+ OPT_r = (1 << 6) /* Compat dummy. Linux Makefile uses it */
+};
+
int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int depmod_main(int argc UNUSED_PARAM, char **argv)
{
- module_info *modules = NULL, *m, *dep;
+ module_info *modules, *m, *dep;
const char *moddir_base = "/";
char *moddir, *version;
struct utsname uts;
@@ -152,36 +176,30 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
/* If a version is provided, then that kernel version's module directory
* is used, rather than the current kernel version (as returned by
* "uname -r"). */
- if (*argv && sscanf(*argv, "%d.%d.%d", &tmp, &tmp, &tmp) == 3) {
+ if (*argv && sscanf(*argv, "%u.%u.%u", &tmp, &tmp, &tmp) == 3) {
version = *argv++;
} else {
uname(&uts);
version = uts.release;
}
moddir = concat_path_file(&CONFIG_DEFAULT_MODULES_DIR[1], version);
+ xchdir(moddir);
+ if (ENABLE_FEATURE_CLEAN_UP)
+ free(moddir);
/* Scan modules */
+ modules = NULL;
if (*argv) {
- char *modfile;
- struct stat sb;
do {
- modfile = concat_path_file(moddir, *argv);
- xstat(modfile, &sb);
- parse_module(modfile, &sb, &modules, 0);
- free(modfile);
- } while (*(++argv));
+ parse_module(*argv, /*sb (unused):*/ NULL, &modules, 0);
+ } while (*++argv);
} else {
- recursive_action(moddir, ACTION_RECURSE,
+ recursive_action(".", ACTION_RECURSE,
parse_module, NULL, &modules, 0);
}
- /* Prepare for writing out the dep files */
- xchdir(moddir);
- if (ENABLE_FEATURE_CLEAN_UP)
- free(moddir);
-
/* Generate dependency and alias files */
- if (!(option_mask32 & ARG_n))
+ if (!(option_mask32 & OPT_n))
xfreopen_write(CONFIG_DEFAULT_DEPMOD_FILE, stdout);
for (m = modules; m != NULL; m = m->next) {
printf("%s:", m->name);
@@ -200,7 +218,7 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
}
#if ENABLE_FEATURE_MODUTILS_ALIAS
- if (!(option_mask32 & ARG_n))
+ if (!(option_mask32 & OPT_n))
xfreopen_write("modules.alias", stdout);
for (m = modules; m != NULL; m = m->next) {
const char *fname = bb_basename(m->name);
@@ -218,7 +236,7 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
}
#endif
#if ENABLE_FEATURE_MODUTILS_SYMBOLS
- if (!(option_mask32 & ARG_n))
+ if (!(option_mask32 & OPT_n))
xfreopen_write("modules.symbols", stdout);
for (m = modules; m != NULL; m = m->next) {
const char *fname = bb_basename(m->name);
--
cgit v1.2.3-55-g6feb
From b9e35dc15dbf8aa22dbc260d121ad8f7a34017de Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Sun, 18 Jul 2010 22:21:24 +0200
Subject: lineedit: cosmetics, no code changes
Signed-off-by: Denys Vlasenko
---
libbb/lineedit.c | 50 ++++++++++++++++++++++++--------------------------
1 file changed, 24 insertions(+), 26 deletions(-)
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 8a2ea7974..3905b8cc4 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -53,19 +53,15 @@
#if ENABLE_FEATURE_EDITING
-#define ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR \
+#define ENABLE_USERNAME_OR_HOMEDIR \
(ENABLE_FEATURE_USERNAME_COMPLETION || ENABLE_FEATURE_EDITING_FANCY_PROMPT)
-#define IF_FEATURE_GETUSERNAME_AND_HOMEDIR(...)
-#if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR
-#undef IF_FEATURE_GETUSERNAME_AND_HOMEDIR
-#define IF_FEATURE_GETUSERNAME_AND_HOMEDIR(...) __VA_ARGS__
+#define IF_USERNAME_OR_HOMEDIR(...)
+#if ENABLE_USERNAME_OR_HOMEDIR
+# undef IF_USERNAME_OR_HOMEDIR
+# define IF_USERNAME_OR_HOMEDIR(...) __VA_ARGS__
#endif
-#define SEQ_CLEAR_TILL_END_OF_SCREEN "\033[J"
-//#define SEQ_CLEAR_TILL_END_OF_LINE "\033[K"
-
-
#undef CHAR_T
#if ENABLE_UNICODE_SUPPORT
# define BB_NUL ((wchar_t)0)
@@ -90,14 +86,16 @@ static bool BB_ispunct(CHAR_T c) { return ((unsigned)c < 256 && ispunct(c)); }
# define BB_isalnum(c) isalnum(c)
# define BB_ispunct(c) ispunct(c)
#endif
+#if ENABLE_UNICODE_PRESERVE_BROKEN
+# define unicode_mark_raw_byte(wc) ((wc) | 0x20000000)
+# define unicode_is_raw_byte(wc) ((wc) & 0x20000000)
+#else
+# define unicode_is_raw_byte(wc) 0
+#endif
-# if ENABLE_UNICODE_PRESERVE_BROKEN
-# define unicode_mark_raw_byte(wc) ((wc) | 0x20000000)
-# define unicode_is_raw_byte(wc) ((wc) & 0x20000000)
-# else
-# define unicode_is_raw_byte(wc) 0
-# endif
+#define SEQ_CLEAR_TILL_END_OF_SCREEN "\033[J"
+//#define SEQ_CLEAR_TILL_END_OF_LINE "\033[K"
enum {
@@ -107,7 +105,7 @@ enum {
: 0x7ff0
};
-#if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR
+#if ENABLE_USERNAME_OR_HOMEDIR
static const char null_str[] ALIGN1 = "";
#endif
@@ -134,7 +132,7 @@ struct lineedit_statics {
int num_ok_lines; /* = 1; */
#endif
-#if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR
+#if ENABLE_USERNAME_OR_HOMEDIR
char *user_buf;
char *home_pwd_buf; /* = (char*)null_str; */
#endif
@@ -145,7 +143,7 @@ struct lineedit_statics {
#endif
#if ENABLE_FEATURE_EDITING_VI
-#define DELBUFSIZ 128
+# define DELBUFSIZ 128
CHAR_T *delptr;
smallint newdelflag; /* whether delbuf should be reused yet */
CHAR_T delbuf[DELBUFSIZ]; /* a place to store deleted characters */
@@ -191,7 +189,7 @@ extern struct lineedit_statics *const lineedit_ptr_to_statics;
barrier(); \
cmdedit_termw = 80; \
IF_FEATURE_EDITING_FANCY_PROMPT(num_ok_lines = 1;) \
- IF_FEATURE_GETUSERNAME_AND_HOMEDIR(home_pwd_buf = (char*)null_str;) \
+ IF_USERNAME_OR_HOMEDIR(home_pwd_buf = (char*)null_str;) \
} while (0)
static void deinit_S(void)
{
@@ -200,7 +198,7 @@ static void deinit_S(void)
* (otherwise it points to verbatim prompt (NOT malloced) */
free((char*)cmdedit_prompt);
#endif
-#if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR
+#if ENABLE_USERNAME_OR_HOMEDIR
free(user_buf);
if (home_pwd_buf != null_str)
free(home_pwd_buf);
@@ -1669,7 +1667,7 @@ static void parse_and_put_prompt(const char *prmt_ptr)
c = *prmt_ptr++;
switch (c) {
-# if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR
+# if ENABLE_USERNAME_OR_HOMEDIR
case 'u':
pbuf = user_buf ? user_buf : (char*)"";
break;
@@ -1681,7 +1679,7 @@ static void parse_and_put_prompt(const char *prmt_ptr)
case '$':
c = (geteuid() == 0 ? '#' : '$');
break;
-# if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR
+# if ENABLE_USERNAME_OR_HOMEDIR
case 'w':
/* /home/user[/something] -> ~[/something] */
pbuf = cwd_buf;
@@ -1957,7 +1955,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
/* Now initialize things */
previous_SIGWINCH_handler = signal(SIGWINCH, win_changed);
win_changed(0); /* do initial resizing */
-#if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR
+#if ENABLE_USERNAME_OR_HOMEDIR
{
struct passwd *entry;
@@ -2379,7 +2377,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
}
#endif
-/* Stop bug catching using "command_must_not_be_used" trick */
+/* End of bug-catching "command_must_not_be_used" trick */
#undef command
#if ENABLE_UNICODE_SUPPORT
@@ -2413,7 +2411,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
return len; /* can't return command_len, DEINIT_S() destroys it */
}
-#else
+#else /* !FEATURE_EDITING */
#undef read_line_input
int FAST_FUNC read_line_input(const char* prompt, char* command, int maxsize)
@@ -2424,7 +2422,7 @@ int FAST_FUNC read_line_input(const char* prompt, char* command, int maxsize)
return strlen(command);
}
-#endif /* FEATURE_EDITING */
+#endif /* !FEATURE_EDITING */
/*
--
cgit v1.2.3-55-g6feb
From 55241fa2e0a623c6f3f3f9c6e430d72bc10858bc Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Sun, 18 Jul 2010 22:53:06 +0200
Subject: lineedit: limit ASK_TERMINAL to the case when we can't find out the
width
Signed-off-by: Denys Vlasenko
---
libbb/lineedit.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 3905b8cc4..a62ab6d29 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -149,6 +149,7 @@ struct lineedit_statics {
CHAR_T delbuf[DELBUFSIZ]; /* a place to store deleted characters */
#endif
#if ENABLE_FEATURE_EDITING_ASK_TERMINAL
+ smallint unknown_width;
smallint sent_ESC_br6n;
#endif
@@ -1610,14 +1611,16 @@ static void ask_terminal(void)
* poll([{fd=0, events=POLLIN}], 1, 4294967295) = 1 ([{fd=0, revents=POLLIN}])
* read(0, "\n", 1) = 1 <-- oh crap, user's input got in first
*/
- struct pollfd pfd;
-
- pfd.fd = STDIN_FILENO;
- pfd.events = POLLIN;
- if (safe_poll(&pfd, 1, 0) == 0) {
- S.sent_ESC_br6n = 1;
- fputs("\033" "[6n", stdout);
- fflush_all(); /* make terminal see it ASAP! */
+ if (S.unknown_width) { /* only if window size is not known */
+ struct pollfd pfd;
+
+ pfd.fd = STDIN_FILENO;
+ pfd.events = POLLIN;
+ if (safe_poll(&pfd, 1, 0) == 0) {
+ S.sent_ESC_br6n = 1;
+ fputs("\033" "[6n", stdout);
+ fflush_all(); /* make terminal see it ASAP! */
+ }
}
}
#else
@@ -1763,11 +1766,13 @@ static void cmdedit_setwidth(unsigned w, int redraw_flg)
static void win_changed(int nsig)
{
+ int sv_errno = errno;
unsigned width;
- get_terminal_width_height(0, &width, NULL);
+ IF_FEATURE_EDITING_ASK_TERMINAL(S.unknown_width =) get_terminal_width_height(0, &width, NULL);
cmdedit_setwidth(width, nsig /* - just a yes/no flag */);
if (nsig == SIGWINCH)
signal(SIGWINCH, win_changed); /* rearm ourself */
+ errno = sv_errno;
}
static int lineedit_read_key(char *read_key_buffer)
--
cgit v1.2.3-55-g6feb
From fb4cb1c41697b4009608527a343dbd8265ad7993 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Sun, 18 Jul 2010 23:02:36 +0200
Subject: tweak defconfig
Signed-off-by: Denys Vlasenko
---
e2fsprogs/Config.src | 2 +-
networking/nc.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/e2fsprogs/Config.src b/e2fsprogs/Config.src
index f362c6b0a..62bc810f8 100644
--- a/e2fsprogs/Config.src
+++ b/e2fsprogs/Config.src
@@ -45,7 +45,7 @@ config LSATTR
config TUNE2FS
bool "tune2fs"
- default y
+ default n # off: it is too limited compared to upstream version
help
tune2fs allows the system administrator to adjust various tunable
filesystem parameters on Linux ext2/ext3 filesystems.
diff --git a/networking/nc.c b/networking/nc.c
index 0dacaf117..c77137480 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -34,7 +34,7 @@
//config:
//config:config NC_110_COMPAT
//config: bool "Netcat 1.10 compatibility (+2.5k)"
-//config: default y
+//config: default n # off specially for Rob
//config: depends on NC
//config: help
//config: This option makes nc closely follow original nc-1.10.
--
cgit v1.2.3-55-g6feb
From daf286cda559dd1eff0c9db46a4562c0255e76f1 Mon Sep 17 00:00:00 2001
From: Alexander Shishkin
Date: Thu, 15 Jul 2010 17:39:24 +0300
Subject: Fix out-of-tree build's recursion
While doing O=build build I've noticed that it was getting gradually
slower with each invocation. The reason turned out to be that the build
directory was inside the source tree and got recreated inside itself
with all its subdirectories.
This patch changes the behavior so that only the directories with
Kbuild.src or Config.src in them are created in the out-of-tree build
directory. A quick rebuild from scratch revealed no problems with this.
Signed-off-by: Alexander Shishkin
Signed-off-by: Denys Vlasenko
---
scripts/gen_build_files.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh
index 968158758..18c172d5a 100755
--- a/scripts/gen_build_files.sh
+++ b/scripts/gen_build_files.sh
@@ -53,8 +53,8 @@ fi
src="$srctree/$d/Kbuild.src"
dst="$d/Kbuild"
- mkdir -p -- "$d" 2>/dev/null
if test -f "$src"; then
+ mkdir -p -- "$d" 2>/dev/null
#echo " CHK $dst"
s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c`
@@ -73,8 +73,8 @@ fi
src="$srctree/$d/Config.src"
dst="$d/Config.in"
- mkdir -p -- "$d" 2>/dev/null
if test -f "$src"; then
+ mkdir -p -- "$d" 2>/dev/null
#echo " CHK $dst"
s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c`
--
cgit v1.2.3-55-g6feb
From b175462422f02a159a14dc5561d8bef6f84b2b66 Mon Sep 17 00:00:00 2001
From: Jeremie Koenig
Date: Thu, 27 May 2010 15:32:19 +0200
Subject: readlink: use xmalloc_realpath()
Using realpath() directly with a non-NULL output buffer is unsafe because its
behavior is unspecified on systems which don't have PATH_MAX (ie. Hurd)
I beleive this also fixes a small bug whereby 'buf' would not be freed
on 'readlink -v' with ENABLE_FEATURE_CLEANUP.
Signed-off-by: Jeremie Koenig
Signed-off-by: Denys Vlasenko
---
coreutils/readlink.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/coreutils/readlink.c b/coreutils/readlink.c
index 20df38b96..2ed5e2cac 100644
--- a/coreutils/readlink.c
+++ b/coreutils/readlink.c
@@ -36,7 +36,6 @@ int readlink_main(int argc UNUSED_PARAM, char **argv)
{
char *buf;
char *fname;
- char pathbuf[PATH_MAX];
IF_FEATURE_READLINK_FOLLOW(
unsigned opt;
@@ -56,7 +55,7 @@ int readlink_main(int argc UNUSED_PARAM, char **argv)
logmode = LOGMODE_NONE;
if (opt & 1) { /* -f */
- buf = realpath(fname, pathbuf);
+ buf = xmalloc_realpath(fname);
} else {
buf = xmalloc_readlink_or_warn(fname);
}
@@ -65,7 +64,7 @@ int readlink_main(int argc UNUSED_PARAM, char **argv)
return EXIT_FAILURE;
printf((opt & 2) ? "%s" : "%s\n", buf);
- if (ENABLE_FEATURE_CLEAN_UP && !opt)
+ if (ENABLE_FEATURE_CLEAN_UP)
free(buf);
fflush_stdout_and_exit(EXIT_SUCCESS);
--
cgit v1.2.3-55-g6feb
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
---
Config.in | 12 ++++++++++++
console-tools/Config.src | 13 +++++++++++++
coreutils/Config.src | 2 ++
coreutils/date.c | 2 +-
e2fsprogs/Config.src | 1 +
init/Config.src | 2 ++
init/bootchartd.c | 1 +
libbb/Config.src | 1 +
loginutils/Config.src | 3 +++
miscutils/Config.src | 19 ++++++++++++++++++-
miscutils/conspy.c | 1 +
miscutils/ubi_attach_detach.c | 2 ++
modutils/Config.src | 1 +
networking/Config.src | 23 ++++++++++++++++++++++-
networking/udhcp/Config.src | 2 ++
procps/Config.src | 4 +++-
shell/cttyhack.c | 1 +
sysklogd/Config.src | 1 +
util-linux/Config.src | 27 +++++++++++++++++++++++++++
19 files changed, 114 insertions(+), 4 deletions(-)
diff --git a/Config.in b/Config.in
index eebc9774d..35f43b3cd 100644
--- a/Config.in
+++ b/Config.in
@@ -47,6 +47,17 @@ config USE_PORTABLE_CODE
compiler other than gcc.
If you do use gcc, this option may needlessly increase code size.
+config PLATFORM_LINUX
+ bool "Enable Linux-specific applets and features"
+ default y
+ help
+ For the most part, busybox requires only POSIX compatibility
+ from the target system, but some applets and features use
+ Linux-specific interfaces.
+
+ Answering 'N' here will disable such applets and hide the
+ corresponding configuration options.
+
choice
prompt "Buffer allocation policy"
default FEATURE_BUFFERS_USE_MALLOC
@@ -353,6 +364,7 @@ config FEATURE_SUID_CONFIG_QUIET
config SELINUX
bool "Support NSA Security Enhanced Linux"
default n
+ depends on PLATFORM_LINUX
help
Enable support for SELinux in applets ls, ps, and id. Also provide
the option of compiling in SELinux applets.
diff --git a/console-tools/Config.src b/console-tools/Config.src
index 6e3191ada..cdb26800e 100644
--- a/console-tools/Config.src
+++ b/console-tools/Config.src
@@ -10,6 +10,7 @@ INSERT
config CHVT
bool "chvt"
default y
+ depends on PLATFORM_LINUX
help
This program is used to change to another terminal.
Example: chvt 4 (change to terminal /dev/tty4)
@@ -17,6 +18,7 @@ config CHVT
config FGCONSOLE
bool "fgconsole"
default y
+ depends on PLATFORM_LINUX
help
This program prints active (foreground) console number.
@@ -29,12 +31,14 @@ config CLEAR
config DEALLOCVT
bool "deallocvt"
default y
+ depends on PLATFORM_LINUX
help
This program deallocates unused virtual consoles.
config DUMPKMAP
bool "dumpkmap"
default y
+ depends on PLATFORM_LINUX
help
This program dumps the kernel's keyboard translation table to
stdout, in binary format. You can then use loadkmap to load it.
@@ -42,18 +46,21 @@ config DUMPKMAP
config KBD_MODE
bool "kbd_mode"
default y
+ depends on PLATFORM_LINUX
help
This program reports and sets keyboard mode.
config LOADFONT
bool "loadfont"
default y
+ depends on PLATFORM_LINUX
help
This program loads a console font from standard input.
config LOADKMAP
bool "loadkmap"
default y
+ depends on PLATFORM_LINUX
help
This program loads a keyboard translation table from
standard input.
@@ -61,6 +68,7 @@ config LOADKMAP
config OPENVT
bool "openvt"
default y
+ depends on PLATFORM_LINUX
help
This program is used to start a command on an unused
virtual terminal.
@@ -92,6 +100,7 @@ config FEATURE_RESIZE_PRINT
config SETCONSOLE
bool "setconsole"
default y
+ depends on PLATFORM_LINUX
help
This program redirects the system console to another device,
like the current tty while logged in via telnet.
@@ -106,6 +115,7 @@ config FEATURE_SETCONSOLE_LONG_OPTIONS
config SETFONT
bool "setfont"
default y
+ depends on PLATFORM_LINUX
help
Allows to load console screen map. Useful for i18n.
@@ -127,6 +137,7 @@ config DEFAULT_SETFONT_DIR
config SETKEYCODES
bool "setkeycodes"
default y
+ depends on PLATFORM_LINUX
help
This program loads entries into the kernel's scancode-to-keycode
map, allowing unusual keyboards to generate usable keycodes.
@@ -134,12 +145,14 @@ config SETKEYCODES
config SETLOGCONS
bool "setlogcons"
default y
+ depends on PLATFORM_LINUX
help
This program redirects the output console of kernel messages.
config SHOWKEY
bool "showkey"
default y
+ depends on PLATFORM_LINUX
help
Shows keys pressed.
diff --git a/coreutils/Config.src b/coreutils/Config.src
index d4c9e0541..780b73fda 100644
--- a/coreutils/Config.src
+++ b/coreutils/Config.src
@@ -591,6 +591,7 @@ config FEATURE_SPLIT_FANCY
config STAT
bool "stat"
default y
+ depends on PLATFORM_LINUX # statfs()
help
display file or filesystem status.
@@ -606,6 +607,7 @@ config FEATURE_STAT_FORMAT
config STTY
bool "stty"
default y
+ depends on PLATFORM_LINUX
help
stty is used to change and print terminal line settings.
diff --git a/coreutils/date.c b/coreutils/date.c
index c737f09f3..cb41724af 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -72,7 +72,7 @@
//config:config FEATURE_DATE_NANO
//config: bool "Support %[num]N nanosecond format specifier"
//config: default n
-//config: depends on DATE
+//config: depends on DATE && PLATFORM_LINUX # syscall(__NR_clock_gettime)
//config: help
//config: Support %[num]N format specifier. Adds ~250 bytes of code.
//config:
diff --git a/e2fsprogs/Config.src b/e2fsprogs/Config.src
index 62bc810f8..6043e9b57 100644
--- a/e2fsprogs/Config.src
+++ b/e2fsprogs/Config.src
@@ -33,6 +33,7 @@ config FSCK
config LSATTR
bool "lsattr"
default y
+ depends on PLATFORM_LINUX
help
lsattr lists the file attributes on a second extended file system.
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
diff --git a/libbb/Config.src b/libbb/Config.src
index 09bf89246..9b01757c6 100644
--- a/libbb/Config.src
+++ b/libbb/Config.src
@@ -153,6 +153,7 @@ config FEATURE_COPYBUF_KB
config MONOTONIC_SYSCALL
bool "Use clock_gettime(CLOCK_MONOTONIC) syscall"
default n
+ depends on PLATFORM_LINUX
help
Use clock_gettime(CLOCK_MONOTONIC) syscall for measuring
time intervals (time, ping, traceroute etc need this).
diff --git a/loginutils/Config.src b/loginutils/Config.src
index 5d497c4dc..425d041b9 100644
--- a/loginutils/Config.src
+++ b/loginutils/Config.src
@@ -179,6 +179,7 @@ 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.
@@ -186,6 +187,7 @@ config GETTY
config LOGIN
bool "login"
default y
+ depends on PLATFORM_LINUX
select FEATURE_SUID
select FEATURE_SYSLOG
help
@@ -295,6 +297,7 @@ config SULOGIN
config VLOCK
bool "vlock"
default y
+ depends on PLATFORM_LINUX
select FEATURE_SUID
help
Build the "vlock" applet which allows you to lock (virtual) terminals.
diff --git a/miscutils/Config.src b/miscutils/Config.src
index 2f7c50271..e89e231e6 100644
--- a/miscutils/Config.src
+++ b/miscutils/Config.src
@@ -10,6 +10,7 @@ INSERT
config ADJTIMEX
bool "adjtimex"
default y
+ depends on PLATFORM_LINUX
help
Adjtimex reads and optionally sets adjustment parameters for
the Linux clock adjustment algorithm.
@@ -24,6 +25,7 @@ config BBCONFIG
config BEEP
bool "beep"
default y
+ depends on PLATFORM_LINUX
help
The beep applets beeps in a given freq/Hz.
@@ -180,6 +182,7 @@ config FEATURE_DC_LIBM
config DEVFSD
bool "devfsd (obsolete)"
default n
+ depends on PLATFORM_LINUX
select FEATURE_SYSLOG
help
This is deprecated and should NOT be used anymore.
@@ -223,6 +226,7 @@ config DEVFSD_VERBOSE
config FEATURE_DEVFS
bool "Use devfs names for all devices (obsolete)"
default n
+ depends on PLATFORM_LINUX
help
This is obsolete and should NOT be used anymore.
Use linux >= 2.6 (optionally with hotplug) and mdev instead!
@@ -242,6 +246,7 @@ config DEVMEM
config EJECT
bool "eject"
default y
+ depends on PLATFORM_LINUX
help
Used to eject cdroms. (defaults to /dev/cdrom)
@@ -256,6 +261,7 @@ config FEATURE_EJECT_SCSI
config FBSPLASH
bool "fbsplash"
default y
+ depends on PLATFORM_LINUX
help
Shows splash image and progress bar on framebuffer device.
Can be used during boot phase of an embedded device. ~2kb.
@@ -305,6 +311,7 @@ config FLASH_ERASEALL
config IONICE
bool "ionice"
default y
+ depends on PLATFORM_LINUX
help
Set/set program io scheduling class and priority
Requires kernel >= 2.6.13
@@ -344,6 +351,11 @@ endchoice
config LESS
bool "less"
default y
+ depends on PLATFORM_LINUX
+ depends on PLATFORM_LINUX
+ depends on PLATFORM_LINUX
+ depends on PLATFORM_LINUX
+ depends on PLATFORM_LINUX
help
'less' is a pager, meaning that it displays text files. It possesses
a wide array of features, and is an improvement over 'more'.
@@ -410,6 +422,7 @@ config FEATURE_LESS_LINENUMS
config HDPARM
bool "hdparm"
default y
+ depends on PLATFORM_LINUX
help
Get/Set hard drive parameters. Primarily intended for ATA
drives. Adds about 13k (or around 30k if you enable the
@@ -526,6 +539,7 @@ config MT
config RAIDAUTORUN
bool "raidautorun"
default y
+ depends on PLATFORM_LINUX
help
raidautorun tells the kernel md driver to
search and start RAID arrays.
@@ -533,7 +547,7 @@ config RAIDAUTORUN
config READAHEAD
bool "readahead"
default y
- depends on LFS
+ depends on LFS && PLATFORM_LINUX
help
Preload the files listed on the command line into RAM cache so that
subsequent reads on these files will not block on disk I/O.
@@ -550,6 +564,7 @@ config READAHEAD
config RFKILL
bool "rfkill"
default n # doesn't build on Ubuntu 9.04
+ depends on PLATFORM_LINUX
help
Enable/disable wireless devices.
@@ -570,6 +585,7 @@ config RUNLEVEL
config RX
bool "rx"
default y
+ depends on PLATFORM_LINUX
help
Receive files using the Xmodem protocol.
@@ -641,6 +657,7 @@ config WALL
config WATCHDOG
bool "watchdog"
default y
+ depends on PLATFORM_LINUX
help
The watchdog utility is used with hardware or software watchdog
device drivers. It opens the specified watchdog device special file
diff --git a/miscutils/conspy.c b/miscutils/conspy.c
index 509a0f271..a173d8efd 100644
--- a/miscutils/conspy.c
+++ b/miscutils/conspy.c
@@ -17,6 +17,7 @@
//config:config CONSPY
//config: bool "conspy"
//config: default n
+//config: depends on PLATFORM_LINUX
//config: help
//config: A text-mode VNC like program for Linux virtual terminals.
//config: example: conspy NUM shared access to console num
diff --git a/miscutils/ubi_attach_detach.c b/miscutils/ubi_attach_detach.c
index 7b92a8afc..0d63a10d5 100644
--- a/miscutils/ubi_attach_detach.c
+++ b/miscutils/ubi_attach_detach.c
@@ -12,12 +12,14 @@
//config:config UBIATTACH
//config: bool "ubiattach"
//config: default n
+//config: depends on PLATFORM_LINUX
//config: help
//config: Attach MTD device to an UBI device.
//config:
//config:config UBIDETACH
//config: bool "ubidetach"
//config: default n
+//config: depends on PLATFORM_LINUX
//config: help
//config: Detach MTD device from an UBI device.
diff --git a/modutils/Config.src b/modutils/Config.src
index a7dcb3ab3..4191d29f2 100644
--- a/modutils/Config.src
+++ b/modutils/Config.src
@@ -4,6 +4,7 @@
#
menu "Linux Module Utilities"
+depends on PLATFORM_LINUX
INSERT
diff --git a/networking/Config.src b/networking/Config.src
index 449436247..26c59e7c1 100644
--- a/networking/Config.src
+++ b/networking/Config.src
@@ -43,6 +43,7 @@ config FEATURE_PREFER_IPV4_ADDRESS
config VERBOSE_RESOLUTION_ERRORS
bool "Verbose resolution errors"
default n
+ depends on PLATFORM_LINUX #because of xsocket() in libbb/xfuncs_prinf.c
help
Enable if you are not satisfied with simplistic
"can't resolve 'hostname.com'" and want to know more.
@@ -51,18 +52,21 @@ config VERBOSE_RESOLUTION_ERRORS
config ARP
bool "arp"
default y
+ depends on PLATFORM_LINUX
help
Manipulate the system ARP cache.
config ARPING
bool "arping"
default y
+ depends on PLATFORM_LINUX
help
Ping hosts by ARP packets.
config BRCTL
bool "brctl"
default y
+ depends on PLATFORM_LINUX
help
Manage ethernet bridges.
Supports addbr/delbr and addif/delif.
@@ -95,6 +99,7 @@ config DNSD
config ETHER_WAKE
bool "ether-wake"
default y
+ depends on PLATFORM_LINUX
help
Send a magic packet to wake up sleeping machines.
@@ -269,6 +274,7 @@ config FEATURE_HTTPD_PROXY
config IFCONFIG
bool "ifconfig"
default y
+ depends on PLATFORM_LINUX
help
Ifconfig is used to configure the kernel-resident network interfaces.
@@ -316,6 +322,7 @@ config FEATURE_IFCONFIG_BROADCAST_PLUS
config IFENSLAVE
bool "ifenslave"
default y
+ depends on PLATFORM_LINUX
help
Userspace application to bind several interfaces
to a logical interface (use with kernel bonding driver).
@@ -323,6 +330,7 @@ config IFENSLAVE
config IFPLUGD
bool "ifplugd"
default y
+ depends on PLATFORM_LINUX
help
Network interface plug detection daemon.
@@ -364,7 +372,7 @@ config FEATURE_IFUPDOWN_IP
config FEATURE_IFUPDOWN_IP_BUILTIN
bool "Use busybox ip applet"
default y
- depends on FEATURE_IFUPDOWN_IP
+ depends on FEATURE_IFUPDOWN_IP && PLATFORM_LINUX
select IP
select FEATURE_IP_ADDRESS
select FEATURE_IP_LINK
@@ -483,6 +491,7 @@ config FEATURE_INETD_RPC
config IP
bool "ip"
default y
+ depends on PLATFORM_LINUX
help
The "ip" applet is a TCP/IP interface configuration and routing
utility. You generally don't need "ip" to use busybox with
@@ -598,6 +607,7 @@ config FEATURE_IPCALC_LONG_OPTIONS
config NAMEIF
bool "nameif"
default y
+ depends on PLATFORM_LINUX
select FEATURE_SYSLOG
help
nameif is used to rename network interface by its MAC address.
@@ -626,6 +636,7 @@ config FEATURE_NAMEIF_EXTENDED
config NETSTAT
bool "netstat"
default y
+ depends on PLATFORM_LINUX
help
netstat prints information about the Linux networking subsystem.
@@ -654,6 +665,7 @@ config NSLOOKUP
config NTPD
bool "ntpd"
default y
+ depends on PLATFORM_LINUX
help
The NTP client/server daemon.
@@ -668,6 +680,7 @@ config FEATURE_NTPD_SERVER
config PING
bool "ping"
default y
+ depends on PLATFORM_LINUX
help
ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to
elicit an ICMP ECHO_RESPONSE from a host or gateway.
@@ -696,12 +709,14 @@ config PSCAN
config ROUTE
bool "route"
default y
+ depends on PLATFORM_LINUX
help
Route displays or manipulates the kernel's IP routing tables.
config SLATTACH
bool "slattach"
default y
+ depends on PLATFORM_LINUX
help
slattach is a small utility to attach network interfaces to serial
lines.
@@ -719,6 +734,7 @@ config SLATTACH
config TCPSVD
bool "tcpsvd"
default y
+ depends on PLATFORM_LINUX
help
tcpsvd listens on a TCP port and runs a program for each new
connection.
@@ -888,6 +904,7 @@ config TFTP_DEBUG
config TRACEROUTE
bool "traceroute"
default y
+ depends on PLATFORM_LINUX
help
Utility to trace the route of IP packets.
@@ -924,6 +941,7 @@ config FEATURE_TRACEROUTE_USE_ICMP
config TUNCTL
bool "tunctl"
default y
+ depends on PLATFORM_LINUX
help
tunctl creates or deletes tun devices.
@@ -949,6 +967,7 @@ config IFUPDOWN_UDHCPC_CMD_OPTIONS
config UDPSVD
bool "udpsvd"
default y
+ depends on PLATFORM_LINUX
help
udpsvd listens on an UDP port and runs a program for each new
connection.
@@ -956,6 +975,7 @@ config UDPSVD
config VCONFIG
bool "vconfig"
default y
+ depends on PLATFORM_LINUX
help
Creates, removes, and configures VLAN interfaces
@@ -990,6 +1010,7 @@ config FEATURE_WGET_LONG_OPTIONS
config ZCIP
bool "zcip"
default y
+ depends on PLATFORM_LINUX
select FEATURE_SYSLOG
help
ZCIP provides ZeroConf IPv4 address selection, according to RFC 3927.
diff --git a/networking/udhcp/Config.src b/networking/udhcp/Config.src
index aac88569b..331dffc2e 100644
--- a/networking/udhcp/Config.src
+++ b/networking/udhcp/Config.src
@@ -8,6 +8,7 @@ INSERT
config UDHCPD
bool "udhcp server (udhcpd)"
default y
+ depends on PLATFORM_LINUX
help
udhcpd is a DHCP server geared primarily toward embedded systems,
while striving to be fully functional and RFC compliant.
@@ -51,6 +52,7 @@ config DHCPD_LEASES_FILE
config UDHCPC
bool "udhcp client (udhcpc)"
default y
+ depends on PLATFORM_LINUX
help
udhcpc is a DHCP client geared primarily toward embedded systems,
while striving to be fully functional and RFC compliant.
diff --git a/procps/Config.src b/procps/Config.src
index e61de5614..1ff6dfd30 100644
--- a/procps/Config.src
+++ b/procps/Config.src
@@ -10,6 +10,7 @@ INSERT
config FREE
bool "free"
default y
+ depends on PLATFORM_LINUX #sysinfo()
help
free displays the total amount of free and used physical and swap
memory in the system, as well as the buffers used by the kernel.
@@ -104,7 +105,7 @@ config FEATURE_PS_WIDE
config FEATURE_PS_TIME
bool "Enable time and elapsed time output"
default y
- depends on PS && DESKTOP
+ depends on PS && DESKTOP && PLATFORM_LINUX #sysinfo()
help
Support -o time and -o etime output specifiers.
@@ -200,6 +201,7 @@ config FEATURE_SHOW_THREADS
config UPTIME
bool "uptime"
default y
+ depends on PLATFORM_LINUX #sysinfo()
help
uptime gives a one line display of the current time, how long
the system has been running, how many users are currently logged
diff --git a/shell/cttyhack.c b/shell/cttyhack.c
index 7af13fdfd..a80d49dc3 100644
--- a/shell/cttyhack.c
+++ b/shell/cttyhack.c
@@ -13,6 +13,7 @@
//config:config CTTYHACK
//config: bool "cttyhack"
//config: default y
+//config: depends on PLATFORM_LINUX
//config: help
//config: One common problem reported on the mailing list is "can't access tty;
//config: job control turned off" error message which typically appears when
diff --git a/sysklogd/Config.src b/sysklogd/Config.src
index 6d574abb1..bfe2d1cc3 100644
--- a/sysklogd/Config.src
+++ b/sysklogd/Config.src
@@ -109,6 +109,7 @@ config FEATURE_LOGREAD_REDUCED_LOCKING
config KLOGD
bool "klogd"
default y
+ depends on PLATFORM_LINUX
help
klogd is a utility which intercepts and logs all
messages from the Linux kernel and sends the messages
diff --git a/util-linux/Config.src b/util-linux/Config.src
index 91d1fc2ce..98953c17b 100644
--- a/util-linux/Config.src
+++ b/util-linux/Config.src
@@ -10,6 +10,7 @@ INSERT
config ACPID
bool "acpid"
default y
+ depends on PLATFORM_LINUX
help
acpid listens to ACPI events coming either in textual form from
/proc/acpi/event (though it is marked deprecated it is still widely
@@ -32,6 +33,7 @@ config FEATURE_ACPID_COMPAT
config BLKID
bool "blkid"
default y
+ depends on PLATFORM_LINUX
select VOLUMEID
help
Lists labels and UUIDs of all filesystems.
@@ -41,6 +43,7 @@ config BLKID
config DMESG
bool "dmesg"
default y
+ depends on PLATFORM_LINUX
help
dmesg is used to examine or control the kernel ring buffer. When the
Linux kernel prints messages to the system log, they are stored in
@@ -74,6 +77,7 @@ config FEATURE_DMESG_PRETTY
config FBSET
bool "fbset"
default y
+ depends on PLATFORM_LINUX
help
fbset is used to show or change the settings of a Linux frame buffer
device. The frame buffer device provides a simple and unique
@@ -102,6 +106,7 @@ config FEATURE_FBSET_READMODE
config FDFLUSH
bool "fdflush"
default y
+ depends on PLATFORM_LINUX
help
fdflush is only needed when changing media on slightly-broken
removable media drives. It is used to make Linux believe that a
@@ -114,12 +119,14 @@ config FDFLUSH
config FDFORMAT
bool "fdformat"
default y
+ depends on PLATFORM_LINUX
help
fdformat is used to low-level format a floppy disk.
config FDISK
bool "fdisk"
default y
+ depends on PLATFORM_LINUX
help
The fdisk utility is used to divide hard disks into one or more
logical disks, which are generally called partitions. This utility
@@ -187,6 +194,7 @@ config FEATURE_FDISK_ADVANCED
config FINDFS
bool "findfs"
default y
+ depends on PLATFORM_LINUX
select VOLUMEID
help
Prints the name of a filesystem with given label or UUID.
@@ -202,6 +210,7 @@ config FLOCK
config FREERAMDISK
bool "freeramdisk"
default y
+ depends on PLATFORM_LINUX
help
Linux allows you to create ramdisks. This utility allows you to
delete them and completely free all memory that was used for the
@@ -224,12 +233,14 @@ config FSCK_MINIX
config MKFS_EXT2
bool "mkfs_ext2"
default y
+ depends on PLATFORM_LINUX
help
Utility to create EXT2 filesystems.
config MKFS_MINIX
bool "mkfs_minix"
default y
+ depends on PLATFORM_LINUX
help
The minix filesystem is a nice, small, compact, read-write filesystem
with little overhead. If you wish to be able to create minix
@@ -247,6 +258,7 @@ config FEATURE_MINIX2
config MKFS_REISER
bool "mkfs_reiser"
default n
+ depends on PLATFORM_LINUX
help
Utility to create ReiserFS filesystems.
Note: this applet needs a lot of testing and polishing.
@@ -254,6 +266,7 @@ config MKFS_REISER
config MKFS_VFAT
bool "mkfs_vfat"
default y
+ depends on PLATFORM_LINUX
help
Utility to create FAT32 filesystems.
@@ -302,6 +315,7 @@ config HD
config HWCLOCK
bool "hwclock"
default y
+ depends on PLATFORM_LINUX
help
The hwclock utility is used to read and set the hardware clock
on a system. This is primarily used to set the current time on
@@ -341,6 +355,7 @@ config IPCRM
config IPCS
bool "ipcs"
default y
+ depends on PLATFORM_LINUX
select FEATURE_SUID
help
The ipcs utility is used to provide information on the currently
@@ -349,6 +364,7 @@ config IPCS
config LOSETUP
bool "losetup"
default y
+ depends on PLATFORM_LINUX
help
losetup is used to associate or detach a loop device with a regular
file or block device, and to query the status of a loop device. This
@@ -357,6 +373,7 @@ config LOSETUP
config LSPCI
bool "lspci"
default y
+ #depends on PLATFORM_LINUX
help
lspci is a utility for displaying information about PCI buses in the
system and devices connected to them.
@@ -366,6 +383,7 @@ config LSPCI
config LSUSB
bool "lsusb"
default y
+ #depends on PLATFORM_LINUX
help
lsusb is a utility for displaying information about USB buses in the
system and devices connected to them.
@@ -375,6 +393,7 @@ config LSUSB
config MDEV
bool "mdev"
default y
+ depends on PLATFORM_LINUX
help
mdev is a mini-udev implementation for dynamically creating device
nodes in the /dev directory.
@@ -473,6 +492,7 @@ config FEATURE_USE_TERMIOS
config MOUNT
bool "mount"
default y
+ depends on PLATFORM_LINUX
help
All files and filesystems in Unix are arranged into one big directory
tree. The 'mount' utility is used to graft a filesystem onto a
@@ -555,6 +575,7 @@ config FEATURE_MOUNT_FSTAB
config PIVOT_ROOT
bool "pivot_root"
default y
+ depends on PLATFORM_LINUX
help
The pivot_root utility swaps the mount points for the root filesystem
with some other mounted filesystem. This allows you to do all sorts
@@ -582,12 +603,14 @@ config RDEV
config READPROFILE
bool "readprofile"
default y
+ #depends on PLATFORM_LINUX
help
This allows you to parse /proc/profile for basic profiling.
config RTCWAKE
bool "rtcwake"
default y
+ depends on PLATFORM_LINUX
help
Enter a system sleep state until specified wakeup time.
@@ -607,6 +630,7 @@ config SCRIPTREPLAY
config SETARCH
bool "setarch"
default y
+ depends on PLATFORM_LINUX
help
The linux32 utility is used to create a 32bit environment for the
specified program (usually a shell). It only makes sense to have
@@ -616,6 +640,7 @@ config SETARCH
config SWAPONOFF
bool "swaponoff"
default y
+ depends on PLATFORM_LINUX
help
This option enables both the 'swapon' and the 'swapoff' utilities.
Once you have created some swap space using 'mkswap', you also need
@@ -634,6 +659,7 @@ config FEATURE_SWAPON_PRI
config SWITCH_ROOT
bool "switch_root"
default y
+ depends on PLATFORM_LINUX
help
The switch_root utility is used from initramfs to select a new
root device. Under initramfs, you have to use this instead of
@@ -653,6 +679,7 @@ config SWITCH_ROOT
config UMOUNT
bool "umount"
default y
+ depends on PLATFORM_LINUX
help
When you want to remove a mounted filesystem from its current mount
point, for example when you are shutting down the system, the
--
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(-)
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
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(-)
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 816ed971e4ce60564f7ecbdc016d268d8e936230 Mon Sep 17 00:00:00 2001
From: Jeremie Koenig
Date: Thu, 27 May 2010 15:46:29 +0200
Subject: libbb.h: add device names for Hurd and FreeBSD
Adapted from include.libbb.diff from the Debian kFreeBSD people:
http://svn.debian.org/viewsvn/d-i/people/slackydeb/kfreebsd/busybox/1.14/debian
Signed-off-by: Jeremie Koenig
Signed-off-by: Denys Vlasenko
---
include/libbb.h | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/include/libbb.h b/include/libbb.h
index e2a8322b8..c043506b9 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1613,7 +1613,27 @@ extern const char bb_default_login_shell[];
/* "sh" */
#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+6)
-#if ENABLE_FEATURE_DEVFS
+/* The following devices are the same on all systems. */
+#define CURRENT_TTY "/dev/tty"
+#define DEV_CONSOLE "/dev/console"
+
+#if defined(__FreeBSD_kernel__)
+# define CURRENT_VC CURRENT_TTY
+# define VC_1 "/dev/ttyv0"
+# define VC_2 "/dev/ttyv1"
+# define VC_3 "/dev/ttyv2"
+# define VC_4 "/dev/ttyv3"
+# define VC_5 "/dev/ttyv4"
+# define VC_FORMAT "/dev/ttyv%d"
+#elif defined(__GNU__)
+# define CURRENT_VC CURRENT_TTY
+# define VC_1 "/dev/tty1"
+# define VC_2 "/dev/tty2"
+# define VC_3 "/dev/tty3"
+# define VC_4 "/dev/tty4"
+# define VC_5 "/dev/tty5"
+# define VC_FORMAT "/dev/tty%d"
+#elif ENABLE_FEATURE_DEVFS /* from now on, assume Linux naming */
# define CURRENT_VC "/dev/vc/0"
# define VC_1 "/dev/vc/1"
# define VC_2 "/dev/vc/2"
@@ -1660,10 +1680,6 @@ extern const char bb_default_login_shell[];
# define FB_0 "/dev/fb0"
#endif
-/* The following devices are the same on devfs and non-devfs systems. */
-#define CURRENT_TTY "/dev/tty"
-#define DEV_CONSOLE "/dev/console"
-
#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
--
cgit v1.2.3-55-g6feb
From 84b01d5afc8230c79a1b8469c222d940c0d4e792 Mon Sep 17 00:00:00 2001
From: Jeremie Koenig
Date: Thu, 27 May 2010 15:46:33 +0200
Subject: mkdir: fix -p on FreeBSD
This patch is libbb.make_directory.diff from Debian kFreeBSD 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
---
libbb/make_directory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libbb/make_directory.c b/libbb/make_directory.c
index 4486eb1ed..6dd04cf99 100644
--- a/libbb/make_directory.c
+++ b/libbb/make_directory.c
@@ -86,7 +86,7 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags)
if (mkdir(path, 0777) < 0) {
/* If we failed for any other reason than the directory
* already exists, output a diagnostic and return -1 */
- if (errno != EEXIST
+ if ((errno != EEXIST && errno != EISDIR)
|| !(flags & FILEUTILS_RECUR)
|| ((stat(path, &st) < 0) || !S_ISDIR(st.st_mode))
) {
--
cgit v1.2.3-55-g6feb
From 29885114a5e3d22ee7aa3ab0e373e00e7cff443c Mon Sep 17 00:00:00 2001
From: Jeremie Koenig
Date: Thu, 27 May 2010 15:39:24 +0200
Subject: libbb: conditionalize AF_* usage in error reporting
Signed-off-by: Jeremie Koenig
Signed-off-by: Denys Vlasenko
---
libbb/xfuncs_printf.c | 4 ++++
networking/Config.src | 1 -
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c
index 7069a7c8e..91f7ba22c 100644
--- a/libbb/xfuncs_printf.c
+++ b/libbb/xfuncs_printf.c
@@ -387,8 +387,12 @@ int FAST_FUNC xsocket(int domain, int type, int protocol)
/* Hijack vaguely related config option */
#if ENABLE_VERBOSE_RESOLUTION_ERRORS
const char *s = "INET";
+# ifdef AF_PACKET
if (domain == AF_PACKET) s = "PACKET";
+# endif
+# ifdef AF_NETLINK
if (domain == AF_NETLINK) s = "NETLINK";
+# endif
IF_FEATURE_IPV6(if (domain == AF_INET6) s = "INET6";)
bb_perror_msg_and_die("socket(AF_%s,%d,%d)", s, type, protocol);
#else
diff --git a/networking/Config.src b/networking/Config.src
index 26c59e7c1..fc613e8d3 100644
--- a/networking/Config.src
+++ b/networking/Config.src
@@ -43,7 +43,6 @@ config FEATURE_PREFER_IPV4_ADDRESS
config VERBOSE_RESOLUTION_ERRORS
bool "Verbose resolution errors"
default n
- depends on PLATFORM_LINUX #because of xsocket() in libbb/xfuncs_prinf.c
help
Enable if you are not satisfied with simplistic
"can't resolve 'hostname.com'" and want to know more.
--
cgit v1.2.3-55-g6feb
From 2ea12d8b6d2a36c5d49df1ae97b86ba287835249 Mon Sep 17 00:00:00 2001
From: Jeremie Koenig
Date: Thu, 27 May 2010 15:46:25 +0200
Subject: tcpsvd,udpsvd: conditionalize usage of SO_ORIGINAL_DST
On systems without this call, $TCPORIGDSTADDR is not set.
Signed-off-by: Jeremie Koenig
Signed-off-by: Denys Vlasenko
---
networking/Config.src | 2 --
networking/tcpudp.c | 5 +++++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/networking/Config.src b/networking/Config.src
index fc613e8d3..2d29c423a 100644
--- a/networking/Config.src
+++ b/networking/Config.src
@@ -733,7 +733,6 @@ config SLATTACH
config TCPSVD
bool "tcpsvd"
default y
- depends on PLATFORM_LINUX
help
tcpsvd listens on a TCP port and runs a program for each new
connection.
@@ -966,7 +965,6 @@ config IFUPDOWN_UDHCPC_CMD_OPTIONS
config UDPSVD
bool "udpsvd"
default y
- depends on PLATFORM_LINUX
help
udpsvd listens on an UDP port and runs a program for each new
connection.
diff --git a/networking/tcpudp.c b/networking/tcpudp.c
index 53e622b56..40f68258e 100644
--- a/networking/tcpudp.c
+++ b/networking/tcpudp.c
@@ -30,9 +30,12 @@
*/
#include "libbb.h"
+
/* Wants etc, thus included after libbb.h: */
+#ifdef __linux__
#include /* for __be32 etc */
#include
+#endif
// TODO: move into this file:
#include "tcpudp_perhost.h"
@@ -464,6 +467,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
/* setup ucspi env */
const char *proto = tcp ? "TCP" : "UDP";
+#ifdef SO_ORIGINAL_DST
/* Extract "original" destination addr:port
* from Linux firewall. Useful when you redirect
* an outbond connection to local handler, and it needs
@@ -473,6 +477,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
xsetenv_plain("TCPORIGDSTADDR", addr);
free(addr);
}
+#endif
xsetenv_plain("PROTO", proto);
xsetenv_proto(proto, "LOCALADDR", local_addr);
xsetenv_proto(proto, "REMOTEADDR", remote_addr);
--
cgit v1.2.3-55-g6feb
From ba085c6351b49d7c71f3635a0f4709e1927fdc51 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Wed, 21 Jul 2010 08:58:11 +0200
Subject: make DESKTOP=y the default
Signed-off-by: Denys Vlasenko
---
Config.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Config.in b/Config.in
index 35f43b3cd..828b30471 100644
--- a/Config.in
+++ b/Config.in
@@ -15,7 +15,7 @@ menu "General Configuration"
config DESKTOP
bool "Enable options for full-blown desktop systems"
- default n
+ default y
help
Enable options and features which are not essential.
Select this only if you plan to use busybox on full-blown
--
cgit v1.2.3-55-g6feb
From 23e8c08fa2e1faab335e7ff625272f57d1dde469 Mon Sep 17 00:00:00 2001
From: Marek Polacek
Date: Wed, 21 Jul 2010 10:29:07 +0200
Subject: mpstat: new applet. ~5.5k
Signed-off-by: Marek Polacek
Signed-off-by: Denys Vlasenko
---
procps/mpstat.c | 1024 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 1024 insertions(+)
create mode 100644 procps/mpstat.c
diff --git a/procps/mpstat.c b/procps/mpstat.c
new file mode 100644
index 000000000..0f633c713
--- /dev/null
+++ b/procps/mpstat.c
@@ -0,0 +1,1024 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Per-processor statistics, based on sysstat version 9.1.2 by Sebastien Godard
+ *
+ * Copyright (C) 2010 Marek Polacek
+ *
+ * Licensed under GPLv2, see file License in this tarball for details.
+ */
+
+//applet:IF_MPSTAT(APPLET(mpstat, _BB_DIR_BIN, _BB_SUID_DROP))
+
+//kbuild:lib-$(CONFIG_MPSTAT) += mpstat.o
+
+//config:config MPSTAT
+//config: bool "mpstat"
+//config: default y
+//config: help
+//config: Per-processor statistics
+
+#include "libbb.h"
+#include /* struct utsname */
+
+//#define debug(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
+#define debug(fmt, ...) ((void)0)
+
+/* Size of /proc/interrupts line, CPU data excluded */
+#define INTERRUPTS_LINE 64
+/* Maximum number of interrupts */
+#define NR_IRQS 256
+#define NR_IRQCPU_PREALLOC 3
+#define MAX_IRQ_LEN 16
+#define MAX_PF_NAME 512
+
+/* System files */
+#define SYSFS_DEVCPU "/sys/devices/system/cpu"
+#define PROCFS_STAT "/proc/stat"
+#define PROCFS_INTERRUPTS "/proc/interrupts"
+#define PROCFS_SOFTIRQS "/proc/softirqs"
+#define PROCFS_UPTIME "/proc/uptime"
+
+
+#if 1
+typedef unsigned long long data_t;
+typedef long long idata_t;
+#define FMT_DATA "ll"
+#define DATA_MAX ULLONG_MAX
+#else
+typedef unsigned long data_t;
+typedef long idata_t;
+#define FMT_DATA "l"
+#define DATA_MAX ULONG_MAX
+#endif
+
+
+struct stats_irqcpu {
+ unsigned interrupt;
+ char irq_name[MAX_IRQ_LEN];
+};
+
+/* Structure for CPU statistics */
+struct stats_cpu {
+ data_t cpu_user;
+ data_t cpu_nice;
+ data_t cpu_system;
+ data_t cpu_idle;
+ data_t cpu_iowait;
+ data_t cpu_steal;
+ data_t cpu_irq;
+ data_t cpu_softirq;
+ data_t cpu_guest;
+};
+
+/* Struct for interrupts statistics */
+struct stats_irq {
+ data_t irq_nr;
+};
+
+
+/* Globals. Try to sort by size. */
+struct globals {
+ int interval;
+ int count;
+ unsigned cpu_nr; /* Number of CPUs */
+ unsigned irqcpu_nr; /* Number of interrupts per CPU */
+ unsigned softirqcpu_nr; /* Number of soft interrupts per CPU */
+ unsigned options;
+ unsigned hz;
+ unsigned cpu_bitmap_len;
+ smallint p_option;
+ smallint header_done;
+ smallint avg_header_done;
+ unsigned char *cpu_bitmap; /* Bit 0: global, bit 1: 1st proc... */
+ data_t global_uptime[3];
+ data_t per_cpu_uptime[3];
+ struct stats_cpu *st_cpu[3];
+ struct stats_irq *st_irq[3];
+ struct stats_irqcpu *st_irqcpu[3];
+ struct stats_irqcpu *st_softirqcpu[3];
+ struct tm timestamp[3];
+};
+#define G (*ptr_to_globals)
+#define INIT_G() do { \
+ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
+} while (0)
+
+/* The selected interrupts statistics (bits in G.options) */
+enum {
+ D_CPU = 1 << 0,
+ D_IRQ_SUM = 1 << 1,
+ D_IRQ_CPU = 1 << 2,
+ D_SOFTIRQS = 1 << 3,
+};
+
+
+/* Does str start with "cpu"? */
+static int starts_with_cpu(const char *str)
+{
+ return !((str[0] - 'c') | (str[1] - 'p') | (str[2] - 'u'));
+}
+
+/* Is option on? */
+static ALWAYS_INLINE int display_opt(int opt)
+{
+ return (opt & G.options);
+}
+
+#if DATA_MAX > 0xffffffff
+/*
+ * Handle overflow conditions properly for counters which can have
+ * less bits than data_t, depending on the kernel version.
+ */
+/* Surprisingly, on 32bit inlining is a size win */
+static ALWAYS_INLINE data_t overflow_safe_sub(data_t prev, data_t curr)
+{
+ data_t v = curr - prev;
+
+ if ((idata_t)v < 0 /* curr < prev - counter overflow? */
+ && prev <= 0xffffffff /* kernel uses 32bit value for the counter? */
+ ) {
+ /* Add 33th bit set to 1 to curr, compensating for the overflow */
+ /* double shift defeats "warning: left shift count >= width of type" */
+ v += ((data_t)1 << 16) << 16;
+ }
+ return v;
+}
+#else
+static ALWAYS_INLINE data_t overflow_safe_sub(data_t prev, data_t curr)
+{
+ return curr - prev;
+}
+#endif
+
+static double percent_value(data_t prev, data_t curr, data_t itv)
+{
+ return ((double)overflow_safe_sub(prev, curr)) / itv * 100;
+}
+
+static double hz_value(data_t prev, data_t curr, data_t itv)
+{
+ return ((double)overflow_safe_sub(prev, curr)) / itv * G.hz;
+}
+
+static ALWAYS_INLINE data_t jiffies_diff(data_t old, data_t new)
+{
+ data_t diff = new - old;
+ return (diff == 0) ? 1 : diff;
+}
+
+static int is_cpu_in_bitmap(unsigned cpu)
+{
+ return G.cpu_bitmap[cpu >> 3] & (1 << (cpu & 7));
+}
+
+static void write_irqcpu_stats(struct stats_irqcpu *per_cpu_stats[],
+ int total_irqs,
+ data_t itv,
+ int prev, int current,
+ const char *prev_str, const char *current_str)
+{
+ int j;
+ int offset, cpu;
+ struct stats_irqcpu *p0, *q0;
+
+ /* Check if number of IRQs has changed */
+ if (G.interval != 0) {
+ for (j = 0; j <= total_irqs; j++) {
+ p0 = &per_cpu_stats[current][j];
+ if (p0->irq_name[0] != '\0') {
+ q0 = &per_cpu_stats[prev][j];
+ if (strcmp(p0->irq_name, q0->irq_name) != 0) {
+ /* Strings are different */
+ break;
+ }
+ }
+ }
+ }
+
+ /* Print header */
+ printf("\n%-11s CPU", prev_str);
+ for (j = 0; j < total_irqs; j++) {
+ p0 = &per_cpu_stats[current][j];
+ if (p0->irq_name[0] != '\0')
+ printf(" %8s/s", p0->irq_name);
+ }
+ bb_putchar('\n');
+
+ for (cpu = 1; cpu <= G.cpu_nr; cpu++) {
+ /* Check if we want stats about this CPU */
+ if (!is_cpu_in_bitmap(cpu) && G.p_option) {
+ continue;
+ }
+
+ printf("%-11s %4u", current_str, cpu - 1);
+
+ for (j = 0; j < total_irqs; j++) {
+ /* IRQ field set only for proc 0 */
+ p0 = &per_cpu_stats[current][j];
+
+ /*
+ * An empty string for irq name means that
+ * interrupt is no longer used.
+ */
+ if (p0->irq_name[0] != '\0') {
+ offset = j;
+ q0 = &per_cpu_stats[prev][offset];
+
+ /*
+ * If we want stats for the time since boot
+ * we have p0->irq != q0->irq.
+ */
+ if (strcmp(p0->irq_name, q0->irq_name) != 0
+ && G.interval != 0
+ ) {
+ if (j) {
+ offset = j - 1;
+ q0 = &per_cpu_stats[prev][offset];
+ }
+ if (strcmp(p0->irq_name, q0->irq_name) != 0
+ && (j + 1 < total_irqs)
+ ) {
+ offset = j + 1;
+ q0 = &per_cpu_stats[prev][offset];
+ }
+ }
+
+ if (strcmp(p0->irq_name, q0->irq_name) == 0
+ || G.interval == 0
+ ) {
+ struct stats_irqcpu *p, *q;
+ p = &per_cpu_stats[current][(cpu - 1) * total_irqs + j];
+ q = &per_cpu_stats[prev][(cpu - 1) * total_irqs + offset];
+ printf(" %10.2f",
+ (double)(p->interrupt - q->interrupt) / itv * G.hz);
+ } else {
+ printf(" N/A");
+ }
+ }
+ }
+ bb_putchar('\n');
+ }
+}
+
+static data_t get_per_cpu_interval(const struct stats_cpu *scc,
+ const struct stats_cpu *scp)
+{
+ return ((scc->cpu_user + scc->cpu_nice +
+ scc->cpu_system + scc->cpu_iowait +
+ scc->cpu_idle + scc->cpu_steal +
+ scc->cpu_irq + scc->cpu_softirq) -
+ (scp->cpu_user + scp->cpu_nice +
+ scp->cpu_system + scp->cpu_iowait +
+ scp->cpu_idle + scp->cpu_steal +
+ scp->cpu_irq + scp->cpu_softirq));
+}
+
+static void print_stats_cpu_struct(const struct stats_cpu *p,
+ const struct stats_cpu *c,
+ data_t itv)
+{
+ printf(" %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n",
+ percent_value(p->cpu_user - p->cpu_guest,
+ /**/ c->cpu_user - c->cpu_guest, itv),
+ percent_value(p->cpu_nice , c->cpu_nice , itv),
+ percent_value(p->cpu_system , c->cpu_system , itv),
+ percent_value(p->cpu_iowait , c->cpu_iowait , itv),
+ percent_value(p->cpu_irq , c->cpu_irq , itv),
+ percent_value(p->cpu_softirq, c->cpu_softirq, itv),
+ percent_value(p->cpu_steal , c->cpu_steal , itv),
+ percent_value(p->cpu_guest , c->cpu_guest , itv),
+ percent_value(p->cpu_idle , c->cpu_idle , itv)
+ );
+}
+
+static void write_stats_core(int prev, int current,
+ const char *prev_str, const char *current_str)
+{
+ struct stats_cpu *scc, *scp;
+ data_t itv, global_itv;
+ int cpu;
+
+ /* Compute time interval */
+ itv = global_itv = jiffies_diff(G.global_uptime[prev], G.global_uptime[current]);
+
+ /* Reduce interval to one CPU */
+ if (G.cpu_nr > 1)
+ itv = jiffies_diff(G.per_cpu_uptime[prev], G.per_cpu_uptime[current]);
+
+ /* Print CPU stats */
+ if (display_opt(D_CPU)) {
+
+ /* This is done exactly once */
+ if (!G.header_done) {
+ printf("\n%-11s CPU %%usr %%nice %%sys %%iowait %%irq %%soft %%steal %%guest %%idle\n",
+ prev_str
+ );
+ G.header_done = 1;
+ }
+
+ for (cpu = 0; cpu <= G.cpu_nr; cpu++) {
+ data_t per_cpu_itv;
+
+ /* Print stats about this particular CPU? */
+ if (!is_cpu_in_bitmap(cpu))
+ continue;
+
+ scc = &G.st_cpu[current][cpu];
+ scp = &G.st_cpu[prev][cpu];
+ per_cpu_itv = global_itv;
+
+ printf((cpu ? "%-11s %4u" : "%-11s all"), current_str, cpu - 1);
+ if (cpu) {
+ double idle;
+ /*
+ * If the CPU is offline, then it isn't in /proc/stat,
+ * so all values are 0.
+ * NB: Guest time is already included in user time.
+ */
+ if ((scc->cpu_user | scc->cpu_nice | scc->cpu_system |
+ scc->cpu_iowait | scc->cpu_idle | scc->cpu_steal |
+ scc->cpu_irq | scc->cpu_softirq) == 0
+ ) {
+ /*
+ * Set current struct fields to values from prev.
+ * iteration. Then their values won't jump from
+ * zero, when the CPU comes back online.
+ */
+ *scc = *scp;
+ idle = 0.0;
+ goto print_zeros;
+ }
+ /* Compute interval again for current proc */
+ per_cpu_itv = get_per_cpu_interval(scc, scp);
+ if (per_cpu_itv == 0) {
+ /*
+ * If the CPU is tickless then there is no change in CPU values
+ * but the sum of values is not zero.
+ */
+ idle = 100.0;
+ print_zeros:
+ printf(" %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n",
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, idle);
+ continue;
+ }
+ }
+ print_stats_cpu_struct(scp, scc, per_cpu_itv);
+ }
+ }
+
+ /* Print total number of IRQs per CPU */
+ if (display_opt(D_IRQ_SUM)) {
+
+ /* Print average header, this is done exactly once */
+ if (!G.avg_header_done) {
+ printf("\n%-11s CPU intr/s\n", prev_str);
+ G.avg_header_done = 1;
+ }
+
+ for (cpu = 0; cpu <= G.cpu_nr; cpu++) {
+ data_t per_cpu_itv;
+
+ /* Print stats about this CPU? */
+ if (!is_cpu_in_bitmap(cpu))
+ continue;
+
+ per_cpu_itv = itv;
+ printf((cpu ? "%-11s %4u" : "%-11s all"), current_str, cpu - 1);
+ if (cpu) {
+ scc = &G.st_cpu[current][cpu];
+ scp = &G.st_cpu[prev][cpu];
+ /* Compute interval again for current proc */
+ per_cpu_itv = get_per_cpu_interval(scc, scp);
+ if (per_cpu_itv == 0) {
+ printf(" %9.2f\n", 0.0);
+ continue;
+ }
+ }
+ printf(" %9.2f\n", hz_value(G.st_irq[prev][cpu].irq_nr, G.st_irq[current][cpu].irq_nr, per_cpu_itv));
+ }
+ }
+
+ if (display_opt(D_IRQ_CPU)) {
+ write_irqcpu_stats(G.st_irqcpu, G.irqcpu_nr,
+ itv,
+ prev, current,
+ prev_str, current_str
+ );
+ }
+
+ if (display_opt(D_SOFTIRQS)) {
+ write_irqcpu_stats(G.st_softirqcpu, G.softirqcpu_nr,
+ itv,
+ prev, current,
+ prev_str, current_str
+ );
+ }
+}
+
+/*
+ * Print the statistics
+ */
+static void write_stats(int current)
+{
+ char prev_time[16];
+ char curr_time[16];
+
+ strftime(prev_time, sizeof(prev_time), "%X", &G.timestamp[!current]);
+ strftime(curr_time, sizeof(curr_time), "%X", &G.timestamp[current]);
+
+ write_stats_core(!current, current, prev_time, curr_time);
+}
+
+static void write_stats_avg(int current)
+{
+ write_stats_core(2, current, "Average:", "Average:");
+}
+
+/*
+ * Read CPU statistics
+ */
+static void get_cpu_statistics(struct stats_cpu *cpu, data_t *up, data_t *up0)
+{
+ FILE *fp;
+ char buf[1024];
+
+ fp = xfopen_for_read(PROCFS_STAT);
+
+ while (fgets(buf, sizeof(buf), fp)) {
+ data_t sum;
+ unsigned cpu_number;
+ struct stats_cpu *cp;
+
+ if (!starts_with_cpu(buf))
+ continue; /* not "cpu" */
+ if (buf[3] == ' ') {
+ /* "cpu " */
+ cp = cpu;
+ } else {
+ /* "cpuN" */
+ if (G.cpu_nr == 0
+ || sscanf(buf + 3, "%u ", &cpu_number) != 1
+ || cpu_number >= G.cpu_nr
+ ) {
+ continue;
+ }
+ cp = &cpu[cpu_number + 1];
+ }
+
+ /* Read the jiffies, save them */
+ /* Not all fields have to be present */
+ memset(cp, 0, sizeof(*cp));
+ sscanf(skip_non_whitespace(buf + 3),
+ " %"FMT_DATA"u %"FMT_DATA"u %"FMT_DATA"u"
+ " %"FMT_DATA"u %"FMT_DATA"u %"FMT_DATA"u"
+ " %"FMT_DATA"u %"FMT_DATA"u %"FMT_DATA"u",
+ &cp->cpu_user, &cp->cpu_nice, &cp->cpu_system,
+ &cp->cpu_idle, &cp->cpu_iowait, &cp->cpu_irq,
+ &cp->cpu_softirq, &cp->cpu_steal,
+ &cp->cpu_guest
+ );
+ /*
+ * Compute uptime in jiffies (1/HZ), it'll be the sum of
+ * individual CPU's uptimes.
+ * NB: We have to omit cpu_guest, because cpu_user includes it.
+ */
+ sum = cp->cpu_user + cp->cpu_nice + cp->cpu_system +
+ cp->cpu_idle + cp->cpu_iowait + cp->cpu_irq +
+ cp->cpu_softirq + cp->cpu_steal;
+
+ if (buf[3] == ' ') {
+ /* "cpu " */
+ *up = sum;
+ } else {
+ /* "cpuN" */
+ if (cpu_number == 0 && *up0 != 0) {
+ /* Compute uptime of single CPU */
+ *up0 = sum;
+ }
+ }
+ }
+ fclose(fp);
+}
+
+/*
+ * Read IRQs from /proc/stat
+ */
+static void get_irqs_from_stat(struct stats_irq *irq)
+{
+ FILE *fp;
+ char buf[1024];
+
+ fp = fopen_for_read(PROCFS_STAT);
+ if (!fp)
+ return;
+
+ while (fgets(buf, sizeof(buf), fp)) {
+ if (strncmp(buf, "intr ", 5) == 0)
+ /* Read total number of IRQs since system boot */
+ sscanf(buf + 5, "%"FMT_DATA"u", &irq->irq_nr);
+ }
+
+ fclose(fp);
+}
+
+/*
+ * Read stats from /proc/interrupts or /proc/softirqs
+ */
+static void get_irqs_from_interrupts(const char *fname,
+ struct stats_irqcpu *per_cpu_stats[],
+ int irqs_per_cpu, int current)
+{
+ FILE *fp;
+ struct stats_irq *irq_i;
+ struct stats_irqcpu *ic;
+ char *buf;
+ unsigned buflen;
+ unsigned cpu;
+ unsigned irq;
+ int cpu_index[G.cpu_nr];
+ int iindex;
+ int len, digit;
+
+ for (cpu = 1; cpu <= G.cpu_nr; cpu++) {
+ irq_i = &G.st_irq[current][cpu];
+ irq_i->irq_nr = 0;
+ }
+
+ fp = fopen_for_read(fname);
+ if (!fp)
+ return;
+
+ buflen = INTERRUPTS_LINE + 16 * G.cpu_nr;
+ buf = xmalloc(buflen);
+
+ /* Parse header and determine, which CPUs are online */
+ iindex = 0;
+ while (fgets(buf, buflen, fp)) {
+ char *cp, *next;
+ next = buf;
+ while ((cp = strstr(next, "CPU")) != NULL
+ && iindex < G.cpu_nr
+ ) {
+ cpu = strtoul(cp + 3, &next, 10);
+ cpu_index[iindex++] = cpu;
+ }
+ if (iindex) /* We found header */
+ break;
+ }
+
+ irq = 0;
+ while (fgets(buf, buflen, fp)
+ && irq < irqs_per_cpu
+ ) {
+ char *cp;
+ /* Skip over ":" */
+ cp = strchr(buf, ':');
+ if (!cp)
+ continue;
+
+ ic = &per_cpu_stats[current][irq];
+ len = cp - buf;
+ if (len > sizeof(ic->irq_name)) {
+ len = sizeof(ic->irq_name);
+ }
+ safe_strncpy(ic->irq_name, buf, len);
+ digit = isdigit(buf[len - 1]);
+ cp++;
+
+ for (cpu = 0; cpu < iindex; cpu++) {
+ char *next;
+ ic = &per_cpu_stats[current][cpu_index[cpu] * irqs_per_cpu + irq];
+ irq_i = &G.st_irq[current][cpu_index[cpu] + 1];
+ ic->interrupt = strtoul(cp, &next, 10);
+ if (digit) {
+ /* Do not count non-numerical IRQs */
+ irq_i->irq_nr += ic->interrupt;
+ }
+ cp = next;
+ }
+ irq++;
+ }
+ fclose(fp);
+ free(buf);
+
+ while (irq < irqs_per_cpu) {
+ /* Number of interrupts per CPU has changed */
+ ic = &per_cpu_stats[current][irq];
+ ic->irq_name[0] = '\0'; /* False interrupt */
+ irq++;
+ }
+}
+
+static void get_uptime(data_t *uptime)
+{
+ FILE *fp;
+ char buf[sizeof(long)*3 * 2 + 4]; /* enough for long.long */
+ unsigned long uptime_sec, decimal;
+
+ fp = fopen_for_read(PROCFS_UPTIME);
+ if (!fp)
+ return;
+ if (fgets(buf, sizeof(buf), fp)) {
+ if (sscanf(buf, "%lu.%lu", &uptime_sec, &decimal) == 2) {
+ *uptime = (data_t)uptime_sec * G.hz + decimal * G.hz / 100;
+ }
+ }
+
+ fclose(fp);
+}
+
+static void get_localtime(struct tm *tm)
+{
+ time_t timer;
+ time(&timer);
+ localtime_r(&timer, tm);
+}
+
+static void alarm_handler(int sig UNUSED_PARAM)
+{
+ signal(SIGALRM, alarm_handler);
+ alarm(G.interval);
+}
+
+static void main_loop(void)
+{
+ unsigned current;
+ unsigned cpus;
+
+ /* Read the stats */
+ if (G.cpu_nr > 1) {
+ G.per_cpu_uptime[0] = 0;
+ get_uptime(&G.per_cpu_uptime[0]);
+ }
+
+ get_cpu_statistics(G.st_cpu[0], &G.global_uptime[0], &G.per_cpu_uptime[0]);
+
+ if (display_opt(D_IRQ_SUM))
+ get_irqs_from_stat(G.st_irq[0]);
+
+ if (display_opt(D_IRQ_SUM | D_IRQ_CPU))
+ get_irqs_from_interrupts(PROCFS_INTERRUPTS, G.st_irqcpu,
+ G.irqcpu_nr, 0);
+
+ if (display_opt(D_SOFTIRQS))
+ get_irqs_from_interrupts(PROCFS_SOFTIRQS, G.st_softirqcpu,
+ G.softirqcpu_nr, 0);
+
+ if (G.interval == 0) {
+ /* Display since boot time */
+ cpus = G.cpu_nr + 1;
+ G.timestamp[1] = G.timestamp[0];
+ memset(G.st_cpu[1], 0, sizeof(G.st_cpu[1][0]) * cpus);
+ memset(G.st_irq[1], 0, sizeof(G.st_irq[1][0]) * cpus);
+ memset(G.st_irqcpu[1], 0, sizeof(G.st_irqcpu[1][0]) * cpus * G.irqcpu_nr);
+ memset(G.st_softirqcpu[1], 0, sizeof(G.st_softirqcpu[1][0]) * cpus * G.softirqcpu_nr);
+
+ write_stats(0);
+
+ /* And we're done */
+ return;
+ }
+
+ /* Set a handler for SIGALRM */
+ alarm_handler(0);
+
+ /* Save the stats we already have. We need them to compute the average */
+ G.timestamp[2] = G.timestamp[0];
+ G.global_uptime[2] = G.global_uptime[0];
+ G.per_cpu_uptime[2] = G.per_cpu_uptime[0];
+ cpus = G.cpu_nr + 1;
+ memcpy(G.st_cpu[2], G.st_cpu[0], sizeof(G.st_cpu[0][0]) * cpus);
+ memcpy(G.st_irq[2], G.st_irq[0], sizeof(G.st_irq[0][0]) * cpus);
+ memcpy(G.st_irqcpu[2], G.st_irqcpu[0], sizeof(G.st_irqcpu[0][0]) * cpus * G.irqcpu_nr);
+ if (display_opt(D_SOFTIRQS)) {
+ memcpy(G.st_softirqcpu[2], G.st_softirqcpu[0],
+ sizeof(G.st_softirqcpu[0][0]) * cpus * G.softirqcpu_nr);
+ }
+
+ current = 1;
+ while (1) {
+ /* Suspend until a signal is received */
+ pause();
+
+ /* Set structures to 0 to distinguish off/online CPUs */
+ memset(&G.st_cpu[current][/*cpu:*/ 1], 0, sizeof(G.st_cpu[0][0]) * G.cpu_nr);
+
+ get_localtime(&G.timestamp[current]);
+
+ /* Read stats */
+ if (G.cpu_nr > 1) {
+ G.per_cpu_uptime[current] = 0;
+ get_uptime(&G.per_cpu_uptime[current]);
+ }
+ get_cpu_statistics(G.st_cpu[current], &G.global_uptime[current], &G.per_cpu_uptime[current]);
+
+ if (display_opt(D_IRQ_SUM))
+ get_irqs_from_stat(G.st_irq[current]);
+
+ if (display_opt(D_IRQ_SUM | D_IRQ_CPU))
+ get_irqs_from_interrupts(PROCFS_INTERRUPTS, G.st_irqcpu,
+ G.irqcpu_nr, current);
+
+ if (display_opt(D_SOFTIRQS))
+ get_irqs_from_interrupts(PROCFS_SOFTIRQS,
+ G.st_softirqcpu,
+ G.softirqcpu_nr, current);
+
+ write_stats(current);
+
+ if (G.count > 0) {
+ if (--G.count == 0)
+ break;
+ }
+
+ current ^= 1;
+ }
+
+ /* Print average statistics */
+ write_stats_avg(current);
+}
+
+/* Initialization */
+
+/* Get number of clock ticks per sec */
+static ALWAYS_INLINE unsigned get_hz(void)
+{
+ return sysconf(_SC_CLK_TCK);
+}
+
+static void alloc_struct(int cpus)
+{
+ int i;
+ for (i = 0; i < 3; i++) {
+ G.st_cpu[i] = xzalloc(sizeof(G.st_cpu[i][0]) * cpus);
+ G.st_irq[i] = xzalloc(sizeof(G.st_irq[i][0]) * cpus);
+ G.st_irqcpu[i] = xzalloc(sizeof(G.st_irqcpu[i][0]) * cpus * G.irqcpu_nr);
+ G.st_softirqcpu[i] = xzalloc(sizeof(G.st_softirqcpu[i][0]) * cpus * G.softirqcpu_nr);
+ }
+ G.cpu_bitmap_len = (cpus >> 3) + 1;
+ G.cpu_bitmap = xzalloc(G.cpu_bitmap_len);
+}
+
+static void print_header(struct tm *t)
+{
+ char cur_date[16];
+ struct utsname uts;
+
+ /* Get system name, release number and hostname */
+ uname(&uts);
+
+ strftime(cur_date, sizeof(cur_date), "%x", t);
+
+ printf("%s %s (%s) \t%s \t_%s_\t(%d CPU)\n",
+ uts.sysname, uts.release, uts.nodename, cur_date, uts.machine, G.cpu_nr);
+}
+
+/*
+ * Get number of processors in /sys
+ */
+static int get_sys_cpu_nr(void)
+{
+ DIR *dir;
+ struct dirent *d;
+ struct stat buf;
+ char line[MAX_PF_NAME];
+ int proc_nr = 0;
+
+ dir = opendir(SYSFS_DEVCPU);
+ if (!dir)
+ return 0; /* /sys not mounted */
+
+ /* Get current file entry */
+ while ((d = readdir(dir)) != NULL) {
+ if (starts_with_cpu(d->d_name) && isdigit(d->d_name[3])) {
+ snprintf(line, MAX_PF_NAME, "%s/%s", SYSFS_DEVCPU,
+ d->d_name);
+ line[MAX_PF_NAME - 1] = '\0';
+ /* Get information about file */
+ if (stat(line, &buf) < 0)
+ continue;
+ /* If found 'cpuN', we have one more processor */
+ if (S_ISDIR(buf.st_mode))
+ proc_nr++;
+ }
+ }
+
+ closedir(dir);
+ return proc_nr;
+}
+
+/*
+ * Get number of processors in /proc/stat
+ * Return value '0' means one CPU and non SMP kernel.
+ * Otherwise N means N processor(s) and SMP kernel.
+ */
+static int get_proc_cpu_nr(void)
+{
+ FILE *fp;
+ char line[256];
+ int proc_nr = -1;
+
+ fp = xfopen_for_read(PROCFS_STAT);
+ while (fgets(line, sizeof(line), fp)) {
+ if (!starts_with_cpu(line)) {
+ if (proc_nr >= 0)
+ break; /* we are past "cpuN..." lines */
+ continue;
+ }
+ if (line[3] != ' ') { /* "cpuN" */
+ int num_proc;
+ if (sscanf(line + 3, "%u", &num_proc) == 1
+ && num_proc > proc_nr
+ ) {
+ proc_nr = num_proc;
+ }
+ }
+ }
+
+ fclose(fp);
+ return proc_nr + 1;
+}
+
+static int get_cpu_nr(void)
+{
+ int n;
+
+ /* Try to use /sys, if possible */
+ n = get_sys_cpu_nr();
+ if (n == 0)
+ /* Otherwise use /proc/stat */
+ n = get_proc_cpu_nr();
+
+ return n;
+}
+
+/*
+ * Get number of interrupts available per processor
+ */
+static int get_irqcpu_nr(const char *f, int max_irqs)
+{
+ FILE *fp;
+ char *line;
+ unsigned linelen;
+ unsigned irq;
+
+ fp = fopen_for_read(f);
+ if (!fp) /* No interrupts file */
+ return 0;
+
+ linelen = INTERRUPTS_LINE + 16 * G.cpu_nr;
+ line = xmalloc(linelen);
+
+ irq = 0;
+ while (fgets(line, linelen, fp)
+ && irq < max_irqs
+ ) {
+ int p = strcspn(line, ":");
+ if ((p > 0) && (p < 16))
+ irq++;
+ }
+
+ fclose(fp);
+ free(line);
+
+ return irq;
+}
+
+//usage:#define mpstat_trivial_usage
+//usage: "[-A] [-I SUM|CPU|ALL|SCPU] [-u] [-P num|ALL] [INTERVAL [COUNT]]"
+//usage:#define mpstat_full_usage "\n\n"
+//usage: "Per-processor statistics\n"
+//usage: "\nOptions:"
+//usage: "\n -A Same as -I ALL -u -P ALL"
+//usage: "\n -I SUM|CPU|ALL|SCPU Report interrupt statistics"
+//usage: "\n -P num|ALL Processor to monitor"
+//usage: "\n -u Report CPU utilization"
+
+int mpstat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int mpstat_main(int UNUSED_PARAM argc, char **argv)
+{
+ char *opt_irq_fmt;
+ char *opt_set_cpu;
+ int i, opt;
+ enum {
+ OPT_ALL = 1 << 0, /* -A */
+ OPT_INTS = 1 << 1, /* -I */
+ OPT_SETCPU = 1 << 2, /* -P */
+ OPT_UTIL = 1 << 3, /* -u */
+ };
+
+ /* Dont buffer data if redirected to a pipe */
+ setbuf(stdout, NULL);
+
+ INIT_G();
+
+ G.interval = -1;
+
+ /* Get number of processors */
+ G.cpu_nr = get_cpu_nr();
+
+ /* Get number of clock ticks per sec */
+ G.hz = get_hz();
+
+ /* Calculate number of interrupts per processor */
+ G.irqcpu_nr = get_irqcpu_nr(PROCFS_INTERRUPTS, NR_IRQS) + NR_IRQCPU_PREALLOC;
+
+ /* Calculate number of soft interrupts per processor */
+ G.softirqcpu_nr = get_irqcpu_nr(PROCFS_SOFTIRQS, NR_IRQS) + NR_IRQCPU_PREALLOC;
+
+ /* Allocate space for structures. + 1 for global structure. */
+ alloc_struct(G.cpu_nr + 1);
+
+ /* Parse and process arguments */
+ opt = getopt32(argv, "AI:P:u", &opt_irq_fmt, &opt_set_cpu);
+ argv += optind;
+
+ if (*argv) {
+ /* Get interval */
+ G.interval = xatoi_u(*argv);
+ G.count = -1;
+ argv++;
+ if (*argv) {
+ /* Get count value */
+ if (G.interval == 0)
+ bb_show_usage();
+ G.count = xatoi_u(*argv);
+ //if (*++argv)
+ // bb_show_usage();
+ }
+ }
+ if (G.interval < 0)
+ G.interval = 0;
+
+ if (opt & OPT_ALL) {
+ G.p_option = 1;
+ G.options |= D_CPU + D_IRQ_SUM + D_IRQ_CPU + D_SOFTIRQS;
+ /* Select every CPU */
+ memset(G.cpu_bitmap, 0xff, G.cpu_bitmap_len);
+ }
+
+ if (opt & OPT_INTS) {
+ if (strcmp(opt_irq_fmt, "ALL") == 0)
+ G.options |= D_IRQ_SUM + D_IRQ_CPU + D_SOFTIRQS;
+ else if (strcmp(opt_irq_fmt, "CPU") == 0)
+ G.options |= D_IRQ_CPU;
+ else if (strcmp(opt_irq_fmt, "SUM") == 0)
+ G.options |= D_IRQ_SUM;
+ else if (strcmp(opt_irq_fmt, "SCPU") == 0)
+ G.options |= D_SOFTIRQS;
+ else
+ bb_show_usage();
+ }
+
+ if ((opt & OPT_UTIL) /* -u? */
+ || G.options == 0 /* nothing? (use default then) */
+ ) {
+ G.options |= D_CPU;
+ }
+
+ if (opt & OPT_SETCPU) {
+ char *t;
+ G.p_option = 1;
+
+ for (t = strtok(opt_set_cpu, ","); t; t = strtok(NULL, ",")) {
+ if (strcmp(t, "ALL") == 0) {
+ /* Select every CPU */
+ memset(G.cpu_bitmap, 0xff, G.cpu_bitmap_len);
+ } else {
+ /* Get CPU number */
+ unsigned n = xatoi_u(t);
+ if (n >= G.cpu_nr)
+ bb_error_msg_and_die("not that many processors");
+ n++;
+ G.cpu_bitmap[n >> 3] |= 1 << (n & 7);
+ }
+ }
+ }
+
+ if (!G.p_option)
+ /* Display global stats */
+ G.cpu_bitmap[0] = 1;
+
+ /* Get time */
+ get_localtime(&G.timestamp[0]);
+
+ /* Display header */
+ print_header(&G.timestamp[0]);
+
+ /* The main loop */
+ main_loop();
+
+ if (ENABLE_FEATURE_CLEAN_UP) {
+ /* Clean up */
+ for (i = 0; i < 3; i++) {
+ free(G.st_cpu[i]);
+ free(G.st_irq[i]);
+ free(G.st_irqcpu[i]);
+ free(G.st_softirqcpu[i]);
+ }
+ free(G.cpu_bitmap);
+ free(&G);
+ }
+
+ return EXIT_SUCCESS;
+}
--
cgit v1.2.3-55-g6feb
From 217df6ea9fe3fa93e2cf3e6b44cbec14a526f422 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Wed, 21 Jul 2010 11:54:33 +0200
Subject: mpstat: small code shrink
Signed-off-by: Denys Vlasenko
---
procps/mpstat.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/procps/mpstat.c b/procps/mpstat.c
index 0f633c713..125bb3de7 100644
--- a/procps/mpstat.c
+++ b/procps/mpstat.c
@@ -57,7 +57,6 @@ struct stats_irqcpu {
char irq_name[MAX_IRQ_LEN];
};
-/* Structure for CPU statistics */
struct stats_cpu {
data_t cpu_user;
data_t cpu_nice;
@@ -70,13 +69,12 @@ struct stats_cpu {
data_t cpu_guest;
};
-/* Struct for interrupts statistics */
struct stats_irq {
data_t irq_nr;
};
-/* Globals. Try to sort by size. */
+/* Globals. Sort by size and access frequency. */
struct globals {
int interval;
int count;
@@ -451,11 +449,10 @@ static void get_cpu_statistics(struct stats_cpu *cpu, data_t *up, data_t *up0)
if (!starts_with_cpu(buf))
continue; /* not "cpu" */
- if (buf[3] == ' ') {
- /* "cpu " */
- cp = cpu;
- } else {
- /* "cpuN" */
+
+ cp = cpu; /* for "cpu " case */
+ if (buf[3] != ' ') {
+ /* "cpuN " */
if (G.cpu_nr == 0
|| sscanf(buf + 3, "%u ", &cpu_number) != 1
|| cpu_number >= G.cpu_nr
@@ -465,17 +462,16 @@ static void get_cpu_statistics(struct stats_cpu *cpu, data_t *up, data_t *up0)
cp = &cpu[cpu_number + 1];
}
- /* Read the jiffies, save them */
+ /* Read the counters, save them */
/* Not all fields have to be present */
memset(cp, 0, sizeof(*cp));
- sscanf(skip_non_whitespace(buf + 3),
+ sscanf(buf, "%*s"
" %"FMT_DATA"u %"FMT_DATA"u %"FMT_DATA"u"
" %"FMT_DATA"u %"FMT_DATA"u %"FMT_DATA"u"
" %"FMT_DATA"u %"FMT_DATA"u %"FMT_DATA"u",
&cp->cpu_user, &cp->cpu_nice, &cp->cpu_system,
&cp->cpu_idle, &cp->cpu_iowait, &cp->cpu_irq,
- &cp->cpu_softirq, &cp->cpu_steal,
- &cp->cpu_guest
+ &cp->cpu_softirq, &cp->cpu_steal, &cp->cpu_guest
);
/*
* Compute uptime in jiffies (1/HZ), it'll be the sum of
@@ -490,7 +486,7 @@ static void get_cpu_statistics(struct stats_cpu *cpu, data_t *up, data_t *up0)
/* "cpu " */
*up = sum;
} else {
- /* "cpuN" */
+ /* "cpuN " */
if (cpu_number == 0 && *up0 != 0) {
/* Compute uptime of single CPU */
*up0 = sum;
@@ -769,7 +765,7 @@ static void print_header(struct tm *t)
strftime(cur_date, sizeof(cur_date), "%x", t);
- printf("%s %s (%s) \t%s \t_%s_\t(%d CPU)\n",
+ printf("%s %s (%s)\t%s\t_%s_\t(%u CPU)\n",
uts.sysname, uts.release, uts.nodename, cur_date, uts.machine, G.cpu_nr);
}
--
cgit v1.2.3-55-g6feb
From c5fb0ada9b9efe65ceef3f2b5171573463e07b4f Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Wed, 21 Jul 2010 12:39:42 +0200
Subject: vi: fix "ask terminal" code
function old new delta
edit_file 761 793 +32
refresh 773 780 +7
query_screen_dimensions 63 54 -9
Signed-off-by: Denys Vlasenko
---
editors/vi.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/editors/vi.c b/editors/vi.c
index 0f412c362..73e095cf8 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -504,20 +504,17 @@ static int init_text_buffer(char *fn)
}
#if ENABLE_FEATURE_VI_WIN_RESIZE
-static void query_screen_dimensions(void)
+static int query_screen_dimensions(void)
{
-# if ENABLE_FEATURE_VI_ASK_TERMINAL
- if (!G.get_rowcol_error)
- G.get_rowcol_error =
-# endif
- get_terminal_width_height(STDIN_FILENO, &columns, &rows);
+ int err = get_terminal_width_height(STDIN_FILENO, &columns, &rows);
if (rows > MAX_SCR_ROWS)
rows = MAX_SCR_ROWS;
if (columns > MAX_SCR_COLS)
columns = MAX_SCR_COLS;
+ return err;
}
#else
-# define query_screen_dimensions() ((void)0)
+# define query_screen_dimensions() (0)
#endif
static void edit_file(char *fn)
@@ -536,7 +533,7 @@ static void edit_file(char *fn)
rows = 24;
columns = 80;
size = 0;
- query_screen_dimensions();
+ IF_FEATURE_VI_ASK_TERMINAL(G.get_rowcol_error =) query_screen_dimensions();
#if ENABLE_FEATURE_VI_ASK_TERMINAL
if (G.get_rowcol_error /* TODO? && no input on stdin */) {
uint64_t k;
@@ -546,9 +543,12 @@ static void edit_file(char *fn)
if ((int32_t)k == KEYCODE_CURSOR_POS) {
uint32_t rc = (k >> 32);
columns = (rc & 0x7fff);
+ if (columns > MAX_SCR_COLS)
+ columns = MAX_SCR_COLS;
rows = ((rc >> 16) & 0x7fff);
+ if (rows > MAX_SCR_ROWS)
+ rows = MAX_SCR_ROWS;
}
- query_screen_dimensions();
}
#endif
new_screen(rows, columns); // get memory for virtual screen
@@ -2797,7 +2797,7 @@ static void refresh(int full_screen)
int li, changed;
char *tp, *sp; // pointer into text[] and screen[]
- if (ENABLE_FEATURE_VI_WIN_RESIZE) {
+ if (ENABLE_FEATURE_VI_WIN_RESIZE IF_FEATURE_VI_ASK_TERMINAL(&& !G.get_rowcol_error) ) {
unsigned c = columns, r = rows;
query_screen_dimensions();
full_screen |= (c - columns) | (r - rows);
--
cgit v1.2.3-55-g6feb
From 4f0279bd930d02db2d5df51ce878b9b9b940f069 Mon Sep 17 00:00:00 2001
From: Maksym Kryzhanovskyy
Date: Thu, 22 Jul 2010 02:18:05 +0200
Subject: ifplugd: code shrink
function old new delta
ifplugd_main 1089 1161 +72
method_table - 40 +40
detect_link 221 207 -14
static.method 40 - -40
netlink_open 79 - -79
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 1/1 up/down: 112/-133) Total: -21 bytes
Signed-off-by: Denys Vlasenko
---
networking/ifplugd.c | 333 +++++++++++++++++++++++++--------------------------
1 file changed, 164 insertions(+), 169 deletions(-)
diff --git a/networking/ifplugd.c b/networking/ifplugd.c
index eb7442881..2f8c90ffc 100644
--- a/networking/ifplugd.c
+++ b/networking/ifplugd.c
@@ -71,16 +71,6 @@ enum {
# define OPTION_STR "+ansfFi:r:It:u:d:m:pqlx:M"
#endif
-enum { // api mode
- API_AUTO = 'a',
- API_ETHTOOL = 'e',
- API_MII = 'm',
- API_PRIVATE = 'p',
- API_WLAN = 'w',
- API_IFF = 'i',
-};
-static const char api_modes[] ALIGN1 = "aempwi";
-
enum { // interface status
IFSTATUS_ERR = -1,
IFSTATUS_DOWN = 0,
@@ -107,8 +97,6 @@ struct globals {
const char *api_mode;
const char *script_name;
const char *extra_arg;
-
- smallint (*detect_link_func)(void);
};
#define G (*ptr_to_globals)
#define INIT_G() do { \
@@ -123,42 +111,12 @@ struct globals {
} while (0)
-static const char *strstatus(int status)
-{
- if (status == IFSTATUS_ERR)
- return "error";
- return "down\0up" + (status * 5);
-}
+/* Utility routines */
-static int run_script(const char *action)
+static void set_ifreq_to_ifname(struct ifreq *ifreq)
{
- char *env_PREVIOUS, *env_CURRENT;
- char *argv[5];
- int r;
-
- bb_error_msg("executing '%s %s %s'", G.script_name, G.iface, action);
-
- argv[0] = (char*) G.script_name;
- argv[1] = (char*) G.iface;
- argv[2] = (char*) action;
- argv[3] = (char*) G.extra_arg;
- argv[4] = NULL;
-
- env_PREVIOUS = xasprintf("%s=%s", IFPLUGD_ENV_PREVIOUS, strstatus(G.iface_prev_status));
- putenv(env_PREVIOUS);
- env_CURRENT = xasprintf("%s=%s", IFPLUGD_ENV_CURRENT, strstatus(G.iface_last_status));
- putenv(env_CURRENT);
-
- /* r < 0 - can't exec, 0 <= r < 0x180 - exited, >=0x180 - killed by sig (r-0x180) */
- r = spawn_and_wait(argv);
-
- unsetenv(IFPLUGD_ENV_PREVIOUS);
- unsetenv(IFPLUGD_ENV_CURRENT);
- free(env_PREVIOUS);
- free(env_CURRENT);
-
- bb_error_msg("exit code: %d", r & 0xff);
- return (option_mask32 & FLAG_IGNORE_RETVAL) ? 0 : r;
+ memset(ifreq, 0, sizeof(struct ifreq));
+ strncpy_IFNAMSIZ(ifreq->ifr_name, G.iface);
}
static int network_ioctl(int request, void* data, const char *errmsg)
@@ -169,80 +127,7 @@ static int network_ioctl(int request, void* data, const char *errmsg)
return r;
}
-static void set_ifreq_to_ifname(struct ifreq *ifreq)
-{
- memset(ifreq, 0, sizeof(struct ifreq));
- strncpy_IFNAMSIZ(ifreq->ifr_name, G.iface);
-}
-
-static void up_iface(void)
-{
- struct ifreq ifrequest;
-
- if (!G.iface_exists)
- return;
-
- set_ifreq_to_ifname(&ifrequest);
- if (network_ioctl(SIOCGIFFLAGS, &ifrequest, "getting interface flags") < 0) {
- G.iface_exists = 0;
- return;
- }
-
- if (!(ifrequest.ifr_flags & IFF_UP)) {
- ifrequest.ifr_flags |= IFF_UP;
- /* Let user know we mess up with interface */
- bb_error_msg("upping interface");
- if (network_ioctl(SIOCSIFFLAGS, &ifrequest, "setting interface flags") < 0)
- xfunc_die();
- }
-
-#if 0 /* why do we mess with IP addr? It's not our business */
- if (network_ioctl(SIOCGIFADDR, &ifrequest, "can't get interface address") < 0) {
- } else if (ifrequest.ifr_addr.sa_family != AF_INET) {
- bb_perror_msg("the interface is not IP-based");
- } else {
- ((struct sockaddr_in*)(&ifrequest.ifr_addr))->sin_addr.s_addr = INADDR_ANY;
- network_ioctl(SIOCSIFADDR, &ifrequest, "can't set interface address");
- }
- network_ioctl(SIOCGIFFLAGS, &ifrequest, "can't get interface flags");
-#endif
-}
-
-static void maybe_up_new_iface(void)
-{
- if (!(option_mask32 & FLAG_NO_AUTO))
- up_iface();
-
-#if 0 /* bloat */
- struct ifreq ifrequest;
- struct ethtool_drvinfo driver_info;
-
- set_ifreq_to_ifname(&ifrequest);
- driver_info.cmd = ETHTOOL_GDRVINFO;
- ifrequest.ifr_data = &driver_info;
- if (network_ioctl(SIOCETHTOOL, &ifrequest, NULL) == 0) {
- char buf[sizeof("/xx:xx:xx:xx:xx:xx")];
-
- /* Get MAC */
- buf[0] = '\0';
- set_ifreq_to_ifname(&ifrequest);
- if (network_ioctl(SIOCGIFHWADDR, &ifrequest, NULL) == 0) {
- sprintf(buf, "/%02X:%02X:%02X:%02X:%02X:%02X",
- (uint8_t)(ifrequest.ifr_hwaddr.sa_data[0]),
- (uint8_t)(ifrequest.ifr_hwaddr.sa_data[1]),
- (uint8_t)(ifrequest.ifr_hwaddr.sa_data[2]),
- (uint8_t)(ifrequest.ifr_hwaddr.sa_data[3]),
- (uint8_t)(ifrequest.ifr_hwaddr.sa_data[4]),
- (uint8_t)(ifrequest.ifr_hwaddr.sa_data[5]));
- }
-
- bb_error_msg("using interface %s%s with driver<%s> (version: %s)",
- G.iface, buf, driver_info.driver, driver_info.version);
- }
-#endif
- if (G.api_method_num == 0)
- G.detect_link_func = NULL;
-}
+/* Link detection routines and table */
static smallint detect_link_mii(void)
{
@@ -349,18 +234,139 @@ static smallint detect_link_wlan(void)
return IFSTATUS_UP;
}
+enum { // api mode
+ API_ETHTOOL, // 'e'
+ API_MII, // 'm'
+ API_PRIVATE, // 'p'
+ API_WLAN, // 'w'
+ API_IFF, // 'i'
+ API_AUTO, // 'a'
+};
+
+static const char api_modes[] ALIGN1 = "empwia";
+
+static const struct {
+ const char *name;
+ smallint (*func)(void);
+} method_table[] = {
+ { "SIOCETHTOOL" , &detect_link_ethtool },
+ { "SIOCGMIIPHY" , &detect_link_mii },
+ { "SIOCDEVPRIVATE" , &detect_link_priv },
+ { "wireless extension", &detect_link_wlan },
+ { "IFF_RUNNING" , &detect_link_iff },
+};
+
+
+
+static const char *strstatus(int status)
+{
+ if (status == IFSTATUS_ERR)
+ return "error";
+ return "down\0up" + (status * 5);
+}
+
+static int run_script(const char *action)
+{
+ char *env_PREVIOUS, *env_CURRENT;
+ char *argv[5];
+ int r;
+
+ bb_error_msg("executing '%s %s %s'", G.script_name, G.iface, action);
+
+ argv[0] = (char*) G.script_name;
+ argv[1] = (char*) G.iface;
+ argv[2] = (char*) action;
+ argv[3] = (char*) G.extra_arg;
+ argv[4] = NULL;
+
+ env_PREVIOUS = xasprintf("%s=%s", IFPLUGD_ENV_PREVIOUS, strstatus(G.iface_prev_status));
+ putenv(env_PREVIOUS);
+ env_CURRENT = xasprintf("%s=%s", IFPLUGD_ENV_CURRENT, strstatus(G.iface_last_status));
+ putenv(env_CURRENT);
+
+ /* r < 0 - can't exec, 0 <= r < 0x180 - exited, >=0x180 - killed by sig (r-0x180) */
+ r = spawn_and_wait(argv);
+
+ unsetenv(IFPLUGD_ENV_PREVIOUS);
+ unsetenv(IFPLUGD_ENV_CURRENT);
+ free(env_PREVIOUS);
+ free(env_CURRENT);
+
+ bb_error_msg("exit code: %d", r & 0xff);
+ return (option_mask32 & FLAG_IGNORE_RETVAL) ? 0 : r;
+}
+
+static void up_iface(void)
+{
+ struct ifreq ifrequest;
+
+ if (!G.iface_exists)
+ return;
+
+ set_ifreq_to_ifname(&ifrequest);
+ if (network_ioctl(SIOCGIFFLAGS, &ifrequest, "getting interface flags") < 0) {
+ G.iface_exists = 0;
+ return;
+ }
+
+ if (!(ifrequest.ifr_flags & IFF_UP)) {
+ ifrequest.ifr_flags |= IFF_UP;
+ /* Let user know we mess up with interface */
+ bb_error_msg("upping interface");
+ if (network_ioctl(SIOCSIFFLAGS, &ifrequest, "setting interface flags") < 0)
+ xfunc_die();
+ }
+
+#if 0 /* why do we mess with IP addr? It's not our business */
+ if (network_ioctl(SIOCGIFADDR, &ifrequest, "can't get interface address") < 0) {
+ } else if (ifrequest.ifr_addr.sa_family != AF_INET) {
+ bb_perror_msg("the interface is not IP-based");
+ } else {
+ ((struct sockaddr_in*)(&ifrequest.ifr_addr))->sin_addr.s_addr = INADDR_ANY;
+ network_ioctl(SIOCSIFADDR, &ifrequest, "can't set interface address");
+ }
+ network_ioctl(SIOCGIFFLAGS, &ifrequest, "can't get interface flags");
+#endif
+}
+
+static void maybe_up_new_iface(void)
+{
+ if (!(option_mask32 & FLAG_NO_AUTO))
+ up_iface();
+
+#if 0 /* bloat */
+ struct ifreq ifrequest;
+ struct ethtool_drvinfo driver_info;
+
+ set_ifreq_to_ifname(&ifrequest);
+ driver_info.cmd = ETHTOOL_GDRVINFO;
+ ifrequest.ifr_data = &driver_info;
+ if (network_ioctl(SIOCETHTOOL, &ifrequest, NULL) == 0) {
+ char buf[sizeof("/xx:xx:xx:xx:xx:xx")];
+
+ /* Get MAC */
+ buf[0] = '\0';
+ set_ifreq_to_ifname(&ifrequest);
+ if (network_ioctl(SIOCGIFHWADDR, &ifrequest, NULL) == 0) {
+ sprintf(buf, "/%02X:%02X:%02X:%02X:%02X:%02X",
+ (uint8_t)(ifrequest.ifr_hwaddr.sa_data[0]),
+ (uint8_t)(ifrequest.ifr_hwaddr.sa_data[1]),
+ (uint8_t)(ifrequest.ifr_hwaddr.sa_data[2]),
+ (uint8_t)(ifrequest.ifr_hwaddr.sa_data[3]),
+ (uint8_t)(ifrequest.ifr_hwaddr.sa_data[4]),
+ (uint8_t)(ifrequest.ifr_hwaddr.sa_data[5]));
+ }
+
+ bb_error_msg("using interface %s%s with driver<%s> (version: %s)",
+ G.iface, buf, driver_info.driver, driver_info.version);
+ }
+#endif
+ if (G.api_mode[0] == 'a')
+ G.api_method_num = API_AUTO;
+}
+
static smallint detect_link(void)
{
- static const struct {
- const char *name;
- smallint (*func)(void);
- } method[] = {
- { "SIOCETHTOOL" , &detect_link_ethtool },
- { "SIOCGMIIPHY" , &detect_link_mii },
- { "SIOCDEVPRIVATE" , &detect_link_priv },
- { "wireless extension", &detect_link_wlan },
- { "IFF_RUNNING" , &detect_link_iff },
- };
smallint status;
if (!G.iface_exists)
@@ -373,38 +379,34 @@ static smallint detect_link(void)
if (!(option_mask32 & FLAG_NO_AUTO))
up_iface();
- if (!G.detect_link_func) {
- if (G.api_method_num == 0) {
- int i;
- smallint sv_logmode;
-
- sv_logmode = logmode;
- for (i = 0; i < ARRAY_SIZE(method); i++) {
- logmode = LOGMODE_NONE;
- status = method[i].func();
- logmode = sv_logmode;
- if (status != IFSTATUS_ERR) {
- G.detect_link_func = method[i].func;
- bb_error_msg("using %s detection mode", method[i].name);
- goto _2;
- }
+ if (G.api_method_num == API_AUTO) {
+ int i;
+ smallint sv_logmode;
+
+ sv_logmode = logmode;
+ for (i = 0; i < ARRAY_SIZE(method_table); i++) {
+ logmode = LOGMODE_NONE;
+ status = method_table[i].func();
+ logmode = sv_logmode;
+ if (status != IFSTATUS_ERR) {
+ G.api_method_num = i;
+ bb_error_msg("using %s detection mode", method_table[i].name);
+ break;
}
- goto _1;
}
- G.detect_link_func = method[G.api_method_num - 1].func;
+ } else {
+ status = method_table[G.api_method_num].func();
}
- status = G.detect_link_func();
- _1:
if (status == IFSTATUS_ERR) {
if (option_mask32 & FLAG_IGNORE_FAIL)
status = IFSTATUS_DOWN;
else if (option_mask32 & FLAG_IGNORE_FAIL_POSITIVE)
status = IFSTATUS_UP;
- else if (G.api_method_num == 0)
+ else if (G.api_mode[0] == 'a')
bb_error_msg("can't detect link status");
}
- _2:
+
if (status != G.iface_last_status) {
G.iface_prev_status = G.iface_last_status;
G.iface_last_status = status;
@@ -475,23 +477,6 @@ static NOINLINE int check_existence_through_netlink(void)
return G.iface_exists;
}
-static NOINLINE int netlink_open(void)
-{
- int fd;
- struct sockaddr_nl addr;
-
- fd = xsocket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
-
- memset(&addr, 0, sizeof(addr));
- addr.nl_family = AF_NETLINK;
- addr.nl_groups = RTMGRP_LINK;
- addr.nl_pid = getpid();
-
- xbind(fd, (struct sockaddr*)&addr, sizeof(addr));
-
- return fd;
-}
-
#if ENABLE_FEATURE_PIDFILE
static NOINLINE pid_t read_pid(const char *filename)
{
@@ -545,6 +530,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
if (pid_from_pidfile > 0 && kill(pid_from_pidfile, 0) == 0)
bb_error_msg_and_die("daemon already running");
#endif
+
api_mode_found = strchr(api_modes, G.api_mode[0]);
if (!api_mode_found)
bb_error_msg_and_die("unknown API mode '%s'", G.api_mode);
@@ -555,7 +541,16 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
xmove_fd(xsocket(AF_INET, SOCK_DGRAM, 0), ioctl_fd);
if (opts & FLAG_MONITOR) {
- xmove_fd(netlink_open(), netlink_fd);
+ struct sockaddr_nl addr;
+ int fd = xsocket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
+
+ memset(&addr, 0, sizeof(addr));
+ addr.nl_family = AF_NETLINK;
+ addr.nl_groups = RTMGRP_LINK;
+ addr.nl_pid = getpid();
+
+ xbind(fd, (struct sockaddr*)&addr, sizeof(addr));
+ xmove_fd(fd, netlink_fd);
}
write_pidfile(pidfile_name);
--
cgit v1.2.3-55-g6feb
From b78ac5a20ea2f3038f9738cb05bc3bc3725fabba Mon Sep 17 00:00:00 2001
From: Natanael Copa
Date: Fri, 23 Jul 2010 01:31:24 +0200
Subject: libnetlink: code shrink
function old new delta
xrtnl_open 95 93 -2
parse_rtattr 87 85 -2
rtnl_close 9 - -9
xrtnl_wilddump_request 101 64 -37
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/3 up/down: 0/-50) Total: -50 bytes
Signed-off-by: Natanael Copa
Signed-off-by: Denys Vlasenko
---
networking/libiproute/libnetlink.c | 38 ++++++++++++++------------------------
networking/libiproute/libnetlink.h | 6 +++---
2 files changed, 17 insertions(+), 27 deletions(-)
diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c
index ba24832d6..8da80b2fc 100644
--- a/networking/libiproute/libnetlink.c
+++ b/networking/libiproute/libnetlink.c
@@ -1,14 +1,13 @@
/* vi: set sw=4 ts=4: */
/*
- * libnetlink.c RTnetlink service routines.
+ * RTnetlink service routines.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Authors: Alexey Kuznetsov,
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
*
+ * Authors: Alexey Kuznetsov,
*/
#include
@@ -17,12 +16,7 @@
#include "libbb.h"
#include "libnetlink.h"
-void FAST_FUNC rtnl_close(struct rtnl_handle *rth)
-{
- close(rth->fd);
-}
-
-int FAST_FUNC xrtnl_open(struct rtnl_handle *rth/*, unsigned subscriptions*/)
+void FAST_FUNC xrtnl_open(struct rtnl_handle *rth/*, unsigned subscriptions*/)
{
socklen_t addr_len;
@@ -44,7 +38,6 @@ int FAST_FUNC xrtnl_open(struct rtnl_handle *rth/*, unsigned subscriptions*/)
bb_error_msg_and_die("wrong address family %d", rth->local.nl_family);
*/
rth->seq = time(NULL);
- return 0;
}
int FAST_FUNC xrtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
@@ -53,10 +46,6 @@ int FAST_FUNC xrtnl_wilddump_request(struct rtnl_handle *rth, int family, int ty
struct nlmsghdr nlh;
struct rtgenmsg g;
} req;
- struct sockaddr_nl nladdr;
-
- memset(&nladdr, 0, sizeof(nladdr));
- nladdr.nl_family = AF_NETLINK;
req.nlh.nlmsg_len = sizeof(req);
req.nlh.nlmsg_type = type;
@@ -65,8 +54,7 @@ int FAST_FUNC xrtnl_wilddump_request(struct rtnl_handle *rth, int family, int ty
req.nlh.nlmsg_seq = rth->dump = ++rth->seq;
req.g.rtgen_family = family;
- return xsendto(rth->fd, (void*)&req, sizeof(req),
- (struct sockaddr*)&nladdr, sizeof(nladdr));
+ return rtnl_send(rth, (void*)&req, sizeof(req));
}
int FAST_FUNC rtnl_send(struct rtnl_handle *rth, char *buf, int len)
@@ -339,8 +327,10 @@ int FAST_FUNC addattr32(struct nlmsghdr *n, int maxlen, int type, uint32_t data)
{
int len = RTA_LENGTH(4);
struct rtattr *rta;
- if ((int)(NLMSG_ALIGN(n->nlmsg_len) + len) > maxlen)
+
+ if ((int)(NLMSG_ALIGN(n->nlmsg_len) + len) > maxlen) {
return -1;
+ }
rta = (struct rtattr*)(((char*)n) + NLMSG_ALIGN(n->nlmsg_len));
rta->rta_type = type;
rta->rta_len = len;
@@ -354,8 +344,9 @@ int FAST_FUNC addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, in
int len = RTA_LENGTH(alen);
struct rtattr *rta;
- if ((int)(NLMSG_ALIGN(n->nlmsg_len) + len) > maxlen)
+ if ((int)(NLMSG_ALIGN(n->nlmsg_len) + len) > maxlen) {
return -1;
+ }
rta = (struct rtattr*)(((char*)n) + NLMSG_ALIGN(n->nlmsg_len));
rta->rta_type = type;
rta->rta_len = len;
@@ -397,7 +388,7 @@ int FAST_FUNC rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data
}
-int FAST_FUNC parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len)
+void FAST_FUNC parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len)
{
while (RTA_OK(rta, len)) {
if (rta->rta_type <= max) {
@@ -408,5 +399,4 @@ int FAST_FUNC parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int
if (len) {
bb_error_msg("deficit %d, rta_len=%d!", len, rta->rta_len);
}
- return 0;
}
diff --git a/networking/libiproute/libnetlink.h b/networking/libiproute/libnetlink.h
index 41ecfa6d0..4e4d5b7b9 100644
--- a/networking/libiproute/libnetlink.h
+++ b/networking/libiproute/libnetlink.h
@@ -18,8 +18,8 @@ struct rtnl_handle {
uint32_t dump;
};
-extern int xrtnl_open(struct rtnl_handle *rth) FAST_FUNC;
-extern void rtnl_close(struct rtnl_handle *rth) FAST_FUNC;
+extern void xrtnl_open(struct rtnl_handle *rth) FAST_FUNC;
+#define rtnl_close(rth) (close((rth)->fd))
extern int xrtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type) FAST_FUNC;
extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len) FAST_FUNC;
extern int xrtnl_dump_filter(struct rtnl_handle *rth,
@@ -42,7 +42,7 @@ extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int a
extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, uint32_t data) FAST_FUNC;
extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen) FAST_FUNC;
-extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len) FAST_FUNC;
+extern void parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len) FAST_FUNC;
POP_SAVED_FUNCTION_VISIBILITY
--
cgit v1.2.3-55-g6feb
From e0a622093c6c1f3e3a1f58713118395994000fd9 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Sat, 24 Jul 2010 23:26:58 +0200
Subject: ip: fix "ip r" breakage
function old new delta
static.ip_func_ptrs - 32 +32
ip_main 110 53 -57
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 32/-57) Total: -25 bytes
Signed-off-by: Denys Vlasenko
---
networking/ip.c | 62 +++++++++++++++++++++------------------------------------
1 file changed, 23 insertions(+), 39 deletions(-)
diff --git a/networking/ip.c b/networking/ip.c
index 7a0f308f0..3a99fa320 100644
--- a/networking/ip.c
+++ b/networking/ip.c
@@ -1,14 +1,12 @@
/* vi: set sw=4 ts=4: */
/*
- * ip.c "ip" utility frontend.
+ * "ip" utility frontend.
*
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*
- * Authors: Alexey Kuznetsov,
- *
+ * Authors: Alexey Kuznetsov,
*
* Changes:
- *
* Rani Assaf 980929: resolve addresses
* Bernhard Reutner-Fischer rewrote to use index_in_substr_array
*/
@@ -24,12 +22,14 @@
|| ENABLE_FEATURE_IP_TUNNEL \
|| ENABLE_FEATURE_IP_RULE
-static int NORETURN ip_print_help(char **argv UNUSED_PARAM)
+static int ip_print_help(char **argv UNUSED_PARAM)
{
bb_show_usage();
}
-static int ip_do(int (*ip_func)(char **argv), char **argv)
+typedef int (*ip_func_ptr_t)(char**);
+
+static int ip_do(ip_func_ptr_t ip_func, char **argv)
{
argv = ip_parse_common_args(argv + 1);
return ip_func(argv);
@@ -78,45 +78,29 @@ int ip_main(int argc UNUSED_PARAM, char **argv)
static const char keywords[] ALIGN1 =
IF_FEATURE_IP_ADDRESS("address\0")
IF_FEATURE_IP_ROUTE("route\0")
+ IF_FEATURE_IP_ROUTE("r\0")
IF_FEATURE_IP_LINK("link\0")
- IF_FEATURE_IP_TUNNEL("tunnel\0" "tunl\0")
+ IF_FEATURE_IP_TUNNEL("tunnel\0")
+ IF_FEATURE_IP_TUNNEL("tunl\0")
IF_FEATURE_IP_RULE("rule\0")
;
- enum {
- IF_FEATURE_IP_ADDRESS(IP_addr,)
- IF_FEATURE_IP_ROUTE(IP_route,)
- IF_FEATURE_IP_LINK(IP_link,)
- IF_FEATURE_IP_TUNNEL(IP_tunnel, IP_tunl,)
- IF_FEATURE_IP_RULE(IP_rule,)
- IP_none
+ static const ip_func_ptr_t ip_func_ptrs[] = {
+ ip_print_help,
+ IF_FEATURE_IP_ADDRESS(do_ipaddr,)
+ IF_FEATURE_IP_ROUTE(do_iproute,)
+ IF_FEATURE_IP_ROUTE(do_iproute,)
+ IF_FEATURE_IP_LINK(do_iplink,)
+ IF_FEATURE_IP_TUNNEL(do_iptunnel,)
+ IF_FEATURE_IP_TUNNEL(do_iptunnel,)
+ IF_FEATURE_IP_RULE(do_iprule,)
};
- int (*ip_func)(char**) = ip_print_help;
+ ip_func_ptr_t ip_func;
+ int key;
argv = ip_parse_common_args(argv + 1);
- if (*argv) {
- int key = index_in_substrings(keywords, *argv);
- argv++;
-#if ENABLE_FEATURE_IP_ADDRESS
- if (key == IP_addr)
- ip_func = do_ipaddr;
-#endif
-#if ENABLE_FEATURE_IP_ROUTE
- if (key == IP_route)
- ip_func = do_iproute;
-#endif
-#if ENABLE_FEATURE_IP_LINK
- if (key == IP_link)
- ip_func = do_iplink;
-#endif
-#if ENABLE_FEATURE_IP_TUNNEL
- if (key == IP_tunnel || key == IP_tunl)
- ip_func = do_iptunnel;
-#endif
-#if ENABLE_FEATURE_IP_RULE
- if (key == IP_rule)
- ip_func = do_iprule;
-#endif
- }
+ key = *argv ? index_in_substrings(keywords, *argv++) : -1;
+ ip_func = ip_func_ptrs[key + 1];
+
return ip_func(argv);
}
--
cgit v1.2.3-55-g6feb
From 2e9b5510d687e5418bea85c3b04ad1e1fa797b6f Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Sat, 24 Jul 2010 23:27:38 +0200
Subject: libiproute: code shrink by adding FAST_FUNC
function old new delta
ipaddr_list_or_flush 1282 1293 +11
ip_parse_common_args 153 151 -2
ip_main 53 50 -3
ip_do 19 15 -4
do_iptunnel 985 980 -5
do_iprule 982 977 -5
do_iplink 1637 1631 -6
do_iproute 2105 2098 -7
do_ipaddr 1406 1398 -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/8 up/down: 11/-40) Total: -29 bytes
Signed-off-by: Denys Vlasenko
---
networking/ip.c | 4 ++--
networking/libiproute/ip_common.h | 29 ++++++++++++++--------------
networking/libiproute/ip_parse_common_args.c | 2 +-
networking/libiproute/ipaddress.c | 4 ++--
networking/libiproute/iplink.c | 2 +-
networking/libiproute/iproute.c | 2 +-
networking/libiproute/iprule.c | 2 +-
networking/libiproute/iptunnel.c | 2 +-
8 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/networking/ip.c b/networking/ip.c
index 3a99fa320..004289667 100644
--- a/networking/ip.c
+++ b/networking/ip.c
@@ -22,12 +22,12 @@
|| ENABLE_FEATURE_IP_TUNNEL \
|| ENABLE_FEATURE_IP_RULE
-static int ip_print_help(char **argv UNUSED_PARAM)
+static int FAST_FUNC ip_print_help(char **argv UNUSED_PARAM)
{
bb_show_usage();
}
-typedef int (*ip_func_ptr_t)(char**);
+typedef int FAST_FUNC (*ip_func_ptr_t)(char**);
static int ip_do(ip_func_ptr_t ip_func, char **argv)
{
diff --git a/networking/libiproute/ip_common.h b/networking/libiproute/ip_common.h
index aef325281..30c7e595b 100644
--- a/networking/libiproute/ip_common.h
+++ b/networking/libiproute/ip_common.h
@@ -15,22 +15,21 @@
PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
-extern char **ip_parse_common_args(char **argv);
-extern int print_neigh(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
-extern int ipaddr_list_or_flush(char **argv, int flush);
-extern int iproute_monitor(char **argv);
-extern void iplink_usage(void) NORETURN;
-extern void ipneigh_reset_filter(void);
+char FAST_FUNC **ip_parse_common_args(char **argv);
+//int FAST_FUNC print_neigh(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
+int FAST_FUNC ipaddr_list_or_flush(char **argv, int flush);
+//int FAST_FUNC iproute_monitor(char **argv);
+//void FAST_FUNC ipneigh_reset_filter(void);
-extern int do_ipaddr(char **argv);
-extern int do_iproute(char **argv);
-extern int do_iprule(char **argv);
-extern int do_ipneigh(char **argv);
-extern int do_iptunnel(char **argv);
-extern int do_iplink(char **argv);
-extern int do_ipmonitor(char **argv);
-extern int do_multiaddr(char **argv);
-extern int do_multiroute(char **argv);
+int FAST_FUNC do_ipaddr(char **argv);
+int FAST_FUNC do_iproute(char **argv);
+int FAST_FUNC do_iprule(char **argv);
+//int FAST_FUNC do_ipneigh(char **argv);
+int FAST_FUNC do_iptunnel(char **argv);
+int FAST_FUNC do_iplink(char **argv);
+//int FAST_FUNC do_ipmonitor(char **argv);
+//int FAST_FUNC do_multiaddr(char **argv);
+//int FAST_FUNC do_multiroute(char **argv);
POP_SAVED_FUNCTION_VISIBILITY
diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c
index 5e4012b81..bf01528c4 100644
--- a/networking/libiproute/ip_parse_common_args.c
+++ b/networking/libiproute/ip_parse_common_args.c
@@ -22,7 +22,7 @@ family_t preferred_family = AF_UNSPEC;
smallint oneline;
char _SL_;
-char **ip_parse_common_args(char **argv)
+char** FAST_FUNC ip_parse_common_args(char **argv)
{
static const char ip_common_commands[] ALIGN1 =
"oneline" "\0"
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index 381293412..b6f469d0f 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -415,7 +415,7 @@ static void ipaddr_reset_filter(int _oneline)
}
/* Return value becomes exitcode. It's okay to not return at all */
-int ipaddr_list_or_flush(char **argv, int flush)
+int FAST_FUNC ipaddr_list_or_flush(char **argv, int flush)
{
static const char option[] ALIGN1 = "to\0""scope\0""up\0""label\0""dev\0";
@@ -747,7 +747,7 @@ static int ipaddr_modify(int cmd, char **argv)
}
/* Return value becomes exitcode. It's okay to not return at all */
-int do_ipaddr(char **argv)
+int FAST_FUNC do_ipaddr(char **argv)
{
static const char commands[] ALIGN1 =
"add\0""delete\0""list\0""show\0""lst\0""flush\0";
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c
index 8bf892797..9f9218573 100644
--- a/networking/libiproute/iplink.c
+++ b/networking/libiproute/iplink.c
@@ -362,7 +362,7 @@ static int do_change(char **argv, const unsigned rtm)
}
/* Return value becomes exitcode. It's okay to not return at all */
-int do_iplink(char **argv)
+int FAST_FUNC do_iplink(char **argv)
{
static const char keywords[] ALIGN1 =
"add\0""delete\0""set\0""show\0""lst\0""list\0";
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index d771a609b..8dba2bf3d 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -869,7 +869,7 @@ static int iproute_get(char **argv)
}
/* Return value becomes exitcode. It's okay to not return at all */
-int do_iproute(char **argv)
+int FAST_FUNC do_iproute(char **argv)
{
static const char ip_route_commands[] ALIGN1 =
/*0-3*/ "add\0""append\0""change\0""chg\0"
diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c
index 835529ec4..3af6a83a8 100644
--- a/networking/libiproute/iprule.c
+++ b/networking/libiproute/iprule.c
@@ -304,7 +304,7 @@ static int iprule_modify(int cmd, char **argv)
}
/* Return value becomes exitcode. It's okay to not return at all */
-int do_iprule(char **argv)
+int FAST_FUNC do_iprule(char **argv)
{
static const char ip_rule_commands[] ALIGN1 =
"add\0""delete\0""list\0""show\0";
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c
index 257343826..8389ef348 100644
--- a/networking/libiproute/iptunnel.c
+++ b/networking/libiproute/iptunnel.c
@@ -556,7 +556,7 @@ static int do_show(char **argv)
}
/* Return value becomes exitcode. It's okay to not return at all */
-int do_iptunnel(char **argv)
+int FAST_FUNC do_iptunnel(char **argv)
{
static const char keywords[] ALIGN1 =
"add\0""change\0""delete\0""show\0""list\0""lst\0";
--
cgit v1.2.3-55-g6feb
From 451add4f23c14459734e05104ea0bc5ed4de39ee Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Sun, 25 Jul 2010 00:06:41 +0200
Subject: lineedit: mostly revert recent wrong logic in "ask terminal" code
Signed-off-by: Denys Vlasenko
---
libbb/lineedit.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index a62ab6d29..6df556f4e 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -149,7 +149,6 @@ struct lineedit_statics {
CHAR_T delbuf[DELBUFSIZ]; /* a place to store deleted characters */
#endif
#if ENABLE_FEATURE_EDITING_ASK_TERMINAL
- smallint unknown_width;
smallint sent_ESC_br6n;
#endif
@@ -1611,16 +1610,14 @@ static void ask_terminal(void)
* poll([{fd=0, events=POLLIN}], 1, 4294967295) = 1 ([{fd=0, revents=POLLIN}])
* read(0, "\n", 1) = 1 <-- oh crap, user's input got in first
*/
- if (S.unknown_width) { /* only if window size is not known */
- struct pollfd pfd;
-
- pfd.fd = STDIN_FILENO;
- pfd.events = POLLIN;
- if (safe_poll(&pfd, 1, 0) == 0) {
- S.sent_ESC_br6n = 1;
- fputs("\033" "[6n", stdout);
- fflush_all(); /* make terminal see it ASAP! */
- }
+ struct pollfd pfd;
+
+ pfd.fd = STDIN_FILENO;
+ pfd.events = POLLIN;
+ if (safe_poll(&pfd, 1, 0) == 0) {
+ S.sent_ESC_br6n = 1;
+ fputs("\033" "[6n", stdout);
+ fflush_all(); /* make terminal see it ASAP! */
}
}
#else
@@ -1768,7 +1765,7 @@ static void win_changed(int nsig)
{
int sv_errno = errno;
unsigned width;
- IF_FEATURE_EDITING_ASK_TERMINAL(S.unknown_width =) get_terminal_width_height(0, &width, NULL);
+ get_terminal_width_height(0, &width, NULL);
cmdedit_setwidth(width, nsig /* - just a yes/no flag */);
if (nsig == SIGWINCH)
signal(SIGWINCH, win_changed); /* rearm ourself */
--
cgit v1.2.3-55-g6feb
From 535ce1df5cb6a2bf588e1c2655cf09f49ed455db Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Sun, 25 Jul 2010 03:20:25 +0200
Subject: httpd: cosmetic fixes, no code changes
Signed-off-by: Denys Vlasenko
---
networking/httpd.c | 53 +++++++++++++++++++++++------------------------------
1 file changed, 23 insertions(+), 30 deletions(-)
diff --git a/networking/httpd.c b/networking/httpd.c
index 8ad7e88b1..12bad597a 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -5,23 +5,20 @@
* Copyright (C) 2002,2003 Glenn Engel
* Copyright (C) 2003-2006 Vladimir Oleynik
*
- * simplify patch stolen from libbb without using strdup
- *
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
*****************************************************************************
*
* Typical usage:
- * for non root user
- * httpd -p 8080 -h $HOME/public_html
- * or for daemon start from rc script with uid=0:
- * httpd -u www
- * This is equivalent if www user have uid=80 to
- * httpd -p 80 -u 80 -h /www -c /etc/httpd.conf -r "Web Server Authentication"
- *
+ * For non root user:
+ * httpd -p 8080 -h $HOME/public_html
+ * For daemon start from rc script with uid=0:
+ * httpd -u www
+ * which is equivalent to (assuming user www has uid 80):
+ * httpd -p 80 -u 80 -h $PWD -c /etc/httpd.conf -r "Web Server Authentication"
*
- * When an url starts by "/cgi-bin/" it is assumed to be a cgi script. The
- * server changes directory to the location of the script and executes it
+ * When an url starts with "/cgi-bin/" it is assumed to be a cgi script.
+ * The server changes directory to the location of the script and executes it
* after setting QUERY_STRING and other environment variables.
*
* Doc:
@@ -29,8 +26,8 @@
*
* The applet can also be invoked as an url arg decoder and html text encoder
* as follows:
- * foo=`httpd -d $foo` # decode "Hello%20World" as "Hello World"
- * bar=`httpd -e ""` # encode as "<Hello World>"
+ * foo=`httpd -d $foo` # decode "Hello%20World" as "Hello World"
+ * bar=`httpd -e ""` # encode as "<Hello World>"
* Note that url encoding for arguments is not the same as html encoding for
* presentation. -d decodes an url-encoded argument while -e encodes in html
* for page display.
@@ -100,15 +97,14 @@
#if ENABLE_FEATURE_HTTPD_USE_SENDFILE
# include
#endif
-
-#define DEBUG 0
-
-#define IOBUF_SIZE 8192 /* IO buffer */
-
/* amount of buffering in a pipe */
#ifndef PIPE_BUF
# define PIPE_BUF 4096
#endif
+
+#define DEBUG 0
+
+#define IOBUF_SIZE 8192
#if PIPE_BUF >= IOBUF_SIZE
# error "PIPE_BUF >= IOBUF_SIZE"
#endif
@@ -118,6 +114,7 @@
static const char DEFAULT_PATH_HTTPD_CONF[] ALIGN1 = "/etc";
static const char HTTPD_CONF[] ALIGN1 = "httpd.conf";
static const char HTTP_200[] ALIGN1 = "HTTP/1.0 200 OK\r\n";
+static const char index_html[] ALIGN1 = "index.html";
typedef struct has_next_ptr {
struct has_next_ptr *next;
@@ -170,7 +167,6 @@ enum {
HTTP_PAYMENT_REQUIRED = 402,
HTTP_BAD_GATEWAY = 502,
HTTP_SERVICE_UNAVAILABLE = 503, /* overload, maintenance */
- HTTP_RESPONSE_SETSIZE = 0xffffffff
#endif
};
@@ -231,9 +227,6 @@ static const struct {
#endif
};
-static const char index_html[] ALIGN1 = "index.html";
-
-
struct globals {
int verbose; /* must be int (used by getopt32) */
smallint flg_deny_all;
@@ -777,7 +770,7 @@ static char *encodeString(const char *string)
char *p = out;
char ch;
- while ((ch = *string++)) {
+ while ((ch = *string++) != '\0') {
/* very simple check for what to encode */
if (isalnum(ch))
*p++ = ch;
@@ -787,7 +780,7 @@ static char *encodeString(const char *string)
*p = '\0';
return out;
}
-#endif /* FEATURE_HTTPD_ENCODE_URL_STR */
+#endif
/*
* Given a URL encoded string, convert it to plain ascii.
@@ -814,12 +807,12 @@ static unsigned hex_to_bin(unsigned char c)
if (v <= 5)
return v + 10;
return ~0;
-}
/* For testing:
void t(char c) { printf("'%c'(%u) %u\n", c, c, hex_to_bin(c)); }
int main() { t(0x10); t(0x20); t('0'); t('9'); t('A'); t('F'); t('a'); t('f');
t('0'-1); t('9'+1); t('A'-1); t('F'+1); t('a'-1); t('f'+1); return 0; }
*/
+}
static char *decodeString(char *orig, int option_d)
{
/* note that decoded string is always shorter than original */
@@ -1964,7 +1957,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
if (http_major_version >= '0') {
/* Request was with "... HTTP/nXXX", and n >= 0 */
- /* Read until blank line for HTTP version specified, else parse immediate */
+ /* Read until blank line */
while (1) {
if (!get_line())
break; /* EOF or error or empty line */
@@ -1991,9 +1984,9 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
if ((STRNCASECMP(iobuf, "Content-length:") == 0)) {
/* extra read only for POST */
if (prequest != request_GET
-#if ENABLE_FEATURE_HTTPD_CGI
+# if ENABLE_FEATURE_HTTPD_CGI
&& prequest != request_HEAD
-#endif
+# endif
) {
tptr = skip_whitespace(iobuf + sizeof("Content-length:") - 1);
if (!tptr[0])
@@ -2183,9 +2176,9 @@ static void mini_httpd(int server_socket)
/* Wait for connections... */
fromAddr.len = LSA_SIZEOF_SA;
n = accept(server_socket, &fromAddr.u.sa, &fromAddr.len);
-
if (n < 0)
continue;
+
/* set the KEEPALIVE option to cull dead connections */
setsockopt(n, SOL_SOCKET, SO_KEEPALIVE, &const_int_1, sizeof(const_int_1));
@@ -2226,9 +2219,9 @@ static void mini_httpd_nommu(int server_socket, int argc, char **argv)
/* Wait for connections... */
fromAddr.len = LSA_SIZEOF_SA;
n = accept(server_socket, &fromAddr.u.sa, &fromAddr.len);
-
if (n < 0)
continue;
+
/* set the KEEPALIVE option to cull dead connections */
setsockopt(n, SOL_SOCKET, SO_KEEPALIVE, &const_int_1, sizeof(const_int_1));
--
cgit v1.2.3-55-g6feb
From 7a2ba329b9235af4c647e0a88c1db023b51cf8a4 Mon Sep 17 00:00:00 2001
From: Peter Korsgaard
Date: Sun, 25 Jul 2010 03:20:53 +0200
Subject: httpd: optional support for gzip-compressed pages
function old new delta
send_file_and_exit 662 761 +99
handle_incoming_and_exit 2756 2830 +74
send_headers 603 654 +51
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 224/0) Total: 224 bytes
Signed-off-by: Peter Korsgaard
Signed-off-by: Denys Vlasenko
---
networking/Config.src | 8 ++++++++
networking/httpd.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 60 insertions(+), 4 deletions(-)
diff --git a/networking/Config.src b/networking/Config.src
index 2d29c423a..8604c53e9 100644
--- a/networking/Config.src
+++ b/networking/Config.src
@@ -270,6 +270,14 @@ config FEATURE_HTTPD_PROXY
Then a request to /url/myfile will be forwarded to
http://hostname[:port]/new/path/myfile.
+config FEATURE_HTTPD_GZIP
+ bool "Support for GZIP content encoding"
+ default y
+ depends on HTTPD
+ help
+ Makes httpd send files using GZIP content encoding if the
+ client supports it and a pre-compressed .gz exists.
+
config IFCONFIG
bool "ifconfig"
default y
diff --git a/networking/httpd.c b/networking/httpd.c
index 12bad597a..cad45cd5d 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -277,6 +277,10 @@ struct globals {
#if ENABLE_FEATURE_HTTPD_PROXY
Htaccess_Proxy *proxy;
#endif
+#if ENABLE_FEATURE_HTTPD_GZIP
+ /* client can handle gzip / we are going to send gzip */
+ smallint content_gzip;
+#endif
};
#define G (*ptr_to_globals)
#define verbose (G.verbose )
@@ -319,6 +323,11 @@ enum {
#define hdr_cnt (G.hdr_cnt )
#define http_error_page (G.http_error_page )
#define proxy (G.proxy )
+#if ENABLE_FEATURE_HTTPD_GZIP
+# define content_gzip (G.content_gzip )
+#else
+# define content_gzip 0
+#endif
#define INIT_G() do { \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \
@@ -1027,10 +1036,14 @@ static void send_headers(int responseNum)
#endif
"Last-Modified: %s\r\n%s %"OFF_FMT"u\r\n",
tmp_str,
- "Content-length:",
+ content_gzip ? "Transfer-length:" : "Content-length:",
file_size
);
}
+
+ if (content_gzip)
+ len += sprintf(iobuf + len, "Content-Encoding: gzip\r\n");
+
iobuf[len++] = '\r';
iobuf[len++] = '\n';
if (infoString) {
@@ -1500,7 +1513,22 @@ static NOINLINE void send_file_and_exit(const char *url, int what)
int fd;
ssize_t count;
- fd = open(url, O_RDONLY);
+ if (content_gzip) {
+ /* does .gz exist? Then use it instead */
+ char *gzurl = xasprintf("%s.gz", url);
+ fd = open(gzurl, O_RDONLY);
+ free(gzurl);
+ if (fd != -1) {
+ struct stat sb;
+ fstat(fd, &sb);
+ file_size = sb.st_size;
+ } else {
+ IF_FEATURE_HTTPD_GZIP(content_gzip = 0;)
+ fd = open(url, O_RDONLY);
+ }
+ } else {
+ fd = open(url, O_RDONLY);
+ }
if (fd < 0) {
if (DEBUG)
bb_perror_msg("can't open '%s'", url);
@@ -1583,8 +1611,11 @@ static NOINLINE void send_file_and_exit(const char *url, int what)
url, found_mime_type);
#if ENABLE_FEATURE_HTTPD_RANGES
- if (what == SEND_BODY)
- range_start = 0; /* err pages and ranges don't mix */
+ if (what == SEND_BODY /* err pages and ranges don't mix */
+ || content_gzip /* we are sending compressed page: can't do ranges */ ///why?
+ ) {
+ range_start = 0;
+ }
range_len = MAXINT(off_t);
if (range_start) {
if (!range_end) {
@@ -2047,6 +2078,23 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
}
}
}
+#endif
+#if ENABLE_FEATURE_HTTPD_GZIP
+ if (STRNCASECMP(iobuf, "Accept-Encoding:") == 0) {
+ char *s = iobuf + sizeof("Accept-Encoding:")-1;
+ while (*s) {
+ ///is "Accept-Encoding: compress,gzip" valid?
+ // (that is, no space after ',') -
+ // this code won't handle that
+ s = skip_whitespace(s);
+ if (STRNCASECMP(s, "gzip") == 0)
+ content_gzip = 1;
+ /* Note: we do not support "gzip;q=0"
+ * method of _disabling_ gzip
+ * delivery */
+ s = skip_non_whitespace(s);
+ }
+ }
#endif
} /* while extra header reading */
}
--
cgit v1.2.3-55-g6feb
From ccb977186100ccf6b443c5f08c8b179c9b7e720b Mon Sep 17 00:00:00 2001
From: Alexander Shishkin
Date: Sun, 25 Jul 2010 13:07:39 +0200
Subject: ash: fix $! value when traps are set
Signed-off-by: Alexander Shishkin
Signed-off-by: Denys Vlasenko
---
shell/ash.c | 1 +
shell/ash_test/ash-signals/signal7.right | 1 +
shell/ash_test/ash-signals/signal7.tests | 18 ++++++++++++++++++
shell/hush.c | 4 ++--
shell/hush_test/hush-trap/signal7.right | 1 +
shell/hush_test/hush-trap/signal7.tests | 18 ++++++++++++++++++
6 files changed, 41 insertions(+), 2 deletions(-)
create mode 100644 shell/ash_test/ash-signals/signal7.right
create mode 100755 shell/ash_test/ash-signals/signal7.tests
create mode 100644 shell/hush_test/hush-trap/signal7.right
create mode 100755 shell/hush_test/hush-trap/signal7.tests
diff --git a/shell/ash.c b/shell/ash.c
index fd119fa51..988edab8a 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -4633,6 +4633,7 @@ clear_traps(void)
INT_ON;
}
}
+ may_have_traps = 0;
}
/* Lives far away from here, needed for forkchild */
diff --git a/shell/ash_test/ash-signals/signal7.right b/shell/ash_test/ash-signals/signal7.right
new file mode 100644
index 000000000..ba7453e42
--- /dev/null
+++ b/shell/ash_test/ash-signals/signal7.right
@@ -0,0 +1 @@
+Bug detected: 0
diff --git a/shell/ash_test/ash-signals/signal7.tests b/shell/ash_test/ash-signals/signal7.tests
new file mode 100755
index 000000000..c2b1381f9
--- /dev/null
+++ b/shell/ash_test/ash-signals/signal7.tests
@@ -0,0 +1,18 @@
+bug() {
+ trap : exit
+ # Bug was causing sh to be run in subshell,
+ # as if this line is replaced with (sh -c ...; exit $?) &
+ # here:
+ sh -c 'echo REAL_CHILD=$$' &
+ echo PARENTS_IDEA_OF_CHILD=$!
+ wait # make sure bkgd shell completes
+}
+
+bug | {
+while read varval; do
+ eval $varval
+done
+test x"$REAL_CHILD" != x"" \
+&& test x"$REAL_CHILD" = x"$PARENTS_IDEA_OF_CHILD"
+echo "Bug detected: $?"
+}
diff --git a/shell/hush.c b/shell/hush.c
index 9208ec497..45c98bb36 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -4108,8 +4108,6 @@ static void insert_bg_job(struct pipe *pi)
if (G_interactive_fd)
printf("[%d] %d %s\n", job->jobid, job->cmds[0].pid, job->cmdtext);
- /* Last command's pid goes to $! */
- G.last_bg_pid = job->cmds[job->num_cmds - 1].pid;
G.last_jobid = job->jobid;
}
@@ -5076,6 +5074,8 @@ static int run_list(struct pipe *pi)
if (G.run_list_level == 1)
insert_bg_job(pi);
#endif
+ /* Last command's pid goes to $! */
+ G.last_bg_pid = pi->cmds[pi->num_cmds - 1].pid;
G.last_exitcode = rcode = EXIT_SUCCESS;
debug_printf_exec(": cmd&: exitcode EXIT_SUCCESS\n");
} else {
diff --git a/shell/hush_test/hush-trap/signal7.right b/shell/hush_test/hush-trap/signal7.right
new file mode 100644
index 000000000..ba7453e42
--- /dev/null
+++ b/shell/hush_test/hush-trap/signal7.right
@@ -0,0 +1 @@
+Bug detected: 0
diff --git a/shell/hush_test/hush-trap/signal7.tests b/shell/hush_test/hush-trap/signal7.tests
new file mode 100755
index 000000000..c2b1381f9
--- /dev/null
+++ b/shell/hush_test/hush-trap/signal7.tests
@@ -0,0 +1,18 @@
+bug() {
+ trap : exit
+ # Bug was causing sh to be run in subshell,
+ # as if this line is replaced with (sh -c ...; exit $?) &
+ # here:
+ sh -c 'echo REAL_CHILD=$$' &
+ echo PARENTS_IDEA_OF_CHILD=$!
+ wait # make sure bkgd shell completes
+}
+
+bug | {
+while read varval; do
+ eval $varval
+done
+test x"$REAL_CHILD" != x"" \
+&& test x"$REAL_CHILD" = x"$PARENTS_IDEA_OF_CHILD"
+echo "Bug detected: $?"
+}
--
cgit v1.2.3-55-g6feb
From f3ea792badae9cd7c4205ac363301f1e94e57d4e Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Mon, 26 Jul 2010 01:06:14 +0200
Subject: *: mass cosmetic removal of extra empty lines. no code changes
Signed-off-by: Denys Vlasenko
---
archival/bz/compress.c | 1 -
archival/unzip.c | 1 -
coreutils/cut.c | 1 -
coreutils/expr.c | 1 -
coreutils/ls.c | 2 --
e2fsprogs/old_e2fsprogs/e2fsck.c | 34 +++++++++-----------------
e2fsprogs/old_e2fsprogs/ext2fs/alloc.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/alloc_tables.c | 4 ---
e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c | 6 -----
e2fsprogs/old_e2fsprogs/ext2fs/bitops.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/block.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/bmap.c | 3 ---
e2fsprogs/old_e2fsprogs/ext2fs/bmove.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/brel.h | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/closefs.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/cmp_bitmaps.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/dir_iterate.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/dirblock.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/dupfs.c | 2 --
e2fsprogs/old_e2fsprogs/ext2fs/e2image.h | 13 ----------
e2fsprogs/old_e2fsprogs/ext2fs/ext2_ext_attr.h | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/ext2fsP.h | 2 --
e2fsprogs/old_e2fsprogs/ext2fs/freefs.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/get_pathname.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/ind_block.c | 2 --
e2fsprogs/old_e2fsprogs/ext2fs/inline.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/inode.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/inode_io.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/jfs_dat.h | 2 --
e2fsprogs/old_e2fsprogs/ext2fs/lookup.c | 2 --
e2fsprogs/old_e2fsprogs/ext2fs/mkdir.c | 3 ---
e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c | 2 --
e2fsprogs/old_e2fsprogs/ext2fs/namei.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/newdir.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/read_bb.c | 2 --
e2fsprogs/old_e2fsprogs/ext2fs/read_bb_file.c | 2 --
e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/rs_bitmap.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/rw_bitmaps.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/swapfs.c | 2 --
e2fsprogs/old_e2fsprogs/ext2fs/unlink.c | 1 -
e2fsprogs/old_e2fsprogs/util.c | 1 -
loginutils/addgroup.c | 1 -
miscutils/crond.c | 1 -
miscutils/hdparm.c | 4 +--
networking/ntpd.c | 1 -
networking/telnet.c | 1 -
networking/traceroute.c | 1 -
selinux/setfiles.c | 1 -
shell/ash.c | 2 --
shell/hush.c | 1 -
util-linux/fdisk.c | 1 -
util-linux/volume_id/volume_id.c | 1 -
53 files changed, 13 insertions(+), 111 deletions(-)
diff --git a/archival/bz/compress.c b/archival/bz/compress.c
index 640b8872b..b9b0949a9 100644
--- a/archival/bz/compress.c
+++ b/archival/bz/compress.c
@@ -212,7 +212,6 @@ void generateMTFValues(EState* s)
wr++;
s->mtfFreq[j+1]++;
}
-
}
}
diff --git a/archival/unzip.c b/archival/unzip.c
index 84081c021..d9705a56e 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -359,7 +359,6 @@ int unzip_main(int argc, char **argv)
default:
bb_show_usage();
-
}
break;
diff --git a/coreutils/cut.c b/coreutils/cut.c
index 53f343a33..696478bb2 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -37,7 +37,6 @@ static int cmpfunc(const void *a, const void *b)
{
return (((struct cut_list *) a)->startpos -
((struct cut_list *) b)->startpos);
-
}
static void cut_file(FILE *file, char delim, const struct cut_list *cut_lists, unsigned nlists)
diff --git a/coreutils/expr.c b/coreutils/expr.c
index f40edad4e..8988340f1 100644
--- a/coreutils/expr.c
+++ b/coreutils/expr.c
@@ -341,7 +341,6 @@ static VALUE *eval6(void)
freev(i2);
}
return v;
-
}
/* Handle : operator (pattern matching).
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 1197f7d71..3e6980509 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -52,7 +52,6 @@
enum {
-
TERMINAL_WIDTH = 80, /* use 79 if terminal has linefold bug */
COLUMN_GAP = 2, /* includes the file type char */
@@ -120,7 +119,6 @@ LIST_LONG = LIST_MODEBITS | LIST_NLINKS | LIST_ID_NAME | LIST_SIZE | \
SPLIT_DIR = 1,
SPLIT_FILE = 0,
SPLIT_SUBDIR = 2,
-
};
/* "[-]Cadil1", POSIX mandated options, busybox always supports */
diff --git a/e2fsprogs/old_e2fsprogs/e2fsck.c b/e2fsprogs/old_e2fsprogs/e2fsck.c
index 4c4c78d00..f58fe9286 100644
--- a/e2fsprogs/old_e2fsprogs/e2fsck.c
+++ b/e2fsprogs/old_e2fsprogs/e2fsck.c
@@ -517,7 +517,6 @@ static void dict_insert(dict_t *dict, dnode_t *node, const void *key)
}
dict_root(dict)->color = dnode_black;
-
}
/*
@@ -801,7 +800,6 @@ static void e2fsck_add_dx_dir(e2fsck_t ctx, ext2_ino_t ino, int num_blocks)
dir->dx_block = e2fsck_allocate_memory(ctx, num_blocks
* sizeof (struct dx_dirblock_info),
"dx_block info array");
-
}
/*
@@ -1724,7 +1722,6 @@ errout:
ext2fs_free_mem(&j_inode);
ext2fs_free_mem(&journal);
return retval;
-
}
static errcode_t e2fsck_journal_fix_bad_inode(e2fsck_t ctx,
@@ -3375,7 +3372,6 @@ static void e2fsck_pass1(e2fsck_t ctx)
e2fsck_write_inode(ctx, ino, inode,
"pass1");
}
-
}
/*
* If dtime is set, offer to clear it. mke2fs
@@ -3678,7 +3674,6 @@ endit:
ext2fs_free_mem(&block_buf);
ext2fs_free_mem(&inode);
-
}
/*
@@ -4451,8 +4446,7 @@ static void mark_table_blocks(e2fsck_t ctx)
ctx->invalid_bitmaps++;
}
} else {
- ext2fs_mark_block_bitmap(ctx->block_found_map,
- b);
+ ext2fs_mark_block_bitmap(ctx->block_found_map, b);
}
}
}
@@ -4469,10 +4463,9 @@ static void mark_table_blocks(e2fsck_t ctx)
ctx->invalid_bitmaps++;
}
} else {
- ext2fs_mark_block_bitmap(ctx->block_found_map,
- fs->group_desc[i].bg_block_bitmap);
- }
-
+ ext2fs_mark_block_bitmap(ctx->block_found_map,
+ fs->group_desc[i].bg_block_bitmap);
+ }
}
/*
* Mark block used for the inode bitmap
@@ -4486,8 +4479,8 @@ static void mark_table_blocks(e2fsck_t ctx)
ctx->invalid_bitmaps++;
}
} else {
- ext2fs_mark_block_bitmap(ctx->block_found_map,
- fs->group_desc[i].bg_inode_bitmap);
+ ext2fs_mark_block_bitmap(ctx->block_found_map,
+ fs->group_desc[i].bg_inode_bitmap);
}
}
block += fs->super->s_blocks_per_group;
@@ -5588,7 +5581,6 @@ static void e2fsck_pass2(e2fsck_t ctx)
ext2fs_mark_super_dirty(fs);
}
}
-
}
#define MAX_DEPTH 32000
@@ -9748,7 +9740,6 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
if (print_answer)
printf("%s.\n", answer ?
_(preen_msg[(int) ptr->prompt]) : _("IGNORED"));
-
}
if ((ptr->prompt == PROMPT_ABORT) && answer)
@@ -11324,7 +11315,7 @@ static int release_inode_block(ext2_filsys fs, blk_t *block_nr,
if ((blk < fs->super->s_first_data_block) ||
(blk >= fs->super->s_blocks_count)) {
fix_problem(ctx, PR_0_ORPHAN_ILLEGAL_BLOCK_NUM, pctx);
- return_abort:
+ return_abort:
pb->abort = 1;
return BLOCK_ABORT;
}
@@ -11537,7 +11528,7 @@ static int release_orphan_inodes(e2fsck_t ctx)
}
ext2fs_free_mem(&block_buf);
return 0;
-return_abort:
+ return_abort:
ext2fs_free_mem(&block_buf);
return 1;
}
@@ -11618,7 +11609,7 @@ static void check_resize_inode(e2fsck_t ctx)
!(inode.i_mode & LINUX_S_IFREG) ||
(blk < fs->super->s_first_data_block ||
blk >= fs->super->s_blocks_count)) {
- resize_inode_invalid:
+ resize_inode_invalid:
if (fix_problem(ctx, PR_0_RESIZE_INODE_INVALID, &pctx)) {
memset(&inode, 0, sizeof(inode));
e2fsck_write_inode(ctx, EXT2_RESIZE_INO, &inode,
@@ -11660,10 +11651,9 @@ static void check_resize_inode(e2fsck_t ctx)
}
}
-cleanup:
+ cleanup:
ext2fs_free_mem(&dind_buf);
-
- }
+}
static void check_super_block(e2fsck_t ctx)
{
@@ -11842,7 +11832,6 @@ static void check_super_block(e2fsck_t ctx)
(gd->bg_free_inodes_count > sb->s_inodes_per_group) ||
(gd->bg_used_dirs_count > sb->s_inodes_per_group))
ext2fs_unmark_valid(fs);
-
}
/*
@@ -11902,7 +11891,6 @@ static void check_super_block(e2fsck_t ctx)
fs->super->s_feature_incompat &=
~EXT2_FEATURE_INCOMPAT_FILETYPE;
ext2fs_mark_super_dirty(fs);
-
}
}
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/alloc.c b/e2fsprogs/old_e2fsprogs/ext2fs/alloc.c
index 5021d72c9..cbb63e15a 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/alloc.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/alloc.c
@@ -171,4 +171,3 @@ errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, blk_t finish,
} while (b != finish);
return EXT2_ET_BLOCK_ALLOC_FAIL;
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/alloc_tables.c b/e2fsprogs/old_e2fsprogs/ext2fs/alloc_tables.c
index b2d786ed8..7c60e2bf5 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/alloc_tables.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/alloc_tables.c
@@ -97,12 +97,9 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
fs->group_desc[group].bg_inode_table = new_blk;
}
-
return 0;
}
-
-
errcode_t ext2fs_allocate_tables(ext2_filsys fs)
{
errcode_t retval;
@@ -115,4 +112,3 @@ errcode_t ext2fs_allocate_tables(ext2_filsys fs)
}
return 0;
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c b/e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c
index 1deae54e8..a96789618 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c
@@ -260,9 +260,3 @@ static int set_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
*block_nr = blk;
return BLOCK_CHANGED;
}
-
-
-
-
-
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/bitops.c b/e2fsprogs/old_e2fsprogs/ext2fs/bitops.c
index 987061130..3cf157949 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/bitops.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/bitops.c
@@ -88,4 +88,3 @@ void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
bb_error_msg("#%lu", arg);
#endif
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/block.c b/e2fsprogs/old_e2fsprogs/ext2fs/block.c
index 498096995..dbd04f846 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/block.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/block.c
@@ -435,4 +435,3 @@ errcode_t ext2fs_block_iterate(ext2_filsys fs,
return ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_NO_LARGE | flags,
block_buf, xlate_func, &xl);
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/bmap.c b/e2fsprogs/old_e2fsprogs/ext2fs/bmap.c
index b2d0279d8..796b0e4f5 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/bmap.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/bmap.c
@@ -259,6 +259,3 @@ done:
}
return retval;
}
-
-
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/bmove.c b/e2fsprogs/old_e2fsprogs/ext2fs/bmove.c
index 635410da5..ec9244d0b 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/bmove.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/bmove.c
@@ -153,4 +153,3 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs,
}
return 0;
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/brel.h b/e2fsprogs/old_e2fsprogs/ext2fs/brel.h
index 216fd132c..87bf72be4 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/brel.h
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/brel.h
@@ -84,4 +84,3 @@ errcode_t ext2fs_brel_memarray_create(char *name, blk_t max_block,
#define ext2fs_brel_move(brel, old, new) ((brel)->move((brel), old, new))
#define ext2fs_brel_delete(brel, old) ((brel)->delete((brel), old))
#define ext2fs_brel_free(brel) ((brel)->free((brel)))
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/closefs.c b/e2fsprogs/old_e2fsprogs/ext2fs/closefs.c
index 7ba7f22e2..bfa15e22a 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/closefs.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/closefs.c
@@ -378,4 +378,3 @@ errcode_t ext2fs_close(ext2_filsys fs)
ext2fs_free(fs);
return 0;
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/cmp_bitmaps.c b/e2fsprogs/old_e2fsprogs/ext2fs/cmp_bitmaps.c
index 05b8eb8d7..7f78ff804 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/cmp_bitmaps.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/cmp_bitmaps.c
@@ -70,4 +70,3 @@ errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
return 0;
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/dir_iterate.c b/e2fsprogs/old_e2fsprogs/ext2fs/dir_iterate.c
index b7d873595..eb5dae0a6 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/dir_iterate.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/dir_iterate.c
@@ -217,4 +217,3 @@ next:
return BLOCK_ABORT;
return 0;
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/dirblock.c b/e2fsprogs/old_e2fsprogs/ext2fs/dirblock.c
index f651338e3..f9c5a104b 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/dirblock.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/dirblock.c
@@ -130,4 +130,3 @@ errcode_t ext2fs_write_dir_block(ext2_filsys fs, blk_t block,
{
return ext2fs_write_dir_block2(fs, block, inbuf, 0);
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/dupfs.c b/e2fsprogs/old_e2fsprogs/ext2fs/dupfs.c
index 203c29fe3..d1879377a 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/dupfs.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/dupfs.c
@@ -92,6 +92,4 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest)
errout:
ext2fs_free(fs);
return retval;
-
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/e2image.h b/e2fsprogs/old_e2fsprogs/ext2fs/e2image.h
index 8d38ecc13..a598d0111 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/e2image.h
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/e2image.h
@@ -37,16 +37,3 @@ struct ext2_image_hdr {
__u32 offset_blockmap; /* Byte offset of the inode bitmaps */
__u32 offset_reserved[8];
};
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/ext2_ext_attr.h b/e2fsprogs/old_e2fsprogs/ext2fs/ext2_ext_attr.h
index cc91bb8d6..ca309c0d0 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/ext2_ext_attr.h
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/ext2_ext_attr.h
@@ -50,4 +50,3 @@ struct ext2_ext_attr_entry {
sizeof(struct ext2_xattr_entry)) & ~EXT2_EXT_ATTR_ROUND)
#define EXT2_XATTR_SIZE(size) \
(((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/ext2fsP.h b/e2fsprogs/old_e2fsprogs/ext2fs/ext2fsP.h
index 908b5d9a4..7a02e9a8e 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/ext2fsP.h
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/ext2fsP.h
@@ -85,5 +85,3 @@ extern int ext2fs_process_dir_block(ext2_filsys fs,
blk_t ref_block,
int ref_offset,
void *priv_data);
-
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/freefs.c b/e2fsprogs/old_e2fsprogs/ext2fs/freefs.c
index 65c4ee794..0c5d48b11 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/freefs.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/freefs.c
@@ -125,4 +125,3 @@ void ext2fs_free_dblist(ext2_dblist dblist)
dblist->magic = 0;
ext2fs_free_mem(&dblist);
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/get_pathname.c b/e2fsprogs/old_e2fsprogs/ext2fs/get_pathname.c
index a98b2b9e5..a3bbad851 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/get_pathname.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/get_pathname.c
@@ -153,5 +153,4 @@ errcode_t ext2fs_get_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino,
retval = ext2fs_get_pathname_int(fs, dir, ino, 32, buf, name);
ext2fs_free_mem(&buf);
return retval;
-
}
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/ind_block.c b/e2fsprogs/old_e2fsprogs/ext2fs/ind_block.c
index c86a1c59a..a1038300b 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/ind_block.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/ind_block.c
@@ -67,5 +67,3 @@ errcode_t ext2fs_write_ind_block(ext2_filsys fs, blk_t blk, void *buf)
#endif
return io_channel_write_blk(fs->io, blk, 1, buf);
}
-
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/inline.c b/e2fsprogs/old_e2fsprogs/ext2fs/inline.c
index 9b620a772..d328cc950 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/inline.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/inline.c
@@ -30,4 +30,3 @@
#include "ext2_fs.h"
#define INCLUDE_INLINE_FUNCS
#include "ext2fs.h"
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/inode.c b/e2fsprogs/old_e2fsprogs/ext2fs/inode.c
index 5e0d081bd..7a1d5c94b 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/inode.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/inode.c
@@ -764,4 +764,3 @@ errcode_t ext2fs_check_directory(ext2_filsys fs, ext2_ino_t ino)
return EXT2_ET_NO_DIRECTORY;
return 0;
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/inode_io.c b/e2fsprogs/old_e2fsprogs/ext2fs/inode_io.c
index 4bfa93aef..b861d5ff6 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/inode_io.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/inode_io.c
@@ -268,4 +268,3 @@ static errcode_t inode_flush(io_channel channel)
return ext2fs_file_flush(data->file);
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/jfs_dat.h b/e2fsprogs/old_e2fsprogs/ext2fs/jfs_dat.h
index 136635de0..17c586a29 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/jfs_dat.h
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/jfs_dat.h
@@ -60,6 +60,4 @@ typedef struct journal_superblock_s
/* Dynamic information describing the current state of the log */
__u32 s_sequence; /* first commit ID expected in log */
__u32 s_start; /* blocknr of start of log */
-
} journal_superblock_t;
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/lookup.c b/e2fsprogs/old_e2fsprogs/ext2fs/lookup.c
index 31b30a182..b2e8de8ec 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/lookup.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/lookup.c
@@ -66,5 +66,3 @@ errcode_t ext2fs_lookup(ext2_filsys fs, ext2_ino_t dir, const char *name,
return (ls.found) ? 0 : EXT2_ET_FILE_NOT_FOUND;
}
-
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/mkdir.c b/e2fsprogs/old_e2fsprogs/ext2fs/mkdir.c
index 93f47b06f..a86ac8e93 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/mkdir.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/mkdir.c
@@ -136,7 +136,4 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
cleanup:
ext2fs_free_mem(&block);
return retval;
-
}
-
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c b/e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c
index db1c8bff3..748d9abc7 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c
@@ -188,7 +188,6 @@ static int mkjournal_proc(ext2_filsys fs,
return (BLOCK_CHANGED | BLOCK_ABORT);
else
return BLOCK_CHANGED;
-
}
/*
@@ -423,6 +422,5 @@ main(int argc, char **argv)
}
ext2fs_close(fs);
exit(0);
-
}
#endif
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/namei.c b/e2fsprogs/old_e2fsprogs/ext2fs/namei.c
index 14d48fb72..18244613c 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/namei.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/namei.c
@@ -202,4 +202,3 @@ errcode_t ext2fs_follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
ext2fs_free_mem(&buf);
return retval;
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/newdir.c b/e2fsprogs/old_e2fsprogs/ext2fs/newdir.c
index 9470e7f56..9f156626d 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/newdir.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/newdir.c
@@ -66,7 +66,6 @@ errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino,
dir->name_len = 2 | filetype;
dir->name[0] = '.';
dir->name[1] = '.';
-
}
*block = buf;
return 0;
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/read_bb.c b/e2fsprogs/old_e2fsprogs/ext2fs/read_bb.c
index 4766157c2..ce77bc9f6 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/read_bb.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/read_bb.c
@@ -94,5 +94,3 @@ errcode_t ext2fs_read_bb_inode(ext2_filsys fs, ext2_badblocks_list *bb_list)
return rb.err;
}
-
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/read_bb_file.c b/e2fsprogs/old_e2fsprogs/ext2fs/read_bb_file.c
index 831adcc3a..bf1fc328b 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/read_bb_file.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/read_bb_file.c
@@ -94,5 +94,3 @@ errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f,
return ext2fs_read_bb_FILE2(fs, f, bb_list, (void *) invalid,
call_compat_invalid);
}
-
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c b/e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c
index 3c550d511..403463a90 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c
@@ -218,4 +218,3 @@ out_free:
ext2fs_free_mem((void *)&dindir_buf);
return retval;
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/rs_bitmap.c b/e2fsprogs/old_e2fsprogs/ext2fs/rs_bitmap.c
index e932b3c9d..32e87b77a 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/rs_bitmap.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/rs_bitmap.c
@@ -104,4 +104,3 @@ errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end,
bmap->magic = EXT2_ET_MAGIC_BLOCK_BITMAP;
return retval;
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/rw_bitmaps.c b/e2fsprogs/old_e2fsprogs/ext2fs/rw_bitmaps.c
index 0ae0a8234..b618acc5b 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/rw_bitmaps.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/rw_bitmaps.c
@@ -293,4 +293,3 @@ errcode_t ext2fs_write_bitmaps(ext2_filsys fs)
}
return 0;
}
-
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/swapfs.c b/e2fsprogs/old_e2fsprogs/ext2fs/swapfs.c
index 2fca3cfbb..07b757abd 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/swapfs.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/swapfs.c
@@ -66,7 +66,6 @@ void ext2fs_swap_super(struct ext2_super_block * sb)
sb->s_hash_seed[i] = ext2fs_swab32(sb->s_hash_seed[i]);
for (i=0; i < 17; i++)
sb->s_jnl_blocks[i] = ext2fs_swab32(sb->s_jnl_blocks[i]);
-
}
void ext2fs_swap_group_desc(struct ext2_group_desc *gdp)
@@ -222,7 +221,6 @@ void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t,
ext2fs_swap_ext_attr((char *) (eat + 1), (char *) (eaf + 1),
bufsize - sizeof(struct ext2_inode) -
t->i_extra_isize - sizeof(__u32), 0);
-
}
void ext2fs_swap_inode(ext2_filsys fs, struct ext2_inode *t,
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/unlink.c b/e2fsprogs/old_e2fsprogs/ext2fs/unlink.c
index 83ac2713e..71a9ffcb9 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/unlink.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/unlink.c
@@ -97,4 +97,3 @@ errcode_t ext2fs_unlink(ext2_filsys fs, ext2_ino_t dir,
return (ls.done) ? 0 : EXT2_ET_DIR_NO_SPACE;
}
-
diff --git a/e2fsprogs/old_e2fsprogs/util.c b/e2fsprogs/old_e2fsprogs/util.c
index 64cca05a7..0829f5686 100644
--- a/e2fsprogs/old_e2fsprogs/util.c
+++ b/e2fsprogs/old_e2fsprogs/util.c
@@ -95,7 +95,6 @@ force_check:
bb_error_msg("%s is apparently in use by the system", device);
goto force_check;
}
-
}
void parse_journal_opts(char **journal_device, int *journal_flags,
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index 215e4a9e0..78ca22585 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -168,7 +168,6 @@ int addgroup_main(int argc UNUSED_PARAM, char **argv)
{
die_if_bad_username(argv[0]);
new_group(argv[0], gid);
-
}
/* Reached only on success */
return EXIT_SUCCESS;
diff --git a/miscutils/crond.c b/miscutils/crond.c
index 66110bb85..d028eb089 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -243,7 +243,6 @@ static void ParseField(char *user, char *ary, int modvalue, int off,
goto err;
}
} while (n1 != n2);
-
}
if (*ptr != ',') {
break;
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index 9738620fd..236b1749c 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -730,8 +730,8 @@ static void identify(uint16_t *val)
if (val[MINOR] && (val[MINOR] <= MINOR_MAX)) {
if (like_std < 3) like_std = 3;
std = actual_ver[val[MINOR]];
- if (std) printf("\n\tUsed: %s ", nth_string(minor_str, val[MINOR]));
-
+ if (std)
+ printf("\n\tUsed: %s ", nth_string(minor_str, val[MINOR]));
}
/* looks like when they up-issue the std, they obsolete one;
* thus, only the newest 4 issues need be supported. (That's
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 14c3a5fbb..d00ee49e5 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -592,7 +592,6 @@ filter_datapoints(peer_t *p)
p->filter_offset, x,
p->filter_dispersion,
p->filter_jitter);
-
}
static void
diff --git a/networking/telnet.c b/networking/telnet.c
index 57997f6b9..e0022b2cb 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -150,7 +150,6 @@ static void con_escape(void)
cookmode();
ret:
bb_got_signal = 0;
-
}
static void handle_net_output(int len)
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 2d3e77011..c18fba8d0 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -666,7 +666,6 @@ packet_ok(int read_len, len_and_sockaddr *from_lsa,
return (type == ICMP6_TIME_EXCEEDED ? -1 : (code<<8)+1);
}
}
-
}
# if ENABLE_FEATURE_TRACEROUTE_VERBOSE
diff --git a/selinux/setfiles.c b/selinux/setfiles.c
index f45e41b2b..989510e3d 100644
--- a/selinux/setfiles.c
+++ b/selinux/setfiles.c
@@ -118,7 +118,6 @@ static void add_exclude(const char *directory)
if (directory == NULL || directory[0] != '/') {
bb_error_msg_and_die("full path required for exclude: %s", directory);
-
}
if (lstat(directory, &sb)) {
bb_error_msg("directory \"%s\" not found, ignoring", directory);
diff --git a/shell/ash.c b/shell/ash.c
index 988edab8a..d8becc37a 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -11215,7 +11215,6 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
}
IF_ASH_ALIAS(if (c != PEOA))
USTPUTC(c, out);
-
}
c = pgetc_fast();
} /* for (;;) */
@@ -12055,7 +12054,6 @@ evalcmd(int argc UNUSED_PARAM, char **argv)
p = grabstackstr(concat);
}
evalstring(p, ~SKIPEVAL);
-
}
return exitstatus;
}
diff --git a/shell/hush.c b/shell/hush.c
index 45c98bb36..0a420f685 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -4518,7 +4518,6 @@ static NOINLINE int run_pipe(struct pipe *pi)
#ifdef CMD_SINGLEWORD_NOGLOB_COND
else if (command->cmd_type == CMD_SINGLEWORD_NOGLOB_COND) {
argv_expanded = expand_strvec_to_strvec_singleword_noglob_cond(argv + command->assignment_cnt);
-
}
#endif
else {
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index aa718c787..fc02000e5 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -2043,7 +2043,6 @@ fix_partition_table_order(void)
fix_chain_of_logicals();
printf("Done.\n");
-
}
#endif
diff --git a/util-linux/volume_id/volume_id.c b/util-linux/volume_id/volume_id.c
index c8cf946df..f41d4e0d9 100644
--- a/util-linux/volume_id/volume_id.c
+++ b/util-linux/volume_id/volume_id.c
@@ -195,7 +195,6 @@ int FAST_FUNC volume_id_probe_all(struct volume_id *id, /*uint64_t off,*/ uint64
ret:
volume_id_free_buffer(id);
return (- id->error); /* 0 or -1 */
-
}
/* open volume by device node */
--
cgit v1.2.3-55-g6feb
From 0f8960542f6f5ae258e72e56ba7296a01a9c10af Mon Sep 17 00:00:00 2001
From: Denys Vlasenko
Date: Mon, 26 Jul 2010 01:35:44 +0200
Subject: *: more empty lines removed. no code changes
Signed-off-by: Denys Vlasenko
---
archival/lzo1x_9x.c | 1 -
e2fsprogs/old_e2fsprogs/ext2fs/rw_bitmaps.c | 1 -
networking/interface.c | 1 -
networking/ntpd.c | 1 -
scripts/find_stray_empty_lines | 7 +++++++
5 files changed, 7 insertions(+), 4 deletions(-)
create mode 100755 scripts/find_stray_empty_lines
diff --git a/archival/lzo1x_9x.c b/archival/lzo1x_9x.c
index 0baed5469..483205155 100644
--- a/archival/lzo1x_9x.c
+++ b/archival/lzo1x_9x.c
@@ -675,7 +675,6 @@ static int min_gain(unsigned ahead, unsigned lit1,
static void better_match(const lzo_swd_p swd,
unsigned *m_len, unsigned *m_off)
{
-
if (*m_len <= M2_MIN_LEN)
return;
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/rw_bitmaps.c b/e2fsprogs/old_e2fsprogs/ext2fs/rw_bitmaps.c
index b618acc5b..bba432679 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/rw_bitmaps.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/rw_bitmaps.c
@@ -266,7 +266,6 @@ errcode_t ext2fs_read_block_bitmap(ext2_filsys fs)
errcode_t ext2fs_read_bitmaps(ext2_filsys fs)
{
-
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
if (fs->inode_map && fs->block_map)
diff --git a/networking/interface.c b/networking/interface.c
index 659ac36ea..7c6ed82df 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -927,7 +927,6 @@ static void print_bytes_scaled(unsigned long long ull, const char *end)
static void ife_print6(struct interface *ptr)
{
-
FILE *f;
char addr6[40], devname[20];
struct sockaddr_in6 sap;
diff --git a/networking/ntpd.c b/networking/ntpd.c
index d00ee49e5..e9cfdbddd 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -2060,7 +2060,6 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
static double
direct_freq(double fp_offset)
{
-
#ifdef KERNEL_PLL
/*
* If the kernel is enabled, we need the residual offset to
diff --git a/scripts/find_stray_empty_lines b/scripts/find_stray_empty_lines
new file mode 100755
index 000000000..58daf2f0c
--- /dev/null
+++ b/scripts/find_stray_empty_lines
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+grep -n -B1 -r $'^\t*}$' . | grep -A1 '.[ch]-[0-9]*-$'
+grep -n -A1 -r $'^\t*{$' . | grep -B1 '.[ch]-[0-9]*-$'
+# or (less surefire ones):
+grep -n -B1 -r $'^\t*}' . | grep -A1 '.[ch]-[0-9]*-$'
+grep -n -A1 -r $'^\t*{' . | grep -B1 '.[ch]-[0-9]*-$'
--
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(-)
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
-