aboutsummaryrefslogtreecommitdiff
path: root/libbb/appletlib.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
| * fix breakage found by mass one-applet buildsDenys Vlasenko2016-12-231-16/+16
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2016-11-291-9/+17
|\|
| * Do not print useless empty line after list of appletsDenys Vlasenko2016-11-281-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Fix allnoconfig warningsDenys Vlasenko2016-11-181-8/+16
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch busybox (up to "ash: comment out free(p) just before...")Ron Yorston2016-10-191-1/+11
|\|
| * hush: add commented-out debug printouts in "memleak" built-inDenys Vlasenko2016-10-031-0/+8
| | | | | | | | | | | | | | Allocation addresses of malloc() are jittery, thought I had a mem leak in hush, but it was malloc variability. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix a bug in FEATURE_SH_STANDALONE=y config. Closes 9186Denys Vlasenko2016-08-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Run this in a "sh SCRIPT": sha256sum /dev/null echo END sha256sum is a NOEXEC applet. It runs in a forked child. Then child exit()s. By this time, entire script is read, and buffered in a FILE object from fopen("SCRIPT"). But fgetc() did not consume entire input. exit() lseeks back by -9 bytes, from <eof> to 'e' in 'echo'. (this may be libc-specific). This change of fd position *is shared with the parent*! Now parent can read more, and it thinks there is another "echo END". End result: two "echo END"s are run. Fix this by _exit()ing instead. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2016-07-071-28/+35
|\|
| * build system: fix a few warnings for allnoconfig buildDenys Vlasenko2016-07-051-13/+17
| | | | | | | | | | | | Not that allnoconfig build is useful in any way... Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: suppress warning about run_applet_and_exitRon Yorston2016-07-051-2/+2
| | | | | | | | | | | | | | | | | | | | When busybox is configured to contain a single applet an unnecessary declaration of run_applet_and_exit results in a warning. Move the declaration to avoid this. Reported-by: Lauri Kasanen <curaga@operamail.com> Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: move common code into run_applet_and_exitRon Yorston2016-06-191-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both calls to run_applet_and_exit are followed by the same code to print an error message and return status 127. Remove this duplication and make run_applet_and_exit static. function old new delta run_applet_and_exit 675 667 -8 main 119 92 -27 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-35) Total: -35 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Allow "busybox <applet>" to work when busybox is disabledRon Yorston2016-06-181-0/+4
| | | | | | | | | | | | | | | | | | A recent commit made it possible to disable BusyBox's --install and --list options. However it also stopped "busybox <applet> <params>" from working. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Make busybox an optional appletDenys Vlasenko2016-05-311-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If it's disabled, code shrinks by about 900 bytes: function old new delta usr_bin 10 - -10 usr_sbin 11 - -11 install_dir 20 - -20 applet_install_loc 184 - -184 run_applet_and_exit 686 21 -665 ------------------------------------------------------------------------------ (add/remove: 0/4 grow/shrink: 0/1 up/down: 0/-890) Total: -890 bytes text data bss dec hex filename 911327 493 7336 919156 e0674 busybox_old 909848 493 7336 917677 e00ad busybox_unstripped but busybox executable by itself does not say anything useful: $ busybox busybox: applet not found Based on the patch by Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2016-05-161-1/+2
|\|
| * Rewrite iteration through applet names to save a few bytesRon Yorston2016-04-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta run_applet_and_exit 758 755 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3) Total: -3 bytes In standalone shell mode the saving increases to 17 bytes. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | mingw: enable busybox --install by defaultRon Yorston2016-04-061-2/+40
| | | | | | | | | | | | | | | | | | | | | | Allow FEATURE_INSTALLER to be configured and enable it in the default configuration. The behaviour is slightly different from upstream BusyBox: symbolic links are not permitted; if no target directory is provided the directory containing the busybox binary is used as the target.
* | Merge branch 'busybox' into mergeRon Yorston2016-04-041-26/+140
|\|
| * find_applet_by_name: loop index should be signedRon Yorston2016-04-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | The loop for (j = ARRAY_SIZE(applet_nameofs)-1; j >= 0; j--) { was intended to terminate when j goes negative, so j needs to be signed. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * main(): add a TODO about finding a use for _end[] areaDenys Vlasenko2016-04-031-0/+13
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * typo fixDenys Vlasenko2016-04-021-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * find_applet_by_name: add an example of faster linear search codeDenys Vlasenko2016-04-021-3/+77
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * applet_tables: save space by removing applet name offsetsRon Yorston2016-03-301-28/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The array applet_nameofs consumes two bytes per applet. It encodes nofork/noexec flags suid flags the offset of the applet name in the applet_name string Change the applet_table build tool to store the flags in two separate arrays (applet_flags and applet_suid). Replace applet_nameofs[] with a smaller version that only stores a limited number of offsets. This requires changes to the macros APPLET_IS_NOFORK, APPLET_IS_NOEXEC and APPLET_SUID. According to Valgrind the original find_applet_by_name required 353 cycles per call, averaged over all names. Adjusting the number of known offsets allows space to be traded off against execution time: KNOWN_OFFSETS cycles bytes (wrt KNOWN_OFFSETS = 0) 0 9057 - 2 4604 32 4 2407 75 8 1342 98 16 908 130 32 884 194 This patch uses KNOWN_OFFSETS = 8. v2: Remove some dead code from the applet_table tool; Treat the applet in the middle of the table as a special case. v3: Use the middle applet to adjust the start of the linear search as well as the last applet found. v4: Use an augmented linear search in find_applet_by_name. Drop the special treatment of the middle name from get_applet_name: most of the advantage now derives from the last stored value. v5: Don't store index in applet_nameofs, it can be calculated. v6: Tweaks by Denys function old new delta find_applet_by_name 25 125 +100 applet_suid - 92 +92 run_applet_no_and_exit 452 460 +8 run_applet_and_exit 695 697 +2 applet_name_compare 31 - -31 applet_nameofs 734 14 -720 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 3/1 up/down: 202/-751) Total: -549 bytes text data bss dec hex filename 925464 906 17160 943530 e65aa busybox_old 924915 906 17160 942981 e6385 busybox_unstripped Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2015-10-311-5/+5
|\|
| * busybox: alter help message in standalone shell modeRon Yorston2015-10-301-0/+9
| | | | | | | | | | Signed-off-by: Ron Yorston <rmy@frippery.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: factor out code which queries screen widthDenys Vlasenko2015-10-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta get_terminal_width - 17 +17 stty_main 1196 1197 +1 pstree_main 321 319 -2 ls_main 735 731 -4 watch_main 232 225 -7 bb_progress_update 714 706 -8 ps_main 555 543 -12 run_applet_and_exit 708 695 -13 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/6 up/down: 18/-46) Total: -28 byte Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2015-10-191-1/+1
|\|
| * libbb: get_uidgid() always called with allow_numeric=1Denys Vlasenko2015-10-191-1/+1
| | | | | | | | | | | | | | | | | | | | function old new delta xget_uidgid 30 25 -5 make_device 2188 2183 -5 main 797 792 -5 get_uidgid 240 225 -15 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2015-07-141-2/+1
|\|
| * Removes stray empty line from codeManinder Singh2015-07-131-1/+0
| | | | | | | | | | | | | | | | | | This patch removes stray empty line from busybox code reported by script find_stray_empty_lines Signed-off-by: Maninder Singh <maninder1.s@samsung.com> Signed-off-by: Akhilesh Kumar <akhilesh.k@samsung.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Print one less newline at the end of bb_show_usage()Denys Vlasenko2015-05-251-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | libbb: really add build details to bannerRon Yorston2015-06-231-4/+3
| | | | | | | | Look at the environment variable during compilation, not runtime.
* | libbb: add details of build environment to bannerRon Yorston2015-06-231-0/+6
| | | | | | | | | | If the environment variable MINGW_VERSION is set print its contents on a line after the BusyBox version string.
* | busybox: update help messageRon Yorston2015-06-171-4/+9
| | | | | | | | | | Tweak text of help message in standalone shell mode. Add a warning if Windows globbing is enabled.
* | mingw: add magic '--busybox' flagRon Yorston2015-06-011-0/+4
| | | | | | | | | | | | | | | | | | If BusyBox is invoked with argv[1] set to --busybox skip the first two arguments so that argv[2] becomes the applet name and argv[3] et seq are its arguments. This is needed when BusyBox is run as sh.exe and the executable is reexecuted to invoke compress/decompress applets.
* | Enable seamless compression for WIN32Ron Yorston2015-05-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the archival code we pretend that WIN32 is a no-MMU platform and use the new mingw_popen_fd routine to pipe data to/from commands to compress/decompress. The pretence is maintained by redefining MMU macros in bb_archive.h. This is mostly used in the archival code but there are a handful of places where it's used to access public interfaces. The symbol BB_ARCHIVE_PUBLIC is defined in these places. With these changes: tar supports seamless compression/decompression rpm2cpio and dpkg-deb can be enabled
* | Merge branch 'busybox' into mergeFRPRon Yorston2015-05-181-11/+13
|\|
| * special-case {true,false,test} --helpDenys Vlasenko2015-04-211-10/+12
| | | | | | | | | | | | | | | | | | | | This also removes their help texts. function old new delta run_applet_no_and_exit 442 452 +10 packed_usage 30713 30625 -88 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * update copyright yearsAaro Koskinen2015-04-021-1/+1
| | | | | | | | | | | | | | | | Copyright years seem to be out of date, e.g. coreutils/truncate.c has Copyright (C) 2015. Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* | Merge branch 'busybox' into mergeRon Yorston2015-03-141-4/+4
|\| | | | | | | | | | | Conflicts: coreutils/od_bloaty.c libbb/lineedit.c
| * libbb: introduce and use is_prefixed_with()Denys Vlasenko2015-03-121-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta is_prefixed_with - 18 +18 complete_username 78 77 -1 man_main 737 735 -2 fsck_device 429 427 -2 unpack_ar_archive 80 76 -4 strip_unsafe_prefix 105 101 -4 singlemount 1054 1050 -4 rtc_adjtime_is_utc 90 86 -4 resolve_mount_spec 88 84 -4 parse_one_line 1029 1025 -4 parse_conf 1460 1456 -4 may_wakeup 83 79 -4 loadkmap_main 219 215 -4 get_irqs_from_stat 103 99 -4 get_header_cpio 913 909 -4 findfs_main 79 75 -4 fbsplash_main 1230 1226 -4 load_crontab 776 771 -5 expand_vars_to_list 1151 1146 -5 date_main 881 876 -5 skip_dev_pfx 30 24 -6 make_device 2199 2193 -6 complete_cmd_dir_file 773 767 -6 run_applet_and_exit 715 708 -7 uudecode_main 321 313 -8 pwdx_main 197 189 -8 execute 568 560 -8 i2cdetect_main 1186 1176 -10 procps_scan 1242 1230 -12 procps_read_smaps 1017 1005 -12 process_module 746 734 -12 patch_main 1903 1891 -12 nfsmount 3572 3560 -12 stack_machine 126 112 -14 process_timer_stats 449 435 -14 match_fstype 111 97 -14 do_ipaddr 1344 1330 -14 open_list_and_close 359 343 -16 get_header_tar 1795 1779 -16 prepend_new_eth_table 340 323 -17 fsck_main 1811 1794 -17 find_iface_state 56 38 -18 dnsd_main 1321 1303 -18 base_device 179 158 -21 find_keyword 104 82 -22 handle_incoming_and_exit 2785 2762 -23 parse_and_put_prompt 774 746 -28 modinfo 347 317 -30 find_action 204 171 -33 update_passwd 1470 1436 -34 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/49 up/down: 18/-540) Total: -522 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Changes to allow building with MinGW-w64Ron Yorston2015-01-051-0/+12
| |
* | Merge branch 'busybox' into mergeRon Yorston2014-12-141-2/+4
|\| | | | | | | | | | | | | Conflicts: archival/libarchive/open_transformer.c libbb/lineedit.c miscutils/man.c
| * exit with 127 if appled name wasn't found - it's more POSIXyDenys Vlasenko2014-11-171-2/+4
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2014-10-061-10/+19
|\|
| * false: make "false --help" exit with 1Denys Vlasenko2014-09-181-8/+18
| | | | | | | | | | | | | | function old new delta run_applet_no_and_exit 447 445 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * init: if libc-based Unicode support is on, run setlocale(LC_ALL, "") at startupDenys Vlasenko2014-08-111-2/+1
| | | | | | | | | | | | | | | | It is not clear why we were excluding init from this. The "getpid() != 1" clause was there from the beginning (2001) but not explained. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Move handling of Windows globbing out of upstream codeRon Yorston2014-04-211-5/+0
| |
* | Alter help message if configured with standalone shellRon Yorston2014-03-231-0/+9
| |
* | Drop CONFIG_WIN32_NET settingRon Yorston2014-03-171-1/+3
| |
* | Convert argv[0] to lowercase before checking for '.exe'Ron Yorston2014-03-171-5/+8
| |