Re: sighandler_t in non-GNU

2011-01-19 Thread Rich Felker
On Thu, Jan 20, 2011 at 12:53:01AM +0100, Denys Vlasenko wrote: On Wednesday 19 January 2011 20:16, Chris Rees wrote: Hey all, Still plodding away at updating the FreeBSD port. Got another patch; FreeBSD etc doesn't have sighandler_t, used in linedit.c. Perhaps for platform.h?

Re: [PATCH] getty: Wait until all output written to stdout has been transmitted

2011-01-22 Thread Rich Felker
On Sat, Jan 22, 2011 at 01:40:45PM +0100, Mikhail Gusarov wrote: Twas brillig at 02:57:47 22.01.2011 UTC+01 when vda.li...@googlemail.com did gyre and gimble: DV But it may lead to a hang if serial line gets mangled: in some DV situations tcdrain may wait forever. DV I propose adding

Re: [PATCH] getty: Wait until all output written to stdout has been transmitted

2011-01-23 Thread Rich Felker
On Sun, Jan 23, 2011 at 03:39:02PM +0100, Denys Vlasenko wrote: On Sun, Jan 23, 2011 at 11:28 AM, Michal Simek mon...@monstr.eu wrote: Give me what I should test and I will do it. Insert sleep(1) before tcflush(0, TCIOFLUSH) in termios_init in getty.c, and let us know whether the getty

Re: [PATCH] getty: Wait until all output written to stdout has been transmitted

2011-01-24 Thread Rich Felker
On Mon, Jan 24, 2011 at 09:03:45AM +0100, Peter Korsgaard wrote: Ok, what about: + /* Wait up to 5 seconds for the output buffer to drain */ + signal(SIGALRM, record_signo); + alarm(5); + tcdrain(STDIN_FILENO); + alarm(0); + signal(SIGALRM, SIG_DFL);

Re: configure ash to execute /etc/profile by default

2011-01-25 Thread Rich Felker
On Tue, Jan 25, 2011 at 04:45:32PM -0500, rouble wrote: Busybox gurus, Is there anyway to get ash to execute /etc/profile by default without having to use the -l flag? If there isn't a configurable way to do this, any ideas on the best way to change the code to do this are appreciated.

Re: Useless uses of utmp.h

2011-01-25 Thread Rich Felker
On Tue, Jan 25, 2011 at 11:22:38PM +0100, Denys Vlasenko wrote: On Tuesday 25 January 2011 21:48, Chris Rees wrote: Hi again, I've got Busybox to compile on FreeBSD-9 now, but to do that I needed to knock out all occurrences of utmp.h. My solution was to make compilation of utmp.c

Re: Strange echo behaviour

2011-01-26 Thread Rich Felker
On Thu, Jan 27, 2011 at 06:18:25AM +0100, Denys Vlasenko wrote: On Wednesday 26 January 2011 13:21, Baruch Siach wrote: Hi busybox list, I'm running the following command under strace (thanks Rob): echo 56 /sys/class/gpio/export and I see the following output: write(1,

Re: idle (or inactivity) timeout in ash

2011-02-02 Thread Rich Felker
On Wed, Feb 02, 2011 at 08:24:28PM +0100, Denys Vlasenko wrote: +static volatile int timed_out; + +static void alrm_catcher(int i) +{ + printf (\007timed out waiting for input: auto-logout\n); + timed_out = 1; + return; +} (1) printf in signal handler is a bad idea. It's

Re: FEATURE_PREFER_APPLETS should fail gracefully.

2011-02-02 Thread Rich Felker
On Wed, Feb 02, 2011 at 04:59:37PM -0600, Rob Landley wrote: Yeah, factor of 20 is fairly significant. Of course mine didn't have any command line option parsing overhead or similar, it was _just_ measuring the overhead of fork plus wait vs open plus close plus unlink, and doing a

Re: A question of philosophy

2011-02-03 Thread Rich Felker
On Thu, Feb 03, 2011 at 10:45:00AM +, David Collier wrote: Denys, your suggestion above for fixing tar to work with stdin is wonderful - and I'm sure it will work. But it illustrates the different world-views that you and I have. In an illuminating way. You think/speak as if

Re: [Bug 3097] BB making easily-fixed non-portable assumptions

2011-02-07 Thread Rich Felker
On Mon, Feb 07, 2011 at 02:01:13PM +, bugzi...@busybox.net wrote: https://bugs.busybox.net/show_bug.cgi?id=3097 Denys Vlasenko vda.li...@googlemail.com changed: What|Removed |Added

Re: [Bug 3091] Nonportable tool usage in scripts

2011-02-07 Thread Rich Felker
On Mon, Feb 07, 2011 at 01:49:16PM +, bugzi...@busybox.net wrote: https://bugs.busybox.net/show_bug.cgi?id=3091 --- Comment #1 from Denys Vlasenko vda.li...@googlemail.com --- (In reply to comment #0) Created attachment 2845 [details] Patch to fix the issues Busybox sed does not

Re: [Bug 3097] BB making easily-fixed non-portable assumptions

2011-02-07 Thread Rich Felker
On Mon, Feb 07, 2011 at 08:10:48PM +0100, Joakim Tjernlund wrote: Relying on undef - 0 is dangerous. Much better build with -Wundef and fixup the errors. How is this dangerous? Undef - 0 is part of the C language at least since C89, and perhaps before that. Nobody is using pre-ANSI C compilers,

Re: [Bug 3097] BB making easily-fixed non-portable assumptions

2011-02-07 Thread Rich Felker
On Mon, Feb 07, 2011 at 11:13:03PM +0100, Joakim Tjernlund wrote: On Mon, Feb 07, 2011 at 08:10:48PM +0100, Joakim Tjernlund wrote: Relying on undef - 0 is dangerous. Much better build with -Wundef and fixup the errors. How is this dangerous? Undef - 0 is part of the C language at

Re: [Bug 3097] BB making easily-fixed non-portable assumptions

2011-02-08 Thread Rich Felker
On Tue, Feb 08, 2011 at 12:02:26AM +0100, Joakim Tjernlund wrote: On Mon, Feb 07, 2011 at 11:13:03PM +0100, Joakim Tjernlund wrote: On Mon, Feb 07, 2011 at 08:10:48PM +0100, Joakim Tjernlund wrote: Relying on undef - 0 is dangerous. Much better build with -Wundef and fixup the

Re: [Bug 3091] Nonportable tool usage in scripts

2011-02-08 Thread Rich Felker
On Tue, Feb 08, 2011 at 09:49:21PM +0100, Denys Vlasenko wrote: Also, the ? character is not special in POSIX BRE, and \? is not a conformant substitute. The portable solution is to use egrep instead of grep. Great, can you point out where exactly is that ?

Re: [Bug 3091] Nonportable tool usage in scripts

2011-02-08 Thread Rich Felker
On Wed, Feb 09, 2011 at 01:33:28AM +0100, Denys Vlasenko wrote: Oh, sorry. In scripts/mkconfigs, there are two occurrances of: grep '^#\? \?CONFIG_' $config \ they should read: egrep '^#? ?CONFIG_' $config \ I see that this '?' thing is a can of worms. I propose to sidestep it

Re: [PATCH] getty: Wait until all output written to stdout has been transmitted

2011-02-09 Thread Rich Felker
On Sun, Jan 23, 2011 at 08:05:44PM -0600, Rob Landley wrote: /* Optionally wait for CR or LF before writing /etc/issue */ if (option_mask32 F_WAITCRLF) { char ch; debug(waiting for cr-lf\n); while (safe_read(STDIN_FILENO, ch, 1) == 1) { debug(read

Re: [Bug 3091] Nonportable tool usage in scripts

2011-02-09 Thread Rich Felker
On Wed, Feb 09, 2011 at 12:26:41PM +0100, Ralf Friedl wrote: Denys Vlasenko wrote: On Wednesday 09 February 2011 00:56, Rich Felker wrote: Oh, sorry. In scripts/mkconfigs, there are two occurrances of: grep '^#\? \?CONFIG_' $config \ they should read: egrep '^#? ?CONFIG_' $config

Re: PLATFORM_LINUX is evil

2011-02-23 Thread Rich Felker
On Tue, Feb 22, 2011 at 11:16:46PM -0600, Rob Landley wrote: So if you start with allnoconfig and look to see what applets you can enable, things like mount don't exist for you unless you know to look for them. This adds a new layer of black magic and a-priori knowledge required in order to

Re: PLATFORM_LINUX is evil

2011-02-23 Thread Rich Felker
On Wed, Feb 23, 2011 at 10:58:09PM +, Mark Turner wrote: You wrote : There is plenty of usefulness to Busybox that is not Linux-dependent and that, contrary to what you wrote, is not trivial to reimplement. One great example is Busybox ash, which is the only lightweight POSIX-compatible

Re: spoiled for choice on ftp

2011-02-24 Thread Rich Felker
On Thu, Feb 24, 2011 at 09:39:16AM +0100, Harald Becker wrote: Hallo David! So the question is - can anyone explain/guess why it might have been worthwhile to go and get proftpd, when ftpd seems to be there, and to have been fine on the previous model? And in addition: Are you sure that

Re: update a running busybox

2011-03-30 Thread Rich Felker
On Wed, Mar 30, 2011 at 08:52:26AM -0700, Cathey, Jim wrote: One system I used, DNIX, would push an unlinked executing binary into swap space, then do the FS deletion. Was actually pretty nice, it 'just worked'. Once the last executing process died the swap space was released. There was

Re: update a running busybox

2011-03-30 Thread Rich Felker
On Wed, Mar 30, 2011 at 11:51:37AM -0700, Cathey, Jim wrote: In this (DNIX) system the file was not 'open' at the user level, and as a resident of swap space it didn't really have a device or an inode. (As data/bss segments did not. Just memory pages backed to a blocking store.) Even if it

Re: 'ls' output with '\\ \ ' on 1.18.4 - problem with dropbear+mc

2011-04-02 Thread Rich Felker
On Sat, Apr 02, 2011 at 08:40:08PM +0400, Sergey Naumov wrote: It seems that it is problem of new mc. I have similar problems with mc from Debian 6.0.0 and openssh. mc from debian 5.0.0 works fine with my busybox-based system. Parsing ls Output Considered Harmful. Rich

Re: [Bug 3091] Nonportable tool usage in scripts

2011-04-05 Thread Rich Felker
On Thu, Feb 10, 2011 at 09:33:32AM +0100, Denys Vlasenko wrote: While BusyBox supports it, the -r option to sed is nonstandard, so little is improved. If you want to go this route, use: sed -ne 's/\(^#\{0,1\} \{0,1\}CONFIG_.*\)$/\1\\n/gp' $config But really I don't care which solution

Re: [Bug 3091] Nonportable tool usage in scripts

2011-04-07 Thread Rich Felker
On Wed, Apr 06, 2011 at 08:33:13PM +0100, Chris Rees wrote: On 5 April 2011 16:43, Rich Felker dal...@aerifal.cx wrote: On Thu, Feb 10, 2011 at 09:33:32AM +0100, Denys Vlasenko wrote: While BusyBox supports it, the -r option to sed is nonstandard, so little is improved. If you want to go

Busybox portability issues and musl compatibility

2011-04-08 Thread Rich Felker
Hi, I am the author of musl (www.etalabs.net/musl) and also follow busybox development on and off. Recently one of my project's testers has been experimenting with building a musl+busybox based mini-distro. I've been working with him to resolve the build issues caused by things on my end, but

Re: Busybox portability issues and musl compatibility

2011-04-14 Thread Rich Felker
On Sat, Apr 09, 2011 at 12:21:00AM -0400, Rich Felker wrote: I am the author of musl (www.etalabs.net/musl) and also follow busybox development on and off. Recently one of my project's testers has been experimenting with building a musl+busybox based mini-distro. I've been working with him

Re: GNU-ism in sed use in build scripts

2011-04-15 Thread Rich Felker
On Fri, Apr 15, 2011 at 07:17:22PM +0100, Chris Rees wrote: Hi, Is it vital that 'sed --' is used in scripts/gen-build-files.sh? It uses the variable $srcdir, which is set in the Makefile to an absolute path; although of course it would normally be sensible to use -- when using a

Re: Busybox portability issues and musl compatibility

2011-04-17 Thread Rich Felker
On Sun, Apr 17, 2011 at 11:19:10PM +0200, Denys Vlasenko wrote: Finally, one thing that's not in the patch, but should be: Busybox's make config and make menuconfig require a some POSIX interfaces to be provided by the standard C headers, so on musl, HOSTCFLAGS containing

Re: Busybox portability issues and musl compatibility

2011-04-17 Thread Rich Felker
On Sun, Apr 17, 2011 at 11:19:10PM +0200, Denys Vlasenko wrote: Finally, one thing that's not in the patch, but should be: Busybox's make config and make menuconfig require a some POSIX interfaces to be provided by the standard C headers, so on musl, HOSTCFLAGS containing

Re: Busybox portability issues and musl compatibility

2011-04-20 Thread Rich Felker
On Sun, Apr 17, 2011 at 11:19:10PM +0200, Denys Vlasenko wrote: Finally, one thing that's not in the patch, but should be: Busybox's make config and make menuconfig require a some POSIX interfaces to be provided by the standard C headers, so on musl, HOSTCFLAGS containing

Re: [PATCH] make pidfile permissions 644, not 666

2011-04-29 Thread Rich Felker
On Fri, Apr 29, 2011 at 03:30:44PM -0700, Ian Wienand wrote: Hi, 666 seems too permissive for default pidfile permissions. man umask Rich ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox

Re: [PATCH] Compile options: default to -O2 when -Os is not available

2011-05-01 Thread Rich Felker
On Sun, May 01, 2011 at 02:00:27PM +0200, Wolfgang Denk wrote: chains). This commit changes behaviour so -O2 gets used as fallback when -Os is not available. This reduces the image size in above test to 1.3 MiB. This is still 10...15% more then what we get with -Os, but much better than

Re: [PATCH] portmap: new applet

2011-05-01 Thread Rich Felker
On Sun, May 01, 2011 at 07:38:27PM +0200, Marek Polacek wrote: +int portmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; +int portmap_main(int argc, char **argv) +{ + char *host = (char *)0.0.0.0; This cast is a no-op. This doesn't seem right. I think the `host' should be

Re: [PATCH] portmap: new applet

2011-05-02 Thread Rich Felker
On Mon, May 02, 2011 at 11:28:22AM +0200, Stefan Seyfried wrote: On Sun, 1 May 2011 18:13:34 -0400 Rich Felker dal...@aerifal.cx wrote: + char *host = (char *)0.0.0.0; This cast is a no-op. I think it's not. 0.0.0.0 is a (const char *) IIUC. Well you remember incorrectly. C

Re: [PATCH] have tar with GNU extensions use base-256 encoding for large fields

2011-05-04 Thread Rich Felker
On Wed, May 04, 2011 at 09:11:35PM +0200, Denys Vlasenko wrote: All this trouble just for the single one case where we store time? It's much easier to just add statbuf-st_mtime = 0 ? statbuf-st_mtime : 0 there. Agreed. Negative time is generally considered bogus. I don't see why lots of code

Re: all these warnings...

2011-05-04 Thread Rich Felker
On Thu, May 05, 2011 at 01:40:57AM +0200, Denys Vlasenko wrote: config/mconf.c came from kernel tree. I don't plan to maintain a fork, I plan to migrate to updated version from newer kernels. In this case, might I suggest we go back and put the feature test macros (_XOPEN_SOURCE and

Re: [Bug 3547] shell read is maybe too safe

2011-05-09 Thread Rich Felker
On Mon, May 09, 2011 at 01:20:16AM +0200, Denys Vlasenko wrote: Changing signal handling to a different scheme, where they are caught and recorded, will somewhat help, because now poll/read syscalls will be interruptible, but this creates another problem: many other sycalls may start failing

Re: [Bug 3547] shell read is maybe too safe

2011-05-09 Thread Rich Felker
On Mon, May 09, 2011 at 03:28:15PM +0200, Harald Becker wrote: I highly agree to this. It at least was the way it has been handled in bash (at the time I dig deep into bash code, 10 years ago). Don't know if this type of fd protection is still in there. Older shells even limited user fds to

Re: Using linux cryptographic api in busybox

2011-05-09 Thread Rich Felker
On Mon, May 09, 2011 at 09:58:05PM +0200, y...@klacno.sk wrote: const char *alg[] = { md5, sha1, sha224, sha256, sha384, sha512 }; This is a very bloated way of doing strings. Note that the pointer table is not even const! At least use const char *const

Re: [Fwd: Re: Using linux cryptographic api in busybox]

2011-05-09 Thread Rich Felker
On Mon, May 09, 2011 at 11:16:00PM +0200, y...@klacno.sk wrote: Thank you for suggestion, but this is only sample not suited for busybox. First I want to get some criticism if this is good idea before continue porting. I think it's a very good idea, tho I'm not someone to make decisions on

Re: BusyBox dynamic linked on uClibc for init? [resources usage] (fwd)

2011-05-12 Thread Rich Felker
On Fri, May 13, 2011 at 03:45:06AM +0200, Denys Vlasenko wrote: IOW: static i686 build, running on 64-bit kernel, consumes 46 mb of RAM per 1000 busybox sleep processes, or 46 kbytes per process. This is pretty good, but in theory it could be as low as 8k per process (1 page data and 1 page

Re: BusyBox dynamic linked on uClibc for init? [resources usage] (fwd)

2011-05-13 Thread Rich Felker
On Fri, May 13, 2011 at 11:48:40AM +0200, Denys Vlasenko wrote: On Friday 13 May 2011 06:00, Rich Felker wrote: On Fri, May 13, 2011 at 03:45:06AM +0200, Denys Vlasenko wrote: IOW: static i686 build, running on 64-bit kernel, consumes 46 mb of RAM per 1000 busybox sleep processes, or 46

Re: all these warnings...

2011-05-19 Thread Rich Felker
On Fri, May 20, 2011 at 03:54:18AM +0200, Denys Vlasenko wrote: On Thursday 05 May 2011 06:12, Rich Felker wrote: On Thu, May 05, 2011 at 01:40:57AM +0200, Denys Vlasenko wrote: config/mconf.c came from kernel tree. I don't plan to maintain a fork, I plan to migrate to updated version

Re: [PATCH] implement find -ipath

2011-05-21 Thread Rich Felker
On Sun, May 22, 2011 at 03:51:01AM +0200, Denys Vlasenko wrote: - return fnmatch(ap-pattern, fileName, 0) == 0; + return fnmatch(ap-pattern, fileName, (ap-ipath ? FNM_CASEFOLD : 0)) == 0; FNM_CASEFOLD is a nonportable GNU feature. This should be made optional, as this patch seems to

Re: [PATCH] implement find -ipath

2011-05-22 Thread Rich Felker
On Sun, May 22, 2011 at 04:35:11AM +0200, Denys Vlasenko wrote: Also, note that it's nearly impossible to implement case folding fnmatch without just implementing fnmatch in terms of regex, due to the complexity of Unicode case folding, so we have very good reason for not supporting this

Re: Ash eval wierdness

2011-05-25 Thread Rich Felker
On Wed, May 25, 2011 at 04:33:56PM +0200, Yann E. MORIN wrote: echo myvar=my value | while read opt; do [...] That's expected. All that is to the right part of the pipe is running in a sub-shell. So the evaluation is done in a sub-shell. So it is lost as soon as this sub-shell ends. The

Re: [PATCH 2/2] Added support for compiling against Android bionic

2011-05-30 Thread Rich Felker
On Mon, May 30, 2011 at 02:05:13PM -0700, Dan Fandrich wrote: It's not easy compiling something against bionic using the Android compiler outside the Android build system, but it can at least now happen. Signed-off-by: Dan Fandrich d...@coneharvesters.com --- Conditionally compiling

Re: [PATCH 2/2] Added support for compiling against Android bionic

2011-05-31 Thread Rich Felker
On Mon, May 30, 2011 at 11:14:35PM -0700, Dan Fandrich wrote: On Mon, May 30, 2011 at 07:48:05PM -0400, Rich Felker wrote: Plain ttyname could be used, I think. The only reason ttyname_r is used is to avoid enlarging bss for the nasty static buffer; it's not for reentrancy. This could also

Re: [PATCH 2/2] Added support for compiling against Android bionic

2011-06-01 Thread Rich Felker
On Wed, Jun 01, 2011 at 01:54:14PM +0200, Tito wrote: It does look like Walter Harms' suggestion of using sysconf() is the most portable way of getting this value. The attached patch makes that change. Why don't you just include #include asm/page.h asm/* is absolutely not portable and

Re: [PATCH 2/2] Added support for compiling against Android bionic

2011-06-01 Thread Rich Felker
On Wed, Jun 01, 2011 at 09:21:27AM -0700, Dan Fandrich wrote: On Wed, Jun 01, 2011 at 11:59:46AM +0200, walter harms wrote: I have no idea how common _sc_pagesize is. perhaps you should protect that _sc_pagesize like: #ifndef PAGE_SIZE #ifndef _sc_pagesize # error no way to find your

Re: [PATCH 4/5] Gate including net/ethernet.h on HAVE_NET_ETHERNET_H

2011-06-01 Thread Rich Felker
On Wed, Jun 01, 2011 at 01:36:20PM -0700, Dan Fandrich wrote: +#if defined(__GLIBC__) (__GLIBC__ 2 || __GLIBC_MINOR__ 1) +# undef HAVE_NET_ETHERNET_H +#endif This is nonsense. glibc older than 2.1 is definitely not usable. -#if (defined(__GLIBC__) __GLIBC__ = 2 __GLIBC_MINOR__ = 1) ||

Re: [PATCH 4/5] Gate including net/ethernet.h on HAVE_NET_ETHERNET_H

2011-06-02 Thread Rich Felker
On Wed, Jun 01, 2011 at 11:17:16PM -0700, Dan Fandrich wrote: I suspect this might break support for anything that lacks netpacket/packet.h, including musl. In general it's a very bad idea to use the same HAVE_* macro for two completely separate headers. In general, yes, but

Re: [PATCH 4/5] Gate including net/ethernet.h on HAVE_NET_ETHERNET_H

2011-06-02 Thread Rich Felker
On Thu, Jun 02, 2011 at 11:03:14AM -0700, Dan Fandrich wrote: The only serious case I can think of that might break with this would be alternate libcs on Linux, but given that most aim to be compatible with glibc, which is it? If musl (or any others you're aware of) doesn't have

Re: [PATCH 3/5] Use sysconf(_SC_PAGESIZE) to determine PAGE_SIZE

2011-06-03 Thread Rich Felker
On Fri, Jun 03, 2011 at 09:29:26PM +0200, Denys Vlasenko wrote: Moreover, PAGE_SIZE is only used for mallopt(M_TRIM_THRESHOLD, 2 * PAGE_SIZE); mallopt(M_MMAP_THRESHOLD, 8 * PAGE_SIZE - 256); We can simply use fixed constants instead. Agreed. The cleanest is: #ifndef

Re: Significant performance problem with modprobe

2011-06-12 Thread Rich Felker
On Thu, Apr 07, 2011 at 08:31:23PM +0100, Ed W wrote: Obviously fixing iptables is desirable, but is it possible to improve performance I think your time would be much better spent adding a sane version of iptables (without the hideous dlopen abomination) to Busybox. Then the problem would be

Re: [PATCH] Added replacement function for strverscmp

2011-06-13 Thread Rich Felker
On Mon, Jun 13, 2011 at 12:42:09PM -0700, Daniel Fandrich wrote: This is a GNU extension that isn't found in other libcs. [...] --- a/include/platform.h +++ b/include/platform.h @@ -348,6 +348,7 @@ typedef unsigned smalluint; #define HAVE_STRCHRNUL 1 #define HAVE_STRSEP 1 #define

Re: [PATCH] Added replacement function for strverscmp

2011-06-13 Thread Rich Felker
On Mon, Jun 13, 2011 at 01:13:55PM -0700, Dan Fandrich wrote: On Mon, Jun 13, 2011 at 03:47:39PM -0400, Rich Felker wrote: If it's nonstandard and glibc-only, shouldn't it be *undefined* by default and defined only if defined(__GLIBC__)!defined(__UCLIBC__) or similar? Practically all

Re: [PATCH] Added replacement function for strverscmp

2011-06-13 Thread Rich Felker
On Mon, Jun 13, 2011 at 02:57:46PM -0700, Dan Fandrich wrote: It's now used in ls -v, as of a few hours ago. The alternative would be to just surround the -v support with HAVE_STRVERSCMP and not provide a fallback implementation of strverscmp. I would hope -v support would be a build-time

Re: rewriting config_*, xmalloc_fget*

2011-06-15 Thread Rich Felker
On Wed, Jun 15, 2011 at 01:49:30PM +0300, Timo Teräs wrote: Hi all, As recently discussed on the 'Significant performance problems with modprobe', the config_* and xmalloc_fget* API has some performance issues: 1. It uses locking getc 2. It does malloc/realloc/free for each line read Now

Re: rewriting config_*, xmalloc_fget*

2011-06-15 Thread Rich Felker
On Wed, Jun 15, 2011 at 03:28:16PM +0300, Timo Teräs wrote: On 06/15/2011 03:14 PM, Rich Felker wrote: On Wed, Jun 15, 2011 at 01:49:30PM +0300, Timo Teräs wrote: Hi all, As recently discussed on the 'Significant performance problems with modprobe', the config_* and xmalloc_fget* API

Re: rewriting config_*, xmalloc_fget*

2011-06-15 Thread Rich Felker
On Wed, Jun 15, 2011 at 04:04:52PM +0300, Timo Teräs wrote: Mmm.. yeah, uclibc needs fixing here. I'm still slightly doubtful how much the performance difference would be actually. It probably depends on the line lengths totally. On small lines, it's not much. On really long lines, it could be

Re: rewriting config_*, xmalloc_fget*

2011-06-15 Thread Rich Felker
On Wed, Jun 15, 2011 at 04:47:39PM +0300, Timo Teräs wrote: In any case, the difference is *very* small at least on x86 (including SMP/multicore). The cost of the lock xchg vs if (threads1) is something like 50 cycles, and if I remember right, making my implementation always perform

Re: rewriting config_*, xmalloc_fget*

2011-06-16 Thread Rich Felker
On Thu, Jun 16, 2011 at 02:53:41PM +0100, Nuno Lucas wrote: On 06/16/2011 05:51 AM, Timo Teräs wrote: Notably, though, at least sed.c seems to rely on the fact that \n and \0 are both recognized, and jumps through many hoops to handle them both properly. Apparently there's out some sed scripts

Re: rewriting config_*, xmalloc_fget*

2011-06-16 Thread Rich Felker
On Thu, Jun 16, 2011 at 10:26:53AM -0700, Cathey, Jim wrote: There are exactly two characters (of an unsigned char) that cannot be in a Unix filename: '/', which is the path component separator, and '\0'. Everything else, including newlines and spaces, is perfectly legal in a filename,

Re: rewriting config_*, xmalloc_fget*

2011-06-16 Thread Rich Felker
On Thu, Jun 16, 2011 at 03:16:38PM -0400, Paul Smith wrote: PS. Interestingly, there's a move afoot to remove newline from the set of acceptable characters in a POSIX-compliant filename... Do you have details on this? It's interesting because aside from the '/' (which is granted special

Re: rewriting config_*, xmalloc_fget*

2011-06-16 Thread Rich Felker
On Thu, Jun 16, 2011 at 10:12:13PM +0200, Laurent Bercot wrote: Sure -print0 required almost no change in the code for find, but it requires significant change in any program using the output of find. I maintain that shell quoting would have been a much better choice. And it would have

Re: rewriting config_*, xmalloc_fget*

2011-06-17 Thread Rich Felker
On Fri, Jun 17, 2011 at 12:27:29PM +0200, Bernd Petrovitsch wrote: Transformation in the other direction is virtually impossible using the shell and standard utilities - the only way would be to pipe I wouldn't call echo -n $quoted | tr \000 \012 This is useless because you can no longer

Re: [PATCH 3/3] parse_config: use getline to read config

2011-06-19 Thread Rich Felker
On Sun, Jun 19, 2011 at 01:08:53PM +0200, Denys Vlasenko wrote: On both machines speedup is not so big. Hash seems to help more then getline: on F15, it reduced run time from 19 to 16 seconds, while getline won ~0.5 sec only. For what it's worth, getline should make a much more dramatic

Re: [PATCH 2/3] platform: provide getline and getdelim if not available

2011-06-20 Thread Rich Felker
On Mon, Jun 20, 2011 at 10:21:02AM +0200, Denys Vlasenko wrote: Since we don't use getdelim, maybe we should only implement getline? How about just making getdelim static inline until if/when it's needed? That would keep the code nicely factored and should eliminate any cost to leaving it there.

Re: [PATCH 2/3] platform: provide getline and getdelim if not available

2011-06-27 Thread Rich Felker
On Mon, Jun 27, 2011 at 11:37:10AM -0700, Dan Fandrich wrote: On Mon, Jun 20, 2011 at 10:21:02AM +0200, Denys Vlasenko wrote: On Saturday 18 June 2011 17:56, Timo Teräs wrote: Simple implementations. Need to check which platforms need the wrapper. Leaks line on error path. I think you

Re: [PATCH 2/3] platform: provide getline and getdelim if not available

2011-06-28 Thread Rich Felker
On Wed, Jun 29, 2011 at 04:43:58AM +0200, Denys Vlasenko wrote: Are you just waiting for an update on this patch to push it in? The current code in git fails to compile on non-GNU systems because of missing getline(). Applied the fix. Please try current git. Wouldn't it be better to use

Re: [PATCH 2/3] platform: provide getline and getdelim if not available

2011-06-29 Thread Rich Felker
On Wed, Jun 29, 2011 at 10:54:34AM +0200, Denys Vlasenko wrote: On Wednesday 29 June 2011 04:45, Rich Felker wrote: On Wed, Jun 29, 2011 at 04:43:58AM +0200, Denys Vlasenko wrote: Are you just waiting for an update on this patch to push it in? The current code in git fails to compile

Re: [1.16.2] Can't stop ping with CTRL+c

2011-07-04 Thread Rich Felker
On Mon, Jul 04, 2011 at 06:55:42PM +0200, Gilles wrote: On Mon, 04 Jul 2011 10:28:39 -0400, Chuck Meade chuckme...@mindspring.com wrote: http://www.busybox.net/FAQ.html#job_control Thanks for the tip. Busybox's inittab doesn't mention /dev/console: === # Startup the system

Re: [1.16.2] Can't stop ping with CTRL+c

2011-07-08 Thread Rich Felker
On Fri, Jul 08, 2011 at 09:33:30AM +0200, Denys Vlasenko wrote: What would cause TIOCGSERIAL to be undefined while __linux__ is defined, or vice versa? Is that intended to support really old kernels, broken system headers, or something else? There is probably no deep wisdom behind it. I

Re: No brace expansion for ash?

2011-07-10 Thread Rich Felker
On Sun, Jul 10, 2011 at 06:09:01AM +0100, Davide wrote: Thirdly I somewhat disagree that using for instead of brace expansion would make any shell script more readable: mkdir -p /usr/local/people/{me,you,others} mkdir -p /usr/local/people/me /usr/local/people/you /usr/local/people/others

Re: Doesn't build under Linux 3.0?

2011-07-23 Thread Rich Felker
On Sat, Jul 23, 2011 at 05:50:53PM -0500, Rob Landley wrote: On 07/23/2011 05:29 PM, Douglas Mencken wrote: Well, sed -i '/Include our own copy of struct sysinfo/{NN;d}' ./include/libbb.h **doesn't work** as expected (successful build): init/init.c:1010:18: error: storage

Re: Doesn't build under Linux 3.0?

2011-07-25 Thread Rich Felker
On Mon, Jul 25, 2011 at 08:28:21AM +0200, Laurent Bercot wrote: Because they are Unix tools, i.e. they do one thing and do it well. The netcat utility, as you say, has a 'server mode'. But clients and servers aren't the same thing. Yup, I went there: netcat is bloated. The real question

Re: enforce maxlength in usernames

2011-07-28 Thread Rich Felker
On Thu, Jul 28, 2011 at 10:29:01PM +0200, Matthias Andree wrote: /* For example, name like .. can make adduser * chown /home/.. recursively - NOT GOOD */ do { if (*name == '-' || *name == '.') continue; skip: if

Re: enforce maxlength in usernames

2011-07-29 Thread Rich Felker
On Fri, Jul 29, 2011 at 04:30:53PM +0200, Tito wrote: Hi, after more research about this topic I've found a few interesting things about this can of worms I've unknowningly uncovered: 1) 3.426 User Name A string that is used to identify a user; see also User Database. To be portable

Re: [PATCH] 2nd try: improve checks on usernames

2011-08-02 Thread Rich Felker
On Tue, Aug 02, 2011 at 03:37:35PM +0200, walter harms wrote: granted, ntl it would be nice to have a better error that it does not work. Perhaps (s-name) = position ? illegal character at position %d,(s-name) ? wfprintf(stderr, illegal character %.1s\n, s); I'm sure everyone will flame me for

Re: [PATCH] improve checks on usernames V3.

2011-08-03 Thread Rich Felker
On Wed, Aug 03, 2011 at 10:19:55AM +0200, Ralf Friedl wrote: ... just to throw that in. Beside this I like to use User Names with German Umlauts (ÄÖÜäöü) as regular German names may contain those. And I did this successfully on Linux/GNU systems for years ... but know about incompatibility and

Re: [PATCH] improve checks on usernames V3.

2011-08-08 Thread Rich Felker
of the portable filename character set plus '@' and '$'; 3) don't use isalnum as it will allow non-ASCII letters in legacy 8-bit locales as pointed out by Rich Felker; We use ASCII-only isalnum throughout bbox anyway. But ok. Do you mean you have a special isalnum for ASCII-only, or you assume

Re: [PATCH] improve checks on usernames V3.

2011-08-09 Thread Rich Felker
On Tue, Aug 09, 2011 at 09:37:58AM +0200, Denys Vlasenko wrote: #define isalnum(a) bb_ascii_isalnum(a) static ALWAYS_INLINE int bb_ascii_isalnum(unsigned char a) { unsigned char b = a - '0'; if (b = 9) return (b = 9); b = (a|0x20) - 'a';

Re: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground

2011-08-17 Thread Rich Felker
On Wed, Aug 17, 2011 at 03:13:09PM +0200, Denys Vlasenko wrote: This means that the programs you start from the command line, inheriting the shell's stdin/out/err can influence them, and by extension, influence all further programs to be launched. Yes, this is a bug in Unix API.

Re: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground

2011-08-17 Thread Rich Felker
On Wed, Aug 17, 2011 at 10:09:52PM +0200, Laurent Bercot wrote: This is by design and part of how multi-tool script programming works. The Unix design is that scions (via fork() and execve()) inherit stuff from their ancestors. If I'm running nice shoes and the nice program sets stdin

Re: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground

2011-08-17 Thread Rich Felker
On Thu, Aug 18, 2011 at 12:16:30AM +0200, Denys Vlasenko wrote: On Wednesday 17 August 2011 23:20, Rich Felker wrote: I hate it when fools who don't know what they're doing and don't respect standards lobby for nonstandard behavior in Linux, thereby making the portability landscape *worse

Re: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground

2011-08-17 Thread Rich Felker
On Thu, Aug 18, 2011 at 12:45:57AM +0200, Laurent Bercot wrote: Look at multitee: http://code.dogmap.org/fdtools/multitee/ Don't you agree that the *natural* way to write such a program would be an asynchronous loop? Yet, for the very same reason, the author jumped through hoops to avoid

Re: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground

2011-08-17 Thread Rich Felker
On Thu, Aug 18, 2011 at 12:56:09AM +0200, Laurent Bercot wrote: How can I do nonblocking read from fd 0 without affecting other processes which might share it? Assuming no other process will be reading at the same time, you simply call poll first (or select, but select requires the fd #

Re: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground

2011-08-18 Thread Rich Felker
On Thu, Aug 18, 2011 at 08:04:27AM +0200, Laurent Bercot wrote: Nobody decided to accept/include gets. What was decided is the general principle that POSIX is a superset of ISO/IEC 9899:1999, and that in any areas where the two conflict, the conflict is unintentional and the latter (C)

Re: [OT] poll() vs. AIO (was: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground)

2011-08-18 Thread Rich Felker
On Fri, Aug 19, 2011 at 12:36:32AM +0200, Denys Vlasenko wrote: (very) pseudo-code of the good main application loop: while (read(tqfd, event, sizeof event) == sizeof event) switch (event) { case keystroke: ... case menu_item: ... case

Re: [OT] poll() vs. AIO (was: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground)

2011-08-18 Thread Rich Felker
On Fri, Aug 19, 2011 at 05:03:03AM +0200, Laurent Bercot wrote: that era) did not. (In single-CPU systems, which most DNIX boxes were, LWP's are just a way to reorganize the problem and offer no inherent performance or maintainability advantage over an AIO approach, and might actually be

Re: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground

2011-08-19 Thread Rich Felker
On Fri, Aug 19, 2011 at 11:36:43AM +0200, Bernd Petrovitsch wrote: On Fre, 2011-08-19 at 06:55 +0200, Denys Vlasenko wrote: On Thursday 18 August 2011 07:34, Laurent Bercot wrote: It doesn't; it can't. Hence my ranting. A 100% safe 100% orthogonal, useful easy-to-use AIO mechanism

Re: [OT] poll() vs. AIO (was: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground)

2011-08-19 Thread Rich Felker
On Fri, Aug 19, 2011 at 10:03:40AM -0700, Cathey, Jim wrote: Threads are also purely a question of taste. Rich likes them. Lots of people like them. I don't. Alan Cox doesn't. YMMV. I'm torn. Sometimes good, sometimes bad. We're actually having very good luck using them in our product at

Re: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground

2011-08-19 Thread Rich Felker
On Fri, Aug 19, 2011 at 05:17:52PM +0200, Harald Becker wrote: Hallo Rich! sigfillset(set); sigprocmask(SIG_BLOCK, set, 0); sigemptyset(set); sigaddset(set, SIGTERM); /* and any others I want to handle */ sigprocmask(SIG_UNBLOCK, set, 0); This is a lot more robust. Robust yes

Re: [OT] poll() vs. AIO (was: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground)

2011-08-20 Thread Rich Felker
On Sat, Aug 20, 2011 at 01:37:23AM +0200, Bernd Petrovitsch wrote: Multiprocessing can accomplish *some* of the same things, but not all, What does multiprocessing exactly mean? Writing a program that consists of more than one process running in parallel. - A library can't fork new

Re: [OT] poll() vs. AIO

2011-08-20 Thread Rich Felker
On Sat, Aug 20, 2011 at 06:06:04PM +0200, Bernd Petrovitsch wrote: On Sam, 2011-08-20 at 10:00 -0400, Rich Felker wrote: On Sat, Aug 20, 2011 at 01:37:23AM +0200, Bernd Petrovitsch wrote: Multiprocessing can accomplish *some* of the same things, but not all, [] Note that just using

Re: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground

2011-08-20 Thread Rich Felker
On Sat, Aug 20, 2011 at 11:26:30PM +0200, Denys Vlasenko wrote: Guys, can you semd emails to lkml and advocate for recv/send to be enabled for non-sockets? Sorry, first you need to try to get this changed: http://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html ERRORS The recv()

  1   2   3   4   >