busybox Digest, Vol 48, Issue 21

Seif Abaza abazuos at gmail.com
Fri Jul 10 06:46:57 UTC 2009


Hi 4 all , how can i help you?

On 7/10/09, busybox-request at busybox.net <busybox-request at busybox.net> wrote:
> Send busybox mailing list submissions to
> 	busybox at busybox.net
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://lists.busybox.net/mailman/listinfo/busybox
> or, via email, send a message with subject or body 'help' to
> 	busybox-request at busybox.net
>
> You can reach the person managing the list at
> 	busybox-owner at busybox.net
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of busybox digest..."
>
>
> Today's Topics:
>
>    1. Re: init: wait for sysinit completion (Denys Vlasenko)
>    2. Re: sed behaving strangely when -n and the delete command are
>       combined (Denys Vlasenko)
>    3. Re: No ?command? command in busybox? (Denys Vlasenko)
>    4. Re: busybox and upx on arm (Denys Vlasenko)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 9 Jul 2009 15:43:39 +0200
> From: Denys Vlasenko <vda.linux at googlemail.com>
> Subject: Re: init: wait for sysinit completion
> To: Anna Martynova <terrible.broom at gmail.com>
> Cc: busybox at busybox.net
> Message-ID:
> 	<1158166a0907090643x2bb4e5c3i6d261597f1e2a981 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Thu, Jul 9, 2009 at 12:26 PM, Anna Martynova<terrible.broom at gmail.com>
> wrote:
>> Hello, all.
>> At the moment I am upgrading my system from busybox 1.8.2 to 1.14.2. I
>> found
>> such difference in init behavior: in old version 'sysinit' action was
>> called
>> with run() function, so other init actions (such as 'askfirst' - shells on
>> virtual consoles) could be running at the same time. But in the latest
>> version sysinit action is called with waitfor() function, and all other
>> actions wait for it's completion.
>> I found this place in source and changed 'waitfor' to 'run' to check my
>> guess. But the question still exists:
>> What for it has been made? For now I have no idea, from where I can call
>> other start scripts, except rcS... But I need virtual consoles. :)
>> Thanks in advance.
>
> Looks like it was a bug. Sysinit action(s) should be waited for.
> This is what init.c says:
>
> /* Each type of actions can appear many times. They will be
>  * handled in order. RESTART is an exception, only 1st is used.
>  */
> /* Start these actions first and wait for completion */
> #define SYSINIT     0x01
> /* Start these after SYSINIT and wait for completion */
> #define WAIT        0x02
> /* Start these after WAIT and *dont* wait for completion */
> #define ONCE        0x04
> /*
>  * NB: while SYSINIT/WAIT/ONCE are being processed,
>  * SIGHUP ("reread /etc/inittab") will be ignored.
>  * Rationale: it would be ambiguous whether SYSINIT/WAIT/ONCE
>  * need to be rerun or not.
>  */
> /* Start these after ONCE are started, restart on exit */
> #define RESPAWN     0x08
> /* Like RESPAWN, but wait for <Enter> to be pressed on tty */
> #define ASKFIRST    0x10
> /*
>  * Start these on SIGINT, and wait for completion.
>  * Then go back to respawning RESPAWN and ASKFIRST actions.
>  * NB: kernel sends SIGINT to us if Ctrl-Alt-Del was pressed.
>  */
> #define CTRLALTDEL  0x20
> /*
>  * Start these before killing all processes in preparation for
>  * running RESTART actions or doing low-level halt/reboot/poweroff
>  * (initiated by SIGUSR1/SIGTERM/SIGUSR2).
>  * Wait for completion before proceeding.
>  */
> #define SHUTDOWN    0x40
> /*
>  * exec() on SIGQUIT. SHUTDOWN actions are started and waited for,
>  * then all processes are killed, then init exec's 1st RESTART action,
>  * replacing itself by it. If no RESTART action specified,
>  * SIGQUIT has no effect.
>  */
> #define RESTART     0x80
>
>
> Looks like you can use "once" to achieve what you want.
> --
> vda
>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 9 Jul 2009 15:50:31 +0200
> From: Denys Vlasenko <vda.linux at googlemail.com>
> Subject: Re: sed behaving strangely when -n and the delete command are
> 	combined
> To: Rob Landley <rob at landley.net>
> Cc: busybox at busybox.net
> Message-ID:
> 	<1158166a0907090650t32c1b7a8rd3206403e8fe4028 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> On Thu, Jul 9, 2009 at 1:36 PM, Rob Landley<rob at landley.net> wrote:
>> On Wednesday 08 July 2009 07:28:42 Denys Vlasenko wrote:
>>> On Wed, Jul 8, 2009 at 12:16 PM, Rob Landley<rob at landley.net> wrote:
>>> > As far as I can tell, we're in compliance with SUSv4 and your sed
>>> > command
>>> > isn't. ?(Of course gnu has magic extensions out the wazoo and your
>>> > program expects them. ?I guess what you're asking is "please implement
>>> > this funky gnu extension that makes numeric addresses special, even
>>> > when
>>> > the ending case is a regex...)
>>>
>>> I think he just wants hit eglibc build to finish, and
>>> currently the obstacle is that our sed differs from GNU one.
>>>
>>> In order to "take over the world" (as documented in our FAQ) ;]
>>> it makes sense to emulate GNU sed.
>>
>> *shrug* ?Ok.
>>
>> However, the desired behavior is a little more complex than it appears.
>> ?This
>> range starts with a number and ends with a regex, so you can't just say
>> that
>> it continues until < endpoint because the endpoint isn't a number.
>>
>> Also remember that ranges that both start and end with a regex can trigger
>> more than once. ?Therefore, in order to make the start work as >= instead
>> of
>> ==, you have to _disable_ the starting condition after the first time it
>> triggers. ?(Otherwise, every line after that is >=, including the line
>> after
>> the ending regex, so the range never ends. ?Or more accurately,
>> immediately
>> restarts itself.)
>
> That's what the patch did:
>
> +                               if (n && sed_cmd->beg_line > 0) {
> +                                       /* Once matched, "n,regex"
> range is dead, disabling it */
> +                                       regfree(sed_cmd->end_match);
> +                                       free(sed_cmd->end_match);
> +                                       sed_cmd->end_match = NULL;
> +                               }
>
>> That said, this change isn't nearly complex enough to justify 250 lines
>> worth
>> of changes:
>>
>> ?editors/sed.c ? ? ? | ?462
>> ++++++++++++++++++++++++++--------------------------
>> ?testsuite/sed.tests | ? 13 +
>> ?2 files changed, 252 insertions(+), 223 deletions(-)
>>
>> I only looked through the first two pages of that patch, which seemed to
>> be
>> full of random unrelated stuff, and then started doing range comparisons
>> that
>> don't seem right. ?But the way this patch is structured, it's really hard
>> to
>> see what you actually changed and what's noise.
>
>
> Please find attached patch which has indentation change filtered out.
> --
> vda
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: z.diff
> Type: text/x-patch
> Size: 4804 bytes
> Desc: not available
> URL:
> <http://lists.busybox.net/pipermail/busybox/attachments/20090709/82a2564b/attachment-0001.bin>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 9 Jul 2009 22:59:38 +0200
> From: Denys Vlasenko <vda.linux at googlemail.com>
> Subject: Re: No ?command? command in busybox?
> To: busybox at busybox.net
> Message-ID: <200907092259.38939.vda.linux at googlemail.com>
> Content-Type: text/plain;  charset="utf-8"
>
> On Tuesday 07 July 2009 23:16, Karl Ove Hufthammer wrote:
>> I have just started using busybox, and am impressed by the speed of
>> some of its utilities. However, when I tried using it on one of my
>> POSIX-based scripts, I got an error messages indicating that the ?command?
>>
>> command isn?t implemented.
>>
>> Here is an example script, which gives ?command: not found? errors when
>> run
>> through busybox ash or sh:
>>
>> ---
>> command -v grep
>> command -v ls
>> ---
>>
>> The ?command? command is defined in POSIX:
>> http://www.opengroup.org/onlinepubs/009695399/utilities/command.html
>>
>> I?m using the binary builds for my distro (Mandriva 2009.1), so initially
>> I
>> expected that some compile options were missing when building this.
>> However, looking at the list of commands at
>> http://www.busybox.net/downloads/BusyBox.html
>> it seems there really is no ?command? command. Is this true, and is there
>> any
>> reason why? It does seem like quite a simple command. :)
>
> Those are applets. "command" is not an applet, it's a shell builtin.
>
> ash supports it:
>
> # ./busybox ash
> /.1/usr/srcdevel/bbox/fix/busybox.t1 # command -v grep
> /bin/grep
>
> However, hush does not:
>
> # ./busybox hush
> /.1/usr/srcdevel/bbox/fix/busybox.t1 # command -v grep
> hush: can't execute 'command': No such file or directory
>
> What is the version of busybox you tried?
>
> --
> vda
>
>
> ------------------------------
>
> Message: 4
> Date: Thu, 9 Jul 2009 23:21:06 +0200
> From: Denys Vlasenko <vda.linux at googlemail.com>
> Subject: Re: busybox and upx on arm
> To: busybox at busybox.net
> Message-ID: <200907092321.06213.vda.linux at googlemail.com>
> Content-Type: text/plain;  charset="iso-8859-1"
>
> On Tuesday 07 July 2009 21:45, Tito wrote:
>> Hi,
>> I'm experiencing a strange behaviour of busybox.
>> I'm trying to use upx on an android g1 phone.
>> So far I was able to cross-compile a statically linked
>> and working copy of upx
>> upx compresses the executables on the phone just fine,
>> only busybox seems not to work as expected.
>> upx compresses it but when the compressed
>> busybox is launched it runs the command as
>> expected but never returns to the shell unless it is killed.
>> The only suspect log i can see after killing it is:
>>
>> <3>[ 3261.966003] init: untracked pid 5064 exited
>> <3>[ 3290.064056] init: untracked pid 5066 exited
>> <3>[ 3339.908325] init: untracked pid 5069 exited
>>
>> Any hints about what is going wrong here?
>>
>> BTW: busybox packed with upx on x86 works.
>>
>> /system/sd # ./upx busybox
>>                        Ultimate Packer for eXecutables
>>                           Copyright (C) 1996 - 2009
>> UPX 3.04        Markus Oberhumer, Laszlo Molnar & John Reiser   Apr 27th
>> 2009
>>
>>         File size         Ratio      Format      Name
>>    --------------------   ------   -----------   -----------
>>     690276 ->    381428   55.26%   linux/armel   busybox
>>
>> Packed 1 file.
>> /system/sd # ./busybox
>> BusyBox v1.14.2 (2009-07-01 18:27:27 EDT) multi-call binary
>> Copyright (C) 1998-2008 Erik Andersen, Rob Landley, Denys Vlasenko
>> and others. Licensed under GPLv2.
>> See source distribution for full notice.
>>
>> Usage: busybox [function] [arguments]...
>>    or: function [arguments]...
>>
>>         BusyBox is a multi-call binary that combines many common Unix
>>         utilities into a single executable.  Most people will create a
>>         link to busybox for each function they wish to use and BusyBox
>>         will act like whatever it was invoked as!
>>
>> Currently defined functions:
>>         [, [[, arping, ash, awk, basename, bbconfig, bunzip2, bzcat,
>>         bzip2, cat, catv, chgrp, chmod, chown, chroot, chrt, chvt, cksum,
>>         clear, cmp, cp, cpio, crond, crontab, cut, date, dc, dd,
>> deallocvt,
>>         depmod, devmem, df, dhcprelay, diff, dirname, dmesg, dnsd,
>> dos2unix,
>>         du, dumpkmap, dumpleases, echo, egrep, env, ether-wake, expr,
>>         false, fbset, fdisk, fgrep, find, fold, free, freeramdisk, fuser,
>>         getopt, grep, gunzip, gzip, head, hexdump, hostname, hwclock,
>>         ifconfig, ifdown, ifup, insmod, install, ip, ipaddr, iplink,
>>         iproute, iprule, iptunnel, kbd_mode, kill, killall, killall5,
>>         last, length, less, ln, loadfont, loadkmap, losetup, ls, lsmod,
>>         makedevs, md5sum, mdev, mkdir, mkfifo, mknod, mkswap, mktemp,
>>         modprobe, more, mount, mountpoint, mv, nameif, nc, netstat,
>>         nice, nohup, nslookup, od, openvt, patch, pidof, ping,
>> pipe_progress,
>>         pivot_root, printenv, printf, ps, pwd, rdate, rdev, readlink,
>>         readprofile, realpath, renice, reset, rm, rmdir, rmmod, route,
>>         run-parts, sed, seq, setconsole, setkeycodes, setlogcons, setsid,
>>         sh, sha1sum, showkey, sleep, sort, split, stat, strings, stty,
>>         swapoff, swapon, switch_root, sync, sysctl, tac, tail, tar,
>>         tcpsvd, tee, telnet, telnetd, test, tftp, time, top, touch,
>>         tr, traceroute, true, tty, udhcpd, udpsvd, umount, uname, uniq,
>>         unix2dos, unzip, uptime, usleep, uudecode, uuencode, vconfig,
>>         vi, watch, wc, wget, which, who, whoami, xargs, yes, zcat
>> Killed
>
> Try in libbb/appletlib.c:
>
>
> void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv)
> {
>         int argc = 1;
>
>         while (argv[argc])
>                 argc++;
>
>         /* Reinit some shared global data */
>         xfunc_error_retval = EXIT_FAILURE;
>
>         applet_name = APPLET_NAME(applet_no);
>         if (argc == 2 && strcmp(argv[1], "--help") == 0) {
>                 /* Special case. POSIX says "test --help"
>                  * should be no different from e.g. "test --foo".  */
> //TODO: just compare applet_no with APPLET_NO_test
>                 if (!ENABLE_TEST || strcmp(applet_name, "test") != 0)
>                         bb_show_usage();
>         }
>         if (ENABLE_FEATURE_SUID)
>                 check_suid(applet_no);
>         exit(applet_main[applet_no](argc, argv));
> }
>
> Replace
>         exit(applet_main[applet_no](argc, argv));
> with
>         printf("Entering applet_main\n");
>         n = applet_main[applet_no](argc, argv);
>         printf("Exited epplet_main, exiting...\n");
>         exit(n);
>
> and let me know hat do you see when you run "busybox true".
> --
> vda
>
>
> ------------------------------
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
>
> End of busybox Digest, Vol 48, Issue 21
> ***************************************
>

-- 
Sent from my mobile device


More information about the busybox mailing list