Re: [PATCH] devmem: add 128-bit width
Hi, On Fri, Aug 26, 2022 at 05:25:22PM +0200, Denys Vlasenko wrote: > Is there a need to make these 128 reads actually this wide as one atomic load? > (On x86, SSE insn do that). There are arm64 hardware where such register access is needed, and GCC handles that correctly. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] devmem: add 128-bit width
From: Aaro Koskinen Add 128-bit width if the compiler provides the needed type. function old new delta devmem_main 412 517+105 usage_messages 247 313 +66 .rodata 35533571 +18 -- (add/remove: 2/0 grow/shrink: 3/0 up/down: 189/0) Total: 189 bytes Signed-off-by: Aaro Koskinen Signed-off-by: Aaro Koskinen --- miscutils/devmem.c | 113 +++-- 1 file changed, 69 insertions(+), 44 deletions(-) diff --git a/miscutils/devmem.c b/miscutils/devmem.c index f9f0276bc..a6991886a 100644 --- a/miscutils/devmem.c +++ b/miscutils/devmem.c @@ -15,12 +15,15 @@ //kbuild:lib-$(CONFIG_DEVMEM) += devmem.o //usage:#define devmem_trivial_usage -//usage: "ADDRESS [WIDTH [VALUE]]" +//usage: "ADDRESS [WIDTH [VALUE]...]" //usage:#define devmem_full_usage "\n\n" //usage: "Read/write from physical address\n" //usage: "\n ADDRESS Address to act upon" //usage: "\n WIDTH Width (8/16/...)" //usage: "\n VALUE Data to be written" +#ifdef __SIZEOF_INT128__ +//usage: "\n For 128-bit data, provide 64-bit values (LOW, or HI and LOW)" +#endif #include "libbb.h" @@ -28,7 +31,7 @@ int devmem_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int devmem_main(int argc UNUSED_PARAM, char **argv) { void *map_base, *virt_addr; - uint64_t read_result; + uint64_t read_result = read_result; /* for compiler */ uint64_t writeval = writeval; /* for compiler */ off_t target; unsigned page_size, mapped_size, offset_in_page; @@ -96,51 +99,73 @@ int devmem_main(int argc UNUSED_PARAM, char **argv) virt_addr = (char*)map_base + offset_in_page; if (!argv[3]) { - switch (width) { - case 8: - read_result = *(volatile uint8_t*)virt_addr; - break; - case 16: - read_result = *(volatile uint16_t*)virt_addr; - break; - case 32: - read_result = *(volatile uint32_t*)virt_addr; - break; - case 64: - read_result = *(volatile uint64_t*)virt_addr; - break; - default: - bb_simple_error_msg_and_die("bad width"); +#ifdef __SIZEOF_INT128__ + if (width == 128) { + unsigned __int128 rd = + *(volatile unsigned __int128 *)virt_addr; + printf("0x%016llX%016llX\n", (uint64_t)(rd >> 64), + (uint64_t)rd); + } else +#endif + { + switch (width) { + case 8: + read_result = *(volatile uint8_t*)virt_addr; + break; + case 16: + read_result = *(volatile uint16_t*)virt_addr; + break; + case 32: + read_result = *(volatile uint32_t*)virt_addr; + break; + case 64: + read_result = *(volatile uint64_t*)virt_addr; + break; + default: + bb_simple_error_msg_and_die("bad width"); + } +// printf("Value at address 0x%"OFF_FMT"X (%p): 0x%llX\n", +// target, virt_addr, +// (unsigned long long)read_result); + /* Zero-padded output shows the width of access just done */ + printf("0x%0*llX\n", (width >> 2), (unsigned long long)read_result); } -// printf("Value at address 0x%"OFF_FMT"X (%p): 0x%llX\n", -// target, virt_addr, -// (unsigned long long)read_result); - /* Zero-padded output shows the width of access just done */ - printf("0x%0*llX\n", (width >> 2), (unsigned long long)read_result); } else { - switch (width) { - case 8: - *(volatile uint8_t*)virt_addr = writeval; -// read_result = *(volatile uint8_t*)virt_addr; - break; - case 16: - *(volatile uin
Re: Bash compatibility TODO
Hi, On Mon, Jun 27, 2022 at 11:24:15PM +0200, Bernd Petrovitsch wrote: > On 27/06/2022 23:10, David Laight wrote: > > From: Aaro Koskinen > > > Sent: 27 June 2022 21:43 > [...] > > > Looks like it's not possible to build mainline Linux anymore with the > > > busybox as "bash". :-( > > > > Have you posted that to LKML ? > > They really ought to solve the problem a different way. > [...] > > > $ make > > >CC scripts/mod/empty.o > > > ./scripts/check-local-export: line 17: shopt: not found > > > make[1]: *** [scripts/Makefile.build:249: scripts/mod/empty.o] Error 127 > > > make[1]: *** Deleting file 'scripts/mod/empty.o' > > > make: *** [Makefile:1199: prepare0] Error 2 > > > > > > It seems the requirement is to support "lastpipe" option: > > > > > > # Run the last element of a pipeline in the current shell. > > > # Without this, the while-loop would be executed in a subshell, and > > > # the changes made to 'symbol_types' and 'export_symbols' would be lost. > > > shopt -s lastpipe > > FWIW: Debian/Ubuntu has dash as /bin/sh and that doesn't have "shopt" > too. Yes, but that script has "#!/usr/bin/env bash". The "minimal" kernel build requirements now list bash 4.2 as mandatory. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Bash compatibility TODO
Hi all, Looks like it's not possible to build mainline Linux anymore with the busybox as "bash". :-( $ make CC scripts/mod/empty.o ./scripts/check-local-export: line 17: shopt: not found make[1]: *** [scripts/Makefile.build:249: scripts/mod/empty.o] Error 127 make[1]: *** Deleting file 'scripts/mod/empty.o' make: *** [Makefile:1199: prepare0] Error 2 It seems the requirement is to support "lastpipe" option: # Run the last element of a pipeline in the current shell. # Without this, the while-loop would be executed in a subshell, and # the changes made to 'symbol_types' and 'export_symbols' would be lost. shopt -s lastpipe and I don't think these will work either: declare -A symbol_types declare -a export_symbols A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] Improve support for long options to grep
Hi, On Mon, Jan 24, 2022 at 01:12:25PM -0300, Walter Lozano wrote: > In my specific use case, I try to run some Debian scripts, that make use of > some of those long options, of course not all of them. Since I was already > there I thought it would be nice to add them, since these kind of overhead > can be enabled only if needed. Yes, I think it's a valid reason to add them if some widely used scripts/programs use them. > From my understanding long options were enabled if > ENABLE_FEATURE_GREP_CONTEXT, which has some sense, since the color > would be a nice improvement in that case. > > Following the idea that users who use ENABLE_FEATURE_GREP_CONTEXT with color > are looking for a full featured grep I thought that no additional > configuration options should we created to handle this. There is a separate LONG_OPTS feature that users can enable, maybe you should use that instead. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] find: implement -samefile
Implement -samefile. Signed-off-by: Aaro Koskinen --- findutils/find.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/findutils/find.c b/findutils/find.c index fdc5c152d..87fd5b9bc 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -155,6 +155,13 @@ //config: default y //config: depends on FIND //config: +//config:config FEATURE_FIND_SAMEFILE +//config: bool "Enable -samefile: reference file matching" +//config: default y +//config: depends on FIND +//config: help +//config:Support the 'find -samefile' option for searching by a reference file. +//config: //config:config FEATURE_FIND_EXEC //config: bool "Enable -exec: execute commands" //config: default y @@ -350,6 +357,9 @@ //usage: IF_FEATURE_FIND_INUM( //usage: "\n -inum N File has inode number N" //usage: ) +//usage: IF_FEATURE_FIND_SAMEFILE( +//usage: "\n -samefile FILE File is same as FILE" +//usage: ) //usage: IF_FEATURE_FIND_USER( //usage: "\n -user NAME/ID File is owned by given user" //usage: ) @@ -444,6 +454,7 @@ IF_FEATURE_FIND_MTIME( ACTS(mtime, unsigned char time_type; unsigned char mtime IF_FEATURE_FIND_MMIN( ACTS(mmin, unsigned char time_type; unsigned char mmin_char; unsigned mmin_mins;)) IF_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;)) IF_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;)) +IF_FEATURE_FIND_SAMEFILE(ACTS(samefile, ino_t inode_num; dev_t device;)) IF_FEATURE_FIND_USER( ACTS(user, uid_t uid;)) IF_FEATURE_FIND_SIZE( ACTS(size, char size_char; off_t size;)) IF_FEATURE_FIND_CONTEXT(ACTS(context, security_context_t context;)) @@ -731,6 +742,13 @@ ACTF(inum) return (statbuf->st_ino == ap->inode_num); } #endif +#if ENABLE_FEATURE_FIND_SAMEFILE +ACTF(samefile) +{ + return statbuf->st_ino == ap->inode_num && + statbuf->st_dev == ap->device; +} +#endif #if ENABLE_FEATURE_FIND_EXEC static int do_exec(action_exec *ap, const char *fileName) { @@ -1125,6 +1143,7 @@ static action*** parse_params(char **argv) IF_FEATURE_FIND_CMIN( PARM_cmin ,) IF_FEATURE_FIND_NEWER( PARM_newer ,) IF_FEATURE_FIND_INUM( PARM_inum ,) + IF_FEATURE_FIND_SAMEFILE(PARM_samefile ,) IF_FEATURE_FIND_USER( PARM_user ,) IF_FEATURE_FIND_GROUP( PARM_group ,) IF_FEATURE_FIND_SIZE( PARM_size ,) @@ -1173,6 +1192,7 @@ static action*** parse_params(char **argv) IF_FEATURE_FIND_CMIN( "-cmin\0" ) IF_FEATURE_FIND_NEWER( "-newer\0" ) IF_FEATURE_FIND_INUM( "-inum\0" ) + IF_FEATURE_FIND_SAMEFILE("-samefile\0") IF_FEATURE_FIND_USER( "-user\0" ) IF_FEATURE_FIND_GROUP( "-group\0" ) IF_FEATURE_FIND_SIZE( "-size\0" ) @@ -1511,6 +1531,21 @@ static action*** parse_params(char **argv) ap->inode_num = xatoul(arg1); } #endif +#if ENABLE_FEATURE_FIND_SAMEFILE + else if (parm == PARM_samefile) { + action_samefile *ap; + struct stat stbuf; + dbg("%d", __LINE__); + if (G.recurse_flags & (ACTION_FOLLOWLINKS | + ACTION_FOLLOWLINKS_L0)) + xstat(arg1, &stbuf); + else if (lstat(arg1, &stbuf)) + bb_perror_msg_and_die("can't stat '%s'", arg1); + ap = ALLOC_ACTION(samefile); + ap->inode_num = stbuf.st_ino; + ap->device = stbuf.st_dev; + } +#endif #if ENABLE_FEATURE_FIND_USER else if (parm == PARM_user) { action_user *ap; -- 2.17.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Regression: busybox xargs broken
Hi, I noticed the following: $ echo foo bar | ./busybox xargs -n1 foo b a r This makes busybox build fail under busybox (scripts/trylink uses xargs). Bisected to: commit 1ff7002b1d229c678fdffebec602fb4c54439a31 (HEAD -> master) Author: Ron Yorston Date: Fri Jan 24 13:16:45 2020 + xargs: fix handling of quoted arguments, closes 11441 A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Regression: busybox gzip broken
Hi, This time gzip is broken, caused by: c763392458304d68951d0b22e89e2422b9c2f8ef is the first bad commit commit c763392458304d68951d0b22e89e2422b9c2f8ef Author: Denys Vlasenko Date: Sat Oct 19 18:33:49 2019 +0200 gzip: code shrink Decompressing large gzip archive segfaults: $ busybox gzip -cd arm-rootfs.tar.gz > /dev/null Segmentation fault (core dumped) Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00444620 in inflate_codes (state=state@entry=0x15c3220) at archival/libarchive/decompress_gunzip.c:565 565 t = td + ((unsigned) bb & md); (gdb) bt #0 0x00444620 in inflate_codes (state=state@entry=0x15c3220) at archival/libarchive/decompress_gunzip.c:565 #1 0x004449f3 in inflate_get_next_window (state=0x15c3220) at archival/libarchive/decompress_gunzip.c:971 #2 inflate_unzip_internal (state=state@entry=0x15c3220, xstate=xstate@entry=0x7ffd526e4048) at archival/libarchive/decompress_gunzip.c:1020 #3 0x00444c00 in unpack_gz_stream (xstate=xstate@entry=0x7ffd526e4048) at archival/libarchive/decompress_gunzip.c:1240 #4 0x0043dee9 in bbunpack (argv=0x7ffd526e4310, unpacker=0x444a8b , make_new_name=0x43dca5 , expected_ext=0x0) at archival/bbunzip.c:126 #5 0x00407900 in run_applet_no_and_exit (applet_no=63, name=name@entry=0x7ffd526e5884 "gzip", argv=argv@entry=0x7ffd526e4300) at libbb/appletlib.c:997 #6 0x00407bc3 in run_applet_and_exit (name=0x7ffd526e5884 "gzip", argv=argv@entry=0x7ffd526e4300) at libbb/appletlib.c:1015 #7 0x00407ba6 in busybox_main (argv=0x7ffd526e4300) at libbb/appletlib.c:958 #8 run_applet_and_exit (name=, argv=argv@entry=0x7ffd526e42f8) at libbb/appletlib.c:1008 #9 0x00407c44 in main (argc=, argv=0x7ffd526e42f8) at libbb/appletlib.c:1123 (gdb) A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Regression: busybox tar broken
Hi, On Thu, Oct 24, 2019 at 02:30:18AM +0300, Aaro Koskinen wrote: > $ busybox tar > tar: NO OPT �! > $ busybox tar xf foo.tar > tar: NO OPT �! Seems to happen only when CONFIG_FEATURE_SEAMLESS_LZMA is not set. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Regression: busybox tar broken
Hi, I get this with the current git master: $ busybox tar tar: NO OPT �! $ busybox tar xf foo.tar tar: NO OPT �! Bisected to: 16474cf246cb10b982f7365b201f32a930e8af95 is the first bad commit commit 16474cf246cb10b982f7365b201f32a930e8af95 Author: Denys Vlasenko Date: Fri Aug 2 15:19:56 2019 +0200 tar: change -a from meaning "lzma" to mean "autodetect by extension" Used config below: # # Automatically generated make config: don't edit # Busybox version: 1.32.0.git # Thu Oct 24 02:24:50 2019 # CONFIG_HAVE_DOT_CONFIG=y # # Settings # CONFIG_DESKTOP=y CONFIG_EXTRA_COMPAT=y # CONFIG_FEDORA_COMPAT is not set # CONFIG_INCLUDE_SUSv2 is not set CONFIG_LONG_OPTS=y CONFIG_SHOW_USAGE=y CONFIG_FEATURE_VERBOSE_USAGE=y CONFIG_FEATURE_COMPRESS_USAGE=y CONFIG_LFS=y # CONFIG_PAM is not set CONFIG_FEATURE_DEVPTS=y CONFIG_FEATURE_UTMP=y CONFIG_FEATURE_WTMP=y # CONFIG_FEATURE_PIDFILE is not set CONFIG_PID_FILE_PATH="" CONFIG_BUSYBOX=y # CONFIG_FEATURE_SHOW_SCRIPT is not set CONFIG_FEATURE_INSTALLER=y # CONFIG_INSTALL_NO_USR is not set # CONFIG_FEATURE_SUID is not set # CONFIG_FEATURE_SUID_CONFIG is not set # CONFIG_FEATURE_SUID_CONFIG_QUIET is not set # CONFIG_FEATURE_PREFER_APPLETS is not set CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe" # CONFIG_SELINUX is not set # CONFIG_FEATURE_CLEAN_UP is not set CONFIG_FEATURE_SYSLOG_INFO=y CONFIG_FEATURE_SYSLOG=y CONFIG_PLATFORM_LINUX=y # # Build Options # # CONFIG_STATIC is not set # CONFIG_PIE is not set # CONFIG_NOMMU is not set # CONFIG_BUILD_LIBBUSYBOX is not set # CONFIG_FEATURE_LIBBUSYBOX_STATIC is not set # CONFIG_FEATURE_INDIVIDUAL is not set # CONFIG_FEATURE_SHARED_BUSYBOX is not set CONFIG_CROSS_COMPILER_PREFIX="" CONFIG_SYSROOT="" CONFIG_EXTRA_CFLAGS="" CONFIG_EXTRA_LDFLAGS="-lcrypt" CONFIG_EXTRA_LDLIBS="" # CONFIG_USE_PORTABLE_CODE is not set CONFIG_STACK_OPTIMIZATION_386=y # # Installation Options ("make install" behavior) # # CONFIG_INSTALL_APPLET_SYMLINKS is not set CONFIG_INSTALL_APPLET_HARDLINKS=y # CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS is not set # CONFIG_INSTALL_APPLET_DONT is not set # CONFIG_INSTALL_SH_APPLET_SYMLINK is not set # CONFIG_INSTALL_SH_APPLET_HARDLINK is not set # CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER is not set CONFIG_PREFIX="./_install" # # Debugging Options # # CONFIG_DEBUG is not set # CONFIG_DEBUG_PESSIMIZE is not set # CONFIG_DEBUG_SANITIZE is not set # CONFIG_UNIT_TEST is not set # CONFIG_WERROR is not set # CONFIG_WARN_SIMPLE_MSG is not set CONFIG_NO_DEBUG_LIB=y # CONFIG_DMALLOC is not set # CONFIG_EFENCE is not set # # Library Tuning # # CONFIG_FEATURE_USE_BSS_TAIL is not set CONFIG_FLOAT_DURATION=y CONFIG_FEATURE_RTMINMAX=y CONFIG_FEATURE_RTMINMAX_USE_LIBC_DEFINITIONS=y CONFIG_FEATURE_BUFFERS_USE_MALLOC=y # CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set # CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set CONFIG_PASSWORD_MINLEN=6 CONFIG_MD5_SMALL=1 CONFIG_SHA3_SMALL=1 CONFIG_FEATURE_FAST_TOP=y # CONFIG_FEATURE_ETC_NETWORKS is not set # CONFIG_FEATURE_ETC_SERVICES is not set CONFIG_FEATURE_EDITING=y CONFIG_FEATURE_EDITING_MAX_LEN=1024 # CONFIG_FEATURE_EDITING_VI is not set CONFIG_FEATURE_EDITING_HISTORY=255 CONFIG_FEATURE_EDITING_SAVEHISTORY=y # CONFIG_FEATURE_EDITING_SAVE_ON_EXIT is not set CONFIG_FEATURE_REVERSE_SEARCH=y CONFIG_FEATURE_TAB_COMPLETION=y # CONFIG_FEATURE_USERNAME_COMPLETION is not set CONFIG_FEATURE_EDITING_FANCY_PROMPT=y CONFIG_FEATURE_EDITING_WINCH=y # CONFIG_FEATURE_EDITING_ASK_TERMINAL is not set # CONFIG_LOCALE_SUPPORT is not set # CONFIG_UNICODE_SUPPORT is not set # CONFIG_UNICODE_USING_LOCALE is not set # CONFIG_FEATURE_CHECK_UNICODE_IN_ENV is not set CONFIG_SUBST_WCHAR=0 CONFIG_LAST_SUPPORTED_WCHAR=0 # CONFIG_UNICODE_COMBINING_WCHARS is not set # CONFIG_UNICODE_WIDE_WCHARS is not set # CONFIG_UNICODE_BIDI_SUPPORT is not set # CONFIG_UNICODE_NEUTRAL_TABLE is not set # CONFIG_UNICODE_PRESERVE_BROKEN is not set CONFIG_FEATURE_NON_POSIX_CP=y CONFIG_FEATURE_VERBOSE_CP_MESSAGE=y CONFIG_FEATURE_USE_SENDFILE=y CONFIG_FEATURE_COPYBUF_KB=4 CONFIG_FEATURE_SKIP_ROOTFS=y CONFIG_MONOTONIC_SYSCALL=y CONFIG_IOCTL_HEX2STR_ERROR=y # CONFIG_FEATURE_HWIB is not set # # Applets # # # Archival Utilities # CONFIG_FEATURE_SEAMLESS_XZ=y # CONFIG_FEATURE_SEAMLESS_LZMA is not set CONFIG_FEATURE_SEAMLESS_BZ2=y CONFIG_FEATURE_SEAMLESS_GZ=y # CONFIG_FEATURE_SEAMLESS_Z is not set # CONFIG_AR is not set # CONFIG_FEATURE_AR_LONG_FILENAMES is not set # CONFIG_FEATURE_AR_CREATE is not set # CONFIG_UNCOMPRESS is not set CONFIG_GUNZIP=y CONFIG_ZCAT=y CONFIG_FEATURE_GUNZIP_LONG_OPTIONS=y CONFIG_BUNZIP2=y CONFIG_BZCAT=y # CONFIG_UNLZMA is not set CONFIG_LZCAT=y # CONFIG_LZMA is not set CONFIG_UNXZ=y CONFIG_XZCAT=y CONFIG_XZ=y CONFIG_BZIP2=y CONFIG_BZIP2_SMALL=8 CONFIG_FEATURE_BZIP2_DECOMPRESS=y CONFIG_CPIO=y CONFIG_FEATURE_CPIO_O=y CONFIG_FEATURE_CPIO_P=y # CONFIG_DPKG is not set # CONFIG_DPKG_DEB is not set CONFIG_GZIP=y CONFIG_FEATURE_GZIP_LONG_OPTIONS=y CONFIG_GZIP_FAST=0 CONFIG_FEATURE_GZIP_LEVELS=y CONFIG_FEATURE_GZIP_DECOMPRESS=y # CONFIG_
Re: [PATCH] find: implement -empty
Hi, On Wed, Sep 11, 2019 at 03:22:33PM +0200, David Demelier wrote: > You can save an indent level here by removing this else block. Since there > is a return before, no need for this else. The block is used to limit variable scope, so I don't have to declare variables that are only used when else is taken. Though, on my compiler it does not really matter, the generated code is the same. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] find: implement -empty
Hi, On Wed, Sep 11, 2019 at 09:46:45AM +0200, walter harms wrote: > is seems possible to simply that a bit (untested version): > > if ( ! S_ISDIR(statbuf->st_mode)) >return S_ISREG(statbuf->st_mode) && !statbuf->st_size; > > DIR *dir; Not sure if this is allowed by current busybox coding style: findutils/find.c:844:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] DIR *dir; A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] find: implement -empty
Implement -empty. Signed-off-by: Aaro Koskinen --- findutils/find.c | 45 + 1 file changed, 45 insertions(+) diff --git a/findutils/find.c b/findutils/find.c index d6679bd08..3e4ae3266 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -203,6 +203,14 @@ //config: WARNING: This option can do much harm if used wrong. Busybox will not //config: try to protect the user from doing stupid things. Use with care. //config: +//config:config FEATURE_FIND_EMPTY +//config: bool "Enable -empty: match empty files or directories" +//config: default y +//config: depends on FIND +//config: help +//config:Support the 'find -empty' option to find empty regular files +//config:or directories. +//config: //config:config FEATURE_FIND_PATH //config: bool "Enable -path: match pathname with shell pattern" //config: default y @@ -333,6 +341,9 @@ //usage: IF_FEATURE_FIND_DELETE( //usage: "\n -delete Delete current file/directory. Turns on -depth option" //usage: ) +//usage: IF_FEATURE_FIND_EMPTY( +//usage: "\n -empty Match empty file/directory." +//usage: ) //usage: IF_FEATURE_FIND_QUIT( //usage: "\n -quit Exit" //usage: ) @@ -396,6 +407,7 @@ IF_FEATURE_FIND_PAREN( ACTS(paren, action ***subexpr;)) IF_FEATURE_FIND_PRUNE( ACTS(prune)) IF_FEATURE_FIND_QUIT( ACTS(quit)) IF_FEATURE_FIND_DELETE( ACTS(delete)) +IF_FEATURE_FIND_EMPTY( ACTS(empty)) IF_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; /* -exec ARGS */ unsigned *subst_count; @@ -824,6 +836,31 @@ ACTF(delete) return TRUE; } #endif +#if ENABLE_FEATURE_FIND_EMPTY +ACTF(empty) +{ + if (S_ISDIR(statbuf->st_mode)) { + DIR *dir; + + dir = opendir(fileName); + if (!dir) { + bb_simple_perror_msg(fileName); + return FALSE; + } else { + struct dirent *dent; + char n = 0; + + while ((dent = readdir(dir)) != NULL && + DOT_OR_DOTDOT(dent->d_name) && + n++ < 2) + ; + closedir(dir); + return !dent; + } + } + return S_ISREG(statbuf->st_mode) && !statbuf->st_size; +} +#endif #if ENABLE_FEATURE_FIND_CONTEXT ACTF(context) { @@ -989,6 +1026,7 @@ static action*** parse_params(char **argv) IF_FEATURE_FIND_PRUNE( PARM_prune ,) IF_FEATURE_FIND_QUIT( PARM_quit ,) IF_FEATURE_FIND_DELETE( PARM_delete,) + IF_FEATURE_FIND_EMPTY( PARM_empty ,) IF_FEATURE_FIND_EXEC( PARM_exec ,) IF_FEATURE_FIND_EXECUTABLE(PARM_executable,) IF_FEATURE_FIND_PAREN( PARM_char_brace,) @@ -1034,6 +1072,7 @@ static action*** parse_params(char **argv) IF_FEATURE_FIND_PRUNE( "-prune\0" ) IF_FEATURE_FIND_QUIT( "-quit\0" ) IF_FEATURE_FIND_DELETE( "-delete\0" ) + IF_FEATURE_FIND_EMPTY( "-empty\0" ) IF_FEATURE_FIND_EXEC( "-exec\0" ) IF_FEATURE_FIND_EXECUTABLE("-executable\0") IF_FEATURE_FIND_PAREN( "(\0" ) @@ -1203,6 +1242,12 @@ static action*** parse_params(char **argv) (void) ALLOC_ACTION(delete); } #endif +#if ENABLE_FEATURE_FIND_EMPTY + else if (parm == PARM_empty) { + dbg("%d", __LINE__); + (void) ALLOC_ACTION(empty); + } +#endif #if ENABLE_FEATURE_FIND_EXEC else if (parm == PARM_exec) { int i; -- 2.17.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: find options -empty and -delete
Hi, On Tue, Sep 10, 2019 at 06:29:02PM +0200, Tim Tassonis wrote: > I just found out about a terribly convenient way to recursively delete empty > directories with find, using the options -empty and -delete > > It seems current busybox does not support these, are there any plans to add > them? Busybox already supports -delete. I have an old patch to add -empty, I'll post that. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Patches to make GNU gzip and BusyBox gzip produce identical compression results
Hi, On Tue, Sep 03, 2019 at 10:31:20AM +0800, Kang-Che Sung wrote: > gzip -9 is quite fast in modern processors, and if someone builds busybox > without CONFIG_FEATURE_GZIP_LEVELS, I think they are moke likely to stick > with -9 as default instead of -6. No, -9 is really slow with little gain: https://marc.info/?l=busybox&m=142989731614406&w=2 A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH v2] sysctl: fix compatibility with procps sysctl
From: Aaro Koskinen Busybox sysctl is incompatible with procps when '.' appears in directory name, mostly happens with VLANs. busybox syntax (since 2008): net.ipv4.conf.eth0.100.mc_forwarding procps syntax (since 2002): net.ipv4.conf.eth0/100.mc_forwarding (supported by both: net/ipv4/conf/eth0.100/mc_forwarding) Use procps syntax for output; for input, allow both. Signed-off-by: Aaro Koskinen --- v2: Drop the config option, and support the busybox-specific syntax on input. procps/sysctl.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/procps/sysctl.c b/procps/sysctl.c index 5fa7646d1..eb5ed37dc 100644 --- a/procps/sysctl.c +++ b/procps/sysctl.c @@ -57,7 +57,28 @@ enum { static void sysctl_dots_to_slashes(char *name) { char *cptr, *last_good, *end; + int n = 0; + if (!strchr(name, '/')) + goto busybox_old_syntax; + + cptr = name; + while (*cptr) { + if (*cptr == '.') { + *cptr = '/'; + n++; + } else if (*cptr == '/') { + if (!n) + return; /* slash syntax is used */ + *cptr = '.'; + } else if (*cptr == '=') { + return; + } + cptr++; + } + return; + +busybox_old_syntax: /* Convert minimum number of '.' to '/' so that * we end up with existing file's name. * @@ -112,6 +133,8 @@ static int sysctl_act_on_setting(char *setting) while (*cptr) { if (*cptr == '/') *cptr = '.'; + else if (*cptr == '.') + *cptr = '/'; cptr++; } -- 2.17.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] sysctl: fix compatibility with procps sysctl
From: Aaro Koskinen Busybox sysctl is incompatible with procps when '.' appears in directory name, mostly happens with VLANs. busybox syntax (since 2008): net.ipv4.conf.eth0.100.mc_forwarding procps syntax (since 2002): net.ipv4.conf.eth0/100.mc_forwarding (supported by both: net/ipv4/conf/eth0.100/mc_forwarding) Make procps syntax the default; for users relying on the old behaviour provide a config option for time being. Signed-off-by: Aaro Koskinen --- procps/sysctl.c | 41 + 1 file changed, 41 insertions(+) diff --git a/procps/sysctl.c b/procps/sysctl.c index 5fa7646d1..3e79e3927 100644 --- a/procps/sysctl.c +++ b/procps/sysctl.c @@ -15,6 +15,23 @@ //config: default y //config: help //config: Configure kernel parameters at runtime. +//config:config SYSCTL_OLDBUSYBOX_COMPAT +//config: bool "sysctl compatibility with older busybox versions" +//config: default n +//config: depends on BB_SYSCTL +//config: help +//config: Older busybox versions are incompatible with procps when +//config: handling VLAN interfaces. Busybox supported syntax: +//config: net.ipv4.conf.eth0.100.mc_forwarding +//config: while procps supports: +//config: net.ipv4.conf.eth0/100.mc_forwarding +//config: +//config: Choose this option only if you are upgrading from an older +//config: busybox and need to maintain compatilibity e.g. for scripts +//config: that configure VLAN interfaces using sysctl. This option may be +//config: deprecated in the future so consider migrating to the procps +//config: syntax. +//config: //applet:IF_BB_SYSCTL(APPLET_NOEXEC(sysctl, sysctl, BB_DIR_SBIN, BB_SUID_DROP, sysctl)) @@ -56,6 +73,7 @@ enum { static void sysctl_dots_to_slashes(char *name) { +#ifdef CONFIG_SYSCTL_OLDBUSYBOX_COMPAT char *cptr, *last_good, *end; /* Convert minimum number of '.' to '/' so that @@ -97,6 +115,25 @@ static void sysctl_dots_to_slashes(char *name) cptr--; } *end = '\0'; +#else /* CONFIG_SYSCTL_OLDBUSYBOX_COMPAT */ + char *cptr; + int n = 0; + + cptr = name; + while (*cptr) { + if (*cptr == '.') { + *cptr = '/'; + n++; + } else if (*cptr == '/') { + if (!n) + return; /* slash syntax is used */ + *cptr = '.'; + } else if (*cptr == '=') { + return; + } + cptr++; + } +#endif /* CONFIG_SYSCTL_OLDBUSYBOX_COMPAT */ } static int sysctl_act_on_setting(char *setting) @@ -112,6 +149,10 @@ static int sysctl_act_on_setting(char *setting) while (*cptr) { if (*cptr == '/') *cptr = '.'; +#ifndef CONFIG_SYSCTL_OLDBUSYBOX_COMPAT + else if (*cptr == '.') + *cptr = '/'; +#endif cptr++; } -- 2.17.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [RFC PATCH v2] Allow applets to be implemented as scripts
On Tue, Nov 06, 2018 at 08:36:11PM +, Ron Yorston wrote: > For the rest I suppose there are a couple of ways to look at it. The > dependencies could be specified explicitly: > >depends on ASH_EMBEDDED_SCRIPTS && (ECHO || ASH_ECHO) && CAT && SLEEP > > Though this means that scripted applets aren't very discoverable because > they'll only appear in the configuration menu if all their dependencies > are enabled first. > > Alternatively the dependencies could be selected automatically: > >select ECHO >select CAT >select SLEEP > > But in this case it wouldn't be possible to turn off sleep from the > configuration menu if nologin is enabled. And it isn't obvious why. Not sure if either of these are good. The user could have e.g. toybox or even GNU bloat to implement/replace some of the programs, but still want to use an applet script from busybox. Maybe the config help text should just list needed programs? A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [RFC PATCH v2] Allow applets to be implemented as scripts
Hi, On Tue, Nov 06, 2018 at 08:16:33AM +, Ron Yorston wrote: > Now that scripts can be embedded in the BusyBox binary it's possible > to implement applets as scripts. I think both of these are nice features! > +//config:config NOLOGIN > +//config: bool "nologin" > +//config: default y > +//config: depends on ASH_EMBEDDED_SCRIPTS > +//config: help > +//config: Politely refuse a login Should users be told they are enabling a scripted applet? E.g. in this case they should also enable some other busybox applets to make it work (like "cat")... I wonder how it's going to work in practice. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[REGRESSION] busybox less output messed up
Hi, Busybox less output gets messed up if the input is delayed. E.g. on busybox source tree: (sleep 10; ls) | ./busybox less produces the following on my Xterm: [...] ~ LICENSE ~ Makefile ~ Makefile.custom ~Makefile.flags ~ Makefile.help [...] Bisected to: commit aa5ad6a93101d38800467fe3750b35fed6ea Author: Denys Vlasenko Date: Fri Sep 15 17:14:01 2017 +0200 less,microcom,lineedit: use common routine to set raw termios A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] less: implement -F
Implement -F option: Exit if entire file fits on first screen. Signed-off-by: Aaro Koskinen --- miscutils/less.c | 20 +--- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/miscutils/less.c b/miscutils/less.c index 51ef2a59d..3bce93247 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -121,11 +121,12 @@ //kbuild:lib-$(CONFIG_LESS) += less.o //usage:#define less_trivial_usage -//usage: "[-E" IF_FEATURE_LESS_REGEXP("I")IF_FEATURE_LESS_FLAGS("Mm") +//usage: "[-EF" IF_FEATURE_LESS_REGEXP("I")IF_FEATURE_LESS_FLAGS("Mm") //usage: "N" IF_FEATURE_LESS_TRUNCATE("S") IF_FEATURE_LESS_RAW("R") "h~] [FILE]..." //usage:#define less_full_usage "\n\n" //usage: "View FILE (or stdin) one screenful at a time\n" //usage: "\n -E Quit once the end of a file is reached" +//usage: "\n -F Quit if entire file fits on first screen" //usage: IF_FEATURE_LESS_REGEXP( //usage: "\n -I Ignore case in all searches" //usage: ) @@ -175,8 +176,9 @@ enum { FLAG_N = 1 << 3, FLAG_TILDE = 1 << 4, FLAG_I = 1 << 5, - FLAG_S = (1 << 6) * ENABLE_FEATURE_LESS_TRUNCATE, - FLAG_R = (1 << 7) * ENABLE_FEATURE_LESS_RAW, + FLAG_F = 1 << 6, + FLAG_S = (1 << 7) * ENABLE_FEATURE_LESS_TRUNCATE, + FLAG_R = (1 << 8) * ENABLE_FEATURE_LESS_RAW, /* hijack command line options variable for internal state vars */ LESS_STATE_MATCH_BACKWARDS = 1 << 15, }; @@ -906,11 +908,12 @@ static void buffer_print(void) else print_ascii(buffer[i]); } - if ((option_mask32 & FLAG_E) + if ((option_mask32 & (FLAG_E|FLAG_F)) && eof_error <= 0 -&& (max_fline - cur_fline) <= max_displayed_line ) { - less_exit(EXIT_SUCCESS); + i = option_mask32 & FLAG_F ? 0 : cur_fline; + if (max_fline - i <= max_displayed_line) + less_exit(EXIT_SUCCESS); } status_print(); } @@ -1814,7 +1817,7 @@ int less_main(int argc, char **argv) * -s: condense many empty lines to one * (used by some setups for manpage display) */ - getopt32(argv, "EMmN~I" + getopt32(argv, "EMmN~IF" IF_FEATURE_LESS_TRUNCATE("S") IF_FEATURE_LESS_RAW("R") /*ignored:*/"s" @@ -1828,6 +1831,9 @@ int less_main(int argc, char **argv) if (ENABLE_FEATURE_LESS_ENV) { char *c = getenv("LESS"); if (c) while (*c) switch (*c++) { + case 'F': + option_mask32 |= FLAG_F; + break; case 'M': option_mask32 |= FLAG_M; break; -- 2.17.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[REGRESSION] busybox "make install" failure
Hi, make install fails with a minimal busybox config (see further below). Note that it shouldn'd be even trying to install the symlinks (CONFIG_INSTALL_APPLET_DONT=y)... [...] CC libbb/appletlib.o AR shell/lib.a CC libbb/lineedit.o CC libbb/vfork_daemon_rexec.o AR libbb/lib.a LINKbusybox_unstripped Trying libraries: crypt m Library crypt is not needed, excluding it Library m is not needed, excluding it Final link with: tmp//bin/login -> busybox tmp//bin/su -> busybox tmp//usr/bin/passwd -> ../../bin/busybox ln: ../../bin/busybox: No such file or directory make: *** [/home/aaro/git/devel/busybox/Makefile.custom:36: install] Error 1 Bisected this to 952d5a6024e7b2a6d5a351a8d1329bd985da3c76, and also reverting this commit helps. # # Automatically generated make config: don't edit # Busybox version: 1.29.0.git # Sat Apr 14 23:13:51 2018 # CONFIG_HAVE_DOT_CONFIG=y # # Settings # CONFIG_DESKTOP=y # CONFIG_EXTRA_COMPAT is not set # CONFIG_FEDORA_COMPAT is not set # CONFIG_INCLUDE_SUSv2 is not set # CONFIG_LONG_OPTS is not set CONFIG_SHOW_USAGE=y CONFIG_FEATURE_VERBOSE_USAGE=y # CONFIG_FEATURE_COMPRESS_USAGE is not set # CONFIG_LFS is not set # CONFIG_PAM is not set # CONFIG_FEATURE_DEVPTS is not set CONFIG_FEATURE_UTMP=y CONFIG_FEATURE_WTMP=y # CONFIG_FEATURE_PIDFILE is not set CONFIG_PID_FILE_PATH="" CONFIG_BUSYBOX=y # CONFIG_FEATURE_INSTALLER is not set # CONFIG_INSTALL_NO_USR is not set CONFIG_FEATURE_SUID=y # CONFIG_FEATURE_SUID_CONFIG is not set # CONFIG_FEATURE_SUID_CONFIG_QUIET is not set # CONFIG_FEATURE_PREFER_APPLETS is not set CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe" # CONFIG_SELINUX is not set # CONFIG_FEATURE_CLEAN_UP is not set CONFIG_FEATURE_SYSLOG=y CONFIG_PLATFORM_LINUX=y # # Build Options # # CONFIG_STATIC is not set # CONFIG_PIE is not set # CONFIG_NOMMU is not set # CONFIG_BUILD_LIBBUSYBOX is not set # CONFIG_FEATURE_LIBBUSYBOX_STATIC is not set # CONFIG_FEATURE_INDIVIDUAL is not set # CONFIG_FEATURE_SHARED_BUSYBOX is not set CONFIG_CROSS_COMPILER_PREFIX="" CONFIG_SYSROOT="" CONFIG_EXTRA_CFLAGS="" CONFIG_EXTRA_LDFLAGS="-lcrypt" CONFIG_EXTRA_LDLIBS="" # CONFIG_USE_PORTABLE_CODE is not set CONFIG_STACK_OPTIMIZATION_386=y # # Installation Options ("make install" behavior) # # CONFIG_INSTALL_APPLET_SYMLINKS is not set # CONFIG_INSTALL_APPLET_HARDLINKS is not set # CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS is not set CONFIG_INSTALL_APPLET_DONT=y # CONFIG_INSTALL_SH_APPLET_SYMLINK is not set # CONFIG_INSTALL_SH_APPLET_HARDLINK is not set # CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER is not set CONFIG_PREFIX="./_install" # # Debugging Options # # CONFIG_DEBUG is not set # CONFIG_DEBUG_PESSIMIZE is not set # CONFIG_DEBUG_SANITIZE is not set # CONFIG_UNIT_TEST is not set # CONFIG_WERROR is not set CONFIG_NO_DEBUG_LIB=y # CONFIG_DMALLOC is not set # CONFIG_EFENCE is not set # # Library Tuning # # CONFIG_FEATURE_USE_BSS_TAIL is not set # CONFIG_FEATURE_RTMINMAX is not set CONFIG_FEATURE_BUFFERS_USE_MALLOC=y # CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set # CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set CONFIG_PASSWORD_MINLEN=6 CONFIG_MD5_SMALL=1 CONFIG_SHA3_SMALL=1 # CONFIG_FEATURE_FAST_TOP is not set # CONFIG_FEATURE_ETC_NETWORKS is not set # CONFIG_FEATURE_EDITING is not set CONFIG_FEATURE_EDITING_MAX_LEN=0 # CONFIG_FEATURE_EDITING_VI is not set CONFIG_FEATURE_EDITING_HISTORY=0 # CONFIG_FEATURE_EDITING_SAVEHISTORY is not set # CONFIG_FEATURE_EDITING_SAVE_ON_EXIT is not set # CONFIG_FEATURE_REVERSE_SEARCH is not set # CONFIG_FEATURE_TAB_COMPLETION is not set # CONFIG_FEATURE_USERNAME_COMPLETION is not set # CONFIG_FEATURE_EDITING_FANCY_PROMPT is not set # CONFIG_FEATURE_EDITING_WINCH is not set # CONFIG_FEATURE_EDITING_ASK_TERMINAL is not set # CONFIG_LOCALE_SUPPORT is not set # CONFIG_UNICODE_SUPPORT is not set # CONFIG_UNICODE_USING_LOCALE is not set # CONFIG_FEATURE_CHECK_UNICODE_IN_ENV is not set CONFIG_SUBST_WCHAR=0 CONFIG_LAST_SUPPORTED_WCHAR=0 # CONFIG_UNICODE_COMBINING_WCHARS is not set # CONFIG_UNICODE_WIDE_WCHARS is not set # CONFIG_UNICODE_BIDI_SUPPORT is not set # CONFIG_UNICODE_NEUTRAL_TABLE is not set # CONFIG_UNICODE_PRESERVE_BROKEN is not set # CONFIG_FEATURE_NON_POSIX_CP is not set # CONFIG_FEATURE_VERBOSE_CP_MESSAGE is not set # CONFIG_FEATURE_USE_SENDFILE is not set CONFIG_FEATURE_COPYBUF_KB=4 # CONFIG_FEATURE_SKIP_ROOTFS is not set CONFIG_MONOTONIC_SYSCALL=y # CONFIG_IOCTL_HEX2STR_ERROR is not set # CONFIG_FEATURE_HWIB is not set # # Applets # # # Archival Utilities # # CONFIG_FEATURE_SEAMLESS_XZ is not set # CONFIG_FEATURE_SEAMLESS_LZMA is not set # CONFIG_FEATURE_SEAMLESS_BZ2 is not set # CONFIG_FEATURE_SEAMLESS_GZ is not set # CONFIG_FEATURE_SEAMLESS_Z is not set # CONFIG_AR is not set # CONFIG_FEATURE_AR_LONG_FILENAMES is not set # CONFIG_FEATURE_AR_CREATE is not set # CONFIG_UNCOMPRESS is not set # CONFIG_GUNZIP is not set # CONFIG_ZCAT is not set # CONFIG_FEATURE_GUNZIP_LONG_OPTIONS is not set # CONFIG_BUNZIP2 is not set # CO
Re: bc
Hi, On Tue, Mar 13, 2018 at 02:13:24AM +0200, Aaro Koskinen wrote: > On Mon, Mar 12, 2018 at 05:22:05PM -0600, Gavin Howard wrote: > > Over the past month or so, I have written a standalone bc. I have > > written it so it could be integrated into busybox/toybox, etc on an > > automated basis (ie, I submit a new release soon before a busybox > > release). Would you be interested? > > Where is the source? FWIW, as an user I would be happy to see "bc" applet in busybox, as it's needed to build the Linux kernel, so mandatory for any minimal self-hosting busybox-based Linux systems. Also GNU bc is not well these days, the latest release broke cross-compilation, and also added depencies to other GNU extensions/tools. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: bc
Hi, On Mon, Mar 12, 2018 at 05:22:05PM -0600, Gavin Howard wrote: > Over the past month or so, I have written a standalone bc. I have > written it so it could be integrated into busybox/toybox, etc on an > automated basis (ie, I submit a new release soon before a busybox > release). Would you be interested? Where is the source? A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] cp: implement -T
Implement "cp -T". Some Linux kernel Makefiles started using this recently, so allow also building on systems using busybox cp. Signed-off-by: Aaro Koskinen --- coreutils/cp.c | 10 -- include/libbb.h | 7 --- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/coreutils/cp.c b/coreutils/cp.c index 05c725c..e66a21b 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c @@ -48,6 +48,7 @@ //usage: "\n -f Overwrite" //usage: "\n -i Prompt before overwrite" //usage: "\n -l,-s Create (sym)links" +//usage: "\n -T Treat DEST as a normal file" //usage: "\n -u Copy only newer files" #include "libbb.h" @@ -93,6 +94,7 @@ int cp_main(int argc, char **argv) "no-dereference\0" No_argument "P" "recursive\0" No_argument "R" "symbolic-link\0" No_argument "s" + "no-target-directory\0" No_argument "T" "verbose\0"No_argument "v" "update\0" No_argument "u" "remove-destination\0" No_argument "\xff" @@ -140,8 +142,6 @@ int cp_main(int argc, char **argv) * override the usual backup suffix * -t, --target-directory=DIRECTORY * copy all SOURCE arguments into DIRECTORY -* -T, --no-target-directory -* treat DEST as a normal file * -x, --one-file-system * stay on this file system * -Z, --context=CONTEXT @@ -175,6 +175,9 @@ int cp_main(int argc, char **argv) d_flags = cp_mv_stat(last, &dest_stat); if (d_flags < 0) return EXIT_FAILURE; + else if ((flags & FILEUTILS_NO_TARGET_DIR) && !(s_flags & 2) && +(d_flags & 2)) + bb_error_msg_and_die("'%s' is a directory", last); #if ENABLE_FEATURE_CP_LONG_OPTIONS //bb_error_msg("flags:%x FILEUTILS_RMDEST:%x OPT_parents:%x", @@ -193,11 +196,14 @@ int cp_main(int argc, char **argv) if (!((s_flags | d_flags) & 2) /* ...or: recursing, the 1st is a directory, and the 2nd doesn't exist... */ || ((flags & FILEUTILS_RECUR) && (s_flags & 2) && !d_flags) +|| (flags & FILEUTILS_NO_TARGET_DIR) ) { /* Do a simple copy */ dest = last; goto DO_COPY; /* NB: argc==2 -> *++argv==last */ } + } else if (flags & FILEUTILS_NO_TARGET_DIR) { + bb_error_msg_and_die("too many arguments"); } while (1) { diff --git a/include/libbb.h b/include/libbb.h index 5f25b5d..a938640 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -404,10 +404,11 @@ enum {/* cp.c, mv.c, install.c depend on these values. CAREFUL when changing th /* -P = -d (mapped in cp.c) */ FILEUTILS_VERBOSE = (1 << 12) * ENABLE_FEATURE_VERBOSE, /* -v */ FILEUTILS_UPDATE = 1 << 13, /* -u */ + FILEUTILS_NO_TARGET_DIR = 1 << 14, /* -T */ #if ENABLE_SELINUX - FILEUTILS_PRESERVE_SECURITY_CONTEXT = 1 << 14, /* -c */ + FILEUTILS_PRESERVE_SECURITY_CONTEXT = 1 << 15, /* -c */ #endif - FILEUTILS_RMDEST = 1 << (15 - !ENABLE_SELINUX), /* --remove-destination */ + FILEUTILS_RMDEST = 1 << (16 - !ENABLE_SELINUX), /* --remove-destination */ /* * Hole. cp may have some bits set here, * they should not affect remove_file()/copy_file() @@ -417,7 +418,7 @@ enum { /* cp.c, mv.c, install.c depend on these values. CAREFUL when changing th #endif FILEUTILS_IGNORE_CHMOD_ERR = 1 << 31, }; -#define FILEUTILS_CP_OPTSTR "pdRfilsLHarPvu" IF_SELINUX("c") +#define FILEUTILS_CP_OPTSTR "pdRfilsLHarPvuT" IF_SELINUX("c") extern int remove_file(const char *path, int flags) FAST_FUNC; /* NB: without FILEUTILS_RECUR in flags, it will basically "cat" * the source, not copy (unless "source" is a directory). -- 2.9.2 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 1/2] patch: fix debug log failure
If we reach the end of plist it means the input has still data while we are expecting EOF. Fix the log to avoid a crash. Signed-off-by: Aaro Koskinen --- editors/patch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editors/patch.c b/editors/patch.c index 988021d..4ee9339 100644 --- a/editors/patch.c +++ b/editors/patch.c @@ -295,7 +295,7 @@ static int apply_one_hunk(void) // recheck remaining buffered data for a new match. if (PATCH_DEBUG) - fdprintf(2, "NOT: %s\n", plist->data); + fdprintf(2, "NOT: %s\n", plist ? plist->data : "EOF"); TT.state = 3; check = buf; -- 2.9.2 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 2/2] patch: fix matching failure
Fix matching failure when plist is advanced while checking for buffered lines - the lines in the hunk that are about to be added should be skipped when checking for matching context. Also add a valid test case that fails with current busybox and is fixed by the change. Signed-off-by: Aaro Koskinen --- editors/patch.c | 11 +++ testsuite/patch.tests | 45 + 2 files changed, 56 insertions(+) diff --git a/editors/patch.c b/editors/patch.c index 4ee9339..ea1fc09 100644 --- a/editors/patch.c +++ b/editors/patch.c @@ -290,6 +290,17 @@ static int apply_one_hunk(void) // out of buffer. for (;;) { + while (plist && *plist->data == "+-"[reverse]) { + if (!strcmp(check->data, plist->data+1) && + !backwarn) { + backwarn = TT.linenum; + if (option_mask32 & FLAG_IGNORE) { + dummy_revert = 1; + reverse ^= 1; + } + } + plist = plist->next; + } if (!plist || strcmp(check->data, plist->data+1)) { // Match failed. Write out first line of buffered data and // recheck remaining buffered data for a new match. diff --git a/testsuite/patch.tests b/testsuite/patch.tests index 2759d2a..3920524 100755 --- a/testsuite/patch.tests +++ b/testsuite/patch.tests @@ -242,6 +242,51 @@ patch: can't open 'dir2///file': No such file or directory zxc " +testing "patch internal buffering bug?" \ + 'patch -p1 2>&1; echo $?; cat input' \ +"\ +patching file input +0 +foo + + + + + + +1 +2 +3 + +bar +" \ +"\ +foo + + + + + + + +bar +" \ +"\ +--- a/input.orig b/input +@@ -5,5 +5,8 @@ foo + + + ++1 ++2 ++3 + + bar +-- +2.9.2 +" \ + rm input.orig 2>/dev/null exit $FAILCOUNT -- 2.9.2 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH 2/2] cpio: add missing initialization for cpio__owner
Hi, On Fri, Nov 04, 2016 at 10:34:46PM +0100, Denys Vlasenko wrote: > This seems to be fixed already? > > commit 85100a7067a51c5e6720c0a738317cc2144ab219 > Author: Denys Vlasenko > Date: Wed Oct 12 20:56:46 2016 +0200 Yeah, sorry, I had forgotten to refresh the master branch. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 1/2] cpio: add ownership (-R) test cases
Add ownership (-R) test cases. Signed-off-by: Aaro Koskinen --- testsuite/cpio.tests | 24 1 file changed, 24 insertions(+) diff --git a/testsuite/cpio.tests b/testsuite/cpio.tests index 4cd441a..d44c95b 100755 --- a/testsuite/cpio.tests +++ b/testsuite/cpio.tests @@ -127,6 +127,30 @@ testing "cpio extracts in existing directory" \ " "" "" SKIP= +testing "cpio uses by default uid/gid" \ +"echo $0 | cpio -o -H newc | cpio -tv 2>&1 | tail -n +2 | awk ' { print \$2 } '; echo \$?" \ +"\ +$user/$group +0 +" "" "" +SKIP= + +testing "cpio -R with create" \ +"echo $0 | cpio -o -H newc -R 1234:5678 | cpio -tv 2>&1 | tail -n +2 | awk ' { print \$2 } '; echo \$?" \ +"\ +1234/5678 +0 +" "" "" +SKIP= + +testing "cpio -R with extract" \ +"echo $0 | cpio -o -H newc | cpio -tv -R 8765:4321 2>&1 | tail -n +2 | awk ' { print \$2 } '; echo \$?" \ +"\ +8765/4321 +0 +" "" "" +SKIP= + # Clean up rm -rf cpio.testdir cpio.testdir2 2>/dev/null -- 2.9.2 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 2/2] cpio: add missing initialization for cpio__owner
From: Marc Smith Add missing initialization for cpio__owner. Otherwise all files are owned by root. The patch fixes the failing test cases added in the previous patch. Signed-off-by: Aaro Koskinen --- archival/cpio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/archival/cpio.c b/archival/cpio.c index 540218c..34830a7 100644 --- a/archival/cpio.c +++ b/archival/cpio.c @@ -383,6 +383,8 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) archive_handle = init_handle(); /* archive_handle->src_fd = STDIN_FILENO; - done by init_handle */ archive_handle->ah_flags = ARCHIVE_EXTRACT_NEWER; + archive_handle->cpio__owner.uid = -1L; + archive_handle->cpio__owner.gid = -1L; /* As of now we do not enforce this: */ /* -i,-t,-o,-p are mutually exclusive */ -- 2.9.2 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Busybox ash regression
Hi, On Sun, Oct 02, 2016 at 01:27:41AM +0200, Denys Vlasenko wrote: > On Sat, Oct 1, 2016 at 11:18 PM, Aaro Koskinen wrote: > > > > Fails like this (globbing error?): > > > > fgrep: /home/aaro/los/work/pkg/foo/*/stamp.os: No such file or directory > > Can you narrow it down further? Globbing does not work for directories. Try in busybox source tree: $ make $ ./busybox ash $ ls */Kbuild ls: */Kbuild: No such file or directory A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Busybox ash regression
Hi, Current git HEAD (3ed7e2749a3f9fd315d8f46a3b0a25ff10caf726) seems to break GLIBC build when /bin/sh is busybox ash. Steps to reproduce: tar xf glibc-2.24.tar.xz mkdir foo cd foo ../glibc-2.24/configure --prefix=/usr make -j12 Fails like this (globbing error?): [...] LC_ALL=C \ sed -n 's@^/home/aaro/los/work/pkg/foo/\([^(]*\)(\([^)]*\.os\)) *.*$@\1 \2@p' \ /home/aaro/los/work/pkg/foo/elf/librtld.map | \ while read lib file; do \ case $lib in \ libc_pic.a) \ LC_ALL=C fgrep -l /$file \ /home/aaro/los/work/pkg/foo/stamp.os /home/aaro/los/work/pkg/foo/*/sta mp.os | \ LC_ALL=C \ sed 's@^/home/aaro/los/work/pkg/foo/\([^/]*\)/stamp\.os$@rtld-\1'" +=$file@" \ ;; \ */*.a) \ echo rtld-${lib%%/*} += $file ;; \ *) echo "Wasn't expecting $lib($file)" >&2; exit 1 ;; \ esac; \ done > /home/aaro/los/work/pkg/foo/elf/librtld.mkT fgrep: /home/aaro/los/work/pkg/foo/*/stamp.os: No such file or directory fgrep: /home/aaro/los/work/pkg/foo/*/stamp.os: No such file or directory fgrep: /home/aaro/los/work/pkg/foo/*/stamp.os: No such file or directory fgrep: /home/aaro/los/work/pkg/foo/*/stamp.os: No such file or directory fgrep: /home/aaro/los/work/pkg/foo/*/stamp.os: No such file or directory fgrep: /home/aaro/los/work/pkg/foo/*/stamp.os: No such file or directory [...] fgrep: /home/aaro/los/work/pkg/foo/*/stamp.os: No such file or directory fgrep: /home/aaro/los/work/pkg/foo/*/stamp.os: No such file or directory fgrep: /home/aaro/los/work/pkg/foo/*/stamp.os: No such file or directory fgrep: /home/aaro/los/work/pkg/foo/*/stamp.os: No such file or directory fgrep: /home/aaro/los/work/pkg/foo/*/stamp.os: No such file or directory fgrep: /home/aaro/los/work/pkg/foo/*/stamp.os: No such file or directory echo rtld-subdirs = `LC_ALL=C sed 's/^rtld-\([^ ]*\).*$/\1/' /home/aaro/los/work/pkg/foo/elf/librtld.mkT \ | LC_ALL=C sort -u` >> /home/aaro/los/work/pkg/foo/elf/librtld.mkT mv -f /home/aaro/los/work/pkg/foo/elf/librtld.mkT /home/aaro/los/work/pkg/foo/elf/librtld.mk make -f /home/aaro/los/work/pkg/foo/elf/librtld.mk -f rtld-Rules make[3]: Entering directory '/home/aaro/los/work/pkg/glibc-2.24/elf' rtld-Rules:40: *** missing separator. Stop. make[3]: Leaving directory '/home/aaro/los/work/pkg/glibc-2.24/elf' Makefile:376: recipe for target '/home/aaro/los/work/pkg/foo/elf/rtld-libc.a' failed make[2]: *** [/home/aaro/los/work/pkg/foo/elf/rtld-libc.a] Error 2 make[2]: *** Waiting for unfinished jobs make[2]: Leaving directory '/home/aaro/los/work/pkg/glibc-2.24/elf' Makefile:214: recipe for target 'elf/subdir_lib' failed make[1]: *** [elf/subdir_lib] Error 2 make[1]: Leaving directory '/home/aaro/los/work/pkg/glibc-2.24' Makefile:9: recipe for target 'all' failed make: *** [all] Error 2 A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Busybox git build broken
Hi, The following commit: commit 607f2b404e992174d7c5956d11e8f35f78d2701f Author: Denys Vlasenko Date: Tue Aug 23 16:13:33 2016 +0200 fdisk: print much less cryptic partition table broke the fdisk build with CONFIG_FEATURE_SUN_LABEL=y: CC util-linux/fdisk.o In file included from util-linux/fdisk.c:698:0: util-linux/fdisk_sun.c: In function 'sun_list_table': util-linux/fdisk_sun.c:661:5: warning: implicit declaration of function 'partname' [-Wimplicit-function-declaration] partname(disk_device, i+1, w), /* device */ ^~~~ util-linux/fdisk.c: At top level: util-linux/fdisk.c:2061:1: error: conflicting types for 'partname' partname(const char *dev, int pno, int lth) ^~~~ In file included from util-linux/fdisk.c:698:0: util-linux/fdisk_sun.c:661:5: note: previous implicit declaration of 'partname' was here partname(disk_device, i+1, w), /* device */ ^~~~ scripts/Makefile.build:197: recipe for target 'util-linux/fdisk.o' failed make[1]: *** [util-linux/fdisk.o] Error 1 Makefile:742: recipe for target 'util-linux' failed make: *** [util-linux] Error 2 A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH 1/2] Allow BusyBox to be built without a list of applet names
Hi, On Sat, Apr 30, 2016 at 08:58:46AM -0400, Jody Lee Bruchon wrote: > On April 30, 2016 8:39:24 AM EDT, Andreas Oberritter > wrote: > >Even worse, consider a busybox binary that someone expects to contain a > >real command like cat or hexdump, which it doesn't. The colliding hash > >of this command could map to a command that accepts the same > >command-line arguments but destroys data, like mkfs.* or rm. > > > >Still even worse, without the list of applet names included in the > >binary, you can't make sure that the applet you're calling actually > >exists without dissecting the binary. > > > >Btw., invalid symlinks of e.g. previous installations of busybox might > >exist in the filesystem. I've seen that in real products. And I've also > >seen scripts call "busybox $cmd" directly many times before. > > This problem can be avoided at compile time by hashing all possible > applet names in BusyBox and checking for collisions. You would need to check all possible future applet names as well... A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH 1/2] Allow BusyBox to be built without a list of applet names
Hi, On Fri, Apr 29, 2016 at 12:05:24PM -0700, ..mg.. wrote: > The lookup hash isn't collision-free: more than one input string > points to the same applet. Normally invalid applet names might > cause an unexpected one to run Highly insecure, no? A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] less: open new tty fd in non-blocking mode
Open new tty fd in non-blocking mode, instead of first opening it and then changing to non-blocking. This will avoid the issue with serial console login, where less seems to block forever waiting for carrier change when re-opening the serial console. Signed-off-by: Aaro Koskinen --- miscutils/less.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/miscutils/less.c b/miscutils/less.c index c003b8d..2c56eb3 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -1790,18 +1790,17 @@ int less_main(int argc, char **argv) */ tty_name = xmalloc_ttyname(STDOUT_FILENO); if (tty_name) { - tty_fd = open(tty_name, O_RDONLY); + tty_fd = open(tty_name, O_RDONLY | O_NONBLOCK); free(tty_name); if (tty_fd < 0) goto try_ctty; } else { /* Try controlling tty */ try_ctty: - tty_fd = open(CURRENT_TTY, O_RDONLY); + tty_fd = open(CURRENT_TTY, O_RDONLY | O_NONBLOCK); if (tty_fd < 0) return bb_cat(argv); } - ndelay_on(tty_fd); kbd_fd = tty_fd; /* save in a global */ tcgetattr(kbd_fd, &term_orig); -- 2.7.2 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[BISECTED] busybox modprobe regression
Hi, modprobes are failing for me (with some kernel modules reporting -2) with current busybox, and I bisected this to: commit 3a5cc989025eefe03fda0552b253a4a8f015a761 Author: Mike Frysinger Date: Fri Feb 12 23:26:51 2016 -0500 modprobe: only parse files that end in .conf This matches behavior with kmod which has been the standard for a long time at this point. URL: https://bugs.busybox.net/8021 Reported-by: Jö Signed-off-by: Mike Frysinger Reverting this patch fixes an issue when modprobing g_ether on OMAP1: g_ether omap_udc: failed to start g_ether: -2 Unfortunately I cannot debug this further at the moment (I cannot login to the system without g_ether!), but I suspect the issue is that the patch seems to also make read_config("modules.symbols") and read_config("modules.alias") to fail which are needed to properly handle dependencies... A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH v3] nandwrite: implement -n (read/write without ecc)
Implement -n (read/write without ecc). Signed-off-by: Aaro Koskinen --- v3: Use xioctl() instead of open coding it. v2: http://marc.info/?t=14476328081&r=1&w=2 The first version was bogus, opt bits were messed up. v1: http://marc.info/?l=busybox&m=144763034328791&w=2 miscutils/nandwrite.c | 22 ++ 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c index 247fc72..c95cbb2 100644 --- a/miscutils/nandwrite.c +++ b/miscutils/nandwrite.c @@ -29,16 +29,18 @@ //kbuild:lib-$(CONFIG_NANDDUMP) += nandwrite.o //usage:#define nandwrite_trivial_usage -//usage: "[-p] [-s ADDR] MTD_DEVICE [FILE]" +//usage: "[-np] [-s ADDR] MTD_DEVICE [FILE]" //usage:#define nandwrite_full_usage "\n\n" //usage: "Write to MTD_DEVICE\n" +//usage: "\n -n Write without ecc" //usage: "\n -p Pad to page size" //usage: "\n -s ADDR Start address" //usage:#define nanddump_trivial_usage -//usage: "[-o]" IF_LONG_OPTS(" [--bb=padbad|skipbad]") " [-s ADDR] [-l LEN] [-f FILE] MTD_DEVICE" +//usage: "[-no]" IF_LONG_OPTS(" [--bb=padbad|skipbad]") " [-s ADDR] [-l LEN] [-f FILE] MTD_DEVICE" //usage:#define nanddump_full_usage "\n\n" //usage: "Dump MTD_DEVICE\n" +//usage: "\n -n Read without ecc" //usage: "\n -o Dump oob data" //usage: "\n -s ADDR Start address" //usage: "\n -l LEN Length" @@ -57,10 +59,11 @@ #define OPT_p (1 << 0) /* nandwrite only */ #define OPT_o (1 << 0) /* nanddump only */ -#define OPT_s (1 << 1) -#define OPT_f (1 << 2) -#define OPT_l (1 << 3) -#define OPT_bb (1 << 4) /* must be the last one in the list */ +#define OPT_n (1 << 1) +#define OPT_s (1 << 2) +#define OPT_f (1 << 3) +#define OPT_l (1 << 4) +#define OPT_bb (1 << 5) /* must be the last one in the list */ #define BB_PADBAD (1 << 0) #define BB_SKIPBAD (1 << 1) @@ -125,10 +128,10 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv) applet_long_options = "bb\0" Required_argument "\xff"; /* no short equivalent */ #endif - opts = getopt32(argv, "os:f:l:", &opt_s, &opt_f, &opt_l, &opt_bb); + opts = getopt32(argv, "ons:f:l:", &opt_s, &opt_f, &opt_l, &opt_bb); } else { /* nandwrite */ opt_complementary = "-1:?2"; - opts = getopt32(argv, "ps:", &opt_s); + opts = getopt32(argv, "pns:", &opt_s); } argv += optind; @@ -144,6 +147,9 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv) fd = xopen(argv[0], IS_NANDWRITE ? O_RDWR : O_RDONLY); xioctl(fd, MEMGETINFO, &meminfo); + if (opts & OPT_n) + xioctl(fd, MTDFILEMODE, (void *)MTD_FILE_MODE_RAW); + mtdoffset = xstrtou(opt_s, 0); if (IS_NANDDUMP && (opts & OPT_l)) { unsigned length = xstrtou(opt_l, 0); -- 2.4.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] blkdiscard: new applet
Hi, On Fri, Nov 27, 2015 at 10:09:47PM +0200, Ari Sundholm wrote: > + if (!S_ISBLK(st.st_mode)) > + bb_error_msg_and_die("%s is not a block device!", argv[optind]); $ git grep -A1 '!S_ISBLK' | grep bb_error_msg util-linux/fdformat.c- bb_error_msg_and_die("%s: not a block device", *argv); util-linux/mkfs_ext2.c- bb_error_msg_and_die("%s: not a block device", argv[0]); util-linux/mkfs_reiser.c- bb_error_msg_and_die("%s: not a block device", argv[0]); A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH v2] nandwrite: implement -n (read/write without ecc)
Hi, On Mon, Nov 16, 2015 at 06:20:51AM +0200, Baruch Siach wrote: > On Mon, Nov 16, 2015 at 02:10:53AM +0200, Aaro Koskinen wrote: > > @@ -144,6 +147,9 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv) > > fd = xopen(argv[0], IS_NANDWRITE ? O_RDWR : O_RDONLY); > > xioctl(fd, MEMGETINFO, &meminfo); > > > > + if ((opts & OPT_n) && ioctl(fd, MTDFILEMODE, MTD_FILE_MODE_RAW)) > > + bb_simple_perror_msg_and_die("MTDFILEMODE"); > > Why not just use xioctl instead of open coding it? xioctl() takes pointer argument. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH v2] nandwrite: implement -n (read/write without ecc)
Implement -n (read/write without ecc). Signed-off-by: Aaro Koskinen --- v2: The first version was bogus, opt bits were messed up. miscutils/nandwrite.c | 22 ++ 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c index 247fc72..c69f6cf 100644 --- a/miscutils/nandwrite.c +++ b/miscutils/nandwrite.c @@ -29,16 +29,18 @@ //kbuild:lib-$(CONFIG_NANDDUMP) += nandwrite.o //usage:#define nandwrite_trivial_usage -//usage: "[-p] [-s ADDR] MTD_DEVICE [FILE]" +//usage: "[-np] [-s ADDR] MTD_DEVICE [FILE]" //usage:#define nandwrite_full_usage "\n\n" //usage: "Write to MTD_DEVICE\n" +//usage: "\n -n Write without ecc" //usage: "\n -p Pad to page size" //usage: "\n -s ADDR Start address" //usage:#define nanddump_trivial_usage -//usage: "[-o]" IF_LONG_OPTS(" [--bb=padbad|skipbad]") " [-s ADDR] [-l LEN] [-f FILE] MTD_DEVICE" +//usage: "[-no]" IF_LONG_OPTS(" [--bb=padbad|skipbad]") " [-s ADDR] [-l LEN] [-f FILE] MTD_DEVICE" //usage:#define nanddump_full_usage "\n\n" //usage: "Dump MTD_DEVICE\n" +//usage: "\n -n Read without ecc" //usage: "\n -o Dump oob data" //usage: "\n -s ADDR Start address" //usage: "\n -l LEN Length" @@ -57,10 +59,11 @@ #define OPT_p (1 << 0) /* nandwrite only */ #define OPT_o (1 << 0) /* nanddump only */ -#define OPT_s (1 << 1) -#define OPT_f (1 << 2) -#define OPT_l (1 << 3) -#define OPT_bb (1 << 4) /* must be the last one in the list */ +#define OPT_n (1 << 1) +#define OPT_s (1 << 2) +#define OPT_f (1 << 3) +#define OPT_l (1 << 4) +#define OPT_bb (1 << 5) /* must be the last one in the list */ #define BB_PADBAD (1 << 0) #define BB_SKIPBAD (1 << 1) @@ -125,10 +128,10 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv) applet_long_options = "bb\0" Required_argument "\xff"; /* no short equivalent */ #endif - opts = getopt32(argv, "os:f:l:", &opt_s, &opt_f, &opt_l, &opt_bb); + opts = getopt32(argv, "ons:f:l:", &opt_s, &opt_f, &opt_l, &opt_bb); } else { /* nandwrite */ opt_complementary = "-1:?2"; - opts = getopt32(argv, "ps:", &opt_s); + opts = getopt32(argv, "pns:", &opt_s); } argv += optind; @@ -144,6 +147,9 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv) fd = xopen(argv[0], IS_NANDWRITE ? O_RDWR : O_RDONLY); xioctl(fd, MEMGETINFO, &meminfo); + if ((opts & OPT_n) && ioctl(fd, MTDFILEMODE, MTD_FILE_MODE_RAW)) + bb_simple_perror_msg_and_die("MTDFILEMODE"); + mtdoffset = xstrtou(opt_s, 0); if (IS_NANDDUMP && (opts & OPT_l)) { unsigned length = xstrtou(opt_l, 0); -- 2.4.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] nandwrite: implement -n (read/write without ecc)
Implement -n (read/write without ecc). Signed-off-by: Aaro Koskinen --- miscutils/nandwrite.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c index 247fc72..ec0b5b0 100644 --- a/miscutils/nandwrite.c +++ b/miscutils/nandwrite.c @@ -29,16 +29,18 @@ //kbuild:lib-$(CONFIG_NANDDUMP) += nandwrite.o //usage:#define nandwrite_trivial_usage -//usage: "[-p] [-s ADDR] MTD_DEVICE [FILE]" +//usage: "[-np] [-s ADDR] MTD_DEVICE [FILE]" //usage:#define nandwrite_full_usage "\n\n" //usage: "Write to MTD_DEVICE\n" +//usage: "\n -n Write without ecc" //usage: "\n -p Pad to page size" //usage: "\n -s ADDR Start address" //usage:#define nanddump_trivial_usage -//usage: "[-o]" IF_LONG_OPTS(" [--bb=padbad|skipbad]") " [-s ADDR] [-l LEN] [-f FILE] MTD_DEVICE" +//usage: "[-no]" IF_LONG_OPTS(" [--bb=padbad|skipbad]") " [-s ADDR] [-l LEN] [-f FILE] MTD_DEVICE" //usage:#define nanddump_full_usage "\n\n" //usage: "Dump MTD_DEVICE\n" +//usage: "\n -n Read without ecc" //usage: "\n -o Dump oob data" //usage: "\n -s ADDR Start address" //usage: "\n -l LEN Length" @@ -60,7 +62,8 @@ #define OPT_s (1 << 1) #define OPT_f (1 << 2) #define OPT_l (1 << 3) -#define OPT_bb (1 << 4) /* must be the last one in the list */ +#define OPT_n (1 << 4) +#define OPT_bb (1 << 5) /* must be the last one in the list */ #define BB_PADBAD (1 << 0) #define BB_SKIPBAD (1 << 1) @@ -125,10 +128,10 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv) applet_long_options = "bb\0" Required_argument "\xff"; /* no short equivalent */ #endif - opts = getopt32(argv, "os:f:l:", &opt_s, &opt_f, &opt_l, &opt_bb); + opts = getopt32(argv, "os:f:l:n", &opt_s, &opt_f, &opt_l, &opt_bb); } else { /* nandwrite */ opt_complementary = "-1:?2"; - opts = getopt32(argv, "ps:", &opt_s); + opts = getopt32(argv, "ps:n", &opt_s); } argv += optind; @@ -144,6 +147,9 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv) fd = xopen(argv[0], IS_NANDWRITE ? O_RDWR : O_RDONLY); xioctl(fd, MEMGETINFO, &meminfo); + if ((opts & OPT_n) && ioctl(fd, MTDFILEMODE, MTD_FILE_MODE_RAW)) + bb_simple_perror_msg_and_die("MTDFILEMODE"); + mtdoffset = xstrtou(opt_s, 0); if (IS_NANDDUMP && (opts & OPT_l)) { unsigned length = xstrtou(opt_l, 0); -- 2.4.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Busybox tar/gunzip regression
Hi, The below commit broke untarring .gz archives: $ tar xf memtester-4.3.0.tar.gz tar: short read commit 1de25a6e87e0e627aa34298105a3d17c60a1f44e Author: Denys Vlasenko Date: Mon Oct 26 19:33:05 2015 +0100 unzip: test for bad archive SEGVing A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 2/2] gzip: add support for --no-name long option
Add support for --no-name long option. Just silently ignore it like the short -n option. This allows to use busybox gzip with Lynx browser. Signed-off-by: Aaro Koskinen --- archival/bbunzip.c | 1 + archival/gzip.c| 1 + 2 files changed, 2 insertions(+) diff --git a/archival/bbunzip.c b/archival/bbunzip.c index e10372e..b4f754e 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c @@ -335,6 +335,7 @@ static const char gunzip_longopts[] ALIGN1 = "to-stdout\0" No_argument "c" "force\0" No_argument "f" "test\0"No_argument "t" + "no-name\0" No_argument "n" ; #endif diff --git a/archival/gzip.c b/archival/gzip.c index c917130..f9bb3c7 100644 --- a/archival/gzip.c +++ b/archival/gzip.c @@ -2160,6 +2160,7 @@ static const char gzip_longopts[] ALIGN1 = "quiet\0" No_argument "q" "fast\0"No_argument "1" "best\0"No_argument "9" + "no-name\0" No_argument "n" ; #endif -- 2.4.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 1/2] gunzip: add support for long options
Add support for long options. Signed-off-by: Aaro Koskinen --- archival/bbunzip.c | 20 1 file changed, 20 insertions(+) diff --git a/archival/bbunzip.c b/archival/bbunzip.c index 548882f..e10372e 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c @@ -290,6 +290,13 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv) //config:gunzip is used to decompress archives created by gzip. //config:You can use the `-t' option to test the integrity of //config:an archive, without decompressing it. +//config: +//config:config FEATURE_GUNZIP_LONG_OPTIONS +//config: bool "Enable long options" +//config: default y +//config: depends on GUNZIP && LONG_OPTS +//config: help +//config:Enable use of long options. //applet:IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP)) //applet:IF_GUNZIP(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat)) @@ -321,6 +328,16 @@ char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UN } return filename; } + +#if ENABLE_FEATURE_GUNZIP_LONG_OPTIONS +static const char gunzip_longopts[] ALIGN1 = + "stdout\0" No_argument "c" + "to-stdout\0" No_argument "c" + "force\0" No_argument "f" + "test\0"No_argument "t" + ; +#endif + /* * Linux kernel build uses gzip -d -n. We accept and ignore it. * Man page says: @@ -337,6 +354,9 @@ char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UN int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int gunzip_main(int argc UNUSED_PARAM, char **argv) { +#if ENABLE_FEATURE_GUNZIP_LONG_OPTIONS + applet_long_options = gunzip_longopts; +#endif getopt32(argv, "cfvqdtn"); argv += optind; -- 2.4.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] xargs: make -I imply -r
Make -I imply -r (GNU findutils seems to do the same). Fixes the following bug: $ echo -n | xargs -I% echo % Segmentation fault Signed-off-by: Aaro Koskinen --- findutils/xargs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/findutils/xargs.c b/findutils/xargs.c index 5870b8a..e22e986 100644 --- a/findutils/xargs.c +++ b/findutils/xargs.c @@ -577,6 +577,7 @@ int xargs_main(int argc, char **argv) G.argv = argv; argc = 0; read_args = process_stdin_with_replace; + opt |= OPT_NO_EMPTY; } else #endif { -- 2.4.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[BISECTED] Busybox sort regression
Hi, Current busybox git breaks glibc builds because of "sort" regression. Bisected to: commit 8aa7cf305ba5133721aa9852b398cbf1867fc857 Author: Denys Vlasenko Date: Sat Sep 19 22:06:40 2015 +0200 sort: fix -kN,M handling (was including last separator into the comparison) This breaks scripts/versionlist.awk in the glibc source tree (it calls external "sort" program). Simplified reproducer: Try the below input: ->8- GLIBC_2.1 GLIBC_2.1.1 GLIBC_2.2 GLIBC_2.2.1 GLIBC_2.10 GLIBC_2.20 GLIBC_2.21 ->8- with "sort -u -t. -k 1,1 -k 2n,2n -k 3". Output with old busybox: same as input Output with current (broken) busybox: ->8- GLIBC_2.1 GLIBC_2.10 GLIBC_2.1.1 GLIBC_2.20 GLIBC_2.2.1 ->8- A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] cpio: implement -R/--owner
Implement -R/--owner to force ownership of files. function old new delta cpio_main501 556 +55 usage_messages 40468 40504 +36 get_header_cpio 910 943 +33 cpio_o 814 844 +30 -- (add/remove: 0/0 grow/shrink: 4/0 up/down: 154/0) Total: 154 bytes Signed-off-by: Aaro Koskinen --- archival/cpio.c | 40 ++- archival/libarchive/get_header_cpio.c | 6 ++ include/bb_archive.h | 1 + 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/archival/cpio.c b/archival/cpio.c index cdc16c1..05a20c7 100644 --- a/archival/cpio.c +++ b/archival/cpio.c @@ -71,6 +71,7 @@ //usage: "\n -v Verbose" //usage: "\n -u Overwrite" //usage: "\n -F FILE Input (-t,-i,-p) or output (-o) file" +//usage: "\n -R UGID Set owner of created files" //usage: IF_FEATURE_CPIO_O( //usage: "\n -H newc Archive format" //usage: ) @@ -150,7 +151,8 @@ enum { OPT_PRESERVE_MTIME = (1 << 6), OPT_DEREF = (1 << 7), OPT_FILE = (1 << 8), - OPTBIT_FILE = 8, + OPT_OWNER = (1 << 9), + OPTBIT_OWNER = 9, IF_FEATURE_CPIO_O(OPTBIT_CREATE ,) IF_FEATURE_CPIO_O(OPTBIT_FORMAT ,) IF_FEATURE_CPIO_P(OPTBIT_PASSTHROUGH,) @@ -163,7 +165,20 @@ enum { OPT_2STDOUT= IF_LONG_OPTS( (1 << OPTBIT_2STDOUT)) + 0, }; -#define OPTION_STR "it0uvdmLF:" +#define OPTION_STR "it0uvdmLF:R:" + +struct globals { + struct bb_uidgid_t owner_ugid; +} FIX_ALIASING; +#define G (*(struct globals*)&bb_common_bufsiz1) +#define owner_ugid (G.owner_ugid) +void BUG_cpio_globals_too_big(void); +#define INIT_G() do { \ + if (sizeof(G) > COMMON_BUFSIZE) \ + BUG_cpio_globals_too_big(); \ + owner_ugid.uid = -1L; \ + owner_ugid.gid = -1L; \ +} while (0) #if ENABLE_FEATURE_CPIO_O static off_t cpio_pad4(off_t size) @@ -223,6 +238,11 @@ static NOINLINE int cpio_o(void) bb_simple_perror_msg_and_die(name); } + if (owner_ugid.uid != (uid_t)-1L) + st.st_uid = owner_ugid.uid; + if (owner_ugid.gid != (gid_t)-1L) + st.st_gid = owner_ugid.gid; + if (!(S_ISLNK(st.st_mode) || S_ISREG(st.st_mode))) st.st_size = 0; /* paranoia */ @@ -339,6 +359,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) { archive_handle_t *archive_handle; char *cpio_filename; + char *cpio_owner; IF_FEATURE_CPIO_O(const char *cpio_fmt = "";) unsigned opt; @@ -353,12 +374,14 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) "pass-through\0" No_argument "p" #endif #endif + "owner\0"Required_argument "R" "verbose\0" No_argument "v" "quiet\0"No_argument "\xff" "to-stdout\0"No_argument "\xfe" ; #endif + INIT_G(); archive_handle = init_handle(); /* archive_handle->src_fd = STDIN_FILENO; - done by init_handle */ archive_handle->ah_flags = ARCHIVE_EXTRACT_NEWER; @@ -369,14 +392,21 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) /* -L makes sense only with -o or -p */ #if !ENABLE_FEATURE_CPIO_O - opt = getopt32(argv, OPTION_STR, &cpio_filename); + opt = getopt32(argv, OPTION_STR, &cpio_filename, &cpio_owner); +#else + opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), + &cpio_filename, &cpio_owner, &cpio_fmt); +#endif argv += optind; + if (opt & OPT_OWNER) { + parse_chown_usergroup_or_die(&owner_ugid, cpio_owner); + archive_handle->cpio__owner = &owner_ugid; + } +#if !ENABLE_FEATURE_CPIO_O if (opt & OPT_FILE) { /* -F */ xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO); } #else - opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), &cpio_filename, &cpio_fmt); - argv += optind; if ((opt & (OPT_FILE|OPT_CREATE)) == OPT_FILE) { /* -F without -o */
[BISECTED] busybox ash regression
Hi, The following commit: commit 549deab5abd59c1ab752754170f69aa2248e72c9 Author: Ron Yorston Date: Mon May 18 09:57:51 2015 +0200 ash: move parse-time quote flag detection to run-time introduced the following change of behaviour: Commands: mkdir foo cd foo touch a b echo "./"* Old output: ./a ./b Current (incorrect): ./* A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 2/2] diff.tests: add testcases for -B and single line changes
Add testcases for -B and single line changes. Signed-off-by: Aaro Koskinen --- testsuite/diff.tests | 12 1 file changed, 12 insertions(+) diff --git a/testsuite/diff.tests b/testsuite/diff.tests index 84d8538..0ced0f2 100755 --- a/testsuite/diff.tests +++ b/testsuite/diff.tests @@ -98,6 +98,18 @@ testing "diff -B does not ignore changes whose lines are not all blank" \ "a\n" \ "\nb\n\n" +testing "diff -B ignores blank single line change" \ + 'diff -qB - input; echo $?' \ + "0\n" \ + "\n1\n" \ + "1\n" + +testing "diff -B does not ignore non-blank single line change" \ + 'diff -qB - input; echo $?' \ + "Files - and input differ\n1\n" \ + "0\n" \ + "1\n" + testing "diff always takes context from old file" \ "diff -ub - input | $TRIM_TAB" \ "\ -- 2.4.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 1/2] diff: fix -B with single line changes
Fix -B with single line changes. They were always ignored regardless if they were blank or not. Signed-off-by: Aaro Koskinen --- editors/diff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editors/diff.c b/editors/diff.c index cf14b1d..e0adcee 100644 --- a/editors/diff.c +++ b/editors/diff.c @@ -658,8 +658,8 @@ static bool diff(FILE* fp[2], char *file[2]) } for (j = 0; j < 2; j++) - for (k = v[j].a; k < v[j].b; k++) - nonempty |= (ix[j][k+1] - ix[j][k] != 1); + for (k = v[j].a; k <= v[j].b; k++) + nonempty |= (ix[j][k] - ix[j][k - 1] != 1); vec = xrealloc_vector(vec, 6, ++idx); memcpy(vec[idx], v, sizeof(v)); -- 2.4.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
diff -B is broken?
Hi, diff -B option does not seem to work as expected. See the below for an example: $ cat foo 1 $ cat bar 2 $ diff foo bar --- foo +++ bar @@ -1 +1 @@ -1 +2 $ diff -B foo bar $ A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] gzip: add support for compression levels 4-9
Add support for compression levels 4-9. function old new delta gzip_main191 306+115 usage_messages 40461 40504 +43 pack_gzip 19241907 -17 -- (add/remove: 0/0 grow/shrink: 2/1 up/down: 158/-17) Total: 141 bytes The rationale for this feature is that the current hardcoded 9 level is painfully slow with big files. Below are some examples when compressing a rootfs tarball (368.9M uncompressed) with different levels (gzip 1.6 compression time for comparison in parenthesis): compression timecompressed size Without the patch: 1m22.534s 152.0M With the patch, 9: 1m15.351s (1m7.419s)152.0M (old bb default level) 8: 0m46.763s (0m43.335s) 152.1M 7: 0m28.519s (0m27.076s) 152.4M 6: 0m22.960s (0m21.879s) 152.8M (gzip default level) 5: 0m16.058s (0m14.740s) 153.9M 4: 0m12.484s (0m11.167s) 156.4M If the compression level support is enabled, we make 6 the default as with gzip 1.6. Signed-off-by: Aaro Koskinen --- archival/gzip.c | 56 +++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/archival/gzip.c b/archival/gzip.c index bc1f9c6..e6161e2 100644 --- a/archival/gzip.c +++ b/archival/gzip.c @@ -62,14 +62,26 @@ aa: 85.1% -- replaced with aa.gz //config:1: larger buffers, larger hash-tables //config:2: larger buffers, largest hash-tables //config:Larger models may give slightly better compression +//config: +//config:config FEATURE_GZIP_LEVELS +//config: bool "Enable compression levels" +//config: default y +//config: depends on GZIP +//config: help +//config:Enable support for compression levels 4-9. The default level +//config:is 6 (without this option 9). If levels 1-3 are specified, 4 +//config:is used. //applet:IF_GZIP(APPLET(gzip, BB_DIR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_GZIP) += gzip.o //usage:#define gzip_trivial_usage -//usage: "[-cfd] [FILE]..." +//usage: "[-cfd" IF_FEATURE_GZIP_LEVELS("123456789") "] [FILE]..." //usage:#define gzip_full_usage "\n\n" //usage: "Compress FILEs (or stdin)\n" +//usage:IF_FEATURE_GZIP_LEVELS( +//usage: "\n-1..9 Compression level" +//usage:) //usage: "\n -d Decompress" //usage: "\n -c Write to stdout" //usage: "\n -f Force" @@ -252,6 +264,8 @@ enum { * input file length plus MIN_LOOKAHEAD. */ +#ifndef ENABLE_FEATURE_GZIP_LEVELS + max_chain_length = 4096, /* To speed up deflation, hash chains are never searched beyond this length. * A higher limit improves compression ratio but degrades the speed. @@ -283,11 +297,23 @@ enum { * For deflate_fast() (levels <= 3) good is ignored and lazy has a different * meaning. */ +#endif /* ENABLE_FEATURE_GZIP_LEVELS */ }; struct globals { +#ifdef ENABLE_FEATURE_GZIP_LEVELS + unsigned _max_chain_length; + unsigned _max_lazy_match; + unsigned _good_match; + unsigned _nice_match; +#define max_chain_length (G1._max_chain_length) +#define max_lazy_match (G1._max_lazy_match) +#define good_match (G1._good_match) +#define nice_match (G1._nice_match) +#endif /* ENABLE_FEATURE_GZIP_LEVELS */ + lng block_start; /* window position at the beginning of the current output block. Gets @@ -2161,6 +2187,22 @@ int gzip_main(int argc UNUSED_PARAM, char **argv) #endif { unsigned opt; +#ifdef ENABLE_FEATURE_GZIP_LEVELS + unsigned level; + const struct { + unsigned char good; + unsigned char chain_shift; + unsigned short lazy; + unsigned short nice; + } gzip_level_config[6] = { + {4, 4, 4, 16}, /* Level 4 */ + {8, 5, 16, 32}, /* Level 5 */ + {8, 7, 16, 128}, /* Level 6 */ + {8, 8, 32, 128}, /* Level 7 */ + {32, 10, 128, 258}, /* Level 8 */ + {32, 12, 258, 258}, /* Level 9 */ + }; +#endif /* ENABLE_FEATURE_GZIP_LEVELS */ #if ENABLE_FEATURE_GZIP_LONG_OPTIONS applet_long_options = gzip_longopts; @@ -2171,6 +2213,11 @@ int gzip_main(int argc UNUSED_PARAM, char **argv) if (opt & 0x18) // -d and/or -t return gunzip_main(argc, argv); #endif +#ifdef ENABLE_FEATURE_GZIP_LEVELS + /* Map 1..3 to 4 and make 6 a default. */ + level = ffs(
[PATCH] update copyright years
Copyright years seem to be out of date, e.g. coreutils/truncate.c has Copyright (C) 2015. Signed-off-by: Aaro Koskinen --- libbb/appletlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 8fd8fd5..e0b843d 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -631,7 +631,7 @@ static int busybox_main(char **argv) full_write2_str(bb_banner); /* reuse const string */ full_write2_str(" multi-call binary.\n"); /* reuse */ full_write2_str( - "BusyBox is copyrighted by many authors between 1998-2012.\n" + "BusyBox is copyrighted by many authors between 1998-2015.\n" "Licensed under GPLv2. See source distribution for detailed\n" "copyright notices.\n" "\n" -- 2.2.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] install: support -t option
Hi, On Wed, Sep 24, 2014 at 02:53:35AM +0200, Denys Vlasenko wrote: > On Tuesday 23 September 2014 21:12, Aaro Koskinen wrote: > > Some packages want to install themselves using "-t" to specify > > the directory (as supported by GNU coreutils). Add support for the option > > for compatibility reasons. > > > > Tested by building & installing "perf" from Linux kernel tree > > (its install uses -t), plus some other packages which don't use it > > to check there's no breakage. > > Applied with slight changes for smaller code. > Please try current git and let me know if I broke something. Seems to work fine, but usage has a typo: Usage: install [-cdDsp] [-o USER] [-g GRP] [-m MODE] [-d DIR] [SOURCE]... DEST ^^ Should be -t A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] install: support -t option
Some packages want to install themselves using "-t" to specify the directory (as supported by GNU coreutils). Add support for the option for compatibility reasons. Tested by building & installing "perf" from Linux kernel tree (its install uses -t), plus some other packages which don't use it to check there's no breakage. Signed-off-by: Aaro Koskinen --- coreutils/install.c | 36 +--- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/coreutils/install.c b/coreutils/install.c index 6c88ae1..14d6a4e 100644 --- a/coreutils/install.c +++ b/coreutils/install.c @@ -19,6 +19,7 @@ //usage: "\n -o USER Set ownership" //usage: "\n -g GRP Set group ownership" //usage: "\n -m MODE Set permissions" +//usage: "\n -t DEST Set DEST directory" //usage: IF_SELINUX( //usage: "\n -Z Set security context" //usage: ) @@ -37,6 +38,7 @@ static const char install_longopts[] ALIGN1 = "group\0" Required_argument "g" "mode\0"Required_argument "m" "owner\0" Required_argument "o" + "target-directory\0"Required_argument "t" /* autofs build insists of using -b --suffix=.orig */ /* TODO? (short option for --suffix is -S) */ #if ENABLE_SELINUX @@ -113,9 +115,10 @@ int install_main(int argc, char **argv) OPT_GROUP = 1 << 7, OPT_MODE = 1 << 8, OPT_OWNER = 1 << 9, + OPT_TARGET= 1 << 10, #if ENABLE_SELINUX - OPT_SET_SECURITY_CONTEXT = 1 << 10, - OPT_PRESERVE_SECURITY_CONTEXT = 1 << 11, + OPT_SET_SECURITY_CONTEXT = 1 << 11, + OPT_PRESERVE_SECURITY_CONTEXT = 1 << 12, #endif }; @@ -125,8 +128,9 @@ int install_main(int argc, char **argv) opt_complementary = "s--d:d--s" IF_FEATURE_INSTALL_LONG_OPTIONS(IF_SELINUX(":Z--\xff:\xff--Z")); /* -c exists for backwards compatibility, it's needed */ /* -b is ignored ("make a backup of each existing destination file") */ - opts = getopt32(argv, "cvb" "Ddpsg:m:o:" IF_SELINUX("Z:"), - &gid_str, &mode_str, &uid_str IF_SELINUX(, &scontext)); + opts = getopt32(argv, "cvb" "Ddpsg:m:o:t:" IF_SELINUX("Z:"), + &gid_str, &mode_str, &uid_str, &last + IF_SELINUX(, &scontext)); argc -= optind; argv += optind; @@ -160,13 +164,23 @@ int install_main(int argc, char **argv) uid = (opts & OPT_OWNER) ? get_ug_id(uid_str, xuname2uid) : getuid(); gid = (opts & OPT_GROUP) ? get_ug_id(gid_str, xgroup2gid) : getgid(); - last = argv[argc - 1]; - if (!(opts & OPT_DIRECTORY)) { - argv[argc - 1] = NULL; - min_args++; - - /* coreutils install resolves link in this case, don't use lstat */ - isdir = stat(last, &statbuf) < 0 ? 0 : S_ISDIR(statbuf.st_mode); + if (opts & OPT_TARGET) { + if (opts & OPT_DIRECTORY) + bb_error_msg_and_die("-t not allowed with -d"); + isdir = 1; + } else { + last = argv[argc - 1]; + if (!(opts & OPT_DIRECTORY)) { + argv[argc - 1] = NULL; + min_args++; + + /* +* coreutils install resolves link in this case, don't +* use lstat +*/ + isdir = stat(last, &statbuf) < 0 ? 0 : + S_ISDIR(statbuf.st_mode); + } } if (argc < min_args) -- 2.1.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Busybox less sometimes ignores newlines in input?
On Sun, Sep 21, 2014 at 10:10:37PM +0200, Denys Vlasenko wrote: > On Saturday 20 September 2014 13:30, Aaro Koskinen wrote: > > Hi, > > > > Sometimes when running "git log", busybox less won't display a newline > > between commits. This happens when git is slow and less needs to wait > > for new input to appear. > > > > A simple reproducer: > > > > (perl -e 'print "\nfoo\n";'; sleep 1; perl -e 'print "\nbar\n";') | less > > This patch seems to help. Though, now downside is that unwanted extra newline is visible when line length is one less the terminal width (replace 79 below with your terminal width - 1 if you are using != 80): perl -e '$a = "x" x 79 . "\n"; print $a, $a; ' | less (This makes e.g. git diffstats sometimes look ugly...) A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Busybox less sometimes ignores newlines in input?
Hi, On Sun, Sep 21, 2014 at 10:10:37PM +0200, Denys Vlasenko wrote: > On Saturday 20 September 2014 13:30, Aaro Koskinen wrote: > > Hi, > > > > Sometimes when running "git log", busybox less won't display a newline > > between commits. This happens when git is slow and less needs to wait > > for new input to appear. > > > > A simple reproducer: > > > > (perl -e 'print "\nfoo\n";'; sleep 1; perl -e 'print "\nbar\n";') | less > > This patch seems to help. Thanks... I think also found another issue with less... Try "git log | less" on some large git tree (e.g. linux) and press 'G'. What should happen? A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Busybox less sometimes ignores newlines in input?
Hi, Sometimes when running "git log", busybox less won't display a newline between commits. This happens when git is slow and less needs to wait for new input to appear. A simple reproducer: (perl -e 'print "\nfoo\n";'; sleep 1; perl -e 'print "\nbar\n";') | less A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH v2 2/2] tftp: ignore trailing garbage in the request
Hi, On Wed, Sep 03, 2014 at 06:36:36PM +0200, Denys Vlasenko wrote: > On Mon, Sep 1, 2014 at 10:24 PM, Aaro Koskinen wrote: > > The firmware in some HP PA-RISC boxes is always sending fixed > > 512-byte requests, and sometimes there is some garbage at the end > > which makes busybox to reject the request. Ignore any characters after > > the last NUL. > > How about this? As you pointed out, I missed the short read possibility, and by ignoring them that also made me to screw up my testing & analysis (should have checked with tcpdump) - the box is actually sending *516-byte* requests. :-( So following is still needed to current git to work with some PA-RISC: diff --git a/networking/tftp.c b/networking/tftp.c index 8e3b0a2..d9295c9 100644 --- a/networking/tftp.c +++ b/networking/tftp.c @@ -118,7 +118,7 @@ struct globals { uint8_t error_pkt[4 + 32]; struct passwd *pw; /* used in tftpd_main(), a bit big for stack: */ - char block_buf[TFTP_BLKSIZE_DEFAULT]; + char block_buf[TFTP_BLKSIZE_DEFAULT + 4]; char block_buf_tail[1]; #if ENABLE_FEATURE_TFTP_PROGRESS_BAR off_t pos; @@ -811,7 +811,7 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv) ) { goto err; } - /* Some HP PA-RISC firmware always sends fixed 512-byte requests, + /* Some HP PA-RISC firmware always sends fixed 516-byte requests, * with trailing garbage. * Support that by not requiring NUL to be the last byte (see above). * To make strXYZ() ops safe, force NUL termination: Very sorry not realizing this earlier, A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH v2 2/2] tftp: ignore trailing garbage in the request
The firmware in some HP PA-RISC boxes is always sending fixed 512-byte requests, and sometimes there is some garbage at the end which makes busybox to reject the request. Ignore any characters after the last NUL. Signed-off-by: Aaro Koskinen --- networking/tftp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/networking/tftp.c b/networking/tftp.c index de616b7..fb0dbb2 100644 --- a/networking/tftp.c +++ b/networking/tftp.c @@ -757,7 +757,7 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv) { len_and_sockaddr *our_lsa; len_and_sockaddr *peer_lsa; - char *local_file, *mode, *user_opt; + char *local_file, *mode, *user_opt, *last_nul; const char *error_msg; int opt, result, opcode; IF_FEATURE_TFTP_BLOCKSIZE(int blksize = TFTP_BLKSIZE_DEFAULT;) @@ -799,7 +799,7 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv) error_msg = "malformed packet"; opcode = ntohs(*(uint16_t*)G.block_buf); - if (result < 4 || G.block_buf[result-1] != '\0' + if (result < 4 || !(last_nul = memrchr(G.block_buf + 3, 0, result - 3)) || (IF_FEATURE_TFTP_PUT(opcode != TFTP_RRQ) /* not download */ IF_GETPUT(&&) IF_FEATURE_TFTP_GET(opcode != TFTP_WRQ) /* not upload */ @@ -807,6 +807,7 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv) ) { goto err; } + result = last_nul - G.block_buf + 1; /* limit the result to last NUL */ local_file = G.block_buf + 2; if (local_file[0] == '.' || strstr(local_file, "/.")) { error_msg = "dot in file name"; -- 2.0.3 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH v2 1/2] tftp: fix off by one error
RFC 2347 allows requests to be up to 512 bytes, so a request equal to sizeof(G.block_buf) should be fine. The remaining result > sizeof(G.block_buf) check would be redudant, since the recv function should take care of not overrunning the buffer, so delete that too. Signed-off-by: Aaro Koskinen --- networking/tftp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/networking/tftp.c b/networking/tftp.c index 630fdaf..de616b7 100644 --- a/networking/tftp.c +++ b/networking/tftp.c @@ -799,8 +799,7 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv) error_msg = "malformed packet"; opcode = ntohs(*(uint16_t*)G.block_buf); - if (result < 4 || result >= sizeof(G.block_buf) -|| G.block_buf[result-1] != '\0' + if (result < 4 || G.block_buf[result-1] != '\0' || (IF_FEATURE_TFTP_PUT(opcode != TFTP_RRQ) /* not download */ IF_GETPUT(&&) IF_FEATURE_TFTP_GET(opcode != TFTP_WRQ) /* not upload */ -- 2.0.3 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH RESEND v2] less: respect -E (quit at EOF)
Hi, On Sat, Nov 16, 2013 at 08:48:13PM +0200, Aaro Koskinen wrote: > less displays -E in help text, but it's not doing anything. Make it quit > less when the last lines of the file have been printed. > > Signed-off-by: Aaro Koskinen > --- Any comments about this patch? Or should we just drop this flag completely? A. > Patch history: > > v2: Also check that EOF was reached (eof_error <= 0). > > v1: http://marc.info/?t=13791068693&r=1&w=2 > > > miscutils/less.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/miscutils/less.c b/miscutils/less.c > index 60105f4..52ffead 100644 > --- a/miscutils/less.c > +++ b/miscutils/less.c > @@ -795,6 +795,9 @@ static void buffer_print(void) > print_found(buffer[i]); > else > print_ascii(buffer[i]); > + if ((option_mask32 & FLAG_E) && eof_error <= 0 && > + (max_fline - cur_fline) <= max_displayed_line) > + less_exit(EXIT_SUCCESS); > status_print(); > } > > -- > 1.8.4.rc3 > ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] taskset: support more than 64 cores
Hi, BTW, if you care about bloat, please consider stopping sending HTML mails to the list. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] taskset: support more than 64 cores
Hi, On Mon, Aug 11, 2014 at 11:19:34PM +0100, Laszlo Papp wrote: > Right, so you cannot bring up any valid and real use case for this, or do > not want despite the explicit clarification request, I take it. I do not > think theoretical changes should be added just because it is a good > technical challange. Valid use cases oughta be part of the commit message, > but at worst, comment explanation without even explicit request to be > fair. I think the use case is pretty clear: "support more than 64 cores". A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] taskset: support more than 64 cores
Hi, On Mon, Aug 11, 2014 at 10:35:46PM +0100, Laszlo Papp wrote: > Not quite sure what you are trying to achieve, but you wrote embedded > systems _word-by-word_, and I asked for one typical example with more than > 64 cores where busybox is so much needed. I'm not trying the limit busybox usage, and I don't think there are any "typical" embedded system. And Apple or Samsung are definitely not any reference. But if you are happy with their HW, then good for you. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] taskset: support more than 64 cores
Hi, On Mon, Aug 11, 2014 at 10:27:12PM +0100, Laszlo Papp wrote: > Show me one typical embedded system that is high-volume and has more than > 64 cores. Even the full-fledged iphone tablets are not there and even if > they were, they would use complete utils rather than chopped most probably > anyhow. To me, this feature does not seem to fit busybox's goal unless > Apple, Samsung, etc were not notified about some recent boom in the > semiconductor industry. Embedded != consumer electronics. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] taskset: support more than 64 cores
Hi, On Mon, Aug 11, 2014 at 02:25:04PM +0100, Laszlo Papp wrote: > I wonder about the use case for this feature? I mean busybox is meant for > small systems in general, and >=64 cores are not that small embedded > systems, at least not yet, yeah? How you define small? Earlier you said using libc getconf is bloat (as nproc replacement) for multicore systems, but now you suggest that for cores > 64 we should't care. Where do you draw the line? Embedded systems that have lots of RAM and CPUs/cores run-time may be still limited to having a boot flash of just few megs where the whole OS image needs to fit. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] nproc: new applet
Hi, On Mon, Aug 04, 2014 at 11:06:58PM +0100, Steven Honeyman wrote: > Right, seeing as musl libc (and most other non-glibcs) do not provide > a get_nprocs() that actually works... I have mixed both solutions and > used sysconf() instead. It works just as well. If the underlying libc supports sysconf() they also probably provide getconf since it's s standard thing (unlike nproc). A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] nproc: new applet
Hi, On Mon, Aug 04, 2014 at 11:22:13PM +0100, Laszlo Papp wrote: >I am not sure what is unclear. eglibc is eglibc. Yes, they merged lately, >yet, Yocto, et all uses eglibc out there. That would be the most important >to verify. In fact, you will not have a full blown glibc on the target for >good when you only have 4 MB or 8 MB. eglibc is dying and Yocto is marginal, so I don't think they they are "the most important to verify". You can always carry your own patches. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] nproc: new applet
Hi, On Mon, Aug 04, 2014 at 09:51:50PM +0100, Laszlo Papp wrote: > Glibc is out of the question, naturally. What would matter is eglibc > if one can verify it. What you mean? According to EGLIBC home page: "EGLIBC is no longer developed and such goals are now being addressed directly in GLIBC." A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 1/2] tftp: fix off by one error
RFC 2347 allows requests to be up to 512 bytes. Signed-off-by: Aaro Koskinen --- networking/tftp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/networking/tftp.c b/networking/tftp.c index 630fdaf..b91ef5b 100644 --- a/networking/tftp.c +++ b/networking/tftp.c @@ -799,7 +799,7 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv) error_msg = "malformed packet"; opcode = ntohs(*(uint16_t*)G.block_buf); - if (result < 4 || result >= sizeof(G.block_buf) + if (result < 4 || result > sizeof(G.block_buf) || G.block_buf[result-1] != '\0' || (IF_FEATURE_TFTP_PUT(opcode != TFTP_RRQ) /* not download */ IF_GETPUT(&&) -- 2.0.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 2/2] tftp: ignore trailing garbage in the request
The firmware in some HP PA-RISC boxes sending fixed 512-byte requests, and sometimes there is some garbage at the end which makes busybox to reject the request. Ignore any characters after the last NUL. Signed-off-by: Aaro Koskinen --- networking/tftp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/networking/tftp.c b/networking/tftp.c index b91ef5b..1fcfd7a 100644 --- a/networking/tftp.c +++ b/networking/tftp.c @@ -757,7 +757,7 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv) { len_and_sockaddr *our_lsa; len_and_sockaddr *peer_lsa; - char *local_file, *mode, *user_opt; + char *local_file, *mode, *user_opt, *last_nul; const char *error_msg; int opt, result, opcode; IF_FEATURE_TFTP_BLOCKSIZE(int blksize = TFTP_BLKSIZE_DEFAULT;) @@ -800,7 +800,7 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv) error_msg = "malformed packet"; opcode = ntohs(*(uint16_t*)G.block_buf); if (result < 4 || result > sizeof(G.block_buf) -|| G.block_buf[result-1] != '\0' +|| !(last_nul = memrchr(G.block_buf + 3, 0, result - 3)) || (IF_FEATURE_TFTP_PUT(opcode != TFTP_RRQ) /* not download */ IF_GETPUT(&&) IF_FEATURE_TFTP_GET(opcode != TFTP_WRQ) /* not upload */ @@ -808,6 +808,7 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv) ) { goto err; } + result = last_nul - G.block_buf + 1; /* limit the result to last NUL */ local_file = G.block_buf + 2; if (local_file[0] == '.' || strstr(local_file, "/.")) { error_msg = "dot in file name"; -- 2.0.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Ntpd config file support
On Tue, Mar 18, 2014 at 01:43:43PM +0100, Harald Becker wrote: > The Busybox ntpd applet get all information it needs via command > line, so it doesn't need to read any config file. I agree, it would be overlapping functionality and not needed. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] man: default to ascii
Default to ascii instead of latin1. Otherwise man pages will be displayed incorrectly on UTF-8 terminals. E.g. bullets show as "". Signed-off-by: Aaro Koskinen --- miscutils/man.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miscutils/man.c b/miscutils/man.c index d3e832b..7c6f737 100644 --- a/miscutils/man.c +++ b/miscutils/man.c @@ -106,7 +106,7 @@ static int run_pipe(const char *pager, char *man_filename, int man, int level) /* "2>&1" is added so that nroff errors are shown in pager too. * Otherwise it may show just empty screen */ cmd = xasprintf( - man ? "gtbl | nroff -Tlatin1 -mandoc 2>&1 | %s" + man ? "gtbl | nroff -Tascii -mandoc 2>&1 | %s" : "%s", pager); system(cmd); -- 1.9.0 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Interworking of cron and sendmail applets
Hi, On Wed, Jan 22, 2014 at 11:29:14PM +0100, Harald Becker wrote: > I do not know, why this option has made mandatory, but as far as > i know does BB sendmail always need some extra options to know > where to send the mail (mail relay), and will not work without > this information. So it is of no extra cost to add the sender > option at the same time. The server can be specified with an environment variable, so you could still get that part working. I think Kaarle has a valid point that busybox cron should be able to call busybox sendmail without wrapper scripts etc. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: busybox sendmail and recipients list
Hi, On Sun, Dec 29, 2013 at 11:02:21PM +0100, Piotr Rotter wrote: > I observed some problem with busybox sendmail applet in case when > present many recipient in headers in one line like below: > > To: us...@domain.tld,us...@domain.tld Earlier this year some fixes were made to sendmail to address this and some other issues. See e.g. http://git.busybox.net/busybox/commit/mailutils/sendmail.c?id=a8ba0a0d0ce4fa5f5afd0a8246e2378c2664c424 Maybe try the latest git HEAD if you can? A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH RESEND v2] less: respect -E (quit at EOF)
less displays -E in help text, but it's not doing anything. Make it quit less when the last lines of the file have been printed. Signed-off-by: Aaro Koskinen --- Patch history: v2: Also check that EOF was reached (eof_error <= 0). v1: http://marc.info/?t=13791068693&r=1&w=2 miscutils/less.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/miscutils/less.c b/miscutils/less.c index 60105f4..52ffead 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -795,6 +795,9 @@ static void buffer_print(void) print_found(buffer[i]); else print_ascii(buffer[i]); + if ((option_mask32 & FLAG_E) && eof_error <= 0 && + (max_fline - cur_fline) <= max_displayed_line) + less_exit(EXIT_SUCCESS); status_print(); } -- 1.8.4.rc3 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH v2] less: respect -E (quit at EOF)
less displays -E in help text, but it's not doing anything. Make it quit less when the last lines of the file have been printed. Signed-off-by: Aaro Koskinen --- Patch history: v2: Also check that EOF was reached (eof_error <= 0). v1: http://marc.info/?t=13791068693&r=1&w=2 miscutils/less.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/miscutils/less.c b/miscutils/less.c index 60105f4..52ffead 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -795,6 +795,9 @@ static void buffer_print(void) print_found(buffer[i]); else print_ascii(buffer[i]); + if ((option_mask32 & FLAG_E) && eof_error <= 0 && + (max_fline - cur_fline) <= max_displayed_line) + less_exit(EXIT_SUCCESS); status_print(); } -- 1.8.4.rc3 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] less: respect -E (quit at EOF)
Hi, On Sat, Sep 14, 2013 at 12:13:52AM +0300, Aaro Koskinen wrote: > less displays -E in help text, but it's not doing anything. Make it quit > less when the last lines of the file have been printed. Any comments? A. > Signed-off-by: Aaro Koskinen > --- > miscutils/less.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/miscutils/less.c b/miscutils/less.c > index 60105f4..9b0478a 100644 > --- a/miscutils/less.c > +++ b/miscutils/less.c > @@ -795,6 +795,9 @@ static void buffer_print(void) > print_found(buffer[i]); > else > print_ascii(buffer[i]); > + if ((option_mask32 & FLAG_E) && > + (max_fline - cur_fline) <= max_displayed_line) > + less_exit(EXIT_SUCCESS); > status_print(); > } > > -- > 1.8.4.rc3 > > ___ > busybox mailing list > busybox@busybox.net > http://lists.busybox.net/mailman/listinfo/busybox ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] Fix incorrect OS reporting in uname -o
Hi, On Tue, Sep 17, 2013 at 11:47:55PM -0400, Patrick 'P. J.' McDermott wrote: > On 2013-09-17 18:56, Rich Felker wrote: > > - strcpy(uname_info.os, "GNU/Linux"); > > + strcpy(uname_info.os, > > +#ifdef __GLIBC__ > > + "GNU/" > > +#endif > > + "Linux"); > > I'd agree that most BusyBox-based systems can hardly be called > "GNU/Linux", even with glibc. It seems inappropriate to call a system > "GNU" if it has little or no GNU software. Maybe in the case when GNU toolchain was not used to compile the system? > But I'd call such a system "BusyBox/Linux" instead, since BusyBox is the > userspace, regardless of the C library in my opinion. My systems have uname from busybox, but I also have ~80 other packages installed, so "BusyBox/Linux" would be also wrong. Maybe it should be configurable. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] less: respect -E (quit at EOF)
less displays -E in help text, but it's not doing anything. Make it quit less when the last lines of the file have been printed. Signed-off-by: Aaro Koskinen --- miscutils/less.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/miscutils/less.c b/miscutils/less.c index 60105f4..9b0478a 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -795,6 +795,9 @@ static void buffer_print(void) print_found(buffer[i]); else print_ascii(buffer[i]); + if ((option_mask32 & FLAG_E) && + (max_fline - cur_fline) <= max_displayed_line) + less_exit(EXIT_SUCCESS); status_print(); } -- 1.8.4.rc3 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: ash: "source " makes ash exit?
Hi, On Sat, Mar 16, 2013 at 12:38:28AM +0100, Harald Becker wrote: > >"source" is bashism, and "." should be preferred for portability. > > Definitely not! Even very old Unix shells (and alike) back in the 80th > accepted both syntax forms (but shells are different and not all are > standards conform). I do not know, what the standards documents tell > about this, I prefere "source" in scripts (sh not bash) for it's better > readability (and it's easier to search). I used to think so too, but e.g. when Debian changed /bin/sh to dash, many of my scripts broke badly. So it's good to check the standards documents every once in a while... A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: ash: "source " makes ash exit?
Hi, On Sat, Mar 16, 2013 at 12:04:12AM +0100, Harald Becker wrote: > Hi Matthew ! > >I've heard rumors that backticks are discouraged in favor of $( )... > >Can we do the same for . in favor of source? You can't exactly grep > >for '.' > > It was just a hint for novices that both syntax forms behave identical > and description may be used for both. There was no preference which > form shall be used, otherwise you are right. I prefer $() and source > within scripts and tend to use backticks and dot on command line. "source" is bashism, and "." should be preferred for portability. A. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 4/7] sendmail: support address lists
Headers To:, Cc: and Bcc: may have a list of comma-separated addresses. Add support for that. Commas inside double quotes are ignored. Signed-off-by: Aaro Koskinen --- mailutils/sendmail.c | 33 + 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c index 10a5a85..12ca054 100644 --- a/mailutils/sendmail.c +++ b/mailutils/sendmail.c @@ -144,6 +144,33 @@ static void rcptto(const char *s) bb_error_msg("Bad recipient: <%s>", s); } +// send to a list of comma separated addresses +static void rcptto_list(const char *_str) +{ + char *str = xstrdup(_str); + int len = strlen(str); + int in_quote = 0; + char *s = str; + char prev = 0; + int pos; + + for (pos = 0; pos < len; pos++) { + char ch = str[pos]; + + if (ch == 0x22 && prev != 0x5c) { + in_quote = !in_quote; + } else if (!in_quote && ch == ',') { + str[pos] = '\0'; + rcptto(angle_address(s)); + s = str + pos + 1; + } + prev = ch; + } + if (prev != ',') + rcptto(angle_address(s)); + free(str); +} + int sendmail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int sendmail_main(int argc UNUSED_PARAM, char **argv) { @@ -317,14 +344,12 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) // To: or Cc: headers add recipients if (opts & OPT_t) { if (0 == strncasecmp("To:", s, 3) || 0 == strncasecmp("Bcc:" + 1, s, 3)) { - char *r = xstrdup(s+3); - rcptto(angle_address(r)); - free(r); + rcptto_list(s+3); goto addheader; } // Bcc: header adds blind copy (hidden) recipient if (0 == strncasecmp("Bcc:", s, 4)) { - rcptto(angle_address(s+4)); + rcptto_list(s+4); free(s); continue; // N.B. Bcc: vanishes from headers! } -- 1.7.10.4 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 1/7] sendmail: avoid sending mail to wrong addresses
If we get an address we cannot parse properly, we currently just strip the unknown characters and still try to send it. This is considered harmful as the resulting address may still be valid but different from what the user originally intended. Instead, skip sending to an address we cannot fully understand and print the characters what we have scanned so far. Leading and trailing whitespace is allowed and silently stripped. Signed-off-by: Aaro Koskinen --- mailutils/sendmail.c | 17 - 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c index c426e9d..4f73512 100644 --- a/mailutils/sendmail.c +++ b/mailutils/sendmail.c @@ -94,9 +94,22 @@ static char *sane_address(char *str) { char *s = str; char *p = s; + int leading_space = 1; + int trailing_space = 0; + while (*s) { - if (isalnum(*s) || '_' == *s || '-' == *s || '.' == *s || '@' == *s) { + if (isspace(*s)) { + trailing_space = !leading_space; + } else { *p++ = *s; + if ((!isalnum(*s) && !strchr("_-.@", *s)) || + trailing_space) { + *p = '\0'; + bb_error_msg("Bad address: %s", str); + *str = '\0'; + return str; + } + leading_space = 0; } s++; } @@ -106,6 +119,8 @@ static char *sane_address(char *str) static void rcptto(const char *s) { + if (!*s) + return; // N.B. we don't die if recipient is rejected, for the other recipients may be accepted if (250 != smtp_checkp("RCPT TO:<%s>", s, -1)) bb_error_msg("Bad recipient: <%s>", s); -- 1.7.10.4 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 5/7] sendmail: support long header fields for recipients
Support long header fields in To:, Cc: and Bcc: headers. Signed-off-by: Aaro Koskinen --- mailutils/sendmail.c | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c index 12ca054..9c1c589 100644 --- a/mailutils/sendmail.c +++ b/mailutils/sendmail.c @@ -181,6 +181,12 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) char *host = sane_address(safe_gethostname()); unsigned nheaders = 0; int code; + enum { + HDR_OTHER = 0, + HDR_TOCC, + HDR_BCC, + } last_hdr = 0; + int check_hdr; enum { //--- standard options @@ -345,20 +351,31 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) if (opts & OPT_t) { if (0 == strncasecmp("To:", s, 3) || 0 == strncasecmp("Bcc:" + 1, s, 3)) { rcptto_list(s+3); + last_hdr = HDR_TOCC; goto addheader; } // Bcc: header adds blind copy (hidden) recipient if (0 == strncasecmp("Bcc:", s, 4)) { rcptto_list(s+4); free(s); + last_hdr = HDR_BCC; continue; // N.B. Bcc: vanishes from headers! } } - if (strchr(s, ':') || (list && isspace(s[0]))) { + check_hdr = list && isspace(s[0]); + if (strchr(s, ':') || check_hdr) { // other headers go verbatim // N.B. RFC2822 2.2.3 "Long Header Fields" allows for headers to occupy several lines. // Continuation is denoted by prefixing additional lines with whitespace(s). // Thanks (stefan.seyfried at googlemail.com) for pointing this out. + if (check_hdr && last_hdr != HDR_OTHER) { + rcptto_list(s+1); + if (last_hdr == HDR_BCC) + continue; + // N.B. Bcc: vanishes from headers! + } else { + last_hdr = HDR_OTHER; + } addheader: // N.B. we allow MAX_HEADERS generic headers at most to prevent attacks if (MAX_HEADERS && ++nheaders >= MAX_HEADERS) -- 1.7.10.4 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 7/7] sendmail: don't add multiple To: headers
When adding To: header, add only a single header. If there are multiple addresses, make it multiline. Signed-off-by: Aaro Koskinen --- mailutils/sendmail.c | 22 ++ 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c index 323ad0a..320a259 100644 --- a/mailutils/sendmail.c +++ b/mailutils/sendmail.c @@ -172,7 +172,7 @@ static void rcptto_list(const char *_str) } int sendmail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -int sendmail_main(int argc UNUSED_PARAM, char **argv) +int sendmail_main(int argc, char **argv) { char *opt_connect = opt_connect; char *opt_from; @@ -218,7 +218,7 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) // it is still under development. opts = getopt32(argv, "tf:o:iw:H:S:a::v", &opt_from, NULL, &timeout, &opt_connect, &opt_connect, &list, &verbose); - //argc -= optind; + argc -= optind; argv += optind; // process -a[upm] options @@ -389,15 +389,29 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) // so stop "analyze headers" mode reenter: // put recipients specified on cmdline + check_hdr = 1; while (*argv) { char *t = sane_address(*argv); rcptto(t); //if (MAX_HEADERS && ++nheaders >= MAX_HEADERS) // goto bail; - if (!has_to) + if (!has_to) { + char const *hdr; + + if (check_hdr && argc > 1) + hdr = "To: %s,"; + else if (check_hdr) + hdr = "To: %s"; + else if (argc > 1) + hdr = "To: %s," + 3; + else + hdr = "To: %s" + 3; llist_add_to_end(&list, - xasprintf("To: %s", t)); +xasprintf(hdr, t)); + check_hdr = 0; + } argv++; + argc--; } // enter "put message" mode // N.B. DATA fails iff no recipients were accepted (or even provided) -- 1.7.10.4 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 3/7] sendmail: support addresses inside angle brackets
When we extract addresses from the e-mail, try to first check for an address inside angle brackets. Signed-off-by: Aaro Koskinen --- mailutils/sendmail.c | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c index 0f536ad..10a5a85 100644 --- a/mailutils/sendmail.c +++ b/mailutils/sendmail.c @@ -117,6 +117,24 @@ static char *sane_address(char *str) return str; } +// check for an address inside angle brackets, if not found fall back to normal +static char *angle_address(char *str) +{ + char *s = str; + char *e = str + strlen(str); + + while (e != str && (isspace(*e) || *e == '\0')) + e--; + if (*e != '>') + goto done; + *e = '\0'; + e = strrchr(s, '<'); + if (e != NULL) + s = e + 1; +done: + return sane_address(s); +} + static void rcptto(const char *s) { if (!*s) @@ -300,13 +318,13 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) if (opts & OPT_t) { if (0 == strncasecmp("To:", s, 3) || 0 == strncasecmp("Bcc:" + 1, s, 3)) { char *r = xstrdup(s+3); - rcptto(sane_address(r)); + rcptto(angle_address(r)); free(r); goto addheader; } // Bcc: header adds blind copy (hidden) recipient if (0 == strncasecmp("Bcc:", s, 4)) { - rcptto(sane_address(s+4)); + rcptto(angle_address(s+4)); free(s); continue; // N.B. Bcc: vanishes from headers! } -- 1.7.10.4 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 6/7] sendmail: don't add To: header if it already exists
If the message we are sending already has To: header, don't add a new one. Signed-off-by: Aaro Koskinen --- mailutils/sendmail.c |9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c index 9c1c589..323ad0a 100644 --- a/mailutils/sendmail.c +++ b/mailutils/sendmail.c @@ -187,6 +187,7 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) HDR_BCC, } last_hdr = 0; int check_hdr; + int has_to = 0; enum { //--- standard options @@ -348,8 +349,10 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) // analyze headers // To: or Cc: headers add recipients + check_hdr = 0 == strncasecmp("To:", s, 3); + has_to |= check_hdr; if (opts & OPT_t) { - if (0 == strncasecmp("To:", s, 3) || 0 == strncasecmp("Bcc:" + 1, s, 3)) { + if (check_hdr || 0 == strncasecmp("Bcc:" + 1, s, 3)) { rcptto_list(s+3); last_hdr = HDR_TOCC; goto addheader; @@ -391,7 +394,9 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) rcptto(t); //if (MAX_HEADERS && ++nheaders >= MAX_HEADERS) // goto bail; - llist_add_to_end(&list, xasprintf("To: %s", t)); + if (!has_to) + llist_add_to_end(&list, + xasprintf("To: %s", t)); argv++; } // enter "put message" mode -- 1.7.10.4 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 0/7] sendmail: improve recipient address handling
Hi, Here's some suggestions for sendmail applet. While I understand it's "bare bones" implementation, it should at least handle the most common cases for recipient addresses, or if not possible, then fail in a safe manner. This set tries to implement/fix the following (when -t is used): * If the address looks wrong, don't try to correct it, instead drop it and warn. * Support "Real Name " type of addresses. * Support multiple comma-separated addresses. * Support long header fields when adding recipient addresses. * Don't add multiple To: fields. I'll only accept review comments sent with busybox sendmail. :-) Aaro Koskinen (7): sendmail: avoid sending mail to wrong addresses sendmail: don't mangle e-mail headers sendmail: support addresses inside angle brackets sendmail: support address lists sendmail: support long header fields for recipients sendmail: don't add To: header if it already exists sendmail: don't add multiple To: headers mailutils/sendmail.c | 112 ++ 1 file changed, 104 insertions(+), 8 deletions(-) -- 1.7.10.4 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 2/7] sendmail: don't mangle e-mail headers
Leave the original To: and Cc: headers untouched, when we try to extract addresses from them. Signed-off-by: Aaro Koskinen --- mailutils/sendmail.c |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c index 4f73512..0f536ad 100644 --- a/mailutils/sendmail.c +++ b/mailutils/sendmail.c @@ -299,7 +299,9 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) // To: or Cc: headers add recipients if (opts & OPT_t) { if (0 == strncasecmp("To:", s, 3) || 0 == strncasecmp("Bcc:" + 1, s, 3)) { - rcptto(sane_address(s+3)); + char *r = xstrdup(s+3); + rcptto(sane_address(r)); + free(r); goto addheader; } // Bcc: header adds blind copy (hidden) recipient -- 1.7.10.4 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 1/2] fdisk_sun: fix corrupted partition data with blank disk
After creating Sun disk label for the first time for a blank disk, the partition table appears corrupted because current_label_type will never get set to a proper type. Fix this by calling check_sun_label() after BusyBox has created the label. Signed-off-by: Aaro Koskinen --- util-linux/fdisk_sun.c |1 + 1 file changed, 1 insertion(+) diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c index e7fcc06..d11c540 100644 --- a/util-linux/fdisk_sun.c +++ b/util-linux/fdisk_sun.c @@ -348,6 +348,7 @@ create_sunlabel(void) set_all_unchanged(); set_changed(0); + check_sun_label(); get_boot(CREATE_EMPTY_SUN); } -- 1.7.10.4 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH 2/2] fdisk_sun: fix partition alignment
When the display unit is sectors, the partition alignment will convert the partition start to a wrong unit (it should always be in sectors). Fix this. Signed-off-by: Aaro Koskinen --- util-linux/fdisk_sun.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c index d11c540..e32740d 100644 --- a/util-linux/fdisk_sun.c +++ b/util-linux/fdisk_sun.c @@ -498,11 +498,14 @@ add_sun_partition(int n, int sys) else first = read_int(scround(start), scround(stop)+1, scround(stop), 0, mesg); - if (display_in_cyl_units) + if (display_in_cyl_units) { first *= units_per_sector; - else + } else { /* Starting sector has to be properly aligned */ - first = (first + g_heads * g_sectors - 1) / (g_heads * g_sectors); + first = (first + g_heads * g_sectors - 1) / + (g_heads * g_sectors); + first *= g_heads * g_sectors; + } if (n == 2 && first != 0) printf("\ It is highly recommended that the third partition covers the whole disk\n\ -- 1.7.10.4 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] cttyhack: handle multiple consoles found from sysfs
If multiple consoles are found from the sysfs file, cttyhack will fail: cttyhack: can't open '/dev/tty0 ttyS0': No such file or directory In such cases take the last one as the kernel will use that one for /dev/console. Signed-off-by: Aaro Koskinen --- shell/cttyhack.c |9 + 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/shell/cttyhack.c b/shell/cttyhack.c index 6ff8674..b2614b5 100644 --- a/shell/cttyhack.c +++ b/shell/cttyhack.c @@ -128,10 +128,19 @@ int cttyhack_main(int argc UNUSED_PARAM, char **argv) int s = open_read_close("/sys/class/tty/console/active", console + 5, sizeof(console) - 5); if (s > 0) { + char *last; /* found active console via sysfs (Linux 2.6.38+) * sysfs string looks like "ttyS0\n" so zap the newline: */ console[4 + s] = '\0'; + /* if there are multiple consoles, take the last +* one: +*/ + last = strrchr(console + 5, ' '); + if (last != NULL) + memmove(console + 5, + last + 1, + s - (last - (console + 5)) - 1); break; } -- 1.7.2.5 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox