aboutsummaryrefslogtreecommitdiff
path: root/miscutils
AgeCommit message (Collapse)Author
2016-04-03whitespace and namespace cleanupsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-03ubirmvol: Implement -N switch for ubirmvolSven Eisenberg
function old new delta get_volid_by_name - 125 +125 ubi_devnum_from_devname - 43 +43 ubi_tools_main 1215 1220 +5 packed_usage 30674 30655 -19 ubirename_main 394 221 -173 ------------------------------------------------------------------------------ (add/remove: 3/0 grow/shrink: 1/2 up/down: 173/-192) Total: -19 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-03ubirename: new appletSven Eisenberg
function old new delta ubirename_main - 394 +394 packed_usage 30611 30674 +63 applet_names 2530 2540 +10 Signed-off-by: Sven Eisenberg <sven.eisenberg@novero.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-30Replace a few more bb_info_msg's by bb_error_msg or printfDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-30Use bb_error_msg instead of bb_info_msg in all commented-out debug printoutsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-14more bionic fixesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-14fixes for problems found by bionic buildDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-06inotifyd: swap meaning of 'y' and 'm' events in help text. Closes 8726Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-02-26taskset: fix non-fancy cpuset printing on big-endianArnout Vandecappelle (Essensium/Mind)
The non-fancy version of the from_cpuset uses CPU_SETSIZE as if it represents the number of bytes in the cpuset, while it is actually the number of bits. This leads to out-of-bounds accesses on the cpu_set_t in the big-endian case. Basically all uses of CPU_SETSIZE have to be divided by 8. This is done correctly in the fancy version of from_cpuset. In addition, the big-endian case is completely wrong to begin with. All standard C libraries that I know of implement cpu_set_t as an unsigned long array, so both for big and little endian, the least significant bits are in the beginning of the array. Therefore, the approach taken for the little endian case is equally valid. We only need special handling for big endian when CPU_SETSIZE is large and we use an unsigned long long to get more bits out. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-01-17setsid: implement -cDenys Vlasenko
function old new delta setsid_main 53 96 +43 packed_usage 30846 30833 -13 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-01-02nandwrite: implement -n (read/write without ecc)Aaro Koskinen
Implement -n (read/write without ecc). Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-11-01i2c_tools: suppress "'blen' may be used uninitialized in this function"Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-11-01i2cdump: display the numeric value for block read ioctl() errorsBartosz Golaszewski
This makes busybox i2cdump compatible with the upstream version, which also displays the numeric error value in case of a block read failure. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-11-01i2cdump: bail-out if block read failsBartosz Golaszewski
We should bail-out if i2c_smbus_read_block_data() or i2c_smbus_read_i2c_block_data() return 0 or less. Add the missing check for the former and fix the existing for the latter. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-11-01i2cdump: use I2C block mode for the 'i' mode parameterBartosz Golaszewski
Currently we're calling i2c_smbus_read_block_data() for both 'i' and 's' mode parameters. If the bus doesn't support SMBus block mode, then the i2c access ioctl() fails. Make i2cdump behave compatibly with upstream version by calling i2c_smbus_read_i2c_block_data() for I2C block. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-11-01i2cdump: don't read block data in non-block modesBartosz Golaszewski
We currently read data twice in byte mode. Add a check to avoid calling i2c_smbus_read_i2c_block_data() if we're not in I2C or SMBus block mode. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-11-01i2cdetect: coding style: add a space after 'for'Bartosz Golaszewski
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-11-01i2cdetect: fix address skipping in auto modeBartosz Golaszewski
If the bus doesn't support SMBus Quick Write or Receive Byte commands and we're running in auto mode all addresses will be skipped resulting in an empty table being printed. This is caused by not restoring the auto mode after it's been changed for certain address ranges - we need an additional variable to hold the temporary state. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-27fbsplash: use virtual y size in mmap size calculationsTimo Teräs
The virtual y can be larger - and we can be even writing there since we are taking into account the y offset. Avoids possible crash. But use it only if set, seems it is not set if virtual area is not allocated (though, often fbcon allocates some scrollback area). Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-25tweak defconfigDenys Vlasenko
MONOTONIC_SYSCALL=y by default FEATURE_LAST_SMALL is gone: now FEATURE_LAST_FANCY is a "bool", not a "choice". Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-13*: more BUILD_BUG_ON conversionsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-11randconfig fixDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-09use auto_string() where appropriate to kill a few staticsDenys Vlasenko
Custom linker script 'busybox_ldscript' found, using it function old new delta static.str 4 - -4 static.passwd 4 0 -4 bb_ask 322 311 -11 ether_print 63 47 -16 UNSPEC_print 82 66 -16 INET_sprint 59 38 -21 INET6_sprint 54 30 -24 make_human_readable_str 292 235 -57 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 0/7 up/down: 0/-153) Total: -153 bytes text data bss dec hex filename 939880 992 17480 958352 e9f90 busybox_old 939736 992 17456 958184 e9ee8 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-08join some common strings, -400 bytesDenys Vlasenko
function old new delta print_intel_cstates 499 511 +12 file_insert 355 364 +9 dpkg_main 2944 2940 -4 ifenslave_main 645 640 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 21/-9) Total: 12 bytes text data bss dec hex filename 937564 932 17676 956172 e970c busybox_old 937164 932 17676 955772 e957c busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-07build system: -fno-builtin-printfDenys Vlasenko
Benefits are: drops reference to out-of-line putchar(), fixes a few cases of failed string merge. function old new delta i2cdump_main 1488 1502 +14 sha256_process_block64 423 433 +10 sendmail_main 1183 1185 +2 list_table 1114 1116 +2 i2cdetect_main 1235 1237 +2 fdisk_main 2852 2854 +2 builtin_type 119 121 +2 unicode_conv_to_printable2 325 324 -1 scan_recursive 380 378 -2 mkfs_minix_main 2687 2684 -3 buffer_fill_and_print 178 169 -9 putchar 152 - -152 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 7/4 up/down: 34/-167) Total: -133 bytes text data bss dec hex filename 937788 932 17676 956396 e97ec busybox_old 937564 932 17676 956172 e970c busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-09-21i2c-tools: rename remaining definesBartosz Golaszewski
Rename the defines not present in linux UAPI headers to better reflect their purpose. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-09-21i2c-tools: remove duplicate definitionsBartosz Golaszewski
Most applets include linux' user API headers instead of duplicating the definitions. Make it the case for i2c-tools as well. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-16less: fix botched attempt to use last columnRon Yorston
Commit 1ecb996 attempted to make read_lines() use the last column of the terminal (as re_wrap() did). There were two problems with this: - The size of the buffer allocated for lines wasn't increased to allow for the extra character. - The test for width overflow was moved after the point where the next character was added to the buffer. This caused a buffer overflow in certain circumstances. For example, if the line beyond the end of the display was wider than the display read_lines() would initially read the partial line into a buffer. When the user moved down read_lines() would be called again to ensure the rest of the line was read. This would place the next character in the partial line before checking for overflow. This can be fixed by moving the test for overflow back to where it was before commit 1ecb996 and changing the comparison to `>` rather than `>=`. There are two other places where buffers are created without allowing for width+1 characters. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-03less: further tweaks to regular file detectionRon Yorston
Test explicitly for REOPEN flags: update_num_lines is called unconditionally so (num_lines != NOT_REGULAR_FILE) is also true when num_lines contains a valid number of lines. The call to fstat doesn't need to be in #if ENABLE_FEATURE_LESS_FLAGS: the whole function is already in such a test. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-31less: improve regular file detection in line counting codeDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-31less: allow use of last column of terminalRon Yorston
When read_lines tests whether a character will fit on the current line it checks the *next* character but in case of overflow doesn't display the *current* one. This results in the last column of the terminal never being used. The test in re_wrap (used when the terminal width changes or line numbers are enabled/disabled) is different: it does allow the use of the final column. function old new delta read_lines 764 770 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 6/0) Total: 6 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-31less: fix line number confusionRon Yorston
Much of the code refers to lines using indices into the flines array (which splits lines into portions that fit on the terminal). In some cases this is wrong and actual line numbers should be used: - when lines are being truncated rather than wrapped (-S flag) - when line numbers have been entered by the user Also fix a bug in numeric input and improve the display at EOF. function old new delta goto_lineno - 111 +111 cap_cur_fline - 101 +101 buffer_to_line - 56 +56 buffer_up 35 66 +31 less_main 2606 2615 +9 goto_match 125 127 +2 buffer_down 81 56 -25 buffer_line 64 - -64 ------------------------------------------------------------------------------ (add/remove: 3/1 grow/shrink: 3/1 up/down: 310/-89) Total: 221 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-31less: add a function to detect when display is at end of fileRon Yorston
Add a function to package the test that detects whether enough has been read from the file to allow a screenful to be displayed. Also use this to determine when to display '(END)' in the status line. The previous code was incomplete and didn't handle truncated lines (-S flag) properly. function old new delta at_end - 63 +63 status_print 111 109 -2 read_lines 819 764 -55 getch_nowait 319 264 -55 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/3 up/down: 63/-112) Total: -49 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-31less: rearrange detection of non-regular filesRon Yorston
Move the code to detect non-regular files to the point where the file is being opened. If num_lines == READING_FILE guarantees that the file is regular. Detect when a file becomes unreadable between it first being opened and the call to update_num_lines. Mark the file as being non-regular so we don't try that again. function old new delta reinitialize 197 245 +48 update_num_lines 159 127 -32 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 48/-32) Total: 16 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-31less: move code to count lines into a separate functionRon Yorston
function old new delta update_num_lines - 159 +159 m_status_print 409 266 -143 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 159/-143) Total: 16 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-31less: fix numeric inputRon Yorston
Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-21less: improvements to verbose status messagesRon Yorston
Make verbose status messages (-m/-M flags) behave more like the real `less` command: - fix display of line numbers so they're correct whether lines are being truncated (-S flag) or wrapped. - don't display total lines or percentage when lines are read from stdin: we don't have that information until we reach EOF. When we do reach EOF the additional information is displayed. - when lines are read from a file count the total number of lines so that we can display percentages. Counting lines is avoided until the information is actually needed. If the user pages to EOF the separate read pass can be avoided entirely. Fixes Bug 7586 function old new delta m_status_print 195 382 +187 safe_lineno - 35 +35 reinitialize 172 182 +10 read_lines 675 685 +10 buffer_fill_and_print 178 169 -9 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 3/1 up/down: 242/-9) Total: 233 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-19libbb: add a function to make a copy of a region of memoryRon Yorston
Introduce a library routine to package the idiom: p = xmalloc(b, n); memcpy(p, b, n); and use it where possible. The example in traceroute used xzalloc but it didn't need to. function old new delta xmemdup - 32 +32 last_main 834 826 -8 make_device 2321 2311 -10 common_traceroute_main 3698 3685 -13 readtoken1 3182 3168 -14 procps_scan 1222 1206 -16 forkchild 655 638 -17 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/6 up/down: 32/-78) Total: -46 bytes Signed-off-by: Ron Yorston <rmy@frippery.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-19less: correctly account for tabs when rewrapping linesRon Yorston
Lines are rewrapped when the terminal width changes or line numbers are enabled/disabled. The current calculation always adds eight to the line length for a tab whereas it should only add enough to move to the next tab stop. This doesn't affect the display of lines, which is handled elsewhere and gets tab stops right, but it does cause lines to be wrapped at the wrong position. Signed-off-by: Ron Yorston <rmy@frippery.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-19less: fix display of line numbersRon Yorston
Line numbers are displayed incorrectly on lines that have a search pattern highlighted. The problem can be fixed by moving the call to lineno_str in print_found above the while loop that alters the value of the line pointer. However, a more substantial rewrite results in savings. function old new delta buffer_print 688 697 +9 .rodata 156077 156045 -32 lineno_str 85 - -85 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/1 up/down: 9/-117) Total: -108 bytes Signed-off-by: Ron Yorston <rmy@frippery.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-19less: document -S flag and make it independently configurableRon Yorston
The -S flag, to cause long lines to be truncated, was enabled by FEATURE_LESS_DASHCMD. This is non-obvious and -S is useful even if the '-' command isn't enabled. function old new delta .rodata 156045 156077 +32 packed_usage 30223 30244 +21 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 53/0) Total: 53 bytes Signed-off-by: Ron Yorston <rmy@frippery.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-13Removes stray empty line from codeManinder Singh
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>
2015-06-07i2cdetect: use break instead of goto in list_i2c_busses_and_exit()Bartosz Golaszewski
Since there are now more statements in the if block after the while loop in list_i2c_busses_and_exit(), there's no need for a label. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-06-07i2cdump: code reworkBartosz Golaszewski
Split i2cdump_main() into shorter functions. Simplify the code a bit. Make block an array of ints so that we can store negative results of read functions (fixes a bug found by Denys Vlasenko). Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-06-07i2cdetect: add a check for (mode == DETECT_MODE_AUTO)Bartosz Golaszewski
We should only warn the user about addresses to be skipped if (mode == DETECT_MODE_AUTO). Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-06-07i2cdetect: don't scan non-regular addresses without the '-a' optionBartosz Golaszewski
Addresses 0x00-0x02 shouldn't be scanned by default. This patch makes 'first' default to 0x03 and only enables lower addresses if '-a' option is passed Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-06-07i2cdetect: don't die on addresses already in use by driversBartosz Golaszewski
We can't use i2c_set_slave_addr() in i2cdetect, as we have to check for EBUSY after calling ioctl(I2C_SLAVE) and print 'UU' on busy addresses instead of bailing-out. While we're at it: reorder definitions of local vars in i2cdetect_main(). function old new delta i2cdetect_main 703 744 +41 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 41/0) Total: 41 bytes text data bss dec hex filename 826097 4164 9584 839845 cd0a5 busybox_old 826145 4164 9584 839893 cd0d5 busybox_unstripped Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-25typo fixesManinder Singh
Signed-off-by: Maninder Singh <maninder1.s@samsung.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-25dc: fix "dc p" prinitng bogus dataDenys Vlasenko
function old new delta check_under - 20 +20 print_no_pop 27 32 +5 pop 33 24 -9 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 25/-9) Total: 16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-11i2c-tools: only try /dev/i2c/* if opening /dev/i2c-* fails with ENOENTBartosz Golaszewski
Trying to access /dev/i2c/* on every error after opening /dev/i2c-* can mislead users who e.g. don't have root access. Instead of bailing-out with "permission denied" we currently print "no such file or directory". Fix it by trying open("/dev/i2c/%d") only if we got ENOENT. Upstream i2cdetect tries to get any info it can from /sys and /proc even when invoked by an unprivileged user, but we don't want to add unnecessary bloat. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>