From aldot at busybox.net Sun Jun 1 03:10:23 2008 From: aldot at busybox.net (aldot at busybox.net) Date: Sun, 1 Jun 2008 03:10:23 -0700 (PDT) Subject: svn commit: trunk/busybox: init loginutils miscutils Message-ID: <20080601101023.EEDEB3C7E8@busybox.net> Author: aldot Date: 2008-06-01 03:10:22 -0700 (Sun, 01 Jun 2008) New Revision: 22156 Log: - use ut_user rather than ut_name (Cristian Ionescu-Idbohrn) - use ut_tv.tv_sec rather than ut_time (me) - shrink halt a little bit (me): halt_main 464 433 -31 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-31) Total: -31 bytes Modified: trunk/busybox/init/halt.c trunk/busybox/loginutils/getty.c trunk/busybox/loginutils/login.c trunk/busybox/miscutils/last.c trunk/busybox/miscutils/last_fancy.c Changeset: Modified: trunk/busybox/init/halt.c =================================================================== --- trunk/busybox/init/halt.c 2008-05-31 21:39:13 UTC (rev 22155) +++ trunk/busybox/init/halt.c 2008-06-01 10:10:22 UTC (rev 22156) @@ -37,7 +37,6 @@ int which, flags, rc = 1; #if ENABLE_FEATURE_WTMP struct utmp utmp; - struct timeval tv; struct utsname uts; #endif @@ -56,9 +55,7 @@ close(creat(bb_path_wtmp_file, 0664)); } memset(&utmp, 0, sizeof(utmp)); - gettimeofday(&tv, NULL); - utmp.ut_tv.tv_sec = tv.tv_sec; - utmp.ut_tv.tv_usec = tv.tv_usec; + utmp.ut_tv.tv_sec = time(NULL); safe_strncpy(utmp.ut_user, "shutdown", UT_NAMESIZE); utmp.ut_type = RUN_LVL; safe_strncpy(utmp.ut_id, "~~", sizeof(utmp.ut_id)); Modified: trunk/busybox/loginutils/getty.c =================================================================== --- trunk/busybox/loginutils/getty.c 2008-05-31 21:39:13 UTC (rev 22155) +++ trunk/busybox/loginutils/getty.c 2008-06-01 10:10:22 UTC (rev 22156) @@ -605,7 +605,7 @@ safe_strncpy(ut.ut_line, line, sizeof(ut.ut_line)); if (fakehost) safe_strncpy(ut.ut_host, fakehost, sizeof(ut.ut_host)); - ut.ut_time = time(NULL); + ut.ut_tv.tv_sec = time(NULL); ut.ut_type = LOGIN_PROCESS; ut.ut_pid = mypid; Modified: trunk/busybox/loginutils/login.c =================================================================== --- trunk/busybox/loginutils/login.c 2008-05-31 21:39:13 UTC (rev 22155) +++ trunk/busybox/loginutils/login.c 2008-06-01 10:10:22 UTC (rev 22156) @@ -80,7 +80,7 @@ * remotely meaningful by skipping "tty"... */ strncpy(utptr->ut_id, short_tty + 3, sizeof(utptr->ut_id)); strncpy(utptr->ut_user, "LOGIN", sizeof(utptr->ut_user)); - utptr->ut_time = time(NULL); + utptr->ut_tv.tv_sec = time(NULL); } if (!picky) /* root login */ memset(utptr->ut_host, 0, sizeof(utptr->ut_host)); @@ -96,7 +96,7 @@ { utptr->ut_type = USER_PROCESS; strncpy(utptr->ut_user, username, sizeof(utptr->ut_user)); - utptr->ut_time = time(NULL); + utptr->ut_tv.tv_sec = time(NULL); /* other fields already filled in by read_or_build_utent above */ setutent(); pututline(utptr); Modified: trunk/busybox/miscutils/last.c =================================================================== --- trunk/busybox/miscutils/last.c 2008-05-31 21:39:13 UTC (rev 22155) +++ trunk/busybox/miscutils/last.c 2008-06-01 10:10:22 UTC (rev 22156) @@ -83,17 +83,17 @@ ut.ut_type = RUN_LVL; #endif } else { - if (ut.ut_name[0] == '\0' || strcmp(ut.ut_name, "LOGIN") == 0) { + if (ut.ut_user[0] == '\0' || strcmp(ut.ut_user, "LOGIN") == 0) { /* Don't bother. This means we can't find how long * someone was logged in for. Oh well. */ goto next; } if (ut.ut_type != DEAD_PROCESS - && ut.ut_name[0] && ut.ut_line[0] + && ut.ut_user[0] && ut.ut_line[0] ) { ut.ut_type = USER_PROCESS; } - if (strcmp(ut.ut_name, "date") == 0) { + if (strcmp(ut.ut_user, "date") == 0) { if (n == TYPE_OLD_TIME) { /* '|' */ ut.ut_type = OLD_TIME; } Modified: trunk/busybox/miscutils/last_fancy.c =================================================================== --- trunk/busybox/miscutils/last_fancy.c 2008-05-31 21:39:13 UTC (rev 22155) +++ trunk/busybox/miscutils/last_fancy.c 2008-06-01 10:10:22 UTC (rev 22156) @@ -46,7 +46,7 @@ const char *logout_str; const char *duration_str; - safe_strncpy(login_time, ctime(&(ut->ut_time)), 17); + safe_strncpy(login_time, ctime(&(ut->ut_tv.tv_sec)), 17); snprintf(logout_time, 8, "- %s", ctime(&dur_secs) + 11); dur_secs = MAX(dur_secs - (time_t)ut->ut_tv.tv_sec, (time_t)0); @@ -87,7 +87,7 @@ } printf(HEADER_FORMAT, - ut->ut_name, + ut->ut_user, ut->ut_line, show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN, show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN, @@ -112,19 +112,19 @@ return ut->ut_type; } - if (ut->ut_name[0] == 0) { + if (ut->ut_user[0] == 0) { return DEAD_PROCESS; } if ((ut->ut_type != DEAD_PROCESS) - && (strcmp(ut->ut_name, "LOGIN") != 0) - && ut->ut_name[0] + && (strcmp(ut->ut_user, "LOGIN") != 0) + && ut->ut_user[0] && ut->ut_line[0] ) { ut->ut_type = USER_PROCESS; } - if (strcmp(ut->ut_name, "date") == 0) { + if (strcmp(ut->ut_user, "date") == 0) { if (ut->ut_line[0] == '|') { return OLD_TIME; } @@ -196,18 +196,18 @@ xlseek(file, pos, SEEK_SET); xread(file, &ut, sizeof(ut)); /* rewritten by each record, eventially will have - * first record's ut_time: */ - start_time = ut.ut_time; + * first record's ut_tv.tv_sec: */ + start_time = ut.ut_tv.tv_sec; switch (get_ut_type(&ut)) { case SHUTDOWN_TIME: - down_time = ut.ut_time; + down_time = ut.ut_tv.tv_sec; boot_down = DOWN; going_down = 1; break; case RUN_LVL: if (is_runlevel_shutdown(&ut)) { - down_time = ut.ut_time; + down_time = ut.ut_tv.tv_sec; going_down = 1; boot_down = DOWN; } @@ -240,7 +240,7 @@ next = el->link; if (strncmp(up->ut_line, ut.ut_line, UT_LINESIZE) == 0) { if (show) { - show_entry(&ut, NORMAL, up->ut_time); + show_entry(&ut, NORMAL, up->ut_tv.tv_sec); show = 0; } llist_unlink(&zlist, el); @@ -271,7 +271,7 @@ } if (going_down) { - boot_time = ut.ut_time; + boot_time = ut.ut_tv.tv_sec; llist_free(zlist, free); zlist = NULL; going_down = 0; From vda at busybox.net Sun Jun 1 07:16:55 2008 From: vda at busybox.net (vda at busybox.net) Date: Sun, 1 Jun 2008 07:16:55 -0700 (PDT) Subject: svn commit: trunk/busybox/shell/msh_test/msh-execution Message-ID: <20080601141655.4B1B83C827@busybox.net> Author: vda Date: 2008-06-01 07:16:54 -0700 (Sun, 01 Jun 2008) New Revision: 22159 Log: msh: fix ENOENT testcase Modified: trunk/busybox/shell/msh_test/msh-execution/exitcode_ENOENT.right trunk/busybox/shell/msh_test/msh-execution/exitcode_ENOENT.tests Changeset: Modified: trunk/busybox/shell/msh_test/msh-execution/exitcode_ENOENT.right =================================================================== --- trunk/busybox/shell/msh_test/msh-execution/exitcode_ENOENT.right 2008-06-01 12:50:21 UTC (rev 22158) +++ trunk/busybox/shell/msh_test/msh-execution/exitcode_ENOENT.right 2008-06-01 14:16:54 UTC (rev 22159) @@ -1,2 +1,2 @@ -./does_exist_for_sure: not found +./does_not_exist_for_sure: not found 127 Modified: trunk/busybox/shell/msh_test/msh-execution/exitcode_ENOENT.tests =================================================================== --- trunk/busybox/shell/msh_test/msh-execution/exitcode_ENOENT.tests 2008-06-01 12:50:21 UTC (rev 22158) +++ trunk/busybox/shell/msh_test/msh-execution/exitcode_ENOENT.tests 2008-06-01 14:16:54 UTC (rev 22159) @@ -1,2 +1,2 @@ -./does_exist_for_sure +./does_not_exist_for_sure echo $? From vda at busybox.net Sun Jun 1 15:36:39 2008 From: vda at busybox.net (vda at busybox.net) Date: Sun, 1 Jun 2008 15:36:39 -0700 (PDT) Subject: svn commit: trunk/busybox: coreutils include miscutils shell Message-ID: <20080601223639.CA93C3C87C@busybox.net> Author: vda Date: 2008-06-01 15:36:39 -0700 (Sun, 01 Jun 2008) New Revision: 22175 Log: ash: optional printf builtin. +25 bytes if off, +35 if on. by Cristian Ionescu-Idbohrn. Modified: trunk/busybox/coreutils/Kbuild trunk/busybox/coreutils/chown.c trunk/busybox/coreutils/printf.c trunk/busybox/include/applets.h trunk/busybox/include/libbb.h trunk/busybox/miscutils/last.c trunk/busybox/miscutils/last_fancy.c trunk/busybox/shell/Config.in trunk/busybox/shell/ash.c Changeset: Modified: trunk/busybox/coreutils/Kbuild =================================================================== --- trunk/busybox/coreutils/Kbuild 2008-06-01 22:11:07 UTC (rev 22174) +++ trunk/busybox/coreutils/Kbuild 2008-06-01 22:36:39 UTC (rev 22175) @@ -54,6 +54,7 @@ lib-$(CONFIG_OD) += od.o lib-$(CONFIG_PRINTENV) += printenv.o lib-$(CONFIG_PRINTF) += printf.o +lib-$(CONFIG_ASH_BUILTIN_PRINTF) += printf.o lib-$(CONFIG_PWD) += pwd.o lib-$(CONFIG_READLINK) += readlink.o lib-$(CONFIG_REALPATH) += realpath.o Modified: trunk/busybox/coreutils/chown.c =================================================================== --- trunk/busybox/coreutils/chown.c 2008-06-01 22:11:07 UTC (rev 22174) +++ trunk/busybox/coreutils/chown.c 2008-06-01 22:36:39 UTC (rev 22175) @@ -61,7 +61,6 @@ return FALSE; } -int chown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int chown_main(int argc ATTRIBUTE_UNUSED, char **argv) { int retval = EXIT_SUCCESS; Modified: trunk/busybox/coreutils/printf.c =================================================================== --- trunk/busybox/coreutils/printf.c 2008-06-01 22:11:07 UTC (rev 22174) +++ trunk/busybox/coreutils/printf.c 2008-06-01 22:36:39 UTC (rev 22175) @@ -193,6 +193,7 @@ unsigned direc_length; /* Length of % directive. */ int field_width; /* Arg to first '*', or -1 if none. */ int precision; /* Arg to second '*', or -1 if none. */ + char **saved_argv = argv; for (; *f; ++f) { switch (*f) { @@ -264,8 +265,9 @@ precision, ""); break; case '\\': - if (*++f == 'c') - exit(EXIT_SUCCESS); + if (*++f == 'c') { + return saved_argv; /* causes main() to exit */ + } bb_putchar(bb_process_escape_sequence((const char **)&f)); f--; break; @@ -277,12 +279,22 @@ return argv; } -int printf_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int printf_main(int argc ATTRIBUTE_UNUSED, char **argv) { char *format; char **argv2; + /* We must check that stdout is not closed. + * The reason for this is highly non-obvious. printf_main is used from shell. + * Shell must correctly handle 'printf "%s" foo' + * if stdout is closed. With stdio, output gets shoveled into + * stdout buffer, and even fflush cannot clear it out. It seems that + * even if libc receives EBADF on write attempts, it feels determined + * to output data no matter what. So it will try later, + * and possibly will clobber future output. Not good. */ + if (dup2(1, 1) != 1) + return -1; + /* bash builtin errors out on "printf '-%s-\n' foo", * coreutils-6.9 works. Both work with "printf -- '-%s-\n' foo". * We will mimic coreutils. */ Modified: trunk/busybox/include/applets.h =================================================================== --- trunk/busybox/include/applets.h 2008-06-01 22:11:07 UTC (rev 22174) +++ trunk/busybox/include/applets.h 2008-06-01 22:36:39 UTC (rev 22175) @@ -275,7 +275,7 @@ USE_PKILL(APPLET_ODDNAME(pkill, pgrep, _BB_DIR_USR_BIN, _BB_SUID_NEVER, pkill)) USE_HALT(APPLET_ODDNAME(poweroff, halt, _BB_DIR_SBIN, _BB_SUID_NEVER, poweroff)) USE_PRINTENV(APPLET(printenv, _BB_DIR_BIN, _BB_SUID_NEVER)) -USE_PRINTF(APPLET(printf, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) +USE_PRINTF(APPLET_NOFORK(printf, printf, _BB_DIR_USR_BIN, _BB_SUID_NEVER, printf)) USE_PS(APPLET(ps, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_PSCAN(APPLET(pscan, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_PWD(APPLET_NOFORK(pwd, pwd, _BB_DIR_BIN, _BB_SUID_NEVER, pwd)) Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2008-06-01 22:11:07 UTC (rev 22174) +++ trunk/busybox/include/libbb.h 2008-06-01 22:36:39 UTC (rev 22175) @@ -878,13 +878,16 @@ #endif -/* applets which are useful from another applets */ +/* Applets which are useful from another applets */ int bb_cat(char** argv); -/* If shell needs them, these three "exist" even if not enabled as applets */ +/* If shell needs them, they exist even if not enabled as applets */ int echo_main(int argc, char** argv) USE_ECHO(MAIN_EXTERNALLY_VISIBLE); +int printf_main(int argc, char **argv) USE_PRINTF(MAIN_EXTERNALLY_VISIBLE); int test_main(int argc, char **argv) USE_TEST(MAIN_EXTERNALLY_VISIBLE); int kill_main(int argc, char **argv) USE_KILL(MAIN_EXTERNALLY_VISIBLE); -int chown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; +/* Similar, but used by chgrp, not shell */ +int chown_main(int argc, char **argv) USE_CHOWN(MAIN_EXTERNALLY_VISIBLE); +/* Don't need USE_xxx() guard for these */ int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int bbunpack(char **argv, Modified: trunk/busybox/miscutils/last.c =================================================================== --- trunk/busybox/miscutils/last.c 2008-06-01 22:11:07 UTC (rev 22174) +++ trunk/busybox/miscutils/last.c 2008-06-01 22:36:39 UTC (rev 22175) @@ -10,6 +10,9 @@ #include "libbb.h" #include +/* NB: ut_name and ut_user are the same field, use only one name (ut_user) + * to reduce confusion */ + #ifndef SHUTDOWN_TIME # define SHUTDOWN_TIME 254 #endif Modified: trunk/busybox/miscutils/last_fancy.c =================================================================== --- trunk/busybox/miscutils/last_fancy.c 2008-06-01 22:11:07 UTC (rev 22174) +++ trunk/busybox/miscutils/last_fancy.c 2008-06-01 22:36:39 UTC (rev 22175) @@ -10,6 +10,9 @@ #include "libbb.h" #include +/* NB: ut_name and ut_user are the same field, use only one name (ut_user) + * to reduce confusion */ + #ifndef SHUTDOWN_TIME # define SHUTDOWN_TIME 254 #endif Modified: trunk/busybox/shell/Config.in =================================================================== --- trunk/busybox/shell/Config.in 2008-06-01 22:11:07 UTC (rev 22174) +++ trunk/busybox/shell/Config.in 2008-06-01 22:36:39 UTC (rev 22175) @@ -114,6 +114,13 @@ help Enable support for echo, builtin to ash. +config ASH_BUILTIN_PRINTF + bool "Builtin version of 'printf'" + default y + depends on ASH + help + Enable support for printf, builtin to ash. + config ASH_BUILTIN_TEST bool "Builtin version of 'test'" default y Modified: trunk/busybox/shell/ash.c =================================================================== --- trunk/busybox/shell/ash.c 2008-06-01 22:11:07 UTC (rev 22174) +++ trunk/busybox/shell/ash.c 2008-06-01 22:36:39 UTC (rev 22175) @@ -8488,17 +8488,18 @@ * Apart from the above, [[ expr ]] should work as [ expr ] */ -#define testcmd test_main -#define echocmd echo_main +#define echocmd echo_main +#define printfcmd printf_main +#define testcmd test_main /* Keep these in proper order since it is searched via bsearch() */ static const struct builtincmd builtintab[] = { { BUILTIN_SPEC_REG ".", dotcmd }, { BUILTIN_SPEC_REG ":", truecmd }, #if ENABLE_ASH_BUILTIN_TEST - { BUILTIN_REGULAR "[", testcmd }, + { BUILTIN_REGULAR "[", testcmd }, #if ENABLE_ASH_BASH_COMPAT - { BUILTIN_REGULAR "[[", testcmd }, + { BUILTIN_REGULAR "[[", testcmd }, #endif #endif #if ENABLE_ASH_ALIAS @@ -8540,6 +8541,9 @@ { BUILTIN_NOSPEC "let", letcmd }, #endif { BUILTIN_ASSIGN "local", localcmd }, +#if ENABLE_ASH_BUILTIN_PRINTF + { BUILTIN_REGULAR "printf", printfcmd }, +#endif { BUILTIN_NOSPEC "pwd", pwdcmd }, { BUILTIN_REGULAR "read", readcmd }, { BUILTIN_SPEC_REG_ASSG "readonly", exportcmd }, @@ -8548,7 +8552,7 @@ { BUILTIN_SPEC_REG "shift", shiftcmd }, { BUILTIN_SPEC_REG "source", dotcmd }, #if ENABLE_ASH_BUILTIN_TEST - { BUILTIN_REGULAR "test", testcmd }, + { BUILTIN_REGULAR "test", testcmd }, #endif { BUILTIN_SPEC_REG "times", timescmd }, { BUILTIN_SPEC_REG "trap", trapcmd }, From vda at busybox.net Sun Jun 1 21:51:30 2008 From: vda at busybox.net (vda at busybox.net) Date: Sun, 1 Jun 2008 21:51:30 -0700 (PDT) Subject: svn commit: trunk/busybox: modutils scripts Message-ID: <20080602045130.A89F73C834@busybox.net> Author: vda Date: 2008-06-01 21:51:29 -0700 (Sun, 01 Jun 2008) New Revision: 22176 Log: Reinstate CONFIG_CROSS_COMPILE_PREFIX Modified: trunk/busybox/Config.in trunk/busybox/Makefile trunk/busybox/modutils/insmod.c trunk/busybox/scripts/Makefile.IMA Changeset: Modified: trunk/busybox/Config.in =================================================================== --- trunk/busybox/Config.in 2008-06-01 22:36:39 UTC (rev 22175) +++ trunk/busybox/Config.in 2008-06-02 04:51:29 UTC (rev 22176) @@ -363,6 +363,16 @@ cp, mount, tar, and many others. If you want to access files larger than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'. +config CROSS_COMPILER_PREFIX + string "Cross Compiler prefix" + default "" + help + If you want to build BusyBox with a cross compiler, then you + will need to set this to the cross-compiler prefix, for example, + "i386-uclibc-". Note that CROSS_COMPILE environment variable + or "make CROSS_COMPILE=xxx ..." will override this selection. + For native build leave it empty. + endmenu menu 'Debugging Options' Modified: trunk/busybox/Makefile =================================================================== --- trunk/busybox/Makefile 2008-06-01 22:36:39 UTC (rev 22175) +++ trunk/busybox/Makefile 2008-06-02 04:51:29 UTC (rev 22176) @@ -142,17 +142,6 @@ export srctree objtree VPATH TOPDIR -# SUBARCH tells the usermode build what the underlying arch is. That is set -# first, and if a usermode build is happening, the "ARCH=um" on the command -# line overrides the setting of ARCH below. If a native build is happening, -# then ARCH is assigned, getting whatever value it gets normally, and -# SUBARCH is subsequently ignored. - -SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ - -e s/arm.*/arm/ -e s/sa110/arm/ \ - -e s/s390x/s390/ -e s/parisc64/parisc/ \ - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ ) - # Cross compiling and selecting different set of gcc/bin-utils # --------------------------------------------------------------------------- # @@ -172,9 +161,34 @@ # Default value for CROSS_COMPILE is not to prefix executables # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile -ARCH ?= $(SUBARCH) CROSS_COMPILE ?= +# bbox: we may have CONFIG_CROSS_COMPILER_PREFIX in .config, +# and it has not been included yet... thus using an awkward syntax. +ifeq ($(CROSS_COMPILE),) +CROSS_COMPILE := $(shell grep ^CONFIG_CROSS_COMPILER_PREFIX .config 2>/dev/null) +CROSS_COMPILE := $(subst CONFIG_CROSS_COMPILER_PREFIX=,,$(CROSS_COMPILE)) +CROSS_COMPILE := $(subst ",,$(CROSS_COMPILE)) +endif +# SUBARCH tells the usermode build what the underlying arch is. That is set +# first, and if a usermode build is happening, the "ARCH=um" on the command +# line overrides the setting of ARCH below. If a native build is happening, +# then ARCH is assigned, getting whatever value it gets normally, and +# SUBARCH is subsequently ignored. + +ifneq ($(CROSS_COMPILE),) +SUBARCH := $(shell echo $(CROSS_COMPILE) | cut -d- -f1) +else +SUBARCH := $(shell uname -m) +endif +SUBARCH := $(shell echo $(SUBARCH) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ ) + +ARCH ?= $(SUBARCH) +$(warning ARCH=$(ARCH) SUBARCH=$(SUBARCH)) + # Architecture as present in compile.h UTS_MACHINE := $(ARCH) Modified: trunk/busybox/modutils/insmod.c =================================================================== --- trunk/busybox/modutils/insmod.c 2008-06-01 22:36:39 UTC (rev 22175) +++ trunk/busybox/modutils/insmod.c 2008-06-02 04:51:29 UTC (rev 22176) @@ -452,7 +452,7 @@ /* The system calls unchanged between 2.0 and 2.1. */ unsigned long create_module(const char *, size_t); -int delete_module(const char *); +int delete_module(const char *module, unsigned int flags); #endif /* module.h */ @@ -4141,18 +4141,18 @@ * now we can load them directly into the kernel memory */ if (!obj_load_progbits(fp, f, (char*)m_addr)) { - delete_module(m_name); + delete_module(m_name, 0); goto out; } #endif if (!obj_relocate(f, m_addr)) { - delete_module(m_name); + delete_module(m_name, 0); goto out; } if (!new_init_module(m_name, f, m_size)) { - delete_module(m_name); + delete_module(m_name, 0); goto out; } Modified: trunk/busybox/scripts/Makefile.IMA =================================================================== --- trunk/busybox/scripts/Makefile.IMA 2008-06-01 22:36:39 UTC (rev 22175) +++ trunk/busybox/scripts/Makefile.IMA 2008-06-02 04:51:29 UTC (rev 22176) @@ -1,4 +1,7 @@ # This is completely unsupported. +# +# Uasge: make -f scripts/Makefile.IMA +# # Fix COMBINED_COMPILE upstream (in the Kbuild) and propagate # the changes back srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)) @@ -11,6 +14,24 @@ default: busybox +include .config + +# Cross compiling and selecting different set of gcc/bin-utils +ifeq ($(CROSS_COMPILE),) +CROSS_COMPILE := $(subst ",,$(CONFIG_CROSS_COMPILER_PREFIX)) +endif + +ifneq ($(CROSS_COMPILE),) +SUBARCH := $(shell echo $(CROSS_COMPILE) | cut -d- -f1) +else +SUBARCH := $(shell uname -m) +endif +SUBARCH := $(shell echo $(SUBARCH) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ ) +ARCH ?= $(SUBARCH) + ifndef HOSTCC HOSTCC = cc endif @@ -27,19 +48,11 @@ CFLAGS := $(CFLAGS) CPPFLAGS+= -D"KBUILD_STR(s)=\#s" #-Q -include .config # We need some generic definitions include $(srctree)/scripts/Kbuild.include include Makefile.flags -SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ - -e s/arm.*/arm/ -e s/sa110/arm/ \ - -e s/s390x/s390/ -e s/parisc64/parisc/ \ - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ ) -ARCH ?= $(SUBARCH) - -# Cross compiling and selecting different set of gcc/bin-utils -include $(srctree)/arch/$(ARCH)/Makefile ifdef CONFIG_FEATURE_COMPRESS_USAGE usage_stuff = include/usage_compressed.h From aldot at busybox.net Mon Jun 2 04:01:41 2008 From: aldot at busybox.net (aldot at busybox.net) Date: Mon, 2 Jun 2008 04:01:41 -0700 (PDT) Subject: svn commit: trunk/busybox/util-linux Message-ID: <20080602110141.89BB73C8BA@busybox.net> Author: aldot Date: 2008-06-02 04:01:40 -0700 (Mon, 02 Jun 2008) New Revision: 22178 Log: - pm_states[PM_SUSPEND_MAX] suggests to support "standby" and not "suspend" Thanks to Paulius Zaleckas for mentioning this. Modified: trunk/busybox/util-linux/rtcwake.c Changeset: Modified: trunk/busybox/util-linux/rtcwake.c =================================================================== --- trunk/busybox/util-linux/rtcwake.c 2008-06-02 05:49:58 UTC (rev 22177) +++ trunk/busybox/util-linux/rtcwake.c 2008-06-02 11:01:40 UTC (rev 22178) @@ -26,7 +26,7 @@ #define SYS_RTC_PATH "/sys/class/rtc/%s/device/power/wakeup" #define SYS_POWER_PATH "/sys/power/state" -#define DEFAULT_MODE "suspend" +#define DEFAULT_MODE "standby" static time_t rtc_time; From aldot at busybox.net Mon Jun 2 06:28:48 2008 From: aldot at busybox.net (aldot at busybox.net) Date: Mon, 2 Jun 2008 06:28:48 -0700 (PDT) Subject: svn commit: trunk/busybox/modutils Message-ID: <20080602132848.651C33C8C7@busybox.net> Author: aldot Date: 2008-06-02 06:28:47 -0700 (Mon, 02 Jun 2008) New Revision: 22182 Log: - optional fancy pruning-mode for depmod Modified: trunk/busybox/modutils/Config.in trunk/busybox/modutils/depmod.c Changeset: Modified: trunk/busybox/modutils/Config.in =================================================================== --- trunk/busybox/modutils/Config.in 2008-06-02 12:25:24 UTC (rev 22181) +++ trunk/busybox/modutils/Config.in 2008-06-02 13:28:47 UTC (rev 22182) @@ -11,6 +11,20 @@ help depmod generates modules.dep (FIXME: elaborate) +config FEATURE_DEPMOD_PRUNE_FANCY + bool "fancy dependency pruning" + default n + depends on DEPMOD + help + By default modules.dep contains all dependencies as listed by + the modules. + If you enable this option then we remove implied modules from + the dependencies. + This makes depmod somewhat bigger but generates a smaller + modules.dep file. + + If unsure, say N. + config INSMOD bool "insmod" default n Modified: trunk/busybox/modutils/depmod.c =================================================================== --- trunk/busybox/modutils/depmod.c 2008-06-02 12:25:24 UTC (rev 22181) +++ trunk/busybox/modutils/depmod.c 2008-06-02 13:28:47 UTC (rev 22182) @@ -10,15 +10,27 @@ #define _GNU_SOURCE #include #include /* uname() */ - +#if ENABLE_DEBUG +#include +#define dbg_assert assert +#else +#define dbg_assert(stuff) do {} while (0) +#endif /* * Theory of operation: * - iterate over all modules and record their full path * - iterate over all modules looking for "depends=" entries * for each depends, look through our list of full paths and emit if found */ + +typedef struct dep_lst_t { + char *name; + llist_t *dependencies; + struct dep_lst_t *next; +} dep_lst_t; + struct globals { - llist_t *lst; /* modules without their corresponding extension */ + dep_lst_t *lst; /* modules without their corresponding extension */ size_t moddir_base_len; /* length of the "-b basedir" */ }; #define G (*(struct globals*)&bb_common_bufsiz1) @@ -28,22 +40,28 @@ static int fill_lst(const char *modulename, struct stat ATTRIBUTE_UNUSED *sb, void ATTRIBUTE_UNUSED *data, int ATTRIBUTE_UNUSED depth) { + /* We get a file here. If the file does not have ".ko" but an * intermittent dentry has, it's just their fault. */ - if (strrstr(modulename, ".ko") != NULL) - llist_add_to(&G.lst, xstrdup(modulename + G.moddir_base_len)); + if (strrstr(modulename, ".ko") != NULL) { + dep_lst_t *new = xzalloc(sizeof(dep_lst_t)); + new->name = xstrdup(modulename + G.moddir_base_len); + new->next = G.lst; + G.lst = new; + } return TRUE; } static int fileAction(const char *fname, struct stat *sb, - void *data, int ATTRIBUTE_UNUSED depth) + void ATTRIBUTE_UNUSED *data, int ATTRIBUTE_UNUSED depth) { size_t len = sb->st_size; void *the_module; char *ptr; int fd; char *depends, *deps; + dep_lst_t *this; if (strrstr(fname, ".ko") == NULL) /* not a module */ goto skip; @@ -61,40 +79,44 @@ close(fd); if (the_module == MAP_FAILED) bb_perror_msg_and_die("mmap"); - ptr = the_module; - - fprintf((FILE*)data, "%s:", fname + G.moddir_base_len); + this = G.lst; + do { + if (!strcmp(fname + G.moddir_base_len, this->name)) + break; + this = this->next; + } while (this); + dbg_assert (this); //bb_info_msg("fname='%s'", fname + G.moddir_base_len); do { /* search for a 'd' */ ptr = memchr(ptr, 'd', len - (ptr - (char*)the_module)); if (ptr == NULL) /* no d left, done */ goto none; - if (strncmp(ptr, "depends=", sizeof("depends=")-1) == 0) + if (!strncmp(ptr, "depends=", sizeof("depends=")-1)) break; ++ptr; } while (1); deps = depends = xstrdup (ptr + sizeof("depends=")-1); //bb_info_msg(" depends='%s'", depends); while (deps) { - llist_t * _lst = G.lst; + dep_lst_t *all = G.lst; ptr = strsep(&deps, ","); - while (_lst) { + while (all) { /* Compare the recorded filenames ignoring ".ko*" at the end. */ - char *tmp = bb_get_last_path_component_nostrip(_lst->data); - if (strncmp(ptr, tmp, strrstr(tmp, ".ko") - tmp) == 0) + char *tmp = bb_get_last_path_component_nostrip(all->name); + if (!strncmp(ptr, tmp, MAX(strlen(ptr),strrstr(tmp, ".ko") - tmp))) break; /* found it */ - _lst = _lst->link; + all = all->next; } - if (_lst) { -//bb_info_msg("[%s] -> '%s'", (char*)ptr, _lst->data); - fprintf((FILE*)data, " %s", _lst->data); + if (all) { + dbg_assert(all->name); /* this cannot be empty */ +//bb_info_msg("[%s] -> '%s'", (char*)ptr, all->name); + llist_add_to_end(&this->dependencies, all->name); } } free(depends); - fprintf((FILE*)data, "\n"); none: munmap(the_module, sb->st_size); skip: @@ -115,11 +137,14 @@ ARG_F = (1<<4), /* System.map that contains the symbols */ ARG_n = (1<<5) /* dry-run, print to stdout only */ }; + INIT_G(); getopt32(argv, "aAb:eF:n", &moddir_base, &system_map); argv += optind; - /* got a version to use? */ + /* 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", &ret, &ret, &ret) == 3)) { moddir = concat_path_file(CONFIG_DEFAULT_MODULES_DIR, *argv++); } else { @@ -160,6 +185,9 @@ else return EXIT_FAILURE; } +#if ENABLE_FEATURE_CLEAN_UP + else +#endif do { chp = option_mask32 & ARG_a ? moddir : *argv++; @@ -167,16 +195,74 @@ ACTION_RECURSE, /* flags */ fileAction, /* file action */ NULL, /* dir action */ - (void*)filedes, /* user data */ + NULL, /* user data */ 0)) { /* depth */ ret = EXIT_FAILURE; } } while (!(option_mask32 & ARG_a) && *argv); + /* modprobe allegedly wants dependencies without duplicates, i.e. + * mod1: mod2 mod3 + * mod2: mod3 + * mod3: + * implies that mod1 directly depends on mod2 and _not_ mod3 as mod3 is + * already implicitely pulled in via mod2. This leaves us with: + * mod1: mod2 + * mod2: mod3 + * mod3: + */ + { + dep_lst_t *mods = G.lst; +#if ENABLE_FEATURE_DEPMOD_PRUNE_FANCY + while (mods) { + llist_t *deps = mods->dependencies; + while (deps) { + dep_lst_t *all = G.lst; + while (all) { + if (!strcmp(all->name, deps->data)) { + llist_t *implied = all->dependencies; + while (implied) { + /* erm, nicer would be to just + * llist_unlink(&mods->dependencies, implied) */ + llist_t *prune = mods->dependencies; + while (prune) { + if (!strcmp(implied->data, prune->data)) + break; + prune = prune->link; + } +//if (prune) bb_info_msg("[%s] '%s' implies '%s', removing", mods->name, all->name, implied->data); + llist_unlink(&mods->dependencies, prune); + implied = implied->link; + } + } + all = all->next; + } + deps = deps->link; + } + mods = mods->next; + } + + mods = G.lst; +#endif + /* Finally print them. */ + while (mods) { + fprintf(filedes, "%s:", mods->name); + while (mods->dependencies) + fprintf(filedes, " %s", (char*)llist_pop(&mods->dependencies)); + fprintf(filedes, "\n"); + mods = mods->next; + } + } + if (ENABLE_FEATURE_CLEAN_UP) { fclose_if_not_stdin(filedes); - llist_free(G.lst, free); free(moddir); + while (G.lst) { + dep_lst_t *old = G.lst; + G.lst = G.lst->next; + free(old->name); + free(old); + } } return ret; } From aldot at busybox.net Mon Jun 2 06:34:37 2008 From: aldot at busybox.net (aldot at busybox.net) Date: Mon, 2 Jun 2008 06:34:37 -0700 (PDT) Subject: svn commit: trunk/busybox/modutils Message-ID: <20080602133438.012133C8A1@busybox.net> Author: aldot Date: 2008-06-02 06:34:36 -0700 (Mon, 02 Jun 2008) New Revision: 22183 Log: - just chdir to the basedir (-30b). Modified: trunk/busybox/modutils/depmod.c Changeset: Modified: trunk/busybox/modutils/depmod.c =================================================================== --- trunk/busybox/modutils/depmod.c 2008-06-02 13:28:47 UTC (rev 22182) +++ trunk/busybox/modutils/depmod.c 2008-06-02 13:34:36 UTC (rev 22183) @@ -31,7 +31,6 @@ struct globals { dep_lst_t *lst; /* modules without their corresponding extension */ - size_t moddir_base_len; /* length of the "-b basedir" */ }; #define G (*(struct globals*)&bb_common_bufsiz1) /* We have to zero it out because of NOEXEC */ @@ -46,7 +45,7 @@ */ if (strrstr(modulename, ".ko") != NULL) { dep_lst_t *new = xzalloc(sizeof(dep_lst_t)); - new->name = xstrdup(modulename + G.moddir_base_len); + new->name = xstrdup(modulename); new->next = G.lst; G.lst = new; } @@ -82,12 +81,12 @@ ptr = the_module; this = G.lst; do { - if (!strcmp(fname + G.moddir_base_len, this->name)) + if (!strcmp(fname, this->name)) break; this = this->next; } while (this); dbg_assert (this); -//bb_info_msg("fname='%s'", fname + G.moddir_base_len); +//bb_info_msg("fname='%s'", fname); do { /* search for a 'd' */ ptr = memchr(ptr, 'd', len - (ptr - (char*)the_module)); @@ -157,13 +156,7 @@ option_mask32 |= *argv == NULL; if (option_mask32 & ARG_b) { - G.moddir_base_len = strlen(moddir_base); - if (ENABLE_FEATURE_CLEAN_UP) { - chp = moddir; - moddir = concat_path_file(moddir_base, moddir); - free (chp); - } else - moddir = concat_path_file(moddir_base, moddir); + xchdir(moddir_base); } if (!(option_mask32 & ARG_n)) { /* --dry-run */ From aldot at busybox.net Mon Jun 2 06:40:13 2008 From: aldot at busybox.net (aldot at busybox.net) Date: Mon, 2 Jun 2008 06:40:13 -0700 (PDT) Subject: svn commit: trunk/busybox/modutils Message-ID: <20080602134013.AF7C33C8C9@busybox.net> Author: aldot Date: 2008-06-02 06:40:13 -0700 (Mon, 02 Jun 2008) New Revision: 22184 Log: - revert revision 22183 since it breaks -b /abs /abs/path/to/mod.ko Modified: trunk/busybox/modutils/depmod.c Changeset: Modified: trunk/busybox/modutils/depmod.c =================================================================== --- trunk/busybox/modutils/depmod.c 2008-06-02 13:34:36 UTC (rev 22183) +++ trunk/busybox/modutils/depmod.c 2008-06-02 13:40:13 UTC (rev 22184) @@ -31,6 +31,7 @@ struct globals { dep_lst_t *lst; /* modules without their corresponding extension */ + size_t moddir_base_len; /* length of the "-b basedir" */ }; #define G (*(struct globals*)&bb_common_bufsiz1) /* We have to zero it out because of NOEXEC */ @@ -45,7 +46,7 @@ */ if (strrstr(modulename, ".ko") != NULL) { dep_lst_t *new = xzalloc(sizeof(dep_lst_t)); - new->name = xstrdup(modulename); + new->name = xstrdup(modulename + G.moddir_base_len); new->next = G.lst; G.lst = new; } @@ -81,12 +82,12 @@ ptr = the_module; this = G.lst; do { - if (!strcmp(fname, this->name)) + if (!strcmp(fname + G.moddir_base_len, this->name)) break; this = this->next; } while (this); dbg_assert (this); -//bb_info_msg("fname='%s'", fname); +//bb_info_msg("fname='%s'", fname + G.moddir_base_len); do { /* search for a 'd' */ ptr = memchr(ptr, 'd', len - (ptr - (char*)the_module)); @@ -156,7 +157,13 @@ option_mask32 |= *argv == NULL; if (option_mask32 & ARG_b) { - xchdir(moddir_base); + G.moddir_base_len = strlen(moddir_base); + if (ENABLE_FEATURE_CLEAN_UP) { + chp = moddir; + moddir = concat_path_file(moddir_base, moddir); + free (chp); + } else + moddir = concat_path_file(moddir_base, moddir); } if (!(option_mask32 & ARG_n)) { /* --dry-run */ From aldot at busybox.net Mon Jun 2 11:59:17 2008 From: aldot at busybox.net (aldot at busybox.net) Date: Mon, 2 Jun 2008 11:59:17 -0700 (PDT) Subject: svn commit: trunk/busybox/modutils Message-ID: <20080602185917.B0EA53C8C1@busybox.net> Author: aldot Date: 2008-06-02 11:59:16 -0700 (Mon, 02 Jun 2008) New Revision: 22185 Log: - add alias support Modified: trunk/busybox/modutils/Config.in trunk/busybox/modutils/depmod.c Changeset: Modified: trunk/busybox/modutils/Config.in =================================================================== --- trunk/busybox/modutils/Config.in 2008-06-02 13:40:13 UTC (rev 22184) +++ trunk/busybox/modutils/Config.in 2008-06-02 18:59:16 UTC (rev 22185) @@ -25,6 +25,16 @@ If unsure, say N. +config FEATURE_DEPMOD_ALIAS + bool "alias support" + default n + depends on DEPMOD + help + By default modules.dep does not contain alias information. + Enable this to emit aliases of the form: + + alias pcmcia:m*c*f03fn*pfn*pa*pb*pc*pd* parport_cs + config INSMOD bool "insmod" default n Modified: trunk/busybox/modutils/depmod.c =================================================================== --- trunk/busybox/modutils/depmod.c 2008-06-02 13:40:13 UTC (rev 22184) +++ trunk/busybox/modutils/depmod.c 2008-06-02 18:59:16 UTC (rev 22185) @@ -10,12 +10,6 @@ #define _GNU_SOURCE #include #include /* uname() */ -#if ENABLE_DEBUG -#include -#define dbg_assert assert -#else -#define dbg_assert(stuff) do {} while (0) -#endif /* * Theory of operation: * - iterate over all modules and record their full path @@ -26,33 +20,33 @@ typedef struct dep_lst_t { char *name; llist_t *dependencies; + llist_t *aliases; struct dep_lst_t *next; } dep_lst_t; struct globals { dep_lst_t *lst; /* modules without their corresponding extension */ - size_t moddir_base_len; /* length of the "-b basedir" */ }; #define G (*(struct globals*)&bb_common_bufsiz1) /* We have to zero it out because of NOEXEC */ #define INIT_G() memset(&G, 0, sizeof(G)) -static int fill_lst(const char *modulename, struct stat ATTRIBUTE_UNUSED *sb, - void ATTRIBUTE_UNUSED *data, int ATTRIBUTE_UNUSED depth) +static char* find_keyword(void *the_module, size_t len, const char * const word) { - - /* We get a file here. If the file does not have ".ko" but an - * intermittent dentry has, it's just their fault. - */ - if (strrstr(modulename, ".ko") != NULL) { - dep_lst_t *new = xzalloc(sizeof(dep_lst_t)); - new->name = xstrdup(modulename + G.moddir_base_len); - new->next = G.lst; - G.lst = new; - } - return TRUE; + char *ptr = the_module; + do { + /* search for the first char in word */ + ptr = memchr(ptr, *word, len - (ptr - (char*)the_module)); + if (ptr == NULL) /* no occurance left, done */ + return NULL; + if (!strncmp(ptr, word, strlen(word))) { + ptr += strlen(word); + break; + } + ++ptr; + } while (1); + return ptr; } - static int fileAction(const char *fname, struct stat *sb, void ATTRIBUTE_UNUSED *data, int ATTRIBUTE_UNUSED depth) { @@ -79,45 +73,37 @@ close(fd); if (the_module == MAP_FAILED) bb_perror_msg_and_die("mmap"); - ptr = the_module; - this = G.lst; - do { - if (!strcmp(fname + G.moddir_base_len, this->name)) - break; - this = this->next; - } while (this); - dbg_assert (this); -//bb_info_msg("fname='%s'", fname + G.moddir_base_len); - do { - /* search for a 'd' */ - ptr = memchr(ptr, 'd', len - (ptr - (char*)the_module)); - if (ptr == NULL) /* no d left, done */ - goto none; - if (!strncmp(ptr, "depends=", sizeof("depends=")-1)) - break; - ++ptr; - } while (1); - deps = depends = xstrdup (ptr + sizeof("depends=")-1); + + this = xzalloc(sizeof(dep_lst_t)); + this->name = xstrdup(fname); + this->next = G.lst; + G.lst = this; +//bb_info_msg("fname='%s'", fname); + ptr = find_keyword(the_module, len, "depends="); + if (!*ptr) + goto d_none; + deps = depends = xstrdup(ptr); //bb_info_msg(" depends='%s'", depends); while (deps) { - dep_lst_t *all = G.lst; - ptr = strsep(&deps, ","); - while (all) { - /* Compare the recorded filenames ignoring ".ko*" at the end. */ - char *tmp = bb_get_last_path_component_nostrip(all->name); - if (!strncmp(ptr, tmp, MAX(strlen(ptr),strrstr(tmp, ".ko") - tmp))) - break; /* found it */ - all = all->next; - } - if (all) { - dbg_assert(all->name); /* this cannot be empty */ -//bb_info_msg("[%s] -> '%s'", (char*)ptr, all->name); - llist_add_to_end(&this->dependencies, all->name); - } +//bb_info_msg("[%s] -> '%s'", fname, (char*)ptr); + llist_add_to_end(&this->dependencies, xstrdup(ptr)); } free(depends); - none: + d_none: + if (ENABLE_FEATURE_DEPMOD_ALIAS) + { + size_t pos = 0; + do { + ptr = find_keyword(the_module + pos, len - pos, "alias="); + if (ptr) { +//bb_info_msg("[%s] alias '%s'", fname, (char*)ptr); + llist_add_to_end(&this->aliases, xstrdup(ptr)); + } else + break; + pos = (ptr - (char*)the_module); + } while (1); + } munmap(the_module, sb->st_size); skip: return TRUE; @@ -127,6 +113,7 @@ int depmod_main(int ATTRIBUTE_UNUSED argc, char **argv) { int ret; + size_t moddir_base_len = 0; /* length of the "-b basedir" */ char *moddir_base = NULL, *moddir, *system_map, *chp; FILE *filedes = stdout; enum { @@ -157,13 +144,8 @@ option_mask32 |= *argv == NULL; if (option_mask32 & ARG_b) { - G.moddir_base_len = strlen(moddir_base); - if (ENABLE_FEATURE_CLEAN_UP) { - chp = moddir; - moddir = concat_path_file(moddir_base, moddir); - free (chp); - } else - moddir = concat_path_file(moddir_base, moddir); + moddir_base_len = strlen(moddir_base) + 1; + xchdir(moddir_base); } if (!(option_mask32 & ARG_n)) { /* --dry-run */ @@ -173,23 +155,8 @@ free(chp); } ret = EXIT_SUCCESS; - /* We have to do a full walk to collect all needed data. */ - if (!recursive_action(moddir, - ACTION_RECURSE, /* flags */ - fill_lst, /* file action */ - NULL, /* dir action */ - NULL, /* user data */ - 0)) { /* depth */ - if (ENABLE_FEATURE_CLEAN_UP) - ret = EXIT_FAILURE; - else - return EXIT_FAILURE; - } -#if ENABLE_FEATURE_CLEAN_UP - else -#endif do { - chp = option_mask32 & ARG_a ? moddir : *argv++; + chp = option_mask32 & ARG_a ? moddir : (*argv + moddir_base_len); if (!recursive_action(chp, ACTION_RECURSE, /* flags */ @@ -199,8 +166,42 @@ 0)) { /* depth */ ret = EXIT_FAILURE; } - } while (!(option_mask32 & ARG_a) && *argv); + } while (!(option_mask32 & ARG_a) && *++argv); + { + dep_lst_t *mods = G.lst; + + /* Fixup the module names in the depends list */ + while (mods) { + llist_t *deps = NULL, *old_deps = mods->dependencies; + + while (old_deps) { + dep_lst_t *all = G.lst; + char *longname = NULL; + char *shortname = llist_pop(&old_deps); + + while (all) { + char *nam = + xstrdup(bb_get_last_path_component_nostrip(all->name)); + char *tmp = strrstr(nam, ".ko"); + + *tmp = '\0'; + if (!strcmp(nam, shortname)) { + if (ENABLE_FEATURE_CLEAN_UP) + free(nam); + longname = all->name; + break; + } + free(nam); + all = all->next; + } + llist_add_to_end(&deps, longname); + } + mods->dependencies = deps; + mods = mods->next; + } + +#if ENABLE_FEATURE_DEPMOD_PRUNE_FANCY /* modprobe allegedly wants dependencies without duplicates, i.e. * mod1: mod2 mod3 * mod2: mod3 @@ -211,9 +212,7 @@ * mod2: mod3 * mod3: */ - { - dep_lst_t *mods = G.lst; -#if ENABLE_FEATURE_DEPMOD_PRUNE_FANCY + mods = G.lst; while (mods) { llist_t *deps = mods->dependencies; while (deps) { @@ -241,15 +240,36 @@ } mods = mods->next; } +#endif mods = G.lst; -#endif /* Finally print them. */ while (mods) { fprintf(filedes, "%s:", mods->name); - while (mods->dependencies) - fprintf(filedes, " %s", (char*)llist_pop(&mods->dependencies)); + /* If we did not resolve all modules, then it's likely that we just did + * not see the names of all prerequisites (which will be NULL in this + * case). */ + while (mods->dependencies) { + char *the_dep = llist_pop(&mods->dependencies); + if (the_dep) + fprintf(filedes, " %s", the_dep); + } fprintf(filedes, "\n"); + if (ENABLE_FEATURE_DEPMOD_ALIAS) + { + char *shortname = + xstrdup(bb_get_last_path_component_nostrip(mods->name)); + char *tmp = strrstr(shortname, ".ko"); + + *tmp = '\0'; + + while (mods->aliases) { + fprintf(filedes, "alias %s %s\n", + (char*)llist_pop(&mods->aliases), + shortname); + } + free(shortname); + } mods = mods->next; } } From aldot at busybox.net Mon Jun 2 12:23:48 2008 From: aldot at busybox.net (aldot at busybox.net) Date: Mon, 2 Jun 2008 12:23:48 -0700 (PDT) Subject: svn commit: trunk/busybox/modutils Message-ID: <20080602192348.71B1E3C86A@busybox.net> Author: aldot Date: 2008-06-02 12:23:47 -0700 (Mon, 02 Jun 2008) New Revision: 22186 Log: - add FIXME. Perhaps somebody is interrested in looking into this one. We would try to be clever and compare the *data instead of the *elt. Somethink like this might be of more general use: /* Unlink arbitrary element from the list that contains data */ void llist_unlink_data(llist_t **head, void *data) { llist_t *elt; for (elt = *head; elt; elt = elt->link) { if (elt->data == data) { llist_unlink(elt); return; } } } Modified: trunk/busybox/modutils/depmod.c Changeset: Modified: trunk/busybox/modutils/depmod.c =================================================================== --- trunk/busybox/modutils/depmod.c 2008-06-02 18:59:16 UTC (rev 22185) +++ trunk/busybox/modutils/depmod.c 2008-06-02 19:23:47 UTC (rev 22186) @@ -221,7 +221,7 @@ if (!strcmp(all->name, deps->data)) { llist_t *implied = all->dependencies; while (implied) { - /* erm, nicer would be to just + /* XXX:FIXME: erm, it would be nicer to just * llist_unlink(&mods->dependencies, implied) */ llist_t *prune = mods->dependencies; while (prune) { From vapier at busybox.net Mon Jun 2 13:37:45 2008 From: vapier at busybox.net (vapier at busybox.net) Date: Mon, 2 Jun 2008 13:37:45 -0700 (PDT) Subject: svn commit: trunk/busybox: include util-linux Message-ID: <20080602203745.D62F93C8F1@busybox.net> Author: vapier Date: 2008-06-02 13:37:45 -0700 (Mon, 02 Jun 2008) New Revision: 22187 Log: make the help for rtcwake reflect the actual default behavior Modified: trunk/busybox/include/usage.h trunk/busybox/util-linux/rtcwake.c Changeset: Modified: trunk/busybox/include/usage.h =================================================================== --- trunk/busybox/include/usage.h 2008-06-02 19:23:47 UTC (rev 22186) +++ trunk/busybox/include/usage.h 2008-06-02 20:37:45 UTC (rev 22187) @@ -3308,7 +3308,7 @@ "\n -l,--local Clock is set to local time" \ "\n -u,--utc Clock is set to UTC time" \ "\n -d,--device=DEV Specify the RTC device" \ - "\n -m,--mode=MODE Set the sleep state (default: standby)" \ + "\n -m,--mode=MODE Set the sleep state (default: suspend)" \ "\n -s,--seconds=SEC Set the timeout in SEC seconds from now" \ "\n -t,--time=TIME Set the timeout to TIME seconds from epoch" \ ) \ Modified: trunk/busybox/util-linux/rtcwake.c =================================================================== --- trunk/busybox/util-linux/rtcwake.c 2008-06-02 19:23:47 UTC (rev 22186) +++ trunk/busybox/util-linux/rtcwake.c 2008-06-02 20:37:45 UTC (rev 22187) @@ -26,7 +26,7 @@ #define SYS_RTC_PATH "/sys/class/rtc/%s/device/power/wakeup" #define SYS_POWER_PATH "/sys/power/state" -#define DEFAULT_MODE "standby" +#define DEFAULT_MODE "suspend" static time_t rtc_time; From vda at busybox.net Mon Jun 2 15:24:35 2008 From: vda at busybox.net (vda at busybox.net) Date: Mon, 2 Jun 2008 15:24:35 -0700 (PDT) Subject: svn commit: trunk/busybox Message-ID: <20080602222435.1A7A13C910@busybox.net> Author: vda Date: 2008-06-02 15:24:34 -0700 (Mon, 02 Jun 2008) New Revision: 22190 Log: Remove stray debug instrumentation Modified: trunk/busybox/Makefile Changeset: Modified: trunk/busybox/Makefile =================================================================== --- trunk/busybox/Makefile 2008-06-02 22:06:58 UTC (rev 22189) +++ trunk/busybox/Makefile 2008-06-02 22:24:34 UTC (rev 22190) @@ -161,7 +161,7 @@ # Default value for CROSS_COMPILE is not to prefix executables # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile -CROSS_COMPILE ?= +CROSS_COMPILE ?= # bbox: we may have CONFIG_CROSS_COMPILER_PREFIX in .config, # and it has not been included yet... thus using an awkward syntax. ifeq ($(CROSS_COMPILE),) @@ -186,8 +186,7 @@ -e s/s390x/s390/ -e s/parisc64/parisc/ \ -e s/ppc.*/powerpc/ -e s/mips.*/mips/ ) -ARCH ?= $(SUBARCH) -$(warning ARCH=$(ARCH) SUBARCH=$(SUBARCH)) +ARCH ?= $(SUBARCH) # Architecture as present in compile.h UTS_MACHINE := $(ARCH) From vda at busybox.net Wed Jun 4 00:59:52 2008 From: vda at busybox.net (vda at busybox.net) Date: Wed, 4 Jun 2008 00:59:52 -0700 (PDT) Subject: svn commit: trunk/busybox: include networking Message-ID: <20080604075952.353C13C649@busybox.net> Author: vda Date: 2008-06-04 00:59:51 -0700 (Wed, 04 Jun 2008) New Revision: 22208 Log: networking/interface.c: fix indentation Modified: trunk/busybox/include/libbb.h trunk/busybox/networking/ifconfig.c trunk/busybox/networking/interface.c Changeset: Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2008-06-03 23:28:43 UTC (rev 22207) +++ trunk/busybox/include/libbb.h 2008-06-04 07:59:51 UTC (rev 22208) @@ -934,6 +934,8 @@ int display_interfaces(char *ifname); #if ENABLE_FEATURE_HWIB int in_ib(const char *bufp, struct sockaddr *sap); +#else +#define in_ib(a, b) 1 /* fail */ #endif const struct aftype *get_aftype(const char *name); const struct hwtype *get_hwtype(const char *name); Modified: trunk/busybox/networking/ifconfig.c =================================================================== --- trunk/busybox/networking/ifconfig.c 2008-06-03 23:28:43 UTC (rev 22207) +++ trunk/busybox/networking/ifconfig.c 2008-06-04 07:59:51 UTC (rev 22208) @@ -252,20 +252,13 @@ /* * A couple of prototypes. */ - #if ENABLE_FEATURE_IFCONFIG_HW static int in_ether(const char *bufp, struct sockaddr *sap); -# if ENABLE_FEATURE_HWIB -extern int in_ib(const char *bufp, struct sockaddr *sap); -# else -# define in_ib(a, b) 1 /* fail */ -# endif #endif /* * Our main function. */ - int ifconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int ifconfig_main(int argc, char **argv) { @@ -436,8 +429,7 @@ bb_show_usage(); /*safe_strncpy(host, *argv, sizeof(host));*/ host = *argv; - if (hw_class == 1 ? in_ether(host, &sa) - : in_ib(host, &sa)) + if (hw_class == 1 ? in_ether(host, &sa) : in_ib(host, &sa)) bb_error_msg_and_die("invalid hw-addr %s", host); p = (char *) &sa; } Modified: trunk/busybox/networking/interface.c =================================================================== --- trunk/busybox/networking/interface.c 2008-06-03 23:28:43 UTC (rev 22207) +++ trunk/busybox/networking/interface.c 2008-06-04 07:59:51 UTC (rev 22208) @@ -680,7 +680,6 @@ return 0; } - static int do_if_fetch(struct interface *ife) { if (if_fetch(ife) < 0) { @@ -1217,63 +1216,62 @@ /* Input an Infiniband address and convert to binary. */ int in_ib(const char *bufp, struct sockaddr *sap) { - unsigned char *ptr; - char c; - const char *orig; - int i; - unsigned val; + unsigned char *ptr; + char c; + const char *orig; + int i; + unsigned val; - sap->sa_family = ib_hwtype.type; - ptr = (unsigned char *) sap->sa_data; + sap->sa_family = ib_hwtype.type; + ptr = (unsigned char *) sap->sa_data; - i = 0; - orig = bufp; - while ((*bufp != '\0') && (i < INFINIBAND_ALEN)) { - val = 0; - c = *bufp++; - if (isdigit(c)) - val = c - '0'; - else if (c >= 'a' && c <= 'f') - val = c - 'a' + 10; - else if (c >= 'A' && c <= 'F') - val = c - 'A' + 10; - else { - errno = EINVAL; - return (-1); - } - val <<= 4; - c = *bufp; - if (isdigit(c)) - val |= c - '0'; - else if (c >= 'a' && c <= 'f') - val |= c - 'a' + 10; - else if (c >= 'A' && c <= 'F') - val |= c - 'A' + 10; - else if (c == ':' || c == 0) - val >>= 4; - else { - errno = EINVAL; - return (-1); - } - if (c != 0) - bufp++; - *ptr++ = (unsigned char) (val & 0377); - i++; + i = 0; + orig = bufp; + while ((*bufp != '\0') && (i < INFINIBAND_ALEN)) { + val = 0; + c = *bufp++; + if (isdigit(c)) + val = c - '0'; + else if (c >= 'a' && c <= 'f') + val = c - 'a' + 10; + else if (c >= 'A' && c <= 'F') + val = c - 'A' + 10; + else { + errno = EINVAL; + return -1; + } + val <<= 4; + c = *bufp; + if (isdigit(c)) + val |= c - '0'; + else if (c >= 'a' && c <= 'f') + val |= c - 'a' + 10; + else if (c >= 'A' && c <= 'F') + val |= c - 'A' + 10; + else if (c == ':' || c == 0) + val >>= 4; + else { + errno = EINVAL; + return -1; + } + if (c != 0) + bufp++; + *ptr++ = (unsigned char) (val & 0377); + i++; - /* We might get a semicolon here - not required. */ - if (*bufp == ':') { - bufp++; + /* We might get a semicolon here - not required. */ + if (*bufp == ':') { + bufp++; + } } - } #ifdef DEBUG -fprintf(stderr, "in_ib(%s): %s\n", orig, UNSPEC_print(sap->sa_data)); + fprintf(stderr, "in_ib(%s): %s\n", orig, UNSPEC_print(sap->sa_data)); #endif - return (0); + return 0; } #endif - int display_interfaces(char *ifname) { int status; From vapier at busybox.net Wed Jun 4 03:33:34 2008 From: vapier at busybox.net (vapier at busybox.net) Date: Wed, 4 Jun 2008 03:33:34 -0700 (PDT) Subject: svn commit: trunk/busybox: include util-linux Message-ID: <20080604103334.279903C64E@busybox.net> Author: vapier Date: 2008-06-04 03:33:33 -0700 (Wed, 04 Jun 2008) New Revision: 22210 Log: change default rtcwake mode to match changed behavior in upstream util-linux Modified: trunk/busybox/include/usage.h trunk/busybox/util-linux/rtcwake.c Changeset: Modified: trunk/busybox/include/usage.h =================================================================== --- trunk/busybox/include/usage.h 2008-06-04 08:57:14 UTC (rev 22209) +++ trunk/busybox/include/usage.h 2008-06-04 10:33:33 UTC (rev 22210) @@ -3308,7 +3308,7 @@ "\n -l,--local Clock is set to local time" \ "\n -u,--utc Clock is set to UTC time" \ "\n -d,--device=DEV Specify the RTC device" \ - "\n -m,--mode=MODE Set the sleep state (default: suspend)" \ + "\n -m,--mode=MODE Set the sleep state (default: standby)" \ "\n -s,--seconds=SEC Set the timeout in SEC seconds from now" \ "\n -t,--time=TIME Set the timeout to TIME seconds from epoch" \ ) \ Modified: trunk/busybox/util-linux/rtcwake.c =================================================================== --- trunk/busybox/util-linux/rtcwake.c 2008-06-04 08:57:14 UTC (rev 22209) +++ trunk/busybox/util-linux/rtcwake.c 2008-06-04 10:33:33 UTC (rev 22210) @@ -26,7 +26,7 @@ #define SYS_RTC_PATH "/sys/class/rtc/%s/device/power/wakeup" #define SYS_POWER_PATH "/sys/power/state" -#define DEFAULT_MODE "suspend" +#define DEFAULT_MODE "standby" static time_t rtc_time; From vda at busybox.net Wed Jun 4 04:28:24 2008 From: vda at busybox.net (vda at busybox.net) Date: Wed, 4 Jun 2008 04:28:24 -0700 (PDT) Subject: svn commit: trunk/busybox: scripts Message-ID: <20080604112824.DE4743C64E@busybox.net> Author: vda Date: 2008-06-04 04:28:24 -0700 (Wed, 04 Jun 2008) New Revision: 22211 Log: build system: add PIE build option Modified: trunk/busybox/Config.in trunk/busybox/Makefile trunk/busybox/Makefile.flags trunk/busybox/scripts/Makefile.IMA trunk/busybox/scripts/Makefile.build Changeset: Modified: trunk/busybox/Config.in =================================================================== --- trunk/busybox/Config.in 2008-06-04 10:33:33 UTC (rev 22210) +++ trunk/busybox/Config.in 2008-06-04 11:28:24 UTC (rev 22211) @@ -262,6 +262,14 @@ Most people will leave this set to 'N'. +config PIE + bool "Build BusyBox as a position independent executable" + default n + depends on !STATIC + help + (TODO: what is it and why/when is it useful?) + Most people will leave this set to 'N'. + config NOMMU bool "Force NOMMU build" default n Modified: trunk/busybox/Makefile =================================================================== --- trunk/busybox/Makefile 2008-06-04 10:33:33 UTC (rev 22210) +++ trunk/busybox/Makefile 2008-06-04 11:28:24 UTC (rev 22211) @@ -315,6 +315,8 @@ # Use LINUXINCLUDE when you must reference the include/ directory. # Needed to be compatible with the O= option CFLAGS := $(CFLAGS) +# Added only to final link stage of busybox binary +CFLAGS_busybox := $(CFLAGS_busybox) CPPFLAGS := $(CPPFLAGS) AFLAGS := $(AFLAGS) LDFLAGS := $(LDFLAGS) @@ -580,7 +582,7 @@ cmd_busybox__ ?= $(srctree)/scripts/trylink \ "$@" \ "$(CC)" \ - "$(CFLAGS)" \ + "$(CFLAGS) $(CFLAGS_busybox)" \ "$(LDFLAGS) $(EXTRA_LDFLAGS)" \ "$(core-y)" \ "$(libs-y)" \ Modified: trunk/busybox/Makefile.flags =================================================================== --- trunk/busybox/Makefile.flags 2008-06-04 10:33:33 UTC (rev 22210) +++ trunk/busybox/Makefile.flags 2008-06-04 11:28:24 UTC (rev 22211) @@ -50,19 +50,33 @@ CFLAGS += $(call cc-option,-g) endif +# If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)... +ARCH_FPIC ?= -fpic +ARCH_FPIE ?= -fpie +ARCH_PIE ?= -pie + ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y) # on i386: 14% smaller libbusybox.so # (code itself is 9% bigger, we save on relocs/PLT/GOT) -CFLAGS += -fpic +CFLAGS += $(ARCH_FPIC) # and another 4% reduction of libbusybox.so: # (external entry points must be marked EXTERNALLY_VISIBLE) CFLAGS += $(call cc-option,-fvisibility=hidden) endif ifeq ($(CONFIG_STATIC),y) -LDFLAGS += -static +CFLAGS_busybox += -static endif +ifeq ($(CONFIG_PIE),y) +CFLAGS_busybox += $(ARCH_PIE) +CFLAGS += $(ARCH_FPIE) +# No switch() jump tables. Code growth +1k, binary size down -12k +# due to reduced number of code pointers. +# (TODO: make overridable: some arches may want to not do this) +CFLAGS += $(call cc-option,-fno-jump-tables) +endif + LDLIBS += m crypt ifeq ($(CONFIG_PAM),y) @@ -81,8 +95,6 @@ LDLIBS += dmalloc endif -#LDFLAGS += -nostdlib - LDFLAGS_ELF2FLT = -Wl,-elf2flt ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS))) SKIP_STRIP = y Modified: trunk/busybox/scripts/Makefile.IMA =================================================================== --- trunk/busybox/scripts/Makefile.IMA 2008-06-04 10:33:33 UTC (rev 22210) +++ trunk/busybox/scripts/Makefile.IMA 2008-06-04 11:28:24 UTC (rev 22211) @@ -45,8 +45,8 @@ OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump -CFLAGS := $(CFLAGS) -CPPFLAGS+= -D"KBUILD_STR(s)=\#s" #-Q +CFLAGS := $(CFLAGS) +CPPFLAGS += -D"KBUILD_STR(s)=\#s" #-Q # We need some generic definitions include $(srctree)/scripts/Kbuild.include @@ -180,7 +180,7 @@ busybox: busybox_unstripped.o $(srctree)/scripts/trylink \ busybox_unstripped \ - "$(CC)" \ + "$(CC) $(CFLAGS_busybox)" \ "$(CFLAGS)" \ "$(LDFLAGS)" \ "busybox_unstripped.o" \ Modified: trunk/busybox/scripts/Makefile.build =================================================================== --- trunk/busybox/scripts/Makefile.build 2008-06-04 10:33:33 UTC (rev 22210) +++ trunk/busybox/scripts/Makefile.build 2008-06-04 11:28:24 UTC (rev 22211) @@ -251,8 +251,8 @@ quiet_cmd_link_o_target = LD $@ # If the list of objects to link is empty, just create an empty built-in.o cmd_link_o_target = $(if $(strip $(obj-y)),\ - $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\ - rm -f $@; $(AR) rcs $@) + $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\ + rm -f $@; $(AR) rcs $@) $(builtin-target): $(obj-y) FORCE $(call if_changed,link_o_target) From vda at busybox.net Wed Jun 4 04:53:24 2008 From: vda at busybox.net (vda at busybox.net) Date: Wed, 4 Jun 2008 04:53:24 -0700 (PDT) Subject: svn commit: trunk/busybox Message-ID: <20080604115324.90FE33C617@busybox.net> Author: vda Date: 2008-06-04 04:53:24 -0700 (Wed, 04 Jun 2008) New Revision: 22212 Log: remove -fno-jump-tables - after stripping it proved to be worse Modified: trunk/busybox/Makefile.flags Changeset: Modified: trunk/busybox/Makefile.flags =================================================================== --- trunk/busybox/Makefile.flags 2008-06-04 11:28:24 UTC (rev 22211) +++ trunk/busybox/Makefile.flags 2008-06-04 11:53:24 UTC (rev 22212) @@ -71,10 +71,6 @@ ifeq ($(CONFIG_PIE),y) CFLAGS_busybox += $(ARCH_PIE) CFLAGS += $(ARCH_FPIE) -# No switch() jump tables. Code growth +1k, binary size down -12k -# due to reduced number of code pointers. -# (TODO: make overridable: some arches may want to not do this) -CFLAGS += $(call cc-option,-fno-jump-tables) endif LDLIBS += m crypt From vda at busybox.net Wed Jun 4 15:41:15 2008 From: vda at busybox.net (vda at busybox.net) Date: Wed, 4 Jun 2008 15:41:15 -0700 (PDT) Subject: svn commit: trunk/busybox/modutils Message-ID: <20080604224115.DF5343C4EB@busybox.net> Author: vda Date: 2008-06-04 15:41:14 -0700 (Wed, 04 Jun 2008) New Revision: 22218 Log: config help text: fix capitalization Modified: trunk/busybox/modutils/Config.in Changeset: Modified: trunk/busybox/modutils/Config.in =================================================================== --- trunk/busybox/modutils/Config.in 2008-06-04 21:17:40 UTC (rev 22217) +++ trunk/busybox/modutils/Config.in 2008-06-04 22:41:14 UTC (rev 22218) @@ -194,7 +194,7 @@ config DEFAULT_MODULES_DIR # Simulate indentation - string "default directory containing modules" + string "Default directory containing modules" default "/lib/modules" depends on INSMOD || RMMOD || MODPROBE || DEPMOD help @@ -203,7 +203,7 @@ config DEFAULT_DEPMOD_FILE # Simulate indentation - string "default name of modules.dep" + string "Default name of modules.dep" default "modules.dep" depends on INSMOD || RMMOD || MODPROBE || DEPMOD help @@ -215,6 +215,4 @@ default y depends on FEATURE_2_4_MODULES && !FEATURE_2_6_MODULES - endmenu - From vda at busybox.net Wed Jun 4 18:10:04 2008 From: vda at busybox.net (vda at busybox.net) Date: Wed, 4 Jun 2008 18:10:04 -0700 (PDT) Subject: svn commit: branches/busybox_1_10_stable: libbb networking networking/libiproute etc... Message-ID: <20080605011004.7610C3C670@busybox.net> Author: vda Date: 2008-06-04 18:10:03 -0700 (Wed, 04 Jun 2008) New Revision: 22219 Log: Apply post-1.10.2 fixes, bump version to 1.10.3 Modified: branches/busybox_1_10_stable/Makefile branches/busybox_1_10_stable/libbb/udp_io.c branches/busybox_1_10_stable/networking/dnsd.c branches/busybox_1_10_stable/networking/interface.c branches/busybox_1_10_stable/networking/isrv_identd.c branches/busybox_1_10_stable/networking/libiproute/ip_parse_common_args.c branches/busybox_1_10_stable/procps/fuser.c branches/busybox_1_10_stable/shell/hush.c branches/busybox_1_10_stable/sysklogd/syslogd.c branches/busybox_1_10_stable/util-linux/mdev.c Changeset: Modified: branches/busybox_1_10_stable/Makefile =================================================================== --- branches/busybox_1_10_stable/Makefile 2008-06-04 22:41:14 UTC (rev 22218) +++ branches/busybox_1_10_stable/Makefile 2008-06-05 01:10:03 UTC (rev 22219) @@ -1,6 +1,6 @@ VERSION = 1 PATCHLEVEL = 10 -SUBLEVEL = 2 +SUBLEVEL = 3 EXTRAVERSION = NAME = Unnamed Modified: branches/busybox_1_10_stable/libbb/udp_io.c =================================================================== --- branches/busybox_1_10_stable/libbb/udp_io.c 2008-06-04 22:41:14 UTC (rev 22218) +++ branches/busybox_1_10_stable/libbb/udp_io.c 2008-06-05 01:10:03 UTC (rev 22219) @@ -36,11 +36,12 @@ #else struct iovec iov[1]; struct msghdr msg; - char cbuf[sizeof(struct in_pktinfo) + union { + char cmsg[CMSG_SPACE(sizeof(struct in_pktinfo))]; #if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO) - | sizeof(struct in6_pktinfo) /* (a|b) is poor man's max(a,b) */ + char cmsg6[CMSG_SPACE(sizeof(struct in6_pktinfo))]; #endif - ]; + } u; struct cmsghdr* cmsgptr; if (from->sa_family != AF_INET @@ -57,15 +58,15 @@ iov[0].iov_base = buf; iov[0].iov_len = len; - memset(cbuf, 0, sizeof(cbuf)); + memset(&u, 0, sizeof(u)); memset(&msg, 0, sizeof(msg)); msg.msg_name = (void *)(struct sockaddr *)to; /* or compiler will annoy us */ msg.msg_namelen = tolen; msg.msg_iov = iov; msg.msg_iovlen = 1; - msg.msg_control = cbuf; - msg.msg_controllen = sizeof(cbuf); + msg.msg_control = &u; + msg.msg_controllen = sizeof(u); msg.msg_flags = flags; cmsgptr = CMSG_FIRSTHDR(&msg); @@ -89,6 +90,8 @@ pktptr->ipi6_addr = ((struct sockaddr_in6*)from)->sin6_addr; } #endif + msg.msg_controllen = cmsgptr->cmsg_len; + return sendmsg(fd, &msg, flags); #endif } @@ -109,7 +112,9 @@ struct iovec iov[1]; union { char cmsg[CMSG_SPACE(sizeof(struct in_pktinfo))]; +#if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO) char cmsg6[CMSG_SPACE(sizeof(struct in6_pktinfo))]; +#endif } u; struct cmsghdr *cmsgptr; struct msghdr msg; Modified: branches/busybox_1_10_stable/networking/dnsd.c =================================================================== --- branches/busybox_1_10_stable/networking/dnsd.c 2008-06-04 22:41:14 UTC (rev 22218) +++ branches/busybox_1_10_stable/networking/dnsd.c 2008-06-05 01:10:03 UTC (rev 22219) @@ -194,7 +194,8 @@ for (i = 1; i <= (int)(d->name[0]); i++) if (tolower(qs[i]) != d->name[i]) break; - if (i > (int)(d->name[0])) { + if (i > (int)(d->name[0]) || + (d->name[0] == 1 && d->name[1] == '*')) { strcpy((char *)as, d->ip); #if DEBUG fprintf(stderr, " OK as:%s\n", as); @@ -202,7 +203,8 @@ return 0; } } else if (type == REQ_PTR) { /* search by IP-address */ - if (!strncmp((char*)&d->rip[1], (char*)&qs[1], strlen(d->rip)-1)) { + if ((d->name[0] != 1 || d->name[1] != '*') && + !strncmp((char*)&d->rip[1], (char*)&qs[1], strlen(d->rip)-1)) { strcpy((char *)as, d->name); return 0; } @@ -401,7 +403,7 @@ r = process_packet(buf); if (r <= 0) continue; - send_to_from(udps, buf, r, 0, &to->u.sa, &from->u.sa, lsa->len); + send_to_from(udps, buf, r, 0, &from->u.sa, &to->u.sa, lsa->len); } return 0; } Modified: branches/busybox_1_10_stable/networking/interface.c =================================================================== --- branches/busybox_1_10_stable/networking/interface.c 2008-06-04 22:41:14 UTC (rev 22218) +++ branches/busybox_1_10_stable/networking/interface.c 2008-06-05 01:10:03 UTC (rev 22219) @@ -223,7 +223,7 @@ char *pos; unsigned int i; - if (!buff); + if (!buff) buff = xmalloc(sizeof(struct sockaddr) * 3 + 1); pos = buff; for (i = 0; i < sizeof(struct sockaddr); i++) { Modified: branches/busybox_1_10_stable/networking/isrv_identd.c =================================================================== --- branches/busybox_1_10_stable/networking/isrv_identd.c 2008-06-04 22:41:14 UTC (rev 22218) +++ branches/busybox_1_10_stable/networking/isrv_identd.c 2008-06-05 01:10:03 UTC (rev 22219) @@ -113,7 +113,7 @@ strncpy(bogouser, argv[optind], sizeof(bogouser)); /* Daemonize if no -f and no -i and no -w */ - if (!(opt & OPT_fiw)); + if (!(opt & OPT_fiw)) bb_daemonize_or_rexec(0, argv); /* Where to log in inetd modes? "Classic" inetd Modified: branches/busybox_1_10_stable/networking/libiproute/ip_parse_common_args.c =================================================================== --- branches/busybox_1_10_stable/networking/libiproute/ip_parse_common_args.c 2008-06-04 22:41:14 UTC (rev 22218) +++ branches/busybox_1_10_stable/networking/libiproute/ip_parse_common_args.c 2008-06-05 01:10:03 UTC (rev 22219) @@ -54,7 +54,7 @@ break; } } - arg = index_in_strings(ip_common_commands, opt); + arg = index_in_substrings(ip_common_commands, opt); if (arg < 0) bb_show_usage(); if (arg == ARG_oneline) { Modified: branches/busybox_1_10_stable/procps/fuser.c =================================================================== --- branches/busybox_1_10_stable/procps/fuser.c 2008-06-04 22:41:14 UTC (rev 22218) +++ branches/busybox_1_10_stable/procps/fuser.c 2008-06-05 01:10:03 UTC (rev 22219) @@ -208,6 +208,7 @@ return plist; } +/* NB: does chdir internally */ static pid_list *scan_proc_pids(inode_list *ilist) { DIR *d; @@ -215,7 +216,8 @@ pid_t pid; pid_list *plist; - d = opendir("."); + xchdir("/proc"); + d = opendir("/proc"); if (!d) return NULL; @@ -329,7 +331,7 @@ pp++; } - plist = scan_proc_pids(ilist); + plist = scan_proc_pids(ilist); /* changes dir to "/proc" */ if (!plist) return EXIT_FAILURE; Modified: branches/busybox_1_10_stable/shell/hush.c =================================================================== --- branches/busybox_1_10_stable/shell/hush.c 2008-06-04 22:41:14 UTC (rev 22218) +++ branches/busybox_1_10_stable/shell/hush.c 2008-06-05 01:10:03 UTC (rev 22219) @@ -699,9 +699,18 @@ BLTIN(NULL, NULL, NULL) }; +/* Signals are grouped, we handle them in batches */ +static void set_misc_sighandler(void (*handler)(int)) +{ + bb_signals(0 + + (1 << SIGINT) + + (1 << SIGQUIT) + + (1 << SIGTERM) + , handler); +} + #if ENABLE_HUSH_JOB -/* Signals are grouped, we handle them in batches */ static void set_fatal_sighandler(void (*handler)(int)) { bb_signals(0 @@ -725,14 +734,6 @@ + (1 << SIGTTOU) , handler); } -static void set_misc_sighandler(void (*handler)(int)) -{ - bb_signals(0 - + (1 << SIGINT) - + (1 << SIGQUIT) - + (1 << SIGTERM) - , handler); -} /* SIGCHLD is special and handled separately */ static void set_every_sighandler(void (*handler)(int)) @@ -815,7 +816,6 @@ #define set_fatal_sighandler(handler) ((void)0) #define set_jobctrl_sighandler(handler) ((void)0) -#define set_misc_sighandler(handler) ((void)0) #define hush_exit(e) exit(e) #endif /* JOB */ @@ -3907,8 +3907,10 @@ /* give up */ interactive_fd = 0; } - if (interactive_fd) + if (interactive_fd) { fcntl(interactive_fd, F_SETFD, FD_CLOEXEC); + set_misc_sighandler(SIG_IGN); + } } #endif Modified: branches/busybox_1_10_stable/sysklogd/syslogd.c =================================================================== --- branches/busybox_1_10_stable/sysklogd/syslogd.c 2008-06-04 22:41:14 UTC (rev 22218) +++ branches/busybox_1_10_stable/sysklogd/syslogd.c 2008-06-05 01:10:03 UTC (rev 22219) @@ -347,10 +347,11 @@ sprintf(newFile, "%s.%d", G.logFilePath, i); if (i == 0) break; sprintf(oldFile, "%s.%d", G.logFilePath, --i); - xrename(oldFile, newFile); + /* ignore errors - file might be missing */ + rename(oldFile, newFile); } /* newFile == "f.0" now */ - xrename(G.logFilePath, newFile); + rename(G.logFilePath, newFile); fl.l_type = F_UNLCK; fcntl(G.logFD, F_SETLKW, &fl); close(G.logFD); Modified: branches/busybox_1_10_stable/util-linux/mdev.c =================================================================== --- branches/busybox_1_10_stable/util-linux/mdev.c 2008-06-04 22:41:14 UTC (rev 22218) +++ branches/busybox_1_10_stable/util-linux/mdev.c 2008-06-05 01:10:03 UTC (rev 22219) @@ -72,8 +72,14 @@ /* Determine device name, type, major and minor */ device_name = bb_basename(path); /* http://kernel.org/doc/pending/hotplug.txt says that only - * "/sys/block/..." is for block devices. "sys/bus" etc is not! */ - type = (strncmp(&path[5], "block/", 6) == 0 ? S_IFBLK : S_IFCHR); + * "/sys/block/..." is for block devices. "/sys/bus" etc is not! + * Since kernel 2.6.25 block devices are also in /sys/class/block. */ + /* TODO: would it be acceptable to just use strstr(path, "/block/")? */ + if (strncmp(&path[5], "class/block/"+6, 6) != 0 + && strncmp(&path[5], "class/block/", 12) != 0) + type = S_IFCHR; + else + type = S_IFBLK; if (ENABLE_FEATURE_MDEV_CONF) { FILE *fp; @@ -172,8 +178,9 @@ /* substitute %1..9 with off[1..9], if any */ n = 0; s = val; - while (*s && *s++ == '%') - n++; + while (*s) + if (*s++ == '%') + n++; p = alias = xzalloc(strlen(val) + n * strlen(device_name)); s = val + 1; From vda at busybox.net Wed Jun 4 18:10:41 2008 From: vda at busybox.net (vda at busybox.net) Date: Wed, 4 Jun 2008 18:10:41 -0700 (PDT) Subject: svn commit: tags Message-ID: <20080605011041.336733C674@busybox.net> Author: vda Date: 2008-06-04 18:10:40 -0700 (Wed, 04 Jun 2008) New Revision: 22220 Log: create tags/busybox_1_10_3 Added: tags/busybox_1_10_3/ Changeset: Copied: tags/busybox_1_10_3 (from rev 22219, branches/busybox_1_10_stable) From vda at busybox.net Wed Jun 4 18:17:49 2008 From: vda at busybox.net (vda at busybox.net) Date: Wed, 4 Jun 2008 18:17:49 -0700 (PDT) Subject: svn commit: trunk/busybox/docs/busybox.net Message-ID: <20080605011749.76CEE3C67D@busybox.net> Author: vda Date: 2008-06-04 18:17:49 -0700 (Wed, 04 Jun 2008) New Revision: 22221 Log: announce 1.10.3 Modified: trunk/busybox/docs/busybox.net/news.html Changeset: Modified: trunk/busybox/docs/busybox.net/news.html =================================================================== --- trunk/busybox/docs/busybox.net/news.html 2008-06-05 01:10:40 UTC (rev 22220) +++ trunk/busybox/docs/busybox.net/news.html 2008-06-05 01:17:49 UTC (rev 22221) @@ -1,6 +1,21 @@
    +
  • 8 May 2008 -- BusyBox 1.10.3 (stable) +

    BusyBox 1.10.3. + (svn, + patches, + how to add a patch)

    +

    + Bugfix-only release for 1.10.x branch. It contains fixes for dnsd, fuser, hush, + ip, mdev and syslogd. +

    + How to build static busybox against uclibc +

    + The email address gpl at busybox.net is the recommended way to contact + the Software Freedom Law Center to report BusyBox license violations. +

    +
  • 8 May 2008 -- BusyBox 1.10.2 (stable)

    BusyBox 1.10.2. (svn, @@ -11,11 +26,6 @@ start-stop-daemon, tar, taskset, tab completion in shells, build system.

    Please note that mdev was backported from current svn trunk. Please report if you encounter any problems with it. -

    - How to build static busybox against uclibc -

    - The email address gpl at busybox.net is the recommended way to contact - the Software Freedom Law Center to report BusyBox license violations.

  • 19 April 2008 -- BusyBox 1.10.1 (stable) From bugs at busybox.net Wed Jun 4 21:03:08 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Wed, 4 Jun 2008 21:03:08 -0700 Subject: [BusyBox 0003634]: dpkg -r crashes if no conffiles Message-ID: <5dea50035076d5de14ffd518311ed652@busybox.net> The following issue has been SUBMITTED. ====================================================================== http://busybox.net/bugs/view.php?id=3634 ====================================================================== Reported By: wz2b Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 3634 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 06-04-2008 21:03 PDT Last Modified: 06-04-2008 21:03 PDT ====================================================================== Summary: dpkg -r crashes if no conffiles Description: If attempting to remove a debian package that has no conffiles in its DEBIAN subdirectory, busybox attempts to move the conffiles anyway and fails. Suggest that if conffiles isn't there, don't fail - just ignore it. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 06-04-08 21:03 wz2b New Issue 06-04-08 21:03 wz2b Status new => assigned 06-04-08 21:03 wz2b Assigned To => BusyBox ====================================================================== From bugs at busybox.net Wed Jun 4 21:17:54 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Wed, 4 Jun 2008 21:17:54 -0700 Subject: [BusyBox 0003644]: Add script support to dpkg documentation Message-ID: <642fcf05e86b361fc7e9cb0389e298ff@busybox.net> The following issue has been SUBMITTED. ====================================================================== http://busybox.net/bugs/view.php?id=3644 ====================================================================== Reported By: wz2b Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 3644 Category: Documentation Reproducibility: always Severity: feature Priority: normal Status: assigned ====================================================================== Date Submitted: 06-04-2008 21:17 PDT Last Modified: 06-04-2008 21:17 PDT ====================================================================== Summary: Add script support to dpkg documentation Description: From vda at busybox.net Wed Jun 4 22:00:27 2008 From: vda at busybox.net (vda at busybox.net) Date: Wed, 4 Jun 2008 22:00:27 -0700 (PDT) Subject: svn commit: trunk/busybox/networking/libiproute Message-ID: <20080605050027.99E983C642@busybox.net> Author: vda Date: 2008-06-04 22:00:24 -0700 (Wed, 04 Jun 2008) New Revision: 22222 Log: libiproute: use stdout directly instead of passing it as a parameter function old new delta iprule_list 86 82 -4 print_rule 860 791 -69 ipaddr_list_or_flush 2484 2384 -100 print_addrinfo 1498 1292 -206 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-379) Total: -379 bytes Modified: trunk/busybox/networking/libiproute/ipaddress.c trunk/busybox/networking/libiproute/iprule.c Changeset: Modified: trunk/busybox/networking/libiproute/ipaddress.c =================================================================== --- trunk/busybox/networking/libiproute/ipaddress.c 2008-06-05 01:17:49 UTC (rev 22221) +++ trunk/busybox/networking/libiproute/ipaddress.c 2008-06-05 05:00:24 UTC (rev 22222) @@ -39,13 +39,13 @@ #define filter (*(filter_t*)&bb_common_bufsiz1) -static void print_link_flags(FILE *fp, unsigned flags, unsigned mdown) +static void print_link_flags(unsigned flags, unsigned mdown) { - fprintf(fp, "<"); + printf("<"); flags &= ~IFF_RUNNING; #define _PF(f) if (flags & IFF_##f) { \ flags &= ~IFF_##f; \ - fprintf(fp, #f "%s", flags ? "," : ""); } + printf(#f "%s", flags ? "," : ""); } _PF(LOOPBACK); _PF(BROADCAST); _PF(POINTOPOINT); @@ -65,10 +65,10 @@ _PF(UP); #undef _PF if (flags) - fprintf(fp, "%x", flags); + printf("%x", flags); if (mdown) - fprintf(fp, ",M-DOWN"); - fprintf(fp, "> "); + printf(",M-DOWN"); + printf("> "); } static void print_queuelen(char *name) @@ -92,10 +92,8 @@ printf("qlen %d", ifr.ifr_qlen); } -static int print_linkinfo(struct sockaddr_nl ATTRIBUTE_UNUSED *who, - const struct nlmsghdr *n, void ATTRIBUTE_UNUSED *arg) +static int print_linkinfo(const struct nlmsghdr *n) { - FILE *fp = (FILE*)arg; struct ifinfomsg *ifi = NLMSG_DATA(n); struct rtattr * tb[IFLA_MAX+1]; int len = n->nlmsg_len; @@ -127,34 +125,34 @@ } if (n->nlmsg_type == RTM_DELLINK) - fprintf(fp, "Deleted "); + printf("Deleted "); - fprintf(fp, "%d: %s", ifi->ifi_index, + printf("%d: %s", ifi->ifi_index, tb[IFLA_IFNAME] ? (char*)RTA_DATA(tb[IFLA_IFNAME]) : ""); if (tb[IFLA_LINK]) { SPRINT_BUF(b1); int iflink = *(int*)RTA_DATA(tb[IFLA_LINK]); if (iflink == 0) - fprintf(fp, "@NONE: "); + printf("@NONE: "); else { - fprintf(fp, "@%s: ", ll_idx_n2a(iflink, b1)); + printf("@%s: ", ll_idx_n2a(iflink, b1)); m_flag = ll_index_to_flags(iflink); m_flag = !(m_flag & IFF_UP); } } else { - fprintf(fp, ": "); + printf(": "); } - print_link_flags(fp, ifi->ifi_flags, m_flag); + print_link_flags(ifi->ifi_flags, m_flag); if (tb[IFLA_MTU]) - fprintf(fp, "mtu %u ", *(int*)RTA_DATA(tb[IFLA_MTU])); + printf("mtu %u ", *(int*)RTA_DATA(tb[IFLA_MTU])); if (tb[IFLA_QDISC]) - fprintf(fp, "qdisc %s ", (char*)RTA_DATA(tb[IFLA_QDISC])); + printf("qdisc %s ", (char*)RTA_DATA(tb[IFLA_QDISC])); #ifdef IFLA_MASTER if (tb[IFLA_MASTER]) { SPRINT_BUF(b1); - fprintf(fp, "master %s ", ll_idx_n2a(*(int*)RTA_DATA(tb[IFLA_MASTER]), b1)); + printf("master %s ", ll_idx_n2a(*(int*)RTA_DATA(tb[IFLA_MASTER]), b1)); } #endif if (filter.showqueue) @@ -162,27 +160,27 @@ if (!filter.family || filter.family == AF_PACKET) { SPRINT_BUF(b1); - fprintf(fp, "%c link/%s ", _SL_, ll_type_n2a(ifi->ifi_type, b1, sizeof(b1))); + printf("%c link/%s ", _SL_, ll_type_n2a(ifi->ifi_type, b1, sizeof(b1))); if (tb[IFLA_ADDRESS]) { fputs(ll_addr_n2a(RTA_DATA(tb[IFLA_ADDRESS]), RTA_PAYLOAD(tb[IFLA_ADDRESS]), ifi->ifi_type, - b1, sizeof(b1)), fp); + b1, sizeof(b1)), stdout); } if (tb[IFLA_BROADCAST]) { if (ifi->ifi_flags & IFF_POINTOPOINT) - fprintf(fp, " peer "); + printf(" peer "); else - fprintf(fp, " brd "); + printf(" brd "); fputs(ll_addr_n2a(RTA_DATA(tb[IFLA_BROADCAST]), RTA_PAYLOAD(tb[IFLA_BROADCAST]), ifi->ifi_type, - b1, sizeof(b1)), fp); + b1, sizeof(b1)), stdout); } } - fputc('\n', fp); - fflush(fp); + bb_putchar('\n'); + /*fflush(stdout);*/ return 0; } @@ -196,10 +194,9 @@ return 0; } -static int print_addrinfo(struct sockaddr_nl ATTRIBUTE_UNUSED *who, - struct nlmsghdr *n, void ATTRIBUTE_UNUSED *arg) +static int print_addrinfo(struct sockaddr_nl *who ATTRIBUTE_UNUSED, + struct nlmsghdr *n, void *arg ATTRIBUTE_UNUSED) { - FILE *fp = (FILE*)arg; struct ifaddrmsg *ifa = NLMSG_DATA(n); int len = n->nlmsg_len; struct rtattr * rta_tb[IFA_MAX+1]; @@ -268,28 +265,28 @@ } if (n->nlmsg_type == RTM_DELADDR) - fprintf(fp, "Deleted "); + printf("Deleted "); if (filter.oneline) - fprintf(fp, "%u: %s", ifa->ifa_index, ll_index_to_name(ifa->ifa_index)); + printf("%u: %s", ifa->ifa_index, ll_index_to_name(ifa->ifa_index)); if (ifa->ifa_family == AF_INET) - fprintf(fp, " inet "); + printf(" inet "); else if (ifa->ifa_family == AF_INET6) - fprintf(fp, " inet6 "); + printf(" inet6 "); else - fprintf(fp, " family %d ", ifa->ifa_family); + printf(" family %d ", ifa->ifa_family); if (rta_tb[IFA_LOCAL]) { fputs(rt_addr_n2a(ifa->ifa_family, RTA_PAYLOAD(rta_tb[IFA_LOCAL]), RTA_DATA(rta_tb[IFA_LOCAL]), - abuf, sizeof(abuf)), fp); + abuf, sizeof(abuf)), stdout); if (rta_tb[IFA_ADDRESS] == NULL || memcmp(RTA_DATA(rta_tb[IFA_ADDRESS]), RTA_DATA(rta_tb[IFA_LOCAL]), 4) == 0) { - fprintf(fp, "/%d ", ifa->ifa_prefixlen); + printf("/%d ", ifa->ifa_prefixlen); } else { - fprintf(fp, " peer %s/%d ", + printf(" peer %s/%d ", rt_addr_n2a(ifa->ifa_family, RTA_PAYLOAD(rta_tb[IFA_ADDRESS]), RTA_DATA(rta_tb[IFA_ADDRESS]), @@ -299,44 +296,44 @@ } if (rta_tb[IFA_BROADCAST]) { - fprintf(fp, "brd %s ", + printf("brd %s ", rt_addr_n2a(ifa->ifa_family, RTA_PAYLOAD(rta_tb[IFA_BROADCAST]), RTA_DATA(rta_tb[IFA_BROADCAST]), abuf, sizeof(abuf))); } if (rta_tb[IFA_ANYCAST]) { - fprintf(fp, "any %s ", + printf("any %s ", rt_addr_n2a(ifa->ifa_family, RTA_PAYLOAD(rta_tb[IFA_ANYCAST]), RTA_DATA(rta_tb[IFA_ANYCAST]), abuf, sizeof(abuf))); } - fprintf(fp, "scope %s ", rtnl_rtscope_n2a(ifa->ifa_scope, b1, sizeof(b1))); + printf("scope %s ", rtnl_rtscope_n2a(ifa->ifa_scope, b1, sizeof(b1))); if (ifa->ifa_flags & IFA_F_SECONDARY) { ifa->ifa_flags &= ~IFA_F_SECONDARY; - fprintf(fp, "secondary "); + printf("secondary "); } if (ifa->ifa_flags & IFA_F_TENTATIVE) { ifa->ifa_flags &= ~IFA_F_TENTATIVE; - fprintf(fp, "tentative "); + printf("tentative "); } if (ifa->ifa_flags & IFA_F_DEPRECATED) { ifa->ifa_flags &= ~IFA_F_DEPRECATED; - fprintf(fp, "deprecated "); + printf("deprecated "); } if (!(ifa->ifa_flags & IFA_F_PERMANENT)) { - fprintf(fp, "dynamic "); + printf("dynamic "); } else ifa->ifa_flags &= ~IFA_F_PERMANENT; if (ifa->ifa_flags) - fprintf(fp, "flags %02x ", ifa->ifa_flags); + printf("flags %02x ", ifa->ifa_flags); if (rta_tb[IFA_LABEL]) - fputs((char*)RTA_DATA(rta_tb[IFA_LABEL]), fp); + fputs((char*)RTA_DATA(rta_tb[IFA_LABEL]), stdout); if (rta_tb[IFA_CACHEINFO]) { struct ifa_cacheinfo *ci = RTA_DATA(rta_tb[IFA_CACHEINFO]); char buf[128]; - fputc(_SL_, fp); + bb_putchar(_SL_); if (ci->ifa_valid == 0xFFFFFFFFU) sprintf(buf, "valid_lft forever"); else @@ -345,10 +342,10 @@ sprintf(buf+strlen(buf), " preferred_lft forever"); else sprintf(buf+strlen(buf), " preferred_lft %dsec", ci->ifa_prefered); - fprintf(fp, " %s", buf); + printf(" %s", buf); } - fputc('\n', fp); - fflush(fp); + bb_putchar('\n'); + /*fflush(stdout);*/ return 0; } @@ -359,7 +356,7 @@ struct nlmsghdr h; }; -static int print_selected_addrinfo(int ifindex, struct nlmsg_list *ainfo, FILE *fp) +static int print_selected_addrinfo(int ifindex, struct nlmsg_list *ainfo) { for (; ainfo; ainfo = ainfo->next) { struct nlmsghdr *n = &ainfo->h; @@ -375,7 +372,7 @@ (filter.family && filter.family != ifa->ifa_family)) continue; - print_addrinfo(NULL, n, fp); + print_addrinfo(NULL, n, NULL); } return 0; } @@ -498,7 +495,7 @@ for (;;) { xrtnl_wilddump_request(&rth, filter.family, RTM_GETADDR); filter.flushed = 0; - xrtnl_dump_filter(&rth, print_addrinfo, stdout); + xrtnl_dump_filter(&rth, print_addrinfo, NULL); if (filter.flushed == 0) { return 0; } @@ -574,10 +571,10 @@ } for (l = linfo; l; l = l->next) { - if (no_link || print_linkinfo(NULL, &l->h, stdout) == 0) { + if (no_link || print_linkinfo(&l->h) == 0) { struct ifinfomsg *ifi = NLMSG_DATA(&l->h); if (filter.family != AF_PACKET) - print_selected_addrinfo(ifi->ifi_index, ainfo, stdout); + print_selected_addrinfo(ifi->ifi_index, ainfo); } } Modified: trunk/busybox/networking/libiproute/iprule.c =================================================================== --- trunk/busybox/networking/libiproute/iprule.c 2008-06-05 01:17:49 UTC (rev 22221) +++ trunk/busybox/networking/libiproute/iprule.c 2008-06-05 05:00:24 UTC (rev 22222) @@ -41,9 +41,8 @@ */ static int print_rule(struct sockaddr_nl *who ATTRIBUTE_UNUSED, - struct nlmsghdr *n, void *arg) + struct nlmsghdr *n, void *arg ATTRIBUTE_UNUSED) { - FILE *fp = (FILE*)arg; struct rtmsg *r = NLMSG_DATA(n); int len = n->nlmsg_len; int host_len = -1; @@ -71,14 +70,14 @@ host_len = 80; */ if (tb[RTA_PRIORITY]) - fprintf(fp, "%u:\t", *(unsigned*)RTA_DATA(tb[RTA_PRIORITY])); + printf("%u:\t", *(unsigned*)RTA_DATA(tb[RTA_PRIORITY])); else - fprintf(fp, "0:\t"); + printf("0:\t"); - fprintf(fp, "from "); + printf("from "); if (tb[RTA_SRC]) { if (r->rtm_src_len != host_len) { - fprintf(fp, "%s/%u", rt_addr_n2a(r->rtm_family, + printf("%s/%u", rt_addr_n2a(r->rtm_family, RTA_PAYLOAD(tb[RTA_SRC]), RTA_DATA(tb[RTA_SRC]), abuf, sizeof(abuf)), @@ -88,73 +87,73 @@ fputs(format_host(r->rtm_family, RTA_PAYLOAD(tb[RTA_SRC]), RTA_DATA(tb[RTA_SRC]), - abuf, sizeof(abuf)), fp); + abuf, sizeof(abuf)), stdout); } } else if (r->rtm_src_len) { - fprintf(fp, "0/%d", r->rtm_src_len); + printf("0/%d", r->rtm_src_len); } else { - fprintf(fp, "all"); + printf("all"); } - fprintf(fp, " "); + bb_putchar(' '); if (tb[RTA_DST]) { if (r->rtm_dst_len != host_len) { - fprintf(fp, "to %s/%u ", rt_addr_n2a(r->rtm_family, + printf("to %s/%u ", rt_addr_n2a(r->rtm_family, RTA_PAYLOAD(tb[RTA_DST]), RTA_DATA(tb[RTA_DST]), abuf, sizeof(abuf)), r->rtm_dst_len ); } else { - fprintf(fp, "to %s ", format_host(r->rtm_family, + printf("to %s ", format_host(r->rtm_family, RTA_PAYLOAD(tb[RTA_DST]), RTA_DATA(tb[RTA_DST]), abuf, sizeof(abuf))); } } else if (r->rtm_dst_len) { - fprintf(fp, "to 0/%d ", r->rtm_dst_len); + printf("to 0/%d ", r->rtm_dst_len); } if (r->rtm_tos) { - fprintf(fp, "tos %s ", rtnl_dsfield_n2a(r->rtm_tos, b1, sizeof(b1))); + printf("tos %s ", rtnl_dsfield_n2a(r->rtm_tos, b1, sizeof(b1))); } if (tb[RTA_PROTOINFO]) { - fprintf(fp, "fwmark %#x ", *(uint32_t*)RTA_DATA(tb[RTA_PROTOINFO])); + printf("fwmark %#x ", *(uint32_t*)RTA_DATA(tb[RTA_PROTOINFO])); } if (tb[RTA_IIF]) { - fprintf(fp, "iif %s ", (char*)RTA_DATA(tb[RTA_IIF])); + printf("iif %s ", (char*)RTA_DATA(tb[RTA_IIF])); } if (r->rtm_table) - fprintf(fp, "lookup %s ", rtnl_rttable_n2a(r->rtm_table, b1, sizeof(b1))); + printf("lookup %s ", rtnl_rttable_n2a(r->rtm_table, b1, sizeof(b1))); if (tb[RTA_FLOW]) { uint32_t to = *(uint32_t*)RTA_DATA(tb[RTA_FLOW]); uint32_t from = to>>16; to &= 0xFFFF; if (from) { - fprintf(fp, "realms %s/", + printf("realms %s/", rtnl_rtrealm_n2a(from, b1, sizeof(b1))); } - fprintf(fp, "%s ", + printf("%s ", rtnl_rtrealm_n2a(to, b1, sizeof(b1))); } if (r->rtm_type == RTN_NAT) { if (tb[RTA_GATEWAY]) { - fprintf(fp, "map-to %s ", + printf("map-to %s ", format_host(r->rtm_family, RTA_PAYLOAD(tb[RTA_GATEWAY]), RTA_DATA(tb[RTA_GATEWAY]), abuf, sizeof(abuf))); } else - fprintf(fp, "masquerade"); + printf("masquerade"); } else if (r->rtm_type != RTN_UNICAST) - fputs(rtnl_rtntype_n2a(r->rtm_type, b1, sizeof(b1)), fp); + fputs(rtnl_rtntype_n2a(r->rtm_type, b1, sizeof(b1)), stdout); - fputc('\n', fp); - fflush(fp); + bb_putchar('\n'); + /*fflush(stdout);*/ return 0; } @@ -176,7 +175,7 @@ xrtnl_open(&rth); xrtnl_wilddump_request(&rth, af, RTM_GETRULE); - xrtnl_dump_filter(&rth, print_rule, stdout); + xrtnl_dump_filter(&rth, print_rule, NULL); return 0; } From vda at busybox.net Wed Jun 4 23:51:07 2008 From: vda at busybox.net (vda at busybox.net) Date: Wed, 4 Jun 2008 23:51:07 -0700 (PDT) Subject: svn commit: trunk/busybox: miscutils modutils networking/libiproute Message-ID: <20080605065107.C45F83C60A@busybox.net> Author: vda Date: 2008-06-04 23:51:06 -0700 (Wed, 04 Jun 2008) New Revision: 22223 Log: replace single-char printf's with bb_putchar Modified: trunk/busybox/miscutils/hdparm.c trunk/busybox/modutils/lsmod.c trunk/busybox/networking/libiproute/ipaddress.c Changeset: Modified: trunk/busybox/miscutils/hdparm.c =================================================================== --- trunk/busybox/miscutils/hdparm.c 2008-06-05 05:00:24 UTC (rev 22222) +++ trunk/busybox/miscutils/hdparm.c 2008-06-05 06:51:06 UTC (rev 22223) @@ -1108,7 +1108,7 @@ jj = val[ERASE_TIME] & ERASE_BITS; kk = val[ENH_ERASE_TIME] & ERASE_BITS; if (jj || kk) { - printf("\t"); + bb_putchar('\t'); if (jj) printf("%umin for %sSECURITY ERASE UNIT. ", jj==ERASE_BITS ? 508 : jj<<1, ""); if (kk) printf("%umin for %sSECURITY ERASE UNIT. ", kk==ERASE_BITS ? 508 : kk<<1, "ENHANCED "); bb_putchar('\n'); @@ -1235,46 +1235,46 @@ if (id->capability & 1) { if (id->dma_1word | id->dma_mword) { printf("\n DMA modes: "); - if (id->dma_1word & 0x100) printf("*"); + if (id->dma_1word & 0x100) bb_putchar('*'); if (id->dma_1word & 1) printf("sdma0 "); - if (id->dma_1word & 0x200) printf("*"); + if (id->dma_1word & 0x200) bb_putchar('*'); if (id->dma_1word & 2) printf("sdma1 "); - if (id->dma_1word & 0x400) printf("*"); + if (id->dma_1word & 0x400) bb_putchar('*'); if (id->dma_1word & 4) printf("sdma2 "); - if (id->dma_1word & 0xf800) printf("*"); + if (id->dma_1word & 0xf800) bb_putchar('*'); if (id->dma_1word & 0xf8) printf("sdma? "); - if (id->dma_mword & 0x100) printf("*"); + if (id->dma_mword & 0x100) bb_putchar('*'); if (id->dma_mword & 1) printf("mdma0 "); - if (id->dma_mword & 0x200) printf("*"); + if (id->dma_mword & 0x200) bb_putchar('*'); if (id->dma_mword & 2) printf("mdma1 "); - if (id->dma_mword & 0x400) printf("*"); + if (id->dma_mword & 0x400) bb_putchar('*'); if (id->dma_mword & 4) printf("mdma2 "); - if (id->dma_mword & 0xf800) printf("*"); + if (id->dma_mword & 0xf800) bb_putchar('*'); if (id->dma_mword & 0xf8) printf("mdma? "); } } if (((id->capability & 8) || (id->field_valid & 2)) && id->field_valid & 4) { printf("\n UDMA modes: "); - if (id->dma_ultra & 0x100) printf("*"); + if (id->dma_ultra & 0x100) bb_putchar('*'); if (id->dma_ultra & 0x001) printf("udma0 "); - if (id->dma_ultra & 0x200) printf("*"); + if (id->dma_ultra & 0x200) bb_putchar('*'); if (id->dma_ultra & 0x002) printf("udma1 "); - if (id->dma_ultra & 0x400) printf("*"); + if (id->dma_ultra & 0x400) bb_putchar('*'); if (id->dma_ultra & 0x004) printf("udma2 "); #ifdef __NEW_HD_DRIVE_ID if (id->hw_config & 0x2000) { #else /* !__NEW_HD_DRIVE_ID */ if (id->word93 & 0x2000) { #endif /* __NEW_HD_DRIVE_ID */ - if (id->dma_ultra & 0x0800) printf("*"); + if (id->dma_ultra & 0x0800) bb_putchar('*'); if (id->dma_ultra & 0x0008) printf("udma3 "); - if (id->dma_ultra & 0x1000) printf("*"); + if (id->dma_ultra & 0x1000) bb_putchar('*'); if (id->dma_ultra & 0x0010) printf("udma4 "); - if (id->dma_ultra & 0x2000) printf("*"); + if (id->dma_ultra & 0x2000) bb_putchar('*'); if (id->dma_ultra & 0x0020) printf("udma5 "); - if (id->dma_ultra & 0x4000) printf("*"); + if (id->dma_ultra & 0x4000) bb_putchar('*'); if (id->dma_ultra & 0x0040) printf("udma6 "); - if (id->dma_ultra & 0x8000) printf("*"); + if (id->dma_ultra & 0x8000) bb_putchar('*'); if (id->dma_ultra & 0x0080) printf("udma7 "); } } Modified: trunk/busybox/modutils/lsmod.c =================================================================== --- trunk/busybox/modutils/lsmod.c 2008-06-05 05:00:24 UTC (rev 22222) +++ trunk/busybox/modutils/lsmod.c 2008-06-05 06:51:06 UTC (rev 22223) @@ -122,11 +122,13 @@ if (!(info.flags & NEW_MOD_USED_ONCE)) printf(" (unused)"); } - if (count) printf(" ["); + if (count) + printf(" ["); for (j = 0, dn = deps; j < count; dn += strlen(dn) + 1, j++) { printf("%s%s", dn, (j==count-1)? "":" "); } - if (count) printf("]"); + if (count) + bb_putchar(']'); bb_putchar('\n'); } Modified: trunk/busybox/networking/libiproute/ipaddress.c =================================================================== --- trunk/busybox/networking/libiproute/ipaddress.c 2008-06-05 05:00:24 UTC (rev 22222) +++ trunk/busybox/networking/libiproute/ipaddress.c 2008-06-05 06:51:06 UTC (rev 22223) @@ -41,7 +41,7 @@ static void print_link_flags(unsigned flags, unsigned mdown) { - printf("<"); + bb_putchar('<'); flags &= ~IFF_RUNNING; #define _PF(f) if (flags & IFF_##f) { \ flags &= ~IFF_##f; \ From vda at busybox.net Thu Jun 5 01:27:26 2008 From: vda at busybox.net (vda at busybox.net) Date: Thu, 5 Jun 2008 01:27:26 -0700 (PDT) Subject: svn commit: trunk/busybox/testsuite Message-ID: <20080605082726.9D71B3C675@busybox.net> Author: vda Date: 2008-06-05 01:27:26 -0700 (Thu, 05 Jun 2008) New Revision: 22225 Log: added testsuite for printf by Cristian Ionescu-Idbohrn Added: trunk/busybox/testsuite/printf.tests Changeset: Added: trunk/busybox/testsuite/printf.tests =================================================================== --- trunk/busybox/testsuite/printf.tests (rev 0) +++ trunk/busybox/testsuite/printf.tests 2008-06-05 08:27:26 UTC (rev 22225) @@ -0,0 +1,27 @@ +#!/bin/sh + +set -e + +. testing.sh + +# Need this in order to not execute shell builtin +bb="busybox " + +# testing "test name" "command" "expected result" "file input" "stdin" + +testing "printf produce no further output 1" \ + "${bb}printf '\c' foo" \ + "" \ + "" "" + +testing "printf produce no further output 2" \ + "${bb}printf '%s\c' foo \$HOME" \ + "foo" \ + "" "" + +testing "printf repeatedly use pattern for each argv" \ + "${bb}printf '%s\n' foo \$HOME" \ + "foo\n$HOME\n" \ + "" "" + +exit $FAILCOUNT Property changes on: trunk/busybox/testsuite/printf.tests ___________________________________________________________________ Name: svn:executable + * From vda at busybox.net Thu Jun 5 02:07:03 2008 From: vda at busybox.net (vda at busybox.net) Date: Thu, 5 Jun 2008 02:07:03 -0700 (PDT) Subject: svn commit: trunk/busybox/shell/ash_test Message-ID: <20080605090703.AEB073C642@busybox.net> Author: vda Date: 2008-06-05 02:07:02 -0700 (Thu, 05 Jun 2008) New Revision: 22226 Log: ash testsuite: modify it so that it can run hush and msh tests Modified: trunk/busybox/shell/ash_test/run-all Changeset: Modified: trunk/busybox/shell/ash_test/run-all =================================================================== --- trunk/busybox/shell/ash_test/run-all 2008-06-05 08:27:26 UTC (rev 22225) +++ trunk/busybox/shell/ash_test/run-all 2008-06-05 09:07:02 UTC (rev 22226) @@ -1,5 +1,7 @@ #!/bin/sh +TOPDIR=$PWD + test -x ash || { echo "No ./ash?! Perhaps you want to run 'ln -s ../../busybox ash'" exit @@ -18,6 +20,8 @@ { test -d "$1" || return 0 echo do_test "$1" + # $1 but with / replaced by # so that it can be used as filename part + noslash=`echo "$1" | sed 's:/:#:g'` ( cd "$1" || { echo "cannot cd $1!"; exit 1; } for x in run-*; do @@ -27,8 +31,8 @@ *.orig|*~) ;; #*) echo $x ; sh $x ;; *) - sh "$x" >"../$1-$x.fail" 2>&1 && \ - { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail"; + sh "$x" >"$TOPDIR/$noslash-$x.fail" 2>&1 && \ + { echo "$1/$x: ok"; rm "$TOPDIR/$noslash-$x.fail"; } || echo "$1/$x: fail"; ;; esac done @@ -40,7 +44,8 @@ test -f "$name.right" || continue { "$THIS_SH" "./$x" >"$name.xx" 2>&1 - diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail" + diff -u "$name.xx" "$name.right" >"$TOPDIR/$noslash-$x.fail" \ + && rm -f "$name.xx" "$TOPDIR/$noslash-$x.fail" } && echo "$1/$x: ok" || echo "$1/$x: fail" done ) @@ -52,6 +57,9 @@ if [ $# -lt 1 ]; then # All sub directories modules=`ls -d ash-*` + # If you want to test ash against hush and msh testsuites + # (have to copy hush_test and msh_test dirs to current dir first): + #modules=`ls -d ash-* hush_test/hush-* msh_test/msh-*` for module in $modules; do do_test $module From vda at busybox.net Thu Jun 5 05:06:00 2008 From: vda at busybox.net (vda at busybox.net) Date: Thu, 5 Jun 2008 05:06:00 -0700 (PDT) Subject: svn commit: trunk/busybox: debianutils include Message-ID: <20080605120601.0B7DE3C738@busybox.net> Author: vda Date: 2008-06-05 05:06:00 -0700 (Thu, 05 Jun 2008) New Revision: 22231 Log: mktemp: make argument optional (coreutil 6.12 compat) function old new delta mktemp_main 157 174 +17 packed_usage 24508 24504 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 17/-4) Total: 13 bytes Modified: trunk/busybox/debianutils/mktemp.c trunk/busybox/include/usage.h Changeset: Modified: trunk/busybox/debianutils/mktemp.c =================================================================== --- trunk/busybox/debianutils/mktemp.c 2008-06-05 11:48:10 UTC (rev 22230) +++ trunk/busybox/debianutils/mktemp.c 2008-06-05 12:06:00 UTC (rev 22231) @@ -9,34 +9,53 @@ * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ +/* Coreutils 6.12 man page says: + * mktemp [OPTION]... [TEMPLATE] + * Create a temporary file or directory, safely, and print its name. If + * TEMPLATE is not specified, use tmp.XXXXXXXXXX. + * -d, --directory + * create a directory, not a file + * -q, --quiet + * suppress diagnostics about file/dir-creation failure + * -u, --dry-run + * do not create anything; merely print a name (unsafe) + * --tmpdir[=DIR] + * interpret TEMPLATE relative to DIR. If DIR is not specified, + * use $TMPDIR if set, else /tmp. With this option, TEMPLATE must + * not be an absolute name. Unlike with -t, TEMPLATE may contain + * slashes, but even here, mktemp still creates only the final com- + * ponent. + * -p DIR use DIR as a prefix; implies -t [deprecated] + * -t interpret TEMPLATE as a single file name component, relative to + * a directory: $TMPDIR, if set; else the directory specified via + * -p; else /tmp [deprecated] + */ + + #include "libbb.h" int mktemp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int mktemp_main(int argc ATTRIBUTE_UNUSED, char **argv) { - // -d Make a directory instead of a file - // -q Fail silently if an error occurs [bbox: ignored] - // -t Generate a path rooted in temporary directory - // -p DIR Use DIR as a temporary directory (implies -t) const char *path; char *chp; - unsigned flags; + unsigned opt; - opt_complementary = "=1"; /* exactly one arg */ - flags = getopt32(argv, "dqtp:", &path); - chp = argv[optind]; + opt_complementary = "?1"; /* 1 argument max */ + opt = getopt32(argv, "dqtp:", &path); + chp = argv[optind] ? argv[optind] : xstrdup("tmp.XXXXXXXXXX"); - if (flags & (4|8)) { /* -t and/or -p */ + if (opt & (4|8)) { /* -t and/or -p */ const char *dir = getenv("TMPDIR"); if (dir && *dir != '\0') path = dir; - else if (!(flags & 8)) /* No -p */ + else if (!(opt & 8)) /* no -p */ path = "/tmp/"; /* else path comes from -p DIR */ chp = concat_path_file(path, chp); } - if (flags & 1) { /* -d */ + if (opt & 1) { /* -d */ if (mkdtemp(chp) == NULL) return EXIT_FAILURE; } else { Modified: trunk/busybox/include/usage.h =================================================================== --- trunk/busybox/include/usage.h 2008-06-05 11:48:10 UTC (rev 22230) +++ trunk/busybox/include/usage.h 2008-06-05 12:06:00 UTC (rev 22231) @@ -2542,19 +2542,18 @@ #endif #define mktemp_trivial_usage \ - "[-dt] [-p DIR] TEMPLATE" + "[-dt] [-p DIR] [TEMPLATE]" #define mktemp_full_usage "\n\n" \ - "Create a temporary file with its name based on TEMPLATE.\n" \ - "TEMPLATE is any name with six 'Xs' (i.e., /tmp/temp.XXXXXX).\n" \ + "Create a temporary file with name based on TEMPLATE and print its name.\n" \ + "TEMPLATE must end with XXXXXX (i.e., /tmp/temp.XXXXXX).\n" \ "\nOptions:" \ "\n -d Make a directory instead of a file" \ /* "\n -q Fail silently if an error occurs" - we ignore it */ \ "\n -t Generate a path rooted in temporary directory" \ "\n -p DIR Use DIR as a temporary directory (implies -t)" \ "\n" \ - "\n" \ - "For -t or -p, directory is chosen as follows:\n" \ - "$TMPDIR if set, else -p DIR, else /tmp" \ + "\nFor -t or -p, directory is chosen as follows:" \ + "\n$TMPDIR if set, else -p DIR, else /tmp" \ #define mktemp_example_usage \ "$ mktemp /tmp/temp.XXXXXX\n" \ From aldot at busybox.net Thu Jun 5 05:18:43 2008 From: aldot at busybox.net (aldot at busybox.net) Date: Thu, 5 Jun 2008 05:18:43 -0700 (PDT) Subject: svn commit: trunk/busybox/archival Message-ID: <20080605121843.1D7243C765@busybox.net> Author: aldot Date: 2008-06-05 05:18:42 -0700 (Thu, 05 Jun 2008) New Revision: 22232 Log: - The conffiles control file isn't required in Debian packages, so don't error out if it's missing. (Peter Korsgaard) Modified: trunk/busybox/archival/dpkg.c Changeset: Modified: trunk/busybox/archival/dpkg.c =================================================================== --- trunk/busybox/archival/dpkg.c 2008-06-05 12:06:00 UTC (rev 22231) +++ trunk/busybox/archival/dpkg.c 2008-06-05 12:18:42 UTC (rev 22232) @@ -1339,8 +1339,10 @@ free_array(remove_files); free_array(exclude_files); - /* rename .conffile to .list */ - xrename(conffile_name, list_name); + /* rename .conffiles to .list + * The conffiles control file isn't required in Debian packages, so don't + * error out if it's missing. */ + rename(conffile_name, list_name); /* Change package status */ set_status(status_num, "config-files", 3); From vda at busybox.net Thu Jun 5 06:33:59 2008 From: vda at busybox.net (vda at busybox.net) Date: Thu, 5 Jun 2008 06:33:59 -0700 (PDT) Subject: svn commit: trunk/busybox: debianutils include libbb Message-ID: <20080605133359.C94873C72F@busybox.net> Author: vda Date: 2008-06-05 06:33:59 -0700 (Thu, 05 Jun 2008) New Revision: 22234 Log: which: -a support (needed for bfin uclibc build script) real support (with CONFIG_DESKTOP=y): 120+ bytes: text data bss dec hex filename 807958 624 7036 815618 c7202 busybox_old 808085 624 7036 815745 c7281 busybox_unstripped "fake" support (with CONFIG_DESKTOP unset): ~45 bytes: text data bss dec hex filename 797790 611 6996 805397 c4a15 busybox_old 797834 611 6996 805441 c4a41 busybox_unstripped Modified: trunk/busybox/debianutils/which.c trunk/busybox/include/libbb.h trunk/busybox/libbb/execable.c Changeset: Modified: trunk/busybox/debianutils/which.c =================================================================== --- trunk/busybox/debianutils/which.c 2008-06-05 12:29:36 UTC (rev 22233) +++ trunk/busybox/debianutils/which.c 2008-06-05 13:33:59 UTC (rev 22234) @@ -13,30 +13,69 @@ #include "libbb.h" int which_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -int which_main(int argc, char **argv) +int which_main(int argc ATTRIBUTE_UNUSED, char **argv) { + USE_DESKTOP(int opt;) int status = EXIT_SUCCESS; + char *path; char *p; - if (argc <= 1 || argv[1][0] == '-') { - bb_show_usage(); - } + opt_complementary = "-1"; /* at least one argument */ + USE_DESKTOP(opt =) getopt32(argv, "a"); + argv += optind; - /* This matches what is seen on e.g. ubuntu - * "which" there is a shell script */ - if (!getenv("PATH")) { - putenv((char*)bb_PATH_root_path); + /* This matches what is seen on e.g. ubuntu. + * "which" there is a shell script. */ + path = getenv("PATH"); + if (!path) { + path = (char*)bb_PATH_root_path; + putenv(path); + path += 5; /* skip "PATH=" */ } - while (--argc > 0) { - argv++; + do { +#if ENABLE_DESKTOP +/* Much bloat just to support -a */ if (strchr(*argv, '/')) { if (execable_file(*argv)) { puts(*argv); continue; } + status = EXIT_FAILURE; } else { - p = find_execable(*argv); + char *path2 = xstrdup(path); + char *tmp = path2; + + p = find_execable(*argv, &tmp); + if (!p) + status = EXIT_FAILURE; + else { + print: + puts(p); + free(p); + if (opt) { + /* -a: show matches in all PATH components */ + if (tmp) { + p = find_execable(*argv, &tmp); + if (p) + goto print; + } + } + } + free(path2); + } +#else +/* Just ignoring -a */ + if (strchr(*argv, '/')) { + if (execable_file(*argv)) { + puts(*argv); + continue; + } + } else { + char *path2 = xstrdup(path); + char *tmp = path2; + p = find_execable(*argv, &tmp); + free(path2); if (p) { puts(p); free(p); @@ -44,7 +83,8 @@ } } status = EXIT_FAILURE; - } +#endif + } while (*(++argv) != NULL); fflush_stdout_and_exit(status); } Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2008-06-05 12:29:36 UTC (rev 22233) +++ trunk/busybox/include/libbb.h 2008-06-05 13:33:59 UTC (rev 22234) @@ -700,7 +700,7 @@ #endif int execable_file(const char *name); -char *find_execable(const char *filename); +char *find_execable(const char *filename, char **PATHp); int exists_execable(const char *filename); /* BB_EXECxx always execs (it's not doing NOFORK/NOEXEC stuff), Modified: trunk/busybox/libbb/execable.c =================================================================== --- trunk/busybox/libbb/execable.c 2008-06-05 12:29:36 UTC (rev 22233) +++ trunk/busybox/libbb/execable.c 2008-06-05 13:33:59 UTC (rev 22234) @@ -19,15 +19,20 @@ return (!access(name, X_OK) && !stat(name, &s) && S_ISREG(s.st_mode)); } -/* search $PATH for an executable file; +/* search (*PATHp) for an executable file; * return allocated string containing full path if found; - * return NULL otherwise; + * PATHp points to the component after the one where it was found + * (or NULL), + * you may call find_execable again with this PATHp to continue + * (if it's not NULL). + * return NULL otherwise; (PATHp is undefined) + * in all cases (*PATHp) contents will be trashed (s/:/NUL/). */ -char *find_execable(const char *filename) +char *find_execable(const char *filename, char **PATHp) { - char *path, *p, *n; + char *p, *n; - p = path = xstrdup(getenv("PATH")); + p = *PATHp; while (p) { n = strchr(p, ':'); if (n) @@ -35,15 +40,14 @@ if (*p != '\0') { /* it's not a PATH="foo::bar" situation */ p = concat_path_file(p, filename); if (execable_file(p)) { - free(path); + *PATHp = n; return p; } free(p); } p = n; - } - free(path); - return NULL; + } /* on loop exit p == NULL */ + return p; } /* search $PATH for an executable file; @@ -52,7 +56,10 @@ */ int exists_execable(const char *filename) { - char *ret = find_execable(filename); + char *path = xstrdup(getenv("PATH")); + char *tmp = path; + char *ret = find_execable(filename, &tmp); + free(path); if (ret) { free(ret); return 1; From vda at busybox.net Thu Jun 5 07:01:05 2008 From: vda at busybox.net (vda at busybox.net) Date: Thu, 5 Jun 2008 07:01:05 -0700 (PDT) Subject: svn commit: trunk/busybox/networking/libiproute Message-ID: <20080605140105.AA9F73C72F@busybox.net> Author: vda Date: 2008-06-05 07:01:04 -0700 (Thu, 05 Jun 2008) New Revision: 22237 Log: ip: support for the LOWER_UP flag by Natanael Copa . ~50 bytes code growth. Modified: trunk/busybox/networking/libiproute/ipaddress.c Changeset: Modified: trunk/busybox/networking/libiproute/ipaddress.c =================================================================== --- trunk/busybox/networking/libiproute/ipaddress.c 2008-06-05 13:47:35 UTC (rev 22236) +++ trunk/busybox/networking/libiproute/ipaddress.c 2008-06-05 14:01:04 UTC (rev 22237) @@ -18,6 +18,10 @@ #include "rt_names.h" #include "utils.h" +#ifndef IFF_LOWER_UP +/* from linux/if.h */ +#define IFF_LOWER_UP 0x10000 /* driver signals L1 up*/ +#endif typedef struct filter_t { char *label; @@ -63,6 +67,7 @@ _PF(NOTRAILERS); #endif _PF(UP); + _PF(LOWER_UP); #undef _PF if (flags) printf("%x", flags); From bugs at busybox.net Thu Jun 5 07:13:44 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Thu, 5 Jun 2008 07:13:44 -0700 Subject: [BusyBox 0003664]: The 'ip' command fails listing multiple routing tables Message-ID: <832e4b50e73010595d67fbb32d8f10e8@busybox.net> The following issue has been SUBMITTED. ====================================================================== http://busybox.net/bugs/view.php?id=3664 ====================================================================== Reported By: jorcol Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 3664 Category: Documentation Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 06-05-2008 07:13 PDT Last Modified: 06-05-2008 07:13 PDT ====================================================================== Summary: The 'ip' command fails listing multiple routing tables Description: The "ip route list table " command fails with an invalid argument error. However, "ip route add" and "ip route del" work fine with any table ID. I have attached a small patch to version 10.2 that solves this. All it does is call the "rtnl_rttable_a2n" function just like the 'add' and 'del' commands do. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 06-05-08 07:13 jorcol New Issue 06-05-08 07:13 jorcol Status new => assigned 06-05-08 07:13 jorcol Assigned To => BusyBox 06-05-08 07:13 jorcol File Added: patch-busybox-1.10.2-ip-route-list ====================================================================== From aldot at busybox.net Fri Jun 6 01:40:28 2008 From: aldot at busybox.net (aldot at busybox.net) Date: Fri, 6 Jun 2008 01:40:28 -0700 (PDT) Subject: svn commit: trunk/busybox/docs/busybox.net Message-ID: <20080606084028.C24FA3C3F1@busybox.net> Author: aldot Date: 2008-06-06 01:40:28 -0700 (Fri, 06 Jun 2008) New Revision: 22247 Log: - fix copy'n paste error for the release date Modified: trunk/busybox/docs/busybox.net/news.html Changeset: Modified: trunk/busybox/docs/busybox.net/news.html =================================================================== --- trunk/busybox/docs/busybox.net/news.html 2008-06-06 08:05:50 UTC (rev 22246) +++ trunk/busybox/docs/busybox.net/news.html 2008-06-06 08:40:28 UTC (rev 22247) @@ -1,7 +1,7 @@
      -
    • 8 May 2008 -- BusyBox 1.10.3 (stable) +
    • 5 June 2008 -- BusyBox 1.10.3 (stable)

      BusyBox 1.10.3. (svn, patches, From bugs at busybox.net Fri Jun 6 03:16:10 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Fri, 6 Jun 2008 03:16:10 -0700 Subject: [BusyBox 0003674]: copying to a read-only destination gives strange error message (Nokia N800) Message-ID: <2df16fdc815ccf0eebfc2df22efbc458@bugs.busybox.net> The following issue has been SUBMITTED. ====================================================================== http://busybox.net/bugs/view.php?id=3674 ====================================================================== Reported By: Andre Klapper Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 3674 Category: New Features Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 06-06-2008 03:16 PDT Last Modified: 06-06-2008 03:16 PDT ====================================================================== Summary: copying to a read-only destination gives strange error message (Nokia N800) Description: Forwarding bug report from https://bugs.maemo.org/show_bug.cgi?id=2084 to upstream: SUMMARY: using /bin/cp file /media/mmc1 (where user is user and destination is readonly owned by root) gives strange error message EXPECTED OUTCOME: an error indicating that the target destination is read only would be greatly appreciated ACTUAL OUTCOME: busybox 1.4.1: 16 fprintf(stderr, "'%s' exists\n", dest); busybox 1.6.1: 50 bb_perror_msg("cannot remove '%s'", dest); STEPS TO REPRODUCE THE PROBLEM: 1. be sure there is no card in the external mmc slot 2. open xterminal 3. cp /etc/passwd /media/mmc1 OTHER COMMENTS: the code looks something like this: busybox: /libbb/copy_file.c 56 /* Return: 57 * -1 error, copy not made 58 * 0 copy is made or user answered "no" in interactive mode 59 * (failures to preserve mode/owner/times are not reported in exit code) 60 */ 61 int copy_file(const char *source, const char *dest, int flags) ... 80 if (lstat(dest, &dest_stat) < 0) { 81 if (errno != ENOENT) { not quite sure if this is the right point, there's definitely one instance of stat64 returning ENOENT according to strace. ... 193 } else if (S_ISREG(source_stat.st_mode) 194 /* Huh? DEREF uses stat, which never returns links! */ 195 /* || (FLAGS_DEREF && S_ISLNK(source_stat.st_mode)) */ 196 ) { ... 225 #if DO_POSIX_CP /* POSIX way (a security problem versus symlink attacks!): */ 226 dst_fd = open(dest, (flags & FILEUTILS_INTERACTIVE) 227 ? O_WRONLY|O_CREAT|O_EXCL 228 : O_WRONLY|O_CREAT|O_TRUNC, source_stat.st_mode); 229 #else /* safe way: */ 230 dst_fd = open(dest, O_WRONLY|O_CREAT|O_EXCL, source_stat.st_mode); 231 #endif one of these two opens returns -1 EACCES 232 if (dst_fd == -1) { at this point, we know the file doesn't exist and can't be written to 233 ovr = ask_and_unlink(dest, flags); so we try to delete it! 234 if (ovr <= 0) { 235 close(src_fd); 236 return ovr; busybox: libbb/copy_file.c 26 static int ask_and_unlink(const char *dest, int flags) ... 49 if (unlink(dest) < 0) { 50 bb_perror_msg("cannot remove '%s'", dest); 51 return -1; // error it'd be greatly appreciated if the error message was something indicating that the destination is readonly instead of a message talking about not being able to delete the file. note, on the version of busybox i have on my n800, i actually get: /tmp $ cp x.png /media/mmc1/ '/media/mmc1/x.png' exists /tmp $ the sources i'm reading are from busybox 1.6.1, the device has busybox 1.4.1 that code looks like this: busybox: libbb/copy_file.c 13 static int retry_overwrite(const char *dest, int flags) 14 { 15 if (!(flags & (FILEUTILS_FORCE|FILEUTILS_INTERACTIVE))) { 16 fprintf(stderr, "'%s' exists\n", dest); 31 int copy_file(const char *source, const char *dest, int flags) 179 // POSIX: if exists and -i, ask (w/o -i assume yes). 180 // Then open w/o EXCL. 181 // If open still fails and -f, try unlink, then try open again. 182 // Result: a mess: 183 // If dest is a softlink, we overwrite softlink's destination! 184 // (or fail, if it points to dir/nonexistent location/etc). 185 // This is strange, but POSIX-correct. 186 // coreutils cp has --remove-destination to override this... 187 dst_fd = open(dest, (flags & FILEUTILS_INTERACTIVE) 188 ? O_WRONLY|O_CREAT|O_TRUNC|O_EXCL 189 : O_WRONLY|O_CREAT|O_TRUNC, source_stat.st_mode); 190 if (dst_fd == -1) { 191 // We would not do POSIX insanity. -i asks, 192 // then _unlinks_ the offender. Presto. 193 // Or else we will end up having 3 open()s! 194 ovr = retry_overwrite(dest, flags); ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 06-06-08 03:16 Andre Klapper New Issue 06-06-08 03:16 Andre Klapper Status new => assigned 06-06-08 03:16 Andre Klapper Assigned To => BusyBox ====================================================================== From aldot at busybox.net Fri Jun 6 03:31:42 2008 From: aldot at busybox.net (aldot at busybox.net) Date: Fri, 6 Jun 2008 03:31:42 -0700 (PDT) Subject: svn commit: trunk/busybox/include Message-ID: <20080606103142.AC52B3C3F8@busybox.net> Author: aldot Date: 2008-06-06 03:31:39 -0700 (Fri, 06 Jun 2008) New Revision: 22248 Log: - fix compilation on standard-conforming compilers Modified: trunk/busybox/include/libbb.h Changeset: Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2008-06-06 08:40:28 UTC (rev 22247) +++ trunk/busybox/include/libbb.h 2008-06-06 10:31:39 UTC (rev 22248) @@ -1287,7 +1287,7 @@ * If you want to assign a value, use SET_PTR_TO_GLOBALS(x) */ extern struct globals *const ptr_to_globals; /* At least gcc 3.4.6 on mipsel system needs optimization barrier */ -#define barrier() asm volatile("":::"memory") +#define barrier() __asm__ __volatile__("":::"memory") #define SET_PTR_TO_GLOBALS(x) do { \ (*(struct globals**)&ptr_to_globals) = (x); \ barrier(); \ From vda at busybox.net Fri Jun 6 09:08:05 2008 From: vda at busybox.net (vda at busybox.net) Date: Fri, 6 Jun 2008 09:08:05 -0700 (PDT) Subject: svn commit: trunk/busybox: include sysklogd Message-ID: <20080606160805.34E4B3C5DE@busybox.net> Author: vda Date: 2008-06-06 09:08:04 -0700 (Fri, 06 Jun 2008) New Revision: 22251 Log: klogd: make help text more understandable klogd: by using a register instead of global variable, shrink code a bit function old new delta klogd_main 372 362 -10 packed_usage 24504 24486 -18 text data bss dec hex filename 808464 642 7180 816286 c749e busybox_old 808422 642 7180 816244 c7474 busybox_unstripped Modified: trunk/busybox/include/usage.h trunk/busybox/sysklogd/klogd.c Changeset: Modified: trunk/busybox/include/usage.h =================================================================== --- trunk/busybox/include/usage.h 2008-06-06 13:25:09 UTC (rev 22250) +++ trunk/busybox/include/usage.h 2008-06-06 16:08:04 UTC (rev 22251) @@ -2063,11 +2063,11 @@ "\n -l List all signal names and numbers" \ #define klogd_trivial_usage \ - "[-c n] [-n]" + "[-c N] [-n]" #define klogd_full_usage "\n\n" \ "Kernel logger\n" \ "\nOptions:" \ - "\n -c n Set the default log level of console messages to n" \ + "\n -c N Only messages with level < N are printed to console" \ "\n -n Run in foreground" \ #define length_trivial_usage \ Modified: trunk/busybox/sysklogd/klogd.c =================================================================== --- trunk/busybox/sysklogd/klogd.c 2008-06-06 13:25:09 UTC (rev 22250) +++ trunk/busybox/sysklogd/klogd.c 2008-06-06 16:08:04 UTC (rev 22251) @@ -21,10 +21,12 @@ #include #include -static void klogd_signal(int sig ATTRIBUTE_UNUSED) +static void klogd_signal(int sig) { - klogctl(7, NULL, 0); - klogctl(0, NULL, 0); + /* FYI: cmd 7 is equivalent to setting console_loglevel to 7 + * via klogctl(8, NULL, 7). */ + klogctl(7, NULL, 0); /* "7 -- Enable printk's to console" */ + klogctl(0, NULL, 0); /* "0 -- Close the log. Currently a NOP" */ syslog(LOG_NOTICE, "klogd: exiting"); kill_myself_with_sig(sig); } @@ -39,35 +41,33 @@ int klogd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int klogd_main(int argc ATTRIBUTE_UNUSED, char **argv) { - int i = i; /* silence gcc */ + int i = 0; char *start; + int opt; - /* do normal option parsing */ - getopt32(argv, "c:n", &start); - - if (option_mask32 & OPT_LEVEL) { + opt = getopt32(argv, "c:n", &start); + if (opt & OPT_LEVEL) { /* Valid levels are between 1 and 8 */ - i = xatoul_range(start, 1, 8); + i = xatou_range(start, 1, 8); } - - if (!(option_mask32 & OPT_FOREGROUND)) { + if (!(opt & OPT_FOREGROUND)) { bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv); } openlog("kernel", 0, LOG_KERN); - /* Set up sig handlers */ bb_signals(0 + (1 << SIGINT) + (1 << SIGTERM) , klogd_signal); signal(SIGHUP, SIG_IGN); - /* "Open the log. Currently a NOP." */ + /* "Open the log. Currently a NOP" */ klogctl(1, NULL, 0); - /* Set level of kernel console messaging. */ - if (option_mask32 & OPT_LEVEL) + /* "printk() prints a message on the console only if it has a loglevel + * less than console_loglevel". Here we set console_loglevel = i. */ + if (i) klogctl(8, NULL, i); syslog(LOG_NOTICE, "klogd started: %s", bb_banner); @@ -80,11 +80,12 @@ int n; int priority; + /* "2 -- Read from the log." */ n = klogctl(2, log_buffer, KLOGD_LOGBUF_SIZE - 1); if (n < 0) { if (errno == EINTR) continue; - syslog(LOG_ERR, "klogd: error from klogctl(2): %d - %m", + syslog(LOG_ERR, "klogd: error %d in klogctl(2): %m", errno); break; } From vda at busybox.net Fri Jun 6 09:11:13 2008 From: vda at busybox.net (vda at busybox.net) Date: Fri, 6 Jun 2008 09:11:13 -0700 (PDT) Subject: svn commit: trunk/busybox: scripts Message-ID: <20080606161113.65E893C2B3@busybox.net> Author: vda Date: 2008-06-06 09:11:12 -0700 (Fri, 06 Jun 2008) New Revision: 22252 Log: Build system: track -Wl,-elf2flt in CFLAGS_busybox too. Document in comments that it generally should be thers, not in LDFLAGS Modified: trunk/busybox/Makefile.flags trunk/busybox/scripts/Makefile.lib Changeset: Modified: trunk/busybox/Makefile.flags =================================================================== --- trunk/busybox/Makefile.flags 2008-06-06 16:08:04 UTC (rev 22251) +++ trunk/busybox/Makefile.flags 2008-06-06 16:11:12 UTC (rev 22252) @@ -91,8 +91,13 @@ LDLIBS += dmalloc endif -LDFLAGS_ELF2FLT = -Wl,-elf2flt -ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS))) +# If a flat binary should be built, CFLAGS_busybox="-Wl,-elf2flt" +# env var should be set for make invocation. +# Here we check whether CFLAGS_busybox indeed contains that flag. +# (For historical reasons, we also check LDFLAGS, which doesn't +# seem to be entirely correct variable to put "-Wl,-elf2flt" into). +W_ELF2FLT = -Wl,-elf2flt +ifneq (,$(findstring $(W_ELF2FLT),$(LDFLAGS) $(CFLAGS_busybox))) SKIP_STRIP = y endif Modified: trunk/busybox/scripts/Makefile.lib =================================================================== --- trunk/busybox/scripts/Makefile.lib 2008-06-06 16:08:04 UTC (rev 22251) +++ trunk/busybox/scripts/Makefile.lib 2008-06-06 16:11:12 UTC (rev 22252) @@ -117,6 +117,7 @@ cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags) +# TODO: seems to be a wrong thing to do! LDFLAGS contains gcc's flags! ld_flags = $(LDFLAGS) $(EXTRA_LDFLAGS) # Finds the multi-part object the current object will be linked into @@ -146,6 +147,8 @@ # Linking # --------------------------------------------------------------------------- +# TODO: LDFLAGS usually is supposed to contain gcc's flags, not ld's. +# but here we feed them to ld! quiet_cmd_ld = LD $@ cmd_ld = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) \ $(filter-out FORCE,$^) -o $@ From vda at busybox.net Fri Jun 6 22:19:32 2008 From: vda at busybox.net (vda at busybox.net) Date: Fri, 6 Jun 2008 22:19:32 -0700 (PDT) Subject: svn commit: trunk/busybox: editors findutils testsuite Message-ID: <20080607051932.3A9743C2D9@busybox.net> Author: vda Date: 2008-06-06 22:19:31 -0700 (Fri, 06 Jun 2008) New Revision: 22253 Log: grep: make "-f -" work (+ testsuite) diff: small code shrink function old new delta grep_main 722 714 -8 diffreg 1825 1793 -32 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-40) Total: -40 bytes Modified: trunk/busybox/editors/diff.c trunk/busybox/findutils/grep.c trunk/busybox/testsuite/grep.tests Changeset: Modified: trunk/busybox/editors/diff.c =========================================================