Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab4caf099c | ||
|
|
1c3bcfc79f | ||
|
|
096ccd6a69 | ||
|
|
d674b2e2ae | ||
|
|
abe8fc3663 | ||
|
|
981c0b109d | ||
|
|
6673497d3b | ||
|
|
7236b6d717 |
No files matched your search
-11
@@ -50,14 +50,3 @@ cscope.files
|
||||
cscope.in.out
|
||||
cscope.out
|
||||
cscope.po.out
|
||||
|
||||
#
|
||||
# ctags output
|
||||
#
|
||||
tags
|
||||
TAGS
|
||||
|
||||
#
|
||||
# user-supplied scripts
|
||||
#
|
||||
/embed
|
||||
@@ -12,7 +12,7 @@ config HAVE_DOT_CONFIG
|
||||
menu "Settings"
|
||||
|
||||
config DESKTOP
|
||||
bool "Enable compatibility for full-blown desktop systems (8kb)"
|
||||
bool "Enable compatibility for full-blown desktop systems"
|
||||
default y
|
||||
help
|
||||
Enable applet options and features which are not essential.
|
||||
@@ -178,11 +178,6 @@ config BUSYBOX
|
||||
|
||||
Running "busybox APPLET [ARGS...]" will still work, of course.
|
||||
|
||||
config FEATURE_SHOW_SCRIPT
|
||||
bool "Support --show SCRIPT"
|
||||
default y
|
||||
depends on BUSYBOX
|
||||
|
||||
config FEATURE_INSTALLER
|
||||
bool "Support --install [-s] to install applet links at runtime"
|
||||
default y
|
||||
@@ -339,15 +334,6 @@ config FEATURE_CLEAN_UP
|
||||
Don't enable this unless you have a really good reason to clean
|
||||
things up manually.
|
||||
|
||||
config FEATURE_SYSLOG_INFO
|
||||
bool "Support LOG_INFO level syslog messages"
|
||||
default y
|
||||
depends on FEATURE_SYSLOG
|
||||
help
|
||||
Applets which send their output to syslog use either LOG_INFO or
|
||||
LOG_ERR log levels, but by disabling this option all messages will
|
||||
be logged at the LOG_ERR level, saving just under 200 bytes.
|
||||
|
||||
# These are auto-selected by other options
|
||||
|
||||
config FEATURE_SYSLOG
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 31
|
||||
SUBLEVEL = 1
|
||||
PATCHLEVEL = 29
|
||||
SUBLEVEL = 2
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
|
||||
@@ -361,7 +361,7 @@ scripts/basic/%: scripts_basic ;
|
||||
|
||||
# This target generates Kbuild's and Config.in's from *.c files
|
||||
PHONY += gen_build_files
|
||||
gen_build_files: $(wildcard $(srctree)/*/*.c) $(wildcard $(srctree)/*/*/*.c) $(wildcard $(srctree)/embed/*)
|
||||
gen_build_files: $(wildcard $(srctree)/*/*.c) $(wildcard $(srctree)/*/*/*.c)
|
||||
$(Q)$(srctree)/scripts/gen_build_files.sh $(srctree) $(objtree)
|
||||
|
||||
# bbox: we have helpers in applets/
|
||||
@@ -850,14 +850,11 @@ quiet_cmd_gen_common_bufsiz = GEN include/common_bufsiz.h
|
||||
cmd_gen_common_bufsiz = $(srctree)/scripts/generate_BUFSIZ.sh include/common_bufsiz.h
|
||||
quiet_cmd_split_autoconf = SPLIT include/autoconf.h -> include/config/*
|
||||
cmd_split_autoconf = scripts/basic/split-include include/autoconf.h include/config
|
||||
quiet_cmd_gen_embedded_scripts = GEN include/embedded_scripts.h
|
||||
cmd_gen_embedded_scripts = $(srctree)/scripts/embedded_scripts include/embedded_scripts.h $(srctree)/embed $(srctree)/applets_sh
|
||||
#bbox# piggybacked generation of few .h files
|
||||
include/config/MARKER: scripts/basic/split-include include/autoconf.h $(wildcard $(srctree)/embed/*) $(wildcard $(srctree)/applets_sh/*) $(srctree)/scripts/embedded_scripts
|
||||
include/config/MARKER: scripts/basic/split-include include/autoconf.h
|
||||
$(call cmd,split_autoconf)
|
||||
$(call cmd,gen_bbconfigopts)
|
||||
$(call cmd,gen_common_bufsiz)
|
||||
$(call cmd,gen_embedded_scripts)
|
||||
@touch $@
|
||||
|
||||
# Generate some files
|
||||
@@ -977,7 +974,6 @@ MRPROPER_FILES += .config .config.old include/asm .version .old_version \
|
||||
include/autoconf.h \
|
||||
include/bbconfigopts.h \
|
||||
include/bbconfigopts_bz2.h \
|
||||
include/embedded_scripts.h \
|
||||
include/usage_compressed.h \
|
||||
include/applet_tables.h \
|
||||
include/applets.h \
|
||||
|
||||
@@ -84,15 +84,7 @@ int main(int argc, char **argv)
|
||||
|
||||
qsort(applets, NUM_APPLETS, sizeof(applets[0]), cmp_name);
|
||||
|
||||
for (i = j = 0; i < NUM_APPLETS-1; ++i) {
|
||||
if (cmp_name(applets+i, applets+i+1) == 0) {
|
||||
fprintf(stderr, "%s: duplicate applet name '%s'\n", argv[0],
|
||||
applets[i].name);
|
||||
j = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (j != 0 || !argv[1])
|
||||
if (!argv[1])
|
||||
return 1;
|
||||
snprintf(tmp1, PATH_MAX, "%s.%u.new", argv[1], (int) getpid());
|
||||
i = open(tmp1, O_WRONLY | O_TRUNC | O_CREAT, 0666);
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Make busybox scripted applet list file.
|
||||
|
||||
# input $1: full path to Config.h
|
||||
# input $2: full path to applets.h
|
||||
# output (stdout): list of pathnames that should be linked to busybox
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
CONFIG_H=${1:-include/autoconf.h}
|
||||
APPLETS_H=${2:-include/applets.h}
|
||||
$HOSTCC -E -DMAKE_SCRIPTS -include $CONFIG_H $APPLETS_H |
|
||||
awk '/^[ \t]*SCRIPT/{
|
||||
print $2
|
||||
}'
|
||||
+1
-1
@@ -83,7 +83,7 @@ install -m 755 busybox "$prefix/bin/busybox" || exit 1
|
||||
for i in $h; do
|
||||
appdir=`dirname "$i"`
|
||||
app=`basename "$i"`
|
||||
if [ x"$noclobber" = x"1" ] && ([ -e "$prefix/$i" ] || [ -h "$prefix/$i" ]); then
|
||||
if [ x"$noclobber" = x"1" ] && [ -e "$prefix/$i" ]; then
|
||||
echo " $prefix/$i already exists"
|
||||
continue
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
This directory contains examples of applets implemented as shell scripts.
|
||||
|
||||
So far these scripts are not hooked to the build system and are not
|
||||
installed by "make install". If you want to use them,
|
||||
you need to install them by hand.
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
# TODO: use getopt to avoid parsing options as filenames,
|
||||
# and to support -- and --help
|
||||
[ $# -ne 0 ] && DASH_I=-i
|
||||
sed $DASH_I -e 's/\r$//' "$@"
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
cat /etc/nologin.txt 2>/dev/null || echo This account is not available
|
||||
#!/bin/sh
|
||||
cat /etc/nologin.txt 2>/dev/null || echo "This account is not available"
|
||||
sleep 5
|
||||
exit 1
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
# TODO: use getopt to avoid parsing options as filenames,
|
||||
# and to support -- and --help
|
||||
for i in "$@"
|
||||
do
|
||||
sed -e '1!G;h;$!d' "$i"
|
||||
done
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
# TODO: use getopt to avoid parsing options as filenames,
|
||||
# and to support -- and --help
|
||||
[ $# -ne 0 ] && DASH_I=-i
|
||||
sed $DASH_I -e 's/$/\r/' "$@"
|
||||
+6
-6
@@ -299,7 +299,7 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv)
|
||||
//usage: "Decompress to stdout"
|
||||
|
||||
//config:config GUNZIP
|
||||
//config: bool "gunzip (11 kb)"
|
||||
//config: bool "gunzip (12 kb)"
|
||||
//config: default y
|
||||
//config: select FEATURE_GZIP_DECOMPRESS
|
||||
//config: help
|
||||
@@ -308,7 +308,7 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv)
|
||||
//config: an archive, without decompressing it.
|
||||
//config:
|
||||
//config:config ZCAT
|
||||
//config: bool "zcat (24 kb)"
|
||||
//config: bool "zcat (25 kb)"
|
||||
//config: default y
|
||||
//config: select FEATURE_GZIP_DECOMPRESS
|
||||
//config: help
|
||||
@@ -413,7 +413,7 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
//usage: "Decompress to stdout"
|
||||
|
||||
//config:config BUNZIP2
|
||||
//config: bool "bunzip2 (8.7 kb)"
|
||||
//config: bool "bunzip2 (8.8 kb)"
|
||||
//config: default y
|
||||
//config: select FEATURE_BZIP2_DECOMPRESS
|
||||
//config: help
|
||||
@@ -427,7 +427,7 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
//config: should probably say N here.
|
||||
//config:
|
||||
//config:config BZCAT
|
||||
//config: bool "bzcat (8.7 kb)"
|
||||
//config: bool "bzcat (8.8 kb)"
|
||||
//config: default y
|
||||
//config: select FEATURE_BZIP2_DECOMPRESS
|
||||
//config: help
|
||||
@@ -481,7 +481,7 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
//usage: "Decompress to stdout"
|
||||
|
||||
//config:config UNLZMA
|
||||
//config: bool "unlzma (7.5 kb)"
|
||||
//config: bool "unlzma (8.6 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: unlzma is a compression utility using the Lempel-Ziv-Markov chain
|
||||
@@ -490,7 +490,7 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
//config: compressors.
|
||||
//config:
|
||||
//config:config LZCAT
|
||||
//config: bool "lzcat (7.5 kb)"
|
||||
//config: bool "lzcat (8.5 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Alias to "unlzma -c".
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* about bzip2 library code.
|
||||
*/
|
||||
//config:config BZIP2
|
||||
//config: bool "bzip2 (16 kb)"
|
||||
//config: bool "bzip2 (18 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: bzip2 is a compression utility using the Burrows-Wheeler block
|
||||
|
||||
+4
-7
@@ -11,7 +11,7 @@
|
||||
* Only supports new ASCII and CRC formats
|
||||
*/
|
||||
//config:config CPIO
|
||||
//config: bool "cpio (15 kb)"
|
||||
//config: bool "cpio (14 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: cpio is an archival utility program used to create, modify, and
|
||||
@@ -64,17 +64,15 @@
|
||||
//usage: "\n -p DIR Copy files to DIR"
|
||||
//usage: )
|
||||
//usage: "\nOptions:"
|
||||
//usage: IF_FEATURE_CPIO_O(
|
||||
//usage: "\n -H newc Archive format"
|
||||
//usage: )
|
||||
//usage: "\n -d Make leading directories"
|
||||
//usage: "\n -m Preserve mtime"
|
||||
//usage: "\n -v Verbose"
|
||||
//usage: "\n -u Overwrite"
|
||||
//usage: "\n -F FILE Input (-t,-i,-p) or output (-o) file"
|
||||
//usage: "\n -R USER[:GRP] Set owner of created files"
|
||||
//usage: "\n -L Dereference symlinks"
|
||||
//usage: "\n -0 Input is separated by NULs"
|
||||
//usage: IF_FEATURE_CPIO_O(
|
||||
//usage: "\n -H newc Archive format"
|
||||
//usage: )
|
||||
|
||||
/* GNU cpio 2.9 --help (abridged):
|
||||
|
||||
@@ -376,7 +374,6 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
#endif
|
||||
"owner\0" Required_argument "R"
|
||||
"verbose\0" No_argument "v"
|
||||
"null\0" No_argument "0"
|
||||
"quiet\0" No_argument "\xff"
|
||||
"to-stdout\0" No_argument "\xfe"
|
||||
;
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
* - (unknown, please let me know when you find any)
|
||||
*/
|
||||
//config:config DPKG
|
||||
//config: bool "dpkg (43 kb)"
|
||||
//config: bool "dpkg (44 kb)"
|
||||
//config: default y
|
||||
//config: select FEATURE_SEAMLESS_GZ
|
||||
//config: help
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config DPKG_DEB
|
||||
//config: bool "dpkg-deb (30 kb)"
|
||||
//config: bool "dpkg_deb"
|
||||
//config: default y
|
||||
//config: select FEATURE_SEAMLESS_GZ
|
||||
//config: help
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ gzip: bogus: No such file or directory
|
||||
aa: 85.1% -- replaced with aa.gz
|
||||
*/
|
||||
//config:config GZIP
|
||||
//config: bool "gzip (17 kb)"
|
||||
//config: bool "gzip (19 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: gzip is used to compress files.
|
||||
|
||||
@@ -91,7 +91,6 @@ lib-$(CONFIG_FEATURE_SEAMLESS_LZMA) += open_transformer.o decompress_unlzma.
|
||||
lib-$(CONFIG_FEATURE_SEAMLESS_XZ) += open_transformer.o decompress_unxz.o
|
||||
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += open_transformer.o decompress_bunzip2.o
|
||||
lib-$(CONFIG_FEATURE_COMPRESS_BBCONFIG) += open_transformer.o decompress_bunzip2.o
|
||||
lib-$(CONFIG_FEATURE_SH_EMBEDDED_SCRIPTS) += open_transformer.o decompress_bunzip2.o
|
||||
|
||||
ifneq ($(lib-y),)
|
||||
lib-y += $(COMMON_FILES)
|
||||
|
||||
@@ -107,7 +107,7 @@ struct bunzip_data {
|
||||
uint8_t selectors[32768]; /* nSelectors=15 bits */
|
||||
struct group_data groups[MAX_GROUPS]; /* Huffman coding tables */
|
||||
};
|
||||
typedef struct bunzip_data bunzip_data;
|
||||
/* typedef struct bunzip_data bunzip_data; -- done in .h file */
|
||||
|
||||
|
||||
/* Return the next nnn bits of input. All reads from the compressed input
|
||||
@@ -235,9 +235,9 @@ static int get_next_block(bunzip_data *bd)
|
||||
/* Get next value */
|
||||
int n = 0;
|
||||
while (get_bits(bd, 1)) {
|
||||
n++;
|
||||
if (n >= groupCount)
|
||||
return RETVAL_DATA_ERROR;
|
||||
n++;
|
||||
}
|
||||
/* Decode MTF to get the next selector */
|
||||
tmp_byte = mtfSymbol[n];
|
||||
@@ -575,7 +575,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
in outbuf. IOW: on EOF returns len ("all bytes are not filled"), not 0.
|
||||
(Why? This allows to get rid of one local variable)
|
||||
*/
|
||||
static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
int FAST_FUNC read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
{
|
||||
const uint32_t *dbuf;
|
||||
int pos, current, previous;
|
||||
@@ -699,7 +699,7 @@ static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
/* Because bunzip2 is used for help text unpacking, and because bb_show_usage()
|
||||
should work for NOFORK applets too, we must be extremely careful to not leak
|
||||
any allocations! */
|
||||
static int FAST_FUNC start_bunzip(
|
||||
int FAST_FUNC start_bunzip(
|
||||
void *jmpbuf,
|
||||
bunzip_data **bdp,
|
||||
int in_fd,
|
||||
@@ -759,7 +759,7 @@ static int FAST_FUNC start_bunzip(
|
||||
return RETVAL_OK;
|
||||
}
|
||||
|
||||
static void FAST_FUNC dealloc_bunzip(bunzip_data *bd)
|
||||
void FAST_FUNC dealloc_bunzip(bunzip_data *bd)
|
||||
{
|
||||
free(bd->dbuf);
|
||||
free(bd);
|
||||
@@ -809,7 +809,7 @@ unpack_bz2_stream(transformer_state_t *xstate)
|
||||
/* Observed case when i == RETVAL_OK:
|
||||
* "bzcat z.bz2", where "z.bz2" is a bzipped zero-length file
|
||||
* (to be exact, z.bz2 is exactly these 14 bytes:
|
||||
* 42 5a 68 39 17 72 45 38 50 90 00 00 00 00).
|
||||
* 42 5a 68 39 17 72 45 38 50 90 00 00 00 00).
|
||||
*/
|
||||
&& i != RETVAL_OK
|
||||
) {
|
||||
@@ -847,36 +847,6 @@ unpack_bz2_stream(transformer_state_t *xstate)
|
||||
return i ? i : IF_DESKTOP(total_written) + 0;
|
||||
}
|
||||
|
||||
char* FAST_FUNC
|
||||
unpack_bz2_data(const char *packed, int packed_len, int unpacked_len)
|
||||
{
|
||||
char *outbuf = NULL;
|
||||
bunzip_data *bd;
|
||||
int i;
|
||||
jmp_buf jmpbuf;
|
||||
|
||||
/* Setup for I/O error handling via longjmp */
|
||||
i = setjmp(jmpbuf);
|
||||
if (i == 0) {
|
||||
i = start_bunzip(&jmpbuf,
|
||||
&bd,
|
||||
/* src_fd: */ -1,
|
||||
/* inbuf: */ packed,
|
||||
/* len: */ packed_len
|
||||
);
|
||||
}
|
||||
/* read_bunzip can longjmp and end up here with i != 0
|
||||
* on read data errors! Not trivial */
|
||||
if (i == 0) {
|
||||
/* Cannot use xmalloc: will leak bd in NOFORK case! */
|
||||
outbuf = malloc_or_warn(unpacked_len);
|
||||
if (outbuf)
|
||||
read_bunzip(bd, outbuf, unpacked_len);
|
||||
}
|
||||
dealloc_bunzip(bd);
|
||||
return outbuf;
|
||||
}
|
||||
|
||||
#ifdef TESTING
|
||||
|
||||
static char *const bunzip_errors[] = {
|
||||
|
||||
@@ -353,10 +353,8 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||
if ((int32_t)pos < 0) {
|
||||
pos += header.dict_size;
|
||||
/* see unzip_bad_lzma_2.zip: */
|
||||
if (pos >= buffer_size) {
|
||||
dbg("%d pos:%d buffer_size:%d", __LINE__, pos, buffer_size);
|
||||
if (pos >= buffer_size)
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
previous_byte = buffer[pos];
|
||||
goto one_byte1;
|
||||
@@ -432,9 +430,10 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||
for (; num_bits2 != LZMA_NUM_ALIGN_BITS; num_bits2--)
|
||||
rep0 = (rep0 << 1) | rc_direct_bit(rc);
|
||||
rep0 <<= LZMA_NUM_ALIGN_BITS;
|
||||
// Note: (int32_t)rep0 may be < 0 here
|
||||
// (I have linux-3.3.4.tar.lzma which has it).
|
||||
// I moved the check after "++rep0 == 0" check below.
|
||||
if ((int32_t)rep0 < 0) {
|
||||
dbg("%d rep0:%d", __LINE__, rep0);
|
||||
goto bad;
|
||||
}
|
||||
prob3 = p + LZMA_ALIGN;
|
||||
}
|
||||
i2 = 1;
|
||||
@@ -445,13 +444,8 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||
i2 <<= 1;
|
||||
}
|
||||
}
|
||||
rep0++;
|
||||
if ((int32_t)rep0 <= 0) {
|
||||
if (rep0 == 0)
|
||||
break;
|
||||
dbg("%d rep0:%d", __LINE__, rep0);
|
||||
goto bad;
|
||||
}
|
||||
if (++rep0 == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
len += LZMA_MATCH_MIN_LEN;
|
||||
|
||||
@@ -96,24 +96,6 @@ unpack_xz_stream(transformer_state_t *xstate)
|
||||
*/
|
||||
do {
|
||||
if (membuf[iobuf.in_pos] != 0) {
|
||||
/* There is more data, but is it XZ data?
|
||||
* Example: dpkg-deb -f busybox_1.30.1-4_amd64.deb
|
||||
* reads control.tar.xz "control" file
|
||||
* inside the ar archive, but tar.xz
|
||||
* extraction code reaches end of xz data,
|
||||
* reached this code and reads the beginning
|
||||
* of data.tar.xz's ar header, which isn't xz data,
|
||||
* and prints "corrupted data".
|
||||
* The correct solution is to not read
|
||||
* past nested archive (to simulate EOF).
|
||||
* This is a workaround:
|
||||
*/
|
||||
if (membuf[iobuf.in_pos] != 0xfd) {
|
||||
/* It's definitely not a xz signature
|
||||
* (which is 0xfd,"7zXZ",0x00).
|
||||
*/
|
||||
goto end;
|
||||
}
|
||||
xz_dec_reset(state);
|
||||
goto do_run;
|
||||
}
|
||||
@@ -146,7 +128,7 @@ unpack_xz_stream(transformer_state_t *xstate)
|
||||
break;
|
||||
}
|
||||
}
|
||||
end:
|
||||
|
||||
xz_dec_end(state);
|
||||
free(membuf);
|
||||
|
||||
|
||||
@@ -414,8 +414,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
// case 'D': /* GNU dump dir */
|
||||
// case 'M': /* Continuation of multi volume archive */
|
||||
// case 'N': /* Old GNU for names > 100 characters */
|
||||
case 'V': /* Volume header */
|
||||
; /* Fall through to skip it */
|
||||
// case 'V': /* Volume header */
|
||||
#endif
|
||||
}
|
||||
skip_ext_hdr:
|
||||
|
||||
@@ -487,7 +487,7 @@ static int find_match(lzo1x_999_t *c, lzo_swd_p s,
|
||||
}
|
||||
|
||||
/* this is a public functions, but there is no prototype in a header file */
|
||||
static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len,
|
||||
static int lzo1x_999_compress_internal(const uint8_t *in , unsigned in_len,
|
||||
uint8_t *out, unsigned *out_len,
|
||||
void *wrkmem,
|
||||
unsigned good_length,
|
||||
|
||||
@@ -159,44 +159,47 @@ void FAST_FUNC fork_transformer(int fd, const char *transform_prog)
|
||||
*/
|
||||
static transformer_state_t *setup_transformer_on_fd(int fd, int fail_if_not_compressed)
|
||||
{
|
||||
union {
|
||||
uint8_t b[4];
|
||||
uint16_t b16[2];
|
||||
uint32_t b32[1];
|
||||
} magic;
|
||||
transformer_state_t *xstate;
|
||||
|
||||
xstate = xzalloc(sizeof(*xstate));
|
||||
xstate->src_fd = fd;
|
||||
xstate->signature_skipped = 2;
|
||||
|
||||
/* .gz and .bz2 both have 2-byte signature, and their
|
||||
* unpack_XXX_stream wants this header skipped. */
|
||||
xstate->signature_skipped = 2;
|
||||
xread(fd, xstate->magic.b16, 2);
|
||||
xread(fd, magic.b16, sizeof(magic.b16[0]));
|
||||
if (ENABLE_FEATURE_SEAMLESS_GZ
|
||||
&& xstate->magic.b16[0] == GZIP_MAGIC
|
||||
&& magic.b16[0] == GZIP_MAGIC
|
||||
) {
|
||||
xstate->xformer = unpack_gz_stream;
|
||||
USE_FOR_NOMMU(xstate->xformer_prog = "gunzip";)
|
||||
goto found_magic;
|
||||
}
|
||||
if (ENABLE_FEATURE_SEAMLESS_Z
|
||||
&& xstate->magic.b16[0] == COMPRESS_MAGIC
|
||||
&& magic.b16[0] == COMPRESS_MAGIC
|
||||
) {
|
||||
xstate->xformer = unpack_Z_stream;
|
||||
USE_FOR_NOMMU(xstate->xformer_prog = "uncompress";)
|
||||
goto found_magic;
|
||||
}
|
||||
if (ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
&& xstate->magic.b16[0] == BZIP2_MAGIC
|
||||
&& magic.b16[0] == BZIP2_MAGIC
|
||||
) {
|
||||
xstate->xformer = unpack_bz2_stream;
|
||||
USE_FOR_NOMMU(xstate->xformer_prog = "bunzip2";)
|
||||
goto found_magic;
|
||||
}
|
||||
if (ENABLE_FEATURE_SEAMLESS_XZ
|
||||
&& xstate->magic.b16[0] == XZ_MAGIC1
|
||||
&& magic.b16[0] == XZ_MAGIC1
|
||||
) {
|
||||
uint32_t v32;
|
||||
xstate->signature_skipped = 6;
|
||||
xread(fd, &xstate->magic.b16[1], 4);
|
||||
move_from_unaligned32(v32, &xstate->magic.b16[1]);
|
||||
if (v32 == XZ_MAGIC2) {
|
||||
xread(fd, magic.b32, sizeof(magic.b32[0]));
|
||||
if (magic.b32[0] == XZ_MAGIC2) {
|
||||
xstate->xformer = unpack_xz_stream;
|
||||
USE_FOR_NOMMU(xstate->xformer_prog = "unxz";)
|
||||
goto found_magic;
|
||||
@@ -275,7 +278,8 @@ static transformer_state_t *open_transformer(const char *fname, int fail_if_not_
|
||||
|
||||
if (ENABLE_FEATURE_SEAMLESS_LZMA) {
|
||||
/* .lzma has no header/signature, can only detect it by extension */
|
||||
if (is_suffixed_with(fname, ".lzma")) {
|
||||
char *sfx = strrchr(fname, '.');
|
||||
if (sfx && strcmp(sfx+1, "lzma") == 0) {
|
||||
xstate = xzalloc(sizeof(*xstate));
|
||||
xstate->src_fd = fd;
|
||||
xstate->xformer = unpack_lzma_stream;
|
||||
@@ -341,24 +345,11 @@ void* FAST_FUNC xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_
|
||||
*maxsz_p = xstate->mem_output_size;
|
||||
}
|
||||
} else {
|
||||
/* File is not compressed.
|
||||
* We already read first few bytes, account for that.
|
||||
* Example where it happens:
|
||||
* "modinfo MODULE.ko" (not compressed)
|
||||
* open("MODULE.ko", O_RDONLY|O_LARGEFILE) = 4
|
||||
* read(4, "\177E", 2) = 2
|
||||
* fstat64(4, ...)
|
||||
* mmap(...)
|
||||
* read(4, "LF\2\1\1\0\0\0\0"...
|
||||
* ...and we avoided seeking on the fd! :)
|
||||
*/
|
||||
image = xmalloc_read_with_initial_buf(
|
||||
xstate->src_fd,
|
||||
maxsz_p,
|
||||
xmemdup(&xstate->magic, xstate->signature_skipped),
|
||||
xstate->signature_skipped
|
||||
);
|
||||
/* File is not compressed */
|
||||
//FIXME: avoid seek
|
||||
xlseek(xstate->src_fd, - xstate->signature_skipped, SEEK_CUR);
|
||||
xstate->signature_skipped = 0;
|
||||
image = xmalloc_read(xstate->src_fd, maxsz_p);
|
||||
}
|
||||
|
||||
if (!image)
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#define STREAM_HEADER_SIZE 12
|
||||
|
||||
#define HEADER_MAGIC "\375""7zXZ"
|
||||
#define HEADER_MAGIC "\3757zXZ"
|
||||
#define HEADER_MAGIC_SIZE 6
|
||||
|
||||
#define FOOTER_MAGIC "YZ"
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
"Minimalized" for busybox by Alain Knaff
|
||||
*/
|
||||
//config:config LZOP
|
||||
//config: bool "lzop (12 kb)"
|
||||
//config: bool "lzop (13 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Lzop compression/decompresion.
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config RPM
|
||||
//config: bool "rpm (32 kb)"
|
||||
//config: bool "rpm (33 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Mini RPM applet - queries and extracts RPM packages.
|
||||
@@ -499,7 +499,7 @@ int rpm_main(int argc, char **argv)
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config RPM2CPIO
|
||||
//config: bool "rpm2cpio (21 kb)"
|
||||
//config: bool "rpm2cpio (20 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Converts a RPM file into a CPIO archive.
|
||||
|
||||
+39
-51
@@ -23,7 +23,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config TAR
|
||||
//config: bool "tar (39 kb)"
|
||||
//config: bool "tar (40 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: tar is an archiving program. It's commonly used with gzip to
|
||||
@@ -596,46 +596,35 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb
|
||||
/* Don't inline: vfork scares gcc and pessimizes code */
|
||||
static void NOINLINE vfork_compressor(int tar_fd, const char *gzip)
|
||||
{
|
||||
pid_t gzipPid;
|
||||
|
||||
// On Linux, vfork never unpauses parent early, although standard
|
||||
// allows for that. Do we want to waste bytes checking for it?
|
||||
# define WAIT_FOR_CHILD 0
|
||||
volatile int vfork_exec_errno = 0;
|
||||
struct fd_pair data;
|
||||
struct fd_pair gzipDataPipe;
|
||||
# if WAIT_FOR_CHILD
|
||||
struct fd_pair status;
|
||||
xpiped_pair(status);
|
||||
struct fd_pair gzipStatusPipe;
|
||||
xpiped_pair(gzipStatusPipe);
|
||||
# endif
|
||||
xpiped_pair(data);
|
||||
xpiped_pair(gzipDataPipe);
|
||||
|
||||
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
|
||||
|
||||
if (xvfork() == 0) {
|
||||
gzipPid = xvfork();
|
||||
|
||||
if (gzipPid == 0) {
|
||||
/* child */
|
||||
int tfd;
|
||||
/* NB: close _first_, then move fds! */
|
||||
close(data.wr);
|
||||
close(gzipDataPipe.wr);
|
||||
# if WAIT_FOR_CHILD
|
||||
close(status.rd);
|
||||
/* status.wr will close only on exec -
|
||||
close(gzipStatusPipe.rd);
|
||||
/* gzipStatusPipe.wr will close only on exec -
|
||||
* parent waits for this close to happen */
|
||||
fcntl(status.wr, F_SETFD, FD_CLOEXEC);
|
||||
fcntl(gzipStatusPipe.wr, F_SETFD, FD_CLOEXEC);
|
||||
# endif
|
||||
/* copy it: parent's tar_fd variable must not change */
|
||||
tfd = tar_fd;
|
||||
if (tfd == 0) {
|
||||
/* Output tar fd may be zero.
|
||||
* xmove_fd(data.rd, 0) would destroy it.
|
||||
* Reproducer:
|
||||
* exec 0>&-
|
||||
* exec 1>&-
|
||||
* tar czf Z.tar.gz FILE
|
||||
* Swapping move_fd's order wouldn't work:
|
||||
* data.rd is 1 and _it_ would be destroyed.
|
||||
*/
|
||||
tfd = dup(tfd);
|
||||
}
|
||||
xmove_fd(data.rd, 0);
|
||||
xmove_fd(tfd, 1);
|
||||
xmove_fd(gzipDataPipe.rd, 0);
|
||||
xmove_fd(tar_fd, 1);
|
||||
/* exec gzip/bzip2 program/applet */
|
||||
BB_EXECLP(gzip, gzip, "-f", (char *)0);
|
||||
vfork_exec_errno = errno;
|
||||
@@ -643,18 +632,20 @@ static void NOINLINE vfork_compressor(int tar_fd, const char *gzip)
|
||||
}
|
||||
|
||||
/* parent */
|
||||
xmove_fd(data.wr, tar_fd);
|
||||
close(data.rd);
|
||||
xmove_fd(gzipDataPipe.wr, tar_fd);
|
||||
close(gzipDataPipe.rd);
|
||||
# if WAIT_FOR_CHILD
|
||||
close(status.wr);
|
||||
close(gzipStatusPipe.wr);
|
||||
while (1) {
|
||||
/* Wait until child execs (or fails to) */
|
||||
char buf;
|
||||
int n = full_read(status.rd, &buf, 1);
|
||||
int n;
|
||||
|
||||
/* Wait until child execs (or fails to) */
|
||||
n = full_read(gzipStatusPipe.rd, &buf, 1);
|
||||
if (n < 0 /* && errno == EAGAIN */)
|
||||
continue; /* try it again */
|
||||
}
|
||||
close(status.rd);
|
||||
close(gzipStatusPipe.rd);
|
||||
# endif
|
||||
if (vfork_exec_errno) {
|
||||
errno = vfork_exec_errno;
|
||||
@@ -730,7 +721,11 @@ static NOINLINE int writeTarFile(
|
||||
return errorFlag;
|
||||
}
|
||||
|
||||
#endif /* FEATURE_TAR_CREATE */
|
||||
#else /* !FEATURE_TAR_CREATE */
|
||||
|
||||
# define writeTarFile(...) 0
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_TAR_FROM
|
||||
static llist_t *append_file_list_to_list(llist_t *list)
|
||||
@@ -1160,24 +1155,17 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (LONE_DASH(tar_filename)) {
|
||||
tar_handle->src_fd = tar_fd;
|
||||
tar_handle->seek = seek_by_read;
|
||||
} else
|
||||
if (ENABLE_FEATURE_TAR_AUTODETECT
|
||||
&& ENABLE_FEATURE_SEAMLESS_LZMA
|
||||
&& flags == O_RDONLY
|
||||
&& !(opt & OPT_ANY_COMPRESS)
|
||||
&& is_suffixed_with(tar_filename, ".lzma")
|
||||
/* We do this only for .lzma files, they have no signature.
|
||||
* All other compression formats are recognized in
|
||||
* get_header_tar() when first tar block has invalid format.
|
||||
* Doing it here for all filenames would falsely trigger
|
||||
* on e.g. tarball with 1st file named "BZh5".
|
||||
*/
|
||||
) {
|
||||
tar_handle->src_fd = open_zipped(tar_filename, /*fail_if_not_compressed:*/ 0);
|
||||
if (tar_handle->src_fd < 0)
|
||||
bb_perror_msg_and_die("can't open '%s'", tar_filename);
|
||||
} else {
|
||||
tar_handle->src_fd = xopen(tar_filename, flags);
|
||||
if (ENABLE_FEATURE_TAR_AUTODETECT
|
||||
&& flags == O_RDONLY
|
||||
&& !(opt & OPT_ANY_COMPRESS)
|
||||
) {
|
||||
tar_handle->src_fd = open_zipped(tar_filename, /*fail_if_not_compressed:*/ 0);
|
||||
if (tar_handle->src_fd < 0)
|
||||
bb_perror_msg_and_die("can't open '%s'", tar_filename);
|
||||
} else {
|
||||
tar_handle->src_fd = xopen(tar_filename, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+21
-38
@@ -17,7 +17,7 @@
|
||||
* Zip64 + other methods
|
||||
*/
|
||||
//config:config UNZIP
|
||||
//config: bool "unzip (26 kb)"
|
||||
//config: bool "unzip (24 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: unzip will list or extract files from a ZIP archive,
|
||||
@@ -153,15 +153,15 @@ typedef union {
|
||||
#define FIX_ENDIANNESS_CDF(cdf) \
|
||||
do { if (BB_BIG_ENDIAN) { \
|
||||
(cdf).fmt.version_made_by = SWAP_LE16((cdf).fmt.version_made_by); \
|
||||
(cdf).fmt.version_needed = SWAP_LE16((cdf).fmt.version_needed ); \
|
||||
(cdf).fmt.method = SWAP_LE16((cdf).fmt.method ); \
|
||||
(cdf).fmt.modtime = SWAP_LE16((cdf).fmt.modtime ); \
|
||||
(cdf).fmt.moddate = SWAP_LE16((cdf).fmt.moddate ); \
|
||||
(cdf).fmt.crc32 = SWAP_LE32((cdf).fmt.crc32 ); \
|
||||
(cdf).fmt.cmpsize = SWAP_LE32((cdf).fmt.cmpsize ); \
|
||||
(cdf).fmt.ucmpsize = SWAP_LE32((cdf).fmt.ucmpsize ); \
|
||||
(cdf).fmt.filename_len = SWAP_LE16((cdf).fmt.filename_len ); \
|
||||
(cdf).fmt.extra_len = SWAP_LE16((cdf).fmt.extra_len ); \
|
||||
(cdf).fmt.version_needed = SWAP_LE16((cdf).fmt.version_needed); \
|
||||
(cdf).fmt.method = SWAP_LE16((cdf).fmt.method ); \
|
||||
(cdf).fmt.modtime = SWAP_LE16((cdf).fmt.modtime ); \
|
||||
(cdf).fmt.moddate = SWAP_LE16((cdf).fmt.moddate ); \
|
||||
(cdf).fmt.crc32 = SWAP_LE32((cdf).fmt.crc32 ); \
|
||||
(cdf).fmt.cmpsize = SWAP_LE32((cdf).fmt.cmpsize ); \
|
||||
(cdf).fmt.ucmpsize = SWAP_LE32((cdf).fmt.ucmpsize ); \
|
||||
(cdf).fmt.filename_len = SWAP_LE16((cdf).fmt.filename_len); \
|
||||
(cdf).fmt.extra_len = SWAP_LE16((cdf).fmt.extra_len ); \
|
||||
(cdf).fmt.file_comment_length = SWAP_LE16((cdf).fmt.file_comment_length); \
|
||||
(cdf).fmt.external_attributes = SWAP_LE32((cdf).fmt.external_attributes); \
|
||||
}} while (0)
|
||||
@@ -456,9 +456,7 @@ static int get_lstat_mode(const char *dst_fn)
|
||||
struct stat stat_buf;
|
||||
if (lstat(dst_fn, &stat_buf) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
bb_perror_msg_and_die("can't stat '%s'",
|
||||
dst_fn
|
||||
);
|
||||
bb_perror_msg_and_die("can't stat '%s'", dst_fn);
|
||||
}
|
||||
/* File does not exist */
|
||||
return -1;
|
||||
@@ -636,9 +634,7 @@ int unzip_main(int argc, char **argv)
|
||||
break;
|
||||
if (++i > 2) {
|
||||
*ext = '\0';
|
||||
bb_error_msg_and_die("can't open %s[.zip]",
|
||||
src_fn
|
||||
);
|
||||
bb_error_msg_and_die("can't open %s[.zip]", src_fn);
|
||||
}
|
||||
strcpy(ext, extn[i - 1]);
|
||||
}
|
||||
@@ -650,11 +646,8 @@ int unzip_main(int argc, char **argv)
|
||||
xchdir(base_dir);
|
||||
|
||||
if (quiet <= 1) { /* not -qq */
|
||||
if (quiet == 0) {
|
||||
printf("Archive: %s\n",
|
||||
printable_string(src_fn)
|
||||
);
|
||||
}
|
||||
if (quiet == 0)
|
||||
printf("Archive: %s\n", src_fn);
|
||||
if (opts & OPT_l) {
|
||||
puts(verbose ?
|
||||
" Length Method Size Cmpr Date Time CRC-32 Name\n"
|
||||
@@ -838,8 +831,7 @@ int unzip_main(int argc, char **argv)
|
||||
printf( "%9u " "%s " "%s\n",
|
||||
(unsigned)zip.fmt.ucmpsize,
|
||||
dtbuf,
|
||||
printable_string(dst_fn)
|
||||
);
|
||||
dst_fn);
|
||||
} else {
|
||||
char method6[7];
|
||||
unsigned long percents;
|
||||
@@ -868,8 +860,7 @@ int unzip_main(int argc, char **argv)
|
||||
(unsigned)percents,
|
||||
dtbuf,
|
||||
zip.fmt.crc32,
|
||||
printable_string(dst_fn)
|
||||
);
|
||||
dst_fn);
|
||||
total_size += zip.fmt.cmpsize;
|
||||
}
|
||||
total_usize += zip.fmt.ucmpsize;
|
||||
@@ -895,7 +886,7 @@ int unzip_main(int argc, char **argv)
|
||||
mode = get_lstat_mode(dst_fn);
|
||||
if (mode == -1) { /* ENOENT */
|
||||
if (!quiet) {
|
||||
printf(" creating: %s\n", printable_string(dst_fn));
|
||||
printf(" creating: %s\n", dst_fn);
|
||||
}
|
||||
unzip_create_leading_dirs(dst_fn);
|
||||
if (bb_make_directory(dst_fn, dir_mode, FILEUTILS_IGNORE_CHMOD_ERR)) {
|
||||
@@ -904,9 +895,7 @@ int unzip_main(int argc, char **argv)
|
||||
} else {
|
||||
if (!S_ISDIR(mode)) {
|
||||
bb_error_msg_and_die("'%s' exists but is not a %s",
|
||||
printable_string(dst_fn),
|
||||
"directory"
|
||||
);
|
||||
dst_fn, "directory");
|
||||
}
|
||||
}
|
||||
goto skip_cmpsize;
|
||||
@@ -925,16 +914,12 @@ int unzip_main(int argc, char **argv)
|
||||
if (!S_ISREG(mode)) {
|
||||
fishy:
|
||||
bb_error_msg_and_die("'%s' exists but is not a %s",
|
||||
printable_string(dst_fn),
|
||||
"regular file"
|
||||
);
|
||||
dst_fn, "regular file");
|
||||
}
|
||||
if (overwrite == O_ALWAYS) {
|
||||
goto do_open_and_extract;
|
||||
}
|
||||
printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ",
|
||||
printable_string(dst_fn)
|
||||
);
|
||||
printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
|
||||
my_fgets80(key_buf);
|
||||
/* User input could take a long time. Is it still a regular file? */
|
||||
mode = get_lstat_mode(dst_fn);
|
||||
@@ -964,9 +949,7 @@ int unzip_main(int argc, char **argv)
|
||||
if (!quiet) {
|
||||
printf(/* zip.fmt.method == 0
|
||||
? " extracting: %s\n"
|
||||
: */ " inflating: %s\n",
|
||||
printable_string(dst_fn)
|
||||
);
|
||||
: */ " inflating: %s\n", dst_fn);
|
||||
}
|
||||
#if ENABLE_FEATURE_UNZIP_CDF
|
||||
if (S_ISLNK(file_mode)) {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config DUMPKMAP
|
||||
//config: bool "dumpkmap (1.6 kb)"
|
||||
//config: bool "dumpkmap (1.3 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config FGCONSOLE
|
||||
//config: bool "fgconsole (1.5 kb)"
|
||||
//config: bool "fgconsole (1.6 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config KBD_MODE
|
||||
//config: bool "kbd_mode (4.1 kb)"
|
||||
//config: bool "kbd_mode (4 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
* Licensed under GPLv2, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config LOADFONT
|
||||
//config: bool "loadfont (5.2 kb)"
|
||||
//config: bool "loadfont (5.4 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program loads a console font from standard input.
|
||||
//config:
|
||||
//config:config SETFONT
|
||||
//config: bool "setfont (24 kb)"
|
||||
//config: bool "setfont (26 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config LOADKMAP
|
||||
//config: bool "loadkmap (1.8 kb)"
|
||||
//config: bool "loadkmap (1.5 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config OPENVT
|
||||
//config: bool "openvt (7.2 kb)"
|
||||
//config: bool "openvt (7 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config RESET
|
||||
//config: bool "reset (345 bytes)"
|
||||
//config: bool "reset (275 bytes)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: This program is used to reset the terminal screen, if it
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config RESIZE
|
||||
//config: bool "resize (903 bytes)"
|
||||
//config: bool "resize (756 bytes)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: This program is used to (re)set the width and height of your current
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config SETCONSOLE
|
||||
//config: bool "setconsole (3.6 kb)"
|
||||
//config: bool "setconsole (3.7 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config SETKEYCODES
|
||||
//config: bool "setkeycodes (2.1 kb)"
|
||||
//config: bool "setkeycodes (1.7 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* 3) Save some space by using strcmp(). Calling strncmp() here was silly.
|
||||
*/
|
||||
//config:config BASENAME
|
||||
//config: bool "basename (438 bytes)"
|
||||
//config: bool "basename (371 bytes)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: basename is used to strip the directory and suffix from filenames,
|
||||
|
||||
+2
-4
@@ -195,7 +195,6 @@ int cat_main(int argc UNUSED_PARAM, char **argv)
|
||||
# define CAT_OPT_b (1<<1)
|
||||
if (opts & (CAT_OPT_n|CAT_OPT_b)) { /* -n or -b */
|
||||
struct number_state ns;
|
||||
int exitcode;
|
||||
|
||||
ns.width = 6;
|
||||
ns.start = 1;
|
||||
@@ -204,11 +203,10 @@ int cat_main(int argc UNUSED_PARAM, char **argv)
|
||||
ns.empty_str = "\n";
|
||||
ns.all = !(opts & CAT_OPT_b); /* -n without -b */
|
||||
ns.nonempty = (opts & CAT_OPT_b); /* -b (with or without -n) */
|
||||
exitcode = EXIT_SUCCESS;
|
||||
do {
|
||||
exitcode |= print_numbered_lines(&ns, *argv);
|
||||
print_numbered_lines(&ns, *argv);
|
||||
} while (*++argv);
|
||||
fflush_stdout_and_exit(exitcode);
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
/*opts >>= 2;*/
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config CHGRP
|
||||
//config: bool "chgrp (7.6 kb)"
|
||||
//config: bool "chgrp (7.2 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: chgrp is used to change the group ownership of files.
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config CHMOD
|
||||
//config: bool "chmod (5.5 kb)"
|
||||
//config: bool "chmod (5.1 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: chmod is used to change the access permission of files.
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config CHOWN
|
||||
//config: bool "chown (7.6 kb)"
|
||||
//config: bool "chown (7.2 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: chown is used to change the user and/or group ownership
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config CKSUM
|
||||
//config: bool "cksum (4.1 kb)"
|
||||
//config: bool "cksum (4.2 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: cksum is used to calculate the CRC32 checksum of a file.
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config COMM
|
||||
//config: bool "comm (4.2 kb)"
|
||||
//config: bool "comm (3.9 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: comm is used to compare two files line by line and return
|
||||
|
||||
+1
-25
@@ -12,7 +12,7 @@
|
||||
* Size reduction.
|
||||
*/
|
||||
//config:config CP
|
||||
//config: bool "cp (10 kb)"
|
||||
//config: bool "cp (9.7 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: cp is used to copy files and directories.
|
||||
@@ -24,11 +24,6 @@
|
||||
//config: help
|
||||
//config: Enable long options.
|
||||
//config: Also add support for --parents option.
|
||||
//config:
|
||||
//config:config FEATURE_CP_REFLINK
|
||||
//config: bool "Enable --reflink[=auto]"
|
||||
//config: default y
|
||||
//config: depends on FEATURE_CP_LONG_OPTIONS
|
||||
|
||||
//applet:IF_CP(APPLET_NOEXEC(cp, cp, BB_DIR_BIN, BB_SUID_DROP, cp))
|
||||
/* NOEXEC despite cases when it can be a "runner" (cp -r LARGE_DIR NEW_DIR) */
|
||||
@@ -77,14 +72,10 @@ int cp_main(int argc, char **argv)
|
||||
#if ENABLE_FEATURE_CP_LONG_OPTIONS
|
||||
/*OPT_rmdest = FILEUTILS_RMDEST = 1 << FILEUTILS_CP_OPTNUM */
|
||||
OPT_parents = 1 << (FILEUTILS_CP_OPTNUM+1),
|
||||
OPT_reflink = 1 << (FILEUTILS_CP_OPTNUM+2),
|
||||
#endif
|
||||
};
|
||||
|
||||
#if ENABLE_FEATURE_CP_LONG_OPTIONS
|
||||
# if ENABLE_FEATURE_CP_REFLINK
|
||||
char *reflink = NULL;
|
||||
# endif
|
||||
flags = getopt32long(argv, "^"
|
||||
FILEUTILS_CP_OPTSTR
|
||||
"\0"
|
||||
@@ -108,22 +99,7 @@ int cp_main(int argc, char **argv)
|
||||
"update\0" No_argument "u"
|
||||
"remove-destination\0" No_argument "\xff"
|
||||
"parents\0" No_argument "\xfe"
|
||||
# if ENABLE_FEATURE_CP_REFLINK
|
||||
"reflink\0" Optional_argument "\xfd"
|
||||
, &reflink
|
||||
# endif
|
||||
);
|
||||
# if ENABLE_FEATURE_CP_REFLINK
|
||||
BUILD_BUG_ON((int)OPT_reflink != (int)FILEUTILS_REFLINK);
|
||||
if (flags & FILEUTILS_REFLINK) {
|
||||
if (!reflink)
|
||||
flags |= FILEUTILS_REFLINK_ALWAYS;
|
||||
else if (strcmp(reflink, "always") == 0)
|
||||
flags |= FILEUTILS_REFLINK_ALWAYS;
|
||||
else if (strcmp(reflink, "auto") != 0)
|
||||
bb_show_usage();
|
||||
}
|
||||
# endif
|
||||
#else
|
||||
flags = getopt32(argv, "^"
|
||||
FILEUTILS_CP_OPTSTR
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config CUT
|
||||
//config: bool "cut (5.8 kb)"
|
||||
//config: bool "cut (5.3 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: cut is used to print selected parts of lines from
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@
|
||||
much as possible, missed out a lot of bounds checking */
|
||||
|
||||
//config:config DATE
|
||||
//config: bool "date (7 kb)"
|
||||
//config: bool "date (7.1 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: date is used to set the system date or display the
|
||||
@@ -54,7 +54,7 @@
|
||||
//config: date -s (and other commands like touch -d) use more sensible
|
||||
//config: formats (for one, ISO format YYYY-MM-DD hh:mm:ss.ssssss).
|
||||
//config:
|
||||
//config: With this option off, 'date DATE' and 'date -s DATE' support
|
||||
//config: With this option off, 'date DATE' is 'date -s DATE' support
|
||||
//config: the same format. With it on, 'date DATE' additionally supports
|
||||
//config: MMDDhhmm[[YY]YY][.ss] format.
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
//usage: "\n -d,--date TIME Display TIME, not 'now'"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_DATE_ISOFMT(
|
||||
//usage: "\n -D FMT Use FMT (strptime format) for -d TIME conversion"
|
||||
//usage: "\n -D FMT Use FMT for -d TIME conversion"
|
||||
//usage: )
|
||||
//usage: "\n"
|
||||
//usage: "\nRecognized TIME formats:"
|
||||
|
||||
+35
-61
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config DD
|
||||
//config: bool "dd (7.5 kb)"
|
||||
//config: bool "dd (7.1 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: dd copies a file (from standard input to standard output,
|
||||
@@ -37,7 +37,7 @@
|
||||
//config: elapsed time and speed.
|
||||
//config:
|
||||
//config:config FEATURE_DD_IBS_OBS
|
||||
//config: bool "Enable ibs, obs, iflag, oflag and conv options"
|
||||
//config: bool "Enable ibs, obs, iflag and conv options"
|
||||
//config: default y
|
||||
//config: depends on DD
|
||||
//config: help
|
||||
@@ -56,11 +56,8 @@
|
||||
//kbuild:lib-$(CONFIG_DD) += dd.o
|
||||
|
||||
//usage:#define dd_trivial_usage
|
||||
//usage: "[if=FILE] [of=FILE] [" IF_FEATURE_DD_IBS_OBS("ibs=N obs=N/") "bs=N] [count=N] [skip=N] [seek=N]\n"
|
||||
//usage: IF_FEATURE_DD_IBS_OBS(
|
||||
//usage: " [conv=notrunc|noerror|sync|fsync]\n"
|
||||
//usage: " [iflag=skip_bytes|fullblock] [oflag=seek_bytes|append]"
|
||||
//usage: )
|
||||
//usage: "[if=FILE] [of=FILE] " IF_FEATURE_DD_IBS_OBS("[ibs=N] [obs=N] ") "[bs=N] [count=N] [skip=N]\n"
|
||||
//usage: " [seek=N]" IF_FEATURE_DD_IBS_OBS(" [conv=notrunc|noerror|sync|fsync] [iflag=skip_bytes|fullblock]")
|
||||
//usage:#define dd_full_usage "\n\n"
|
||||
//usage: "Copy a file with converting and formatting\n"
|
||||
//usage: "\n if=FILE Read from FILE instead of stdin"
|
||||
@@ -83,8 +80,6 @@
|
||||
//usage: "\n conv=swab Swap every pair of bytes"
|
||||
//usage: "\n iflag=skip_bytes skip=N is in bytes"
|
||||
//usage: "\n iflag=fullblock Read full blocks"
|
||||
//usage: "\n oflag=seek_bytes seek=N is in bytes"
|
||||
//usage: "\n oflag=append Open output file in append mode"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_DD_STATUS(
|
||||
//usage: "\n status=noxfer Suppress rate output"
|
||||
@@ -138,15 +133,10 @@ enum {
|
||||
FLAG_SKIP_BYTES = (1 << 5) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
FLAG_FULLBLOCK = (1 << 6) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
/* end of input flags */
|
||||
/* start of output flags */
|
||||
FLAG_OFLAG_SHIFT = 7,
|
||||
FLAG_SEEK_BYTES = (1 << 7) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
FLAG_APPEND = (1 << 8) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
/* end of output flags */
|
||||
FLAG_TWOBUFS = (1 << 9) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
FLAG_COUNT = 1 << 10,
|
||||
FLAG_STATUS_NONE = 1 << 11,
|
||||
FLAG_STATUS_NOXFER = 1 << 12,
|
||||
FLAG_TWOBUFS = (1 << 7) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
FLAG_COUNT = 1 << 8,
|
||||
FLAG_STATUS_NONE = 1 << 9,
|
||||
FLAG_STATUS_NOXFER = 1 << 10,
|
||||
};
|
||||
|
||||
static void dd_output_status(int UNUSED_PARAM cur_signal)
|
||||
@@ -192,15 +182,23 @@ static void dd_output_status(int UNUSED_PARAM cur_signal)
|
||||
#endif
|
||||
}
|
||||
|
||||
static ssize_t full_write_or_warn(const void *buf, size_t len,
|
||||
const char *const filename)
|
||||
{
|
||||
ssize_t n = full_write(ofd, buf, len);
|
||||
if (n < 0)
|
||||
bb_perror_msg("writing '%s'", filename);
|
||||
return n;
|
||||
}
|
||||
|
||||
static bool write_and_stats(const void *buf, size_t len, size_t obs,
|
||||
const char *filename)
|
||||
{
|
||||
ssize_t n;
|
||||
|
||||
n = full_write(ofd, buf, len);
|
||||
ssize_t n = full_write_or_warn(buf, len, filename);
|
||||
if (n < 0)
|
||||
return 1;
|
||||
#if ENABLE_FEATURE_DD_THIRD_STATUS_LINE
|
||||
if (n > 0)
|
||||
G.total_bytes += n;
|
||||
G.total_bytes += n;
|
||||
#endif
|
||||
if ((size_t)n == obs) {
|
||||
G.out_full++;
|
||||
@@ -210,14 +208,6 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs,
|
||||
G.out_part++;
|
||||
return 0;
|
||||
}
|
||||
/* n is < len (and possibly is -1).
|
||||
* Even if n >= 0, errno is usually set correctly.
|
||||
* For example, if writing to block device and getting ENOSPC,
|
||||
* full_write() first sees a short write, then tries to write
|
||||
* the remainder and gets errno set to ENOSPC.
|
||||
* It returns n > 0 (the amount which it did write).
|
||||
*/
|
||||
bb_perror_msg("error writing '%s'", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -260,7 +250,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
static const char keywords[] ALIGN1 =
|
||||
"bs\0""count\0""seek\0""skip\0""if\0""of\0"IF_FEATURE_DD_STATUS("status\0")
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
"ibs\0""obs\0""conv\0""iflag\0""oflag\0"
|
||||
"ibs\0""obs\0""conv\0""iflag\0"
|
||||
#endif
|
||||
;
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
@@ -268,8 +258,6 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
"notrunc\0""sync\0""noerror\0""fsync\0""swab\0";
|
||||
static const char iflag_words[] ALIGN1 =
|
||||
"skip_bytes\0""fullblock\0";
|
||||
static const char oflag_words[] ALIGN1 =
|
||||
"seek_bytes\0append\0";
|
||||
#endif
|
||||
#if ENABLE_FEATURE_DD_STATUS
|
||||
static const char status_words[] ALIGN1 =
|
||||
@@ -288,7 +276,6 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
OP_obs,
|
||||
OP_conv,
|
||||
OP_iflag,
|
||||
OP_oflag,
|
||||
/* Must be in the same order as FLAG_XXX! */
|
||||
OP_conv_notrunc = 0,
|
||||
OP_conv_sync,
|
||||
@@ -310,7 +297,6 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
//swab swap every pair of input bytes: will abort on non-even reads
|
||||
OP_iflag_skip_bytes,
|
||||
OP_iflag_fullblock,
|
||||
OP_oflag_seek_bytes,
|
||||
#endif
|
||||
};
|
||||
smallint exitcode = EXIT_FAILURE;
|
||||
@@ -326,13 +312,13 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
#endif
|
||||
/* These are all zeroed at once! */
|
||||
struct {
|
||||
IF_FEATURE_DD_IBS_OBS(size_t ocount;)
|
||||
size_t oc;
|
||||
ssize_t prev_read_size; /* for detecting swab failure */
|
||||
off_t count;
|
||||
off_t seek, skip;
|
||||
const char *infile, *outfile;
|
||||
} Z;
|
||||
#define ocount (Z.ocount )
|
||||
#define oc (Z.oc )
|
||||
#define prev_read_size (Z.prev_read_size)
|
||||
#define count (Z.count )
|
||||
#define seek (Z.seek )
|
||||
@@ -382,10 +368,6 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
G.flags |= parse_comma_flags(val, iflag_words, "iflag") << FLAG_IFLAG_SHIFT;
|
||||
/*continue;*/
|
||||
}
|
||||
if (what == OP_oflag) {
|
||||
G.flags |= parse_comma_flags(val, oflag_words, "oflag") << FLAG_OFLAG_SHIFT;
|
||||
/*continue;*/
|
||||
}
|
||||
#endif
|
||||
if (what == OP_bs) {
|
||||
ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, cwbkMG_suffixes);
|
||||
@@ -453,14 +435,11 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
if (!seek && !(G.flags & FLAG_NOTRUNC))
|
||||
oflag |= O_TRUNC;
|
||||
if (G.flags & FLAG_APPEND)
|
||||
oflag |= O_APPEND;
|
||||
|
||||
xmove_fd(xopen(outfile, oflag), ofd);
|
||||
|
||||
if (seek && !(G.flags & FLAG_NOTRUNC)) {
|
||||
size_t blocksz = (G.flags & FLAG_SEEK_BYTES) ? 1 : obs;
|
||||
if (ftruncate(ofd, seek * blocksz) < 0) {
|
||||
if (ftruncate(ofd, seek * obs) < 0) {
|
||||
struct stat st;
|
||||
|
||||
if (fstat(ofd, &st) < 0
|
||||
@@ -493,8 +472,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
}
|
||||
if (seek) {
|
||||
size_t blocksz = (G.flags & FLAG_SEEK_BYTES) ? 1 : obs;
|
||||
if (lseek(ofd, seek * blocksz, SEEK_CUR) < 0)
|
||||
if (lseek(ofd, seek * obs, SEEK_CUR) < 0)
|
||||
goto die_outfile;
|
||||
}
|
||||
|
||||
@@ -549,26 +527,24 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
n = ibs;
|
||||
}
|
||||
}
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
if (G.flags & FLAG_TWOBUFS) {
|
||||
char *tmp = ibuf;
|
||||
while (n) {
|
||||
size_t d = obs - ocount;
|
||||
size_t d = obs - oc;
|
||||
|
||||
if (d > (size_t)n)
|
||||
d = n;
|
||||
memcpy(obuf + ocount, tmp, d);
|
||||
memcpy(obuf + oc, tmp, d);
|
||||
n -= d;
|
||||
tmp += d;
|
||||
ocount += d;
|
||||
if (ocount == obs) {
|
||||
oc += d;
|
||||
if (oc == obs) {
|
||||
if (write_and_stats(obuf, obs, obs, outfile))
|
||||
goto out_status;
|
||||
ocount = 0;
|
||||
oc = 0;
|
||||
}
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
} else {
|
||||
if (write_and_stats(ibuf, n, obs, outfile))
|
||||
goto out_status;
|
||||
}
|
||||
@@ -579,12 +555,10 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
goto die_outfile;
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
if (ocount != 0) {
|
||||
if (write_and_stats(obuf, ocount, obs, outfile))
|
||||
if (ENABLE_FEATURE_DD_IBS_OBS && oc) {
|
||||
if (write_and_stats(obuf, oc, obs, outfile))
|
||||
goto out_status;
|
||||
}
|
||||
#endif
|
||||
if (close(ifd) < 0) {
|
||||
die_infile:
|
||||
bb_simple_perror_msg_and_die(infile);
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
* Implement -P and -B; better coreutils compat; cleanup
|
||||
*/
|
||||
//config:config DF
|
||||
//config: bool "df (6.8 kb)"
|
||||
//config: bool "df (7.5 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: df reports the amount of disk space used and available
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config DIRNAME
|
||||
//config: bool "dirname (329 bytes)"
|
||||
//config: bool "dirname (289 bytes)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: dirname is used to strip a non-directory suffix from
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config DOS2UNIX
|
||||
//config: bool "dos2unix (5.2 kb)"
|
||||
//config: bool "dos2unix (5.1 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: dos2unix is used to convert a text file from DOS format to
|
||||
//config: UNIX format, and vice versa.
|
||||
//config:
|
||||
//config:config UNIX2DOS
|
||||
//config: bool "unix2dos (5.2 kb)"
|
||||
//config: bool "unix2dos (5.1 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: unix2dos is used to convert a text file from UNIX format to
|
||||
|
||||
+6
-4
@@ -19,16 +19,18 @@
|
||||
* 4) Fixed busybox bug #1284 involving long overflow with human_readable.
|
||||
*/
|
||||
//config:config DU
|
||||
//config: bool "du (6.3 kb)"
|
||||
//config: bool "du (default blocksize of 512 bytes)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: du is used to report the amount of disk space used
|
||||
//config: for specified files.
|
||||
//config:
|
||||
//config:config FEATURE_DU_DEFAULT_BLOCKSIZE_1K
|
||||
//config: bool "Use default blocksize of 1024 bytes (else it's 512 bytes)"
|
||||
//config: bool "Use a default blocksize of 1024 bytes (1K)"
|
||||
//config: default y
|
||||
//config: depends on DU
|
||||
//config: help
|
||||
//config: Use a blocksize of (1K) instead of the default 512b.
|
||||
|
||||
//applet:IF_DU(APPLET(du, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
|
||||
@@ -290,11 +292,11 @@ int du_main(int argc UNUSED_PARAM, char **argv)
|
||||
total = 0;
|
||||
do {
|
||||
total += du(*argv);
|
||||
/* otherwise du /dir /dir won't show /dir twice: */
|
||||
reset_ino_dev_hashtable();
|
||||
G.slink_depth = slink_depth_save;
|
||||
} while (*++argv);
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
reset_ino_dev_hashtable();
|
||||
if (opt & OPT_c_total)
|
||||
print(total, "total");
|
||||
|
||||
|
||||
+2
-2
@@ -19,10 +19,10 @@
|
||||
* The previous version did not allow 4-digit octals.
|
||||
*/
|
||||
//config:config ECHO
|
||||
//config: bool "echo (1.8 kb)"
|
||||
//config: bool "echo (basic SuSv3 version taking no options)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: echo prints a specified string to stdout.
|
||||
//config: echo is used to print a specified string to stdout.
|
||||
//config:
|
||||
//config:# this entry also appears in shell/Config.in, next to the echo builtin
|
||||
//config:config FEATURE_FANCY_ECHO
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
* - use xfunc_error_retval
|
||||
*/
|
||||
//config:config ENV
|
||||
//config: bool "env (4 kb)"
|
||||
//config: bool "env (3.8 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: env is used to set an environment variable and run
|
||||
|
||||
+9
-38
@@ -21,13 +21,13 @@
|
||||
* Caveat: this versions of expand and unexpand don't accept tab lists.
|
||||
*/
|
||||
//config:config EXPAND
|
||||
//config: bool "expand (5.1 kb)"
|
||||
//config: bool "expand (5.8 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: By default, convert all tabs to spaces.
|
||||
//config:
|
||||
//config:config UNEXPAND
|
||||
//config: bool "unexpand (5.3 kb)"
|
||||
//config: bool "unexpand (6 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: By default, convert only leading sequences of blanks to tabs.
|
||||
@@ -63,62 +63,33 @@ enum {
|
||||
OPT_ALL = 1 << 2,
|
||||
};
|
||||
|
||||
//FIXME: does not work properly with input containing NULs
|
||||
//coreutils 8.30 preserves NULs but treats them as chars of width zero:
|
||||
//AB<nul><tab>C will expand <tab> to 6 spaces, not 5.
|
||||
|
||||
#if ENABLE_EXPAND
|
||||
static void expand(FILE *file, unsigned tab_size, unsigned opt)
|
||||
{
|
||||
char *line;
|
||||
|
||||
for (;;) {
|
||||
char *line;
|
||||
while ((line = xmalloc_fgets(file)) != NULL) {
|
||||
unsigned char c;
|
||||
char *ptr;
|
||||
char *ptr_strbeg;
|
||||
//commented-out code handles NULs, +90 bytes of code, not tested much
|
||||
// size_t linelen;
|
||||
// unsigned len = 0;
|
||||
|
||||
// linelen = 1024 * 1024;
|
||||
// line = xmalloc_fgets_str_len(file, "\n", &linelen);
|
||||
line = xmalloc_fgets(file); //
|
||||
if (!line)
|
||||
break;
|
||||
ptr = ptr_strbeg = line;
|
||||
for (;;) {
|
||||
unsigned char c = *ptr;
|
||||
if (c == '\0') {
|
||||
// size_t rem = line + linelen - ptr;
|
||||
// if (rem > 0) {
|
||||
//# if ENABLE_UNICODE_SUPPORT
|
||||
// len += unicode_strwidth(ptr_strbeg);
|
||||
//# else
|
||||
// len += ptr - ptr_strbeg;
|
||||
//# endif
|
||||
// printf("%s%c", ptr_strbeg, '\0');
|
||||
// memmove(ptr, ptr + 1, rem + 1);
|
||||
// ptr_strbeg = ptr;
|
||||
// linelen--;
|
||||
// continue;
|
||||
// }
|
||||
break;
|
||||
}
|
||||
while ((c = *ptr) != '\0') {
|
||||
if ((opt & OPT_INITIAL) && !isblank(c)) {
|
||||
/* not space or tab */
|
||||
break;
|
||||
}
|
||||
if (c == '\t') {
|
||||
unsigned len = 0; //
|
||||
unsigned len;
|
||||
*ptr = '\0';
|
||||
# if ENABLE_UNICODE_SUPPORT
|
||||
len += unicode_strwidth(ptr_strbeg);
|
||||
len = unicode_strwidth(ptr_strbeg);
|
||||
# else
|
||||
len += ptr - ptr_strbeg;
|
||||
len = ptr - ptr_strbeg;
|
||||
# endif
|
||||
len = tab_size - (len % tab_size);
|
||||
/*while (ptr[1] == '\t') { ptr++; len += tab_size; } - can handle many tabs at once */
|
||||
printf("%s%*s", ptr_strbeg, len, "");
|
||||
// len = 0;
|
||||
ptr_strbeg = ptr + 1;
|
||||
}
|
||||
ptr++;
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
* provided they all associate ((x op x) op x).
|
||||
*/
|
||||
//config:config EXPR
|
||||
//config: bool "expr (6.6 kb)"
|
||||
//config: bool "expr (6.1 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: expr is used to calculate numbers and print the result
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
* Licensed under GPLv2, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config FACTOR
|
||||
//config: bool "factor (2.7 kb)"
|
||||
//config: bool "factor (2.6 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: factor factorizes integers
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini fsync implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2008 Nokia Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config FSYNC
|
||||
//config: bool "fsync (3.7 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: fsync is used to flush file-related cached blocks to disk.
|
||||
|
||||
//applet:IF_FSYNC(APPLET_NOFORK(fsync, fsync, BB_DIR_BIN, BB_SUID_DROP, fsync))
|
||||
|
||||
//kbuild:lib-$(CONFIG_FSYNC) += fsync.o
|
||||
|
||||
//usage:#define fsync_trivial_usage
|
||||
//usage: "[-d] FILE..."
|
||||
//usage:#define fsync_full_usage "\n\n"
|
||||
//usage: "Write files' buffered blocks to disk\n"
|
||||
//usage: "\n -d Avoid syncing metadata"
|
||||
|
||||
#include "libbb.h"
|
||||
#ifndef O_NOATIME
|
||||
# define O_NOATIME 0
|
||||
#endif
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
int fsync_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int fsync_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
int status;
|
||||
int opts;
|
||||
|
||||
opts = getopt32(argv, "d"); /* fdatasync */
|
||||
argv += optind;
|
||||
if (!*argv) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
status = EXIT_SUCCESS;
|
||||
do {
|
||||
int fd = open_or_warn(*argv, O_NOATIME | O_NOCTTY | O_RDONLY);
|
||||
|
||||
if (fd == -1) {
|
||||
status = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
if ((opts ? fdatasync(fd) : fsync(fd))) {
|
||||
//status = EXIT_FAILURE; - do we want this?
|
||||
bb_simple_perror_msg(*argv);
|
||||
}
|
||||
close(fd);
|
||||
} while (*++argv);
|
||||
|
||||
return status;
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config HEAD
|
||||
//config: bool "head (3.8 kb)"
|
||||
//config: bool "head (3.7 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: head is used to print the first specified number of lines
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config HOSTID
|
||||
//config: bool "hostid (286 bytes)"
|
||||
//config: bool "hostid (247 bytes)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: hostid prints the numeric identifier (in hexadecimal) for
|
||||
|
||||
+2
-2
@@ -13,13 +13,13 @@
|
||||
* Added -G option Tito Ragusa (C) 2008 for SUSv3.
|
||||
*/
|
||||
//config:config ID
|
||||
//config: bool "id (7 kb)"
|
||||
//config: bool "id (6.7 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: id displays the current user and group ID names.
|
||||
//config:
|
||||
//config:config GROUPS
|
||||
//config: bool "groups (6.7 kb)"
|
||||
//config: bool "groups (6.5 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Print the group names associated with current user id.
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
* Licensed under GPLv2, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config LINK
|
||||
//config: bool "link (3.2 kb)"
|
||||
//config: bool "link (3.1 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: link creates hard links between files.
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config LN
|
||||
//config: bool "ln (4.9 kb)"
|
||||
//config: bool "ln (4.5 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: ln is used to create hard or soft links between files.
|
||||
@@ -29,7 +29,7 @@
|
||||
//usage: "\n -n Don't dereference symlinks - treat like normal file"
|
||||
//usage: "\n -b Make a backup of the target (if exists) before link operation"
|
||||
//usage: "\n -S suf Use suffix instead of ~ when making backup files"
|
||||
//usage: "\n -T Treat LINK as a file, not DIR"
|
||||
//usage: "\n -T 2nd arg must be a DIR"
|
||||
//usage: "\n -v Verbose"
|
||||
//usage:
|
||||
//usage:#define ln_example_usage
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* a diagnostic message and an error return.
|
||||
*/
|
||||
//config:config LOGNAME
|
||||
//config: bool "logname (1.1 kb)"
|
||||
//config: bool "logname (894 bytes)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: logname is used to print the current user's login name.
|
||||
|
||||
+6
-14
@@ -421,7 +421,7 @@ static unsigned calc_name_len(const char *name)
|
||||
uni_stat_t uni_stat;
|
||||
|
||||
// TODO: quote tab as \t, etc, if -Q
|
||||
name = printable_string2(&uni_stat, name);
|
||||
name = printable_string(&uni_stat, name);
|
||||
|
||||
if (!(option_mask32 & OPT_Q)) {
|
||||
return uni_stat.unicode_width;
|
||||
@@ -450,7 +450,7 @@ static unsigned print_name(const char *name)
|
||||
uni_stat_t uni_stat;
|
||||
|
||||
// TODO: quote tab as \t, etc, if -Q
|
||||
name = printable_string2(&uni_stat, name);
|
||||
name = printable_string(&uni_stat, name);
|
||||
|
||||
if (!(option_mask32 & OPT_Q)) {
|
||||
fputs(name, stdout);
|
||||
@@ -1016,15 +1016,7 @@ static void scan_and_display_dirs_recur(struct dnode **dn, int first)
|
||||
subdnp = scan_one_dir((*dn)->fullname, &nfiles);
|
||||
#if ENABLE_DESKTOP
|
||||
if (option_mask32 & (OPT_s|OPT_l)) {
|
||||
if (option_mask32 & OPT_h) {
|
||||
printf("total %-"HUMAN_READABLE_MAX_WIDTH_STR"s\n",
|
||||
/* print size, no fractions, use suffixes */
|
||||
make_human_readable_str(calculate_blocks(subdnp) * 1024,
|
||||
0, 0)
|
||||
);
|
||||
} else {
|
||||
printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp));
|
||||
}
|
||||
printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp));
|
||||
}
|
||||
#endif
|
||||
if (nfiles > 0) {
|
||||
@@ -1086,7 +1078,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
|
||||
static const char ls_longopts[] ALIGN1 =
|
||||
"full-time\0" No_argument "\xff"
|
||||
"group-directories-first\0" No_argument "\xfe"
|
||||
IF_FEATURE_LS_COLOR("color\0" Optional_argument "\xfd")
|
||||
"color\0" Optional_argument "\xfd"
|
||||
;
|
||||
#endif
|
||||
|
||||
@@ -1204,8 +1196,8 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
|
||||
nfiles = 0;
|
||||
do {
|
||||
cur = my_stat(*argv, *argv,
|
||||
/* follow links on command line unless -l, -i, -s or -F: */
|
||||
!(option_mask32 & (OPT_l|OPT_i|OPT_s|OPT_F))
|
||||
/* follow links on command line unless -l, -s or -F: */
|
||||
!(option_mask32 & (OPT_l|OPT_s|OPT_F))
|
||||
/* ... or if -H: */
|
||||
|| (option_mask32 & OPT_H)
|
||||
/* ... or if -L, but my_stat always follows links if -L */
|
||||
|
||||
@@ -6,31 +6,31 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config MD5SUM
|
||||
//config: bool "md5sum (6.5 kb)"
|
||||
//config: bool "md5sum (6.8 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Compute and check MD5 message digest
|
||||
//config:
|
||||
//config:config SHA1SUM
|
||||
//config: bool "sha1sum (5.9 kb)"
|
||||
//config: bool "sha1sum (6 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Compute and check SHA1 message digest
|
||||
//config:
|
||||
//config:config SHA256SUM
|
||||
//config: bool "sha256sum (7 kb)"
|
||||
//config: bool "sha256sum (7.1 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Compute and check SHA256 message digest
|
||||
//config:
|
||||
//config:config SHA512SUM
|
||||
//config: bool "sha512sum (7.4 kb)"
|
||||
//config: bool "sha512sum (7.6 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Compute and check SHA512 message digest
|
||||
//config:
|
||||
//config:config SHA3SUM
|
||||
//config: bool "sha3sum (6.1 kb)"
|
||||
//config: bool "sha3sum (6.3 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Compute and check SHA3 message digest
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
/* Nov 28, 2006 Yoshinori Sato <ysato@users.sourceforge.jp>: Add SELinux Support.
|
||||
*/
|
||||
//config:config MKDIR
|
||||
//config: bool "mkdir (4.5 kb)"
|
||||
//config: bool "mkdir (4.4 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: mkdir is used to create directories with the specified names.
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config MKFIFO
|
||||
//config: bool "mkfifo (3.8 kb)"
|
||||
//config: bool "mkfifo (3.7 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: mkfifo is used to create FIFOs (named pipes).
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config MKNOD
|
||||
//config: bool "mknod (4.5 kb)"
|
||||
//config: bool "mknod (4 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: mknod is used to create FIFOs or block/character special
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
* -p; else /tmp [deprecated]
|
||||
*/
|
||||
//config:config MKTEMP
|
||||
//config: bool "mktemp (4.2 kb)"
|
||||
//config: bool "mktemp (4 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: mktemp is used to create unique temporary files
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
* Size reduction and improved error checking.
|
||||
*/
|
||||
//config:config MV
|
||||
//config: bool "mv (10 kb)"
|
||||
//config: bool "mv (9.8 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: mv is used to move or rename files or directories.
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config NICE
|
||||
//config: bool "nice (2.1 kb)"
|
||||
//config: bool "nice (1.8 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: nice runs a program with modified scheduling priority.
|
||||
|
||||
+3
-6
@@ -5,7 +5,7 @@
|
||||
* Licensed under GPLv2, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config NL
|
||||
//config: bool "nl (4.6 kb)"
|
||||
//config: bool "nl (4.3 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: nl is used to number lines of files.
|
||||
@@ -58,8 +58,6 @@ int nl_main(int argc UNUSED_PARAM, char **argv)
|
||||
"number-width\0" Required_argument "w"
|
||||
;
|
||||
#endif
|
||||
int exitcode;
|
||||
|
||||
ns.width = 6;
|
||||
ns.start = 1;
|
||||
ns.inc = 1;
|
||||
@@ -74,10 +72,9 @@ int nl_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (!*argv)
|
||||
*--argv = (char*)"-";
|
||||
|
||||
exitcode = EXIT_SUCCESS;
|
||||
do {
|
||||
exitcode |= print_numbered_lines(&ns, *argv);
|
||||
print_numbered_lines(&ns, *argv);
|
||||
} while (*++argv);
|
||||
|
||||
fflush_stdout_and_exit(exitcode);
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
+11
-35
@@ -4,7 +4,7 @@
|
||||
* Licensed under GPLv2, see LICENSE in this source tree
|
||||
*/
|
||||
//config:config NPROC
|
||||
//config: bool "nproc (3.7 kb)"
|
||||
//config: bool "nproc (248 bytes)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Print number of CPUs
|
||||
@@ -14,14 +14,10 @@
|
||||
//kbuild:lib-$(CONFIG_NPROC) += nproc.o
|
||||
|
||||
//usage:#define nproc_trivial_usage
|
||||
//usage: ""IF_LONG_OPTS("--all --ignore=N")
|
||||
//usage: ""
|
||||
//TODO: "[--all] [--ignore=N]"
|
||||
//usage:#define nproc_full_usage "\n\n"
|
||||
//usage: "Print number of available CPUs"
|
||||
//usage: IF_LONG_OPTS(
|
||||
//usage: "\n"
|
||||
//usage: "\n --all Number of installed CPUs"
|
||||
//usage: "\n --ignore=N Exclude N CPUs"
|
||||
//usage: )
|
||||
//usage: "Print number of CPUs"
|
||||
|
||||
#include <sched.h>
|
||||
#include "libbb.h"
|
||||
@@ -30,30 +26,13 @@ int nproc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int nproc_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
unsigned long mask[1024];
|
||||
int count = 0;
|
||||
#if ENABLE_LONG_OPTS
|
||||
int ignore = 0;
|
||||
int opts = getopt32long(argv, "\xfe:+",
|
||||
"ignore\0" Required_argument "\xfe"
|
||||
"all\0" No_argument "\xff"
|
||||
, &ignore
|
||||
);
|
||||
unsigned i, count = 0;
|
||||
|
||||
//getopt32(argv, "");
|
||||
|
||||
//if --all, count /sys/devices/system/cpu/cpuN dirs, else:
|
||||
|
||||
if (opts & (1 << 1)) {
|
||||
DIR *cpusd = opendir("/sys/devices/system/cpu");
|
||||
if (cpusd) {
|
||||
struct dirent *de;
|
||||
while (NULL != (de = readdir(cpusd))) {
|
||||
char *cpuid = strstr(de->d_name, "cpu");
|
||||
if (cpuid && isdigit(cpuid[strlen(cpuid) - 1]))
|
||||
count++;
|
||||
}
|
||||
closedir(cpusd);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (sched_getaffinity(0, sizeof(mask), (void*)mask) == 0) {
|
||||
int i;
|
||||
for (i = 0; i < ARRAY_SIZE(mask); i++) {
|
||||
unsigned long m = mask[i];
|
||||
while (m) {
|
||||
@@ -63,11 +42,8 @@ int nproc_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IF_LONG_OPTS(count -= ignore;)
|
||||
if (count <= 0)
|
||||
count = 1;
|
||||
|
||||
if (count == 0)
|
||||
count++;
|
||||
printf("%u\n", count);
|
||||
|
||||
return 0;
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config PASTE
|
||||
//config: bool "paste (4.9 kb)"
|
||||
//config: bool "paste (4.5 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: paste is used to paste lines of different files together
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config PRINTENV
|
||||
//config: bool "printenv (1.3 kb)"
|
||||
//config: bool "printenv (1 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: printenv is used to print all or part of environment.
|
||||
|
||||
+3
-12
@@ -38,7 +38,7 @@
|
||||
/* 19990508 Busy Boxed! Dave Cinege */
|
||||
|
||||
//config:config PRINTF
|
||||
//config: bool "printf (3.8 kb)"
|
||||
//config: bool "printf (3.3 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: printf is used to format and print specified strings.
|
||||
@@ -95,12 +95,6 @@ static int multiconvert(const char *arg, void *result, converter convert)
|
||||
|
||||
static void FAST_FUNC conv_strtoull(const char *arg, void *result)
|
||||
{
|
||||
/* Allow leading '+' - bb_strtoull() by itself does not allow it,
|
||||
* and probably shouldn't (other callers might require purely numeric
|
||||
* inputs to be allowed.
|
||||
*/
|
||||
if (arg[0] == '+')
|
||||
arg++;
|
||||
*(unsigned long long*)result = bb_strtoull(arg, NULL, 0);
|
||||
/* both coreutils 6.10 and bash 3.2:
|
||||
* $ printf '%x\n' -2
|
||||
@@ -113,8 +107,6 @@ static void FAST_FUNC conv_strtoull(const char *arg, void *result)
|
||||
}
|
||||
static void FAST_FUNC conv_strtoll(const char *arg, void *result)
|
||||
{
|
||||
if (arg[0] == '+')
|
||||
arg++;
|
||||
*(long long*)result = bb_strtoll(arg, NULL, 0);
|
||||
}
|
||||
static void FAST_FUNC conv_strtod(const char *arg, void *result)
|
||||
@@ -199,7 +191,6 @@ static void print_direc(char *format, unsigned fmt_length,
|
||||
if (have_width - 1 == have_prec)
|
||||
have_width = NULL;
|
||||
|
||||
/* multiconvert sets errno = 0, but %s needs it cleared */
|
||||
errno = 0;
|
||||
|
||||
switch (format[fmt_length - 1]) {
|
||||
@@ -208,7 +199,7 @@ static void print_direc(char *format, unsigned fmt_length,
|
||||
break;
|
||||
case 'd':
|
||||
case 'i':
|
||||
llv = my_xstrtoll(skip_whitespace(argument));
|
||||
llv = my_xstrtoll(argument);
|
||||
print_long:
|
||||
if (!have_width) {
|
||||
if (!have_prec)
|
||||
@@ -226,7 +217,7 @@ static void print_direc(char *format, unsigned fmt_length,
|
||||
case 'u':
|
||||
case 'x':
|
||||
case 'X':
|
||||
llv = my_xstrtoull(skip_whitespace(argument));
|
||||
llv = my_xstrtoull(argument);
|
||||
/* cheat: unsigned long and long have same width, so... */
|
||||
goto print_long;
|
||||
case 's':
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config PWD
|
||||
//config: bool "pwd (3.7 kb)"
|
||||
//config: bool "pwd (3.4 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: pwd is used to print the current directory.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config READLINK
|
||||
//config: bool "readlink (4 kb)"
|
||||
//config: bool "readlink (3.6 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: This program reads a symbolic link and returns the name
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config REALPATH
|
||||
//config: bool "realpath (1.6 kb)"
|
||||
//config: bool "realpath (1.1 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Return the canonicalized absolute pathname.
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
* Size reduction.
|
||||
*/
|
||||
//config:config RM
|
||||
//config: bool "rm (5.4 kb)"
|
||||
//config: bool "rm (4.9 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: rm is used to remove files or directories.
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config RMDIR
|
||||
//config: bool "rmdir (3.5 kb)"
|
||||
//config: bool "rmdir (3.4 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: rmdir is used to remove empty directories.
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config SEQ
|
||||
//config: bool "seq (3.8 kb)"
|
||||
//config: bool "seq (3.6 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: print a sequence of numbers
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* Licensed under GPLv2, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config SHRED
|
||||
//config: bool "shred (4.9 kb)"
|
||||
//config: bool "shred (5 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Overwrite a file to hide its contents, and optionally delete it
|
||||
|
||||
+73
-10
@@ -13,7 +13,7 @@
|
||||
* time suffixes for seconds, minutes, hours, and days.
|
||||
*/
|
||||
//config:config SLEEP
|
||||
//config: bool "sleep (2 kb)"
|
||||
//config: bool "sleep (1.7 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: sleep is used to pause for a specified number of seconds.
|
||||
@@ -32,6 +32,13 @@
|
||||
//config: depends on SLEEP
|
||||
//config: help
|
||||
//config: Allow sleep to pause for specified minutes, hours, and days.
|
||||
//config:
|
||||
//config:config FEATURE_FLOAT_SLEEP
|
||||
//config: bool "Enable fractional arguments"
|
||||
//config: default y
|
||||
//config: depends on FEATURE_FANCY_SLEEP
|
||||
//config: help
|
||||
//config: Allow for fractional numeric parameters.
|
||||
|
||||
/* Do not make this applet NOFORK. It breaks ^C-ing of pauses in shells */
|
||||
//applet:IF_SLEEP(APPLET(sleep, BB_DIR_BIN, BB_SUID_DROP))
|
||||
@@ -59,33 +66,89 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
#if ENABLE_FEATURE_FANCY_SLEEP || ENABLE_FEATURE_FLOAT_SLEEP
|
||||
static const struct suffix_mult sfx[] = {
|
||||
{ "s", 1 },
|
||||
{ "m", 60 },
|
||||
{ "h", 60*60 },
|
||||
{ "d", 24*60*60 },
|
||||
{ "", 0 }
|
||||
};
|
||||
#endif
|
||||
|
||||
int sleep_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int sleep_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
duration_t duration;
|
||||
#if ENABLE_FEATURE_FLOAT_SLEEP
|
||||
double duration;
|
||||
struct timespec ts;
|
||||
#else
|
||||
unsigned duration;
|
||||
#endif
|
||||
|
||||
++argv;
|
||||
if (!*argv)
|
||||
bb_show_usage();
|
||||
|
||||
/* GNU sleep accepts "inf", "INF", "infinity" and "INFINITY" */
|
||||
if (strncasecmp(argv[0], "inf", 3) == 0)
|
||||
for (;;)
|
||||
sleep(INT_MAX);
|
||||
#if ENABLE_FEATURE_FLOAT_SLEEP
|
||||
|
||||
#if ENABLE_FEATURE_FANCY_SLEEP
|
||||
# if ENABLE_FLOAT_DURATION
|
||||
# if ENABLE_LOCALE_SUPPORT
|
||||
/* undo busybox.c setlocale */
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
# endif
|
||||
duration = 0;
|
||||
do {
|
||||
duration += parse_duration_str(*argv);
|
||||
char *arg = *argv;
|
||||
if (strchr(arg, '.')) {
|
||||
double d;
|
||||
char *pp;
|
||||
int len = strspn(arg, "0123456789.");
|
||||
char sv = arg[len];
|
||||
arg[len] = '\0';
|
||||
errno = 0;
|
||||
d = strtod(arg, &pp);
|
||||
if (errno || *pp)
|
||||
bb_show_usage();
|
||||
arg += len;
|
||||
*arg-- = sv;
|
||||
sv = *arg;
|
||||
*arg = '1';
|
||||
duration += d * xatoul_sfx(arg, sfx);
|
||||
*arg = sv;
|
||||
} else {
|
||||
duration += xatoul_sfx(arg, sfx);
|
||||
}
|
||||
} while (*++argv);
|
||||
sleep_for_duration(duration);
|
||||
|
||||
ts.tv_sec = MAXINT(typeof(ts.tv_sec));
|
||||
ts.tv_nsec = 0;
|
||||
if (duration >= 0 && duration < ts.tv_sec) {
|
||||
ts.tv_sec = duration;
|
||||
ts.tv_nsec = (duration - ts.tv_sec) * 1000000000;
|
||||
}
|
||||
do {
|
||||
errno = 0;
|
||||
nanosleep(&ts, &ts);
|
||||
} while (errno == EINTR);
|
||||
|
||||
#elif ENABLE_FEATURE_FANCY_SLEEP
|
||||
|
||||
duration = 0;
|
||||
do {
|
||||
duration += xatou_range_sfx(*argv, 0, UINT_MAX - duration, sfx);
|
||||
} while (*++argv);
|
||||
sleep(duration);
|
||||
|
||||
#else /* simple */
|
||||
|
||||
duration = xatou(*argv);
|
||||
sleep(duration);
|
||||
// Off. If it's really needed, provide example why
|
||||
//if (sleep(duration)) {
|
||||
// bb_perror_nomsg_and_die();
|
||||
//}
|
||||
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+21
-28
@@ -12,7 +12,7 @@
|
||||
* http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
|
||||
*/
|
||||
//config:config SORT
|
||||
//config: bool "sort (7.7 kb)"
|
||||
//config: bool "sort (7.4 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: sort is used to sort lines of text in specified files.
|
||||
@@ -60,7 +60,6 @@
|
||||
//usage: IF_FEATURE_SORT_BIG(
|
||||
//usage: "\n -g General numerical sort"
|
||||
//usage: "\n -M Sort month"
|
||||
//usage: "\n -V Sort version"
|
||||
//usage: "\n -t CHAR Field separator"
|
||||
//usage: "\n -k N[,M] Sort by Nth field"
|
||||
//usage: )
|
||||
@@ -92,33 +91,32 @@
|
||||
|
||||
/* These are sort types */
|
||||
enum {
|
||||
FLAG_n = 1 << 0, /* Numeric sort */
|
||||
FLAG_g = 1 << 1, /* Sort using strtod() */
|
||||
FLAG_M = 1 << 2, /* Sort date */
|
||||
FLAG_V = 1 << 3, /* Sort version */
|
||||
FLAG_n = 1, /* Numeric sort */
|
||||
FLAG_g = 2, /* Sort using strtod() */
|
||||
FLAG_M = 4, /* Sort date */
|
||||
/* ucsz apply to root level only, not keys. b at root level implies bb */
|
||||
FLAG_u = 1 << 4, /* Unique */
|
||||
FLAG_c = 1 << 5, /* Check: no output, exit(!ordered) */
|
||||
FLAG_s = 1 << 6, /* Stable sort, no ascii fallback at end */
|
||||
FLAG_z = 1 << 7, /* Input and output is NUL terminated, not \n */
|
||||
FLAG_u = 8, /* Unique */
|
||||
FLAG_c = 0x10, /* Check: no output, exit(!ordered) */
|
||||
FLAG_s = 0x20, /* Stable sort, no ascii fallback at end */
|
||||
FLAG_z = 0x40, /* Input and output is NUL terminated, not \n */
|
||||
/* These can be applied to search keys, the previous four can't */
|
||||
FLAG_b = 1 << 8, /* Ignore leading blanks */
|
||||
FLAG_r = 1 << 9, /* Reverse */
|
||||
FLAG_d = 1 << 10, /* Ignore !(isalnum()|isspace()) */
|
||||
FLAG_f = 1 << 11, /* Force uppercase */
|
||||
FLAG_i = 1 << 12, /* Ignore !isprint() */
|
||||
FLAG_m = 1 << 13, /* ignored: merge already sorted files; do not sort */
|
||||
FLAG_S = 1 << 14, /* ignored: -S, --buffer-size=SIZE */
|
||||
FLAG_T = 1 << 15, /* ignored: -T, --temporary-directory=DIR */
|
||||
FLAG_o = 1 << 16,
|
||||
FLAG_k = 1 << 17,
|
||||
FLAG_t = 1 << 18,
|
||||
FLAG_b = 0x80, /* Ignore leading blanks */
|
||||
FLAG_r = 0x100, /* Reverse */
|
||||
FLAG_d = 0x200, /* Ignore !(isalnum()|isspace()) */
|
||||
FLAG_f = 0x400, /* Force uppercase */
|
||||
FLAG_i = 0x800, /* Ignore !isprint() */
|
||||
FLAG_m = 0x1000, /* ignored: merge already sorted files; do not sort */
|
||||
FLAG_S = 0x2000, /* ignored: -S, --buffer-size=SIZE */
|
||||
FLAG_T = 0x4000, /* ignored: -T, --temporary-directory=DIR */
|
||||
FLAG_o = 0x8000,
|
||||
FLAG_k = 0x10000,
|
||||
FLAG_t = 0x20000,
|
||||
FLAG_bb = 0x80000000, /* Ignore trailing blanks */
|
||||
FLAG_no_tie_break = 0x40000000,
|
||||
};
|
||||
|
||||
static const char sort_opt_str[] ALIGN1 = "^"
|
||||
"ngMVucszbrdfimS:T:o:k:*t:"
|
||||
"ngMucszbrdfimS:T:o:k:*t:"
|
||||
"\0" "o--o:t--t"/*-t, -o: at most one of each*/;
|
||||
/*
|
||||
* OPT_STR must not be string literal, needs to have stable address:
|
||||
@@ -275,15 +273,10 @@ static int compare_keys(const void *xarg, const void *yarg)
|
||||
y = *(char **)yarg;
|
||||
#endif
|
||||
/* Perform actual comparison */
|
||||
switch (flags & (FLAG_n | FLAG_g | FLAG_M | FLAG_V)) {
|
||||
switch (flags & (FLAG_n | FLAG_M | FLAG_g)) {
|
||||
default:
|
||||
bb_error_msg_and_die("unknown sort type");
|
||||
break;
|
||||
#if defined(HAVE_STRVERSCMP) && HAVE_STRVERSCMP == 1
|
||||
case FLAG_V:
|
||||
retval = strverscmp(x, y);
|
||||
break;
|
||||
#endif
|
||||
/* Ascii sort */
|
||||
case 0:
|
||||
#if ENABLE_LOCALE_SUPPORT
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config SPLIT
|
||||
//config: bool "split (5 kb)"
|
||||
//config: bool "split (5.4 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Split a file into pieces.
|
||||
|
||||
+45
-49
@@ -13,7 +13,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config STAT
|
||||
//config: bool "stat (11 kb)"
|
||||
//config: bool "stat (10 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: display file or filesystem status.
|
||||
@@ -169,42 +169,6 @@ static const char *human_time(time_t t)
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_STAT_FILESYSTEM
|
||||
#define FS_TYPE_LIST \
|
||||
FS_TYPE(0xADFF, "affs") \
|
||||
FS_TYPE(0x1CD1, "devpts") \
|
||||
FS_TYPE(0x137D, "ext") \
|
||||
FS_TYPE(0xEF51, "ext2") \
|
||||
FS_TYPE(0xEF53, "ext2/ext3") \
|
||||
FS_TYPE(0x3153464a, "jfs") \
|
||||
FS_TYPE(0x58465342, "xfs") \
|
||||
FS_TYPE(0xF995E849, "hpfs") \
|
||||
FS_TYPE(0x9660, "isofs") \
|
||||
FS_TYPE(0x4000, "isofs") \
|
||||
FS_TYPE(0x4004, "isofs") \
|
||||
FS_TYPE(0x137F, "minix") \
|
||||
FS_TYPE(0x138F, "minix (30 char.)") \
|
||||
FS_TYPE(0x2468, "minix v2") \
|
||||
FS_TYPE(0x2478, "minix v2 (30 char.)") \
|
||||
FS_TYPE(0x4d44, "msdos") \
|
||||
FS_TYPE(0x4006, "fat") \
|
||||
FS_TYPE(0x564c, "novell") \
|
||||
FS_TYPE(0x6969, "nfs") \
|
||||
FS_TYPE(0x9fa0, "proc") \
|
||||
FS_TYPE(0x517B, "smb") \
|
||||
FS_TYPE(0x012FF7B4, "xenix") \
|
||||
FS_TYPE(0x012FF7B5, "sysv4") \
|
||||
FS_TYPE(0x012FF7B6, "sysv2") \
|
||||
FS_TYPE(0x012FF7B7, "coh") \
|
||||
FS_TYPE(0x00011954, "ufs") \
|
||||
FS_TYPE(0x012FD16D, "xia") \
|
||||
FS_TYPE(0x5346544e, "ntfs") \
|
||||
FS_TYPE(0x1021994, "tmpfs") \
|
||||
FS_TYPE(0x52654973, "reiserfs") \
|
||||
FS_TYPE(0x28cd3d45, "cramfs") \
|
||||
FS_TYPE(0x7275, "romfs") \
|
||||
FS_TYPE(0x858458f6, "ramfs") \
|
||||
FS_TYPE(0x73717368, "squashfs") \
|
||||
FS_TYPE(0x62656572, "sysfs")
|
||||
/* Return the type of the specified file system.
|
||||
* Some systems have statfvs.f_basetype[FSTYPSZ]. (AIX, HP-UX, and Solaris)
|
||||
* Others have statfs.f_fstypename[MFSNAMELEN]. (NetBSD 1.5.2)
|
||||
@@ -212,22 +176,54 @@ FS_TYPE(0x62656572, "sysfs")
|
||||
*/
|
||||
static const char *human_fstype(uint32_t f_type)
|
||||
{
|
||||
# define FS_TYPE(type, name) type,
|
||||
static const uint32_t fstype[] = {
|
||||
FS_TYPE_LIST
|
||||
static const struct types {
|
||||
uint32_t type;
|
||||
const char *const fs;
|
||||
} humantypes[] = {
|
||||
{ 0xADFF, "affs" },
|
||||
{ 0x1Cd1, "devpts" },
|
||||
{ 0x137D, "ext" },
|
||||
{ 0xEF51, "ext2" },
|
||||
{ 0xEF53, "ext2/ext3" },
|
||||
{ 0x3153464a, "jfs" },
|
||||
{ 0x58465342, "xfs" },
|
||||
{ 0xF995E849, "hpfs" },
|
||||
{ 0x9660, "isofs" },
|
||||
{ 0x4000, "isofs" },
|
||||
{ 0x4004, "isofs" },
|
||||
{ 0x137F, "minix" },
|
||||
{ 0x138F, "minix (30 char.)" },
|
||||
{ 0x2468, "minix v2" },
|
||||
{ 0x2478, "minix v2 (30 char.)" },
|
||||
{ 0x4d44, "msdos" },
|
||||
{ 0x4006, "fat" },
|
||||
{ 0x564c, "novell" },
|
||||
{ 0x6969, "nfs" },
|
||||
{ 0x9fa0, "proc" },
|
||||
{ 0x517B, "smb" },
|
||||
{ 0x012FF7B4, "xenix" },
|
||||
{ 0x012FF7B5, "sysv4" },
|
||||
{ 0x012FF7B6, "sysv2" },
|
||||
{ 0x012FF7B7, "coh" },
|
||||
{ 0x00011954, "ufs" },
|
||||
{ 0x012FD16D, "xia" },
|
||||
{ 0x5346544e, "ntfs" },
|
||||
{ 0x1021994, "tmpfs" },
|
||||
{ 0x52654973, "reiserfs" },
|
||||
{ 0x28cd3d45, "cramfs" },
|
||||
{ 0x7275, "romfs" },
|
||||
{ 0x858458f6, "ramfs" },
|
||||
{ 0x73717368, "squashfs" },
|
||||
{ 0x62656572, "sysfs" },
|
||||
{ 0, "UNKNOWN" }
|
||||
};
|
||||
# undef FS_TYPE
|
||||
# define FS_TYPE(type, name) name"\0"
|
||||
static const char humanname[] ALIGN1 =
|
||||
FS_TYPE_LIST
|
||||
"UNKNOWN";
|
||||
# undef FS_TYPE
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(fstype); ++i)
|
||||
if (fstype[i] == f_type)
|
||||
for (i = 0; humantypes[i].type; ++i)
|
||||
if (humantypes[i].type == f_type)
|
||||
break;
|
||||
return nth_string(humanname, i);
|
||||
return humantypes[i].fs;
|
||||
}
|
||||
|
||||
/* "man statfs" says that statfsbuf->f_fsid is a mess */
|
||||
|
||||
+13
-7
@@ -5,12 +5,23 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
/* David MacKenzie <djm@gnu.ai.mit.edu>
|
||||
/* Usage: stty [-ag] [-F device] [setting...]
|
||||
*
|
||||
* Options:
|
||||
* -a Write all current settings to stdout in human-readable form.
|
||||
* -g Write all current settings to stdout in stty-readable form.
|
||||
* -F Open and use the specified device instead of stdin
|
||||
*
|
||||
* If no args are given, write to stdout the baud rate and settings that
|
||||
* have been changed from their defaults. Mode reading and changes
|
||||
* are done on the specified device, or stdin if none was specified.
|
||||
*
|
||||
* David MacKenzie <djm@gnu.ai.mit.edu>
|
||||
*
|
||||
* Special for busybox ported by Vladimir Oleynik <dzo@simtreas.ru> 2001
|
||||
*/
|
||||
//config:config STTY
|
||||
//config: bool "stty (8.9 kb)"
|
||||
//config: bool "stty (8.6 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: stty is used to change and print terminal line settings.
|
||||
@@ -29,11 +40,6 @@
|
||||
//usage: "\n -g Print in stty-readable form"
|
||||
//usage: "\n [SETTING] See manpage"
|
||||
|
||||
/* If no args are given, write to stdout the baud rate and settings that
|
||||
* have been changed from their defaults. Mode reading and changes
|
||||
* are done on the specified device, or stdin if none was specified.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config SUM
|
||||
//config: bool "sum (4 kb)"
|
||||
//config: bool "sum (4.3 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: checksum and count the blocks in a file
|
||||
|
||||
+33
-71
@@ -8,7 +8,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config SYNC
|
||||
//config: bool "sync (3.8 kb)"
|
||||
//config: bool "sync (769 bytes)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: sync is used to flush filesystem buffers.
|
||||
@@ -20,7 +20,6 @@
|
||||
//config: sync -d FILE... executes fdatasync() on each FILE.
|
||||
//config: sync -f FILE... executes syncfs() on each FILE.
|
||||
|
||||
// APPLET_NOFORK:name main location suid_type help
|
||||
//applet:IF_SYNC(APPLET_NOFORK(sync, sync, BB_DIR_BIN, BB_SUID_DROP, sync))
|
||||
|
||||
//kbuild:lib-$(CONFIG_SYNC) += sync.o
|
||||
@@ -43,98 +42,61 @@
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
#if ENABLE_FEATURE_SYNC_FANCY || ENABLE_FSYNC
|
||||
static int sync_common(int opts, char **argv)
|
||||
int sync_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int sync_main(int argc UNUSED_PARAM, char **argv IF_NOT_DESKTOP(UNUSED_PARAM))
|
||||
{
|
||||
int ret;
|
||||
#if !ENABLE_FEATURE_SYNC_FANCY
|
||||
/* coreutils-6.9 compat */
|
||||
bb_warn_ignoring_args(argv[1]);
|
||||
sync();
|
||||
return EXIT_SUCCESS;
|
||||
#else
|
||||
unsigned opts;
|
||||
int ret = EXIT_SUCCESS;
|
||||
|
||||
enum {
|
||||
OPT_DATASYNC = (1 << 0),
|
||||
OPT_SYNCFS = (1 << 1),
|
||||
};
|
||||
|
||||
ret = EXIT_SUCCESS;
|
||||
do {
|
||||
/* GNU "sync FILE" uses O_NONBLOCK open */
|
||||
int fd = open_or_warn(*argv, /*O_NOATIME |*/ O_NOCTTY | O_RDONLY | O_NONBLOCK);
|
||||
/* open(NOATIME) can only be used by owner or root, don't use NOATIME here */
|
||||
opts = getopt32(argv, "^" "df" "\0" "d--f:f--d");
|
||||
argv += optind;
|
||||
|
||||
/* Handle the no-argument case. */
|
||||
if (!argv[0])
|
||||
sync();
|
||||
|
||||
while (*argv) {
|
||||
int fd = open_or_warn(*argv, O_RDONLY);
|
||||
|
||||
if (fd < 0) {
|
||||
ret = EXIT_FAILURE;
|
||||
goto next;
|
||||
}
|
||||
# if ENABLE_FEATURE_SYNC_FANCY
|
||||
if (opts & OPT_DATASYNC) {
|
||||
if (fdatasync(fd))
|
||||
goto err;
|
||||
goto do_close;
|
||||
}
|
||||
if (opts & OPT_SYNCFS) {
|
||||
/*
|
||||
* syncfs is documented to only fail with EBADF,
|
||||
* which can't happen here. So, no error checks.
|
||||
*/
|
||||
syncfs(fd);
|
||||
} else
|
||||
# endif
|
||||
if (((opts & OPT_DATASYNC) ? fdatasync(fd) : fsync(fd)) != 0) {
|
||||
goto do_close;
|
||||
}
|
||||
if (fsync(fd)) {
|
||||
err:
|
||||
bb_simple_perror_msg(*argv);
|
||||
ret = EXIT_FAILURE;
|
||||
}
|
||||
do_close:
|
||||
close(fd);
|
||||
next:
|
||||
argv++;
|
||||
} while (*argv);
|
||||
++argv;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLE_SYNC
|
||||
int sync_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int sync_main(int argc UNUSED_PARAM, char **argv IF_NOT_DESKTOP(UNUSED_PARAM))
|
||||
{
|
||||
# if !ENABLE_FEATURE_SYNC_FANCY
|
||||
/* coreutils-6.9 compat */
|
||||
bb_warn_ignoring_args(argv[1]);
|
||||
sync();
|
||||
return EXIT_SUCCESS;
|
||||
# else
|
||||
unsigned opts = getopt32(argv, "^" "df" "\0" "d--f:f--d");
|
||||
argv += optind;
|
||||
if (!argv[0]) {
|
||||
sync();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
return sync_common(opts, argv);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Mini fsync implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2008 Nokia Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config FSYNC
|
||||
//config: bool "fsync (3.6 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: fsync is used to flush file-related cached blocks to disk.
|
||||
|
||||
// APPLET_NOFORK:name main location suid_type help
|
||||
//applet:IF_FSYNC(APPLET_NOFORK(fsync, fsync, BB_DIR_BIN, BB_SUID_DROP, fsync))
|
||||
|
||||
//kbuild:lib-$(CONFIG_FSYNC) += sync.o
|
||||
|
||||
//usage:#define fsync_trivial_usage
|
||||
//usage: "[-d] FILE..."
|
||||
//usage:#define fsync_full_usage "\n\n"
|
||||
//usage: "Write all buffered blocks in FILEs to disk\n"
|
||||
//usage: "\n -d Avoid syncing metadata"
|
||||
|
||||
#if ENABLE_FSYNC
|
||||
int fsync_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int fsync_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
int opts = getopt32(argv, "^" "d" "\0" "-1"/*min 1 arg*/);
|
||||
argv += optind;
|
||||
return sync_common(opts, argv);
|
||||
}
|
||||
#endif
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* http://www.uclibc.org/lists/busybox/2003-July/008813.html
|
||||
*/
|
||||
//config:config TAC
|
||||
//config: bool "tac (3.9 kb)"
|
||||
//config: bool "tac (4.1 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: tac is used to concatenate and print files in reverse.
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
* 7) lseek attempted when count==0 even if arg was +0 (from top)
|
||||
*/
|
||||
//config:config TAIL
|
||||
//config: bool "tail (6.8 kb)"
|
||||
//config: bool "tail (7.1 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: tail is used to print the last specified number of lines
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
//config:config TEE
|
||||
//config: bool "tee (4.2 kb)"
|
||||
//config: bool "tee (4.3 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: tee is used to read from standard input and write
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
* "This program is in the Public Domain."
|
||||
*/
|
||||
//config:config TEST
|
||||
//config: bool "test (4.1 kb)"
|
||||
//config: bool "test (3.6 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: test is used to check file types and compare values,
|
||||
|
||||
+8
-13
@@ -28,7 +28,7 @@
|
||||
* rewrite 14-11-2008 vda
|
||||
*/
|
||||
//config:config TIMEOUT
|
||||
//config: bool "timeout (6 kb)"
|
||||
//config: bool "timeout (5.5 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Runs a program and watches it. If it does not terminate in
|
||||
@@ -39,10 +39,10 @@
|
||||
//kbuild:lib-$(CONFIG_TIMEOUT) += timeout.o
|
||||
|
||||
//usage:#define timeout_trivial_usage
|
||||
//usage: "[-s SIG] SECS PROG ARGS"
|
||||
//usage: "[-t SECS] [-s SIG] PROG ARGS"
|
||||
//usage:#define timeout_full_usage "\n\n"
|
||||
//usage: "Runs PROG. Sends SIG to it if it is not gone in SECS seconds.\n"
|
||||
//usage: "Default SIG: TERM."
|
||||
//usage: "Defaults: SECS: 10, SIG: TERM."
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
@@ -52,7 +52,7 @@ int timeout_main(int argc UNUSED_PARAM, char **argv)
|
||||
int signo;
|
||||
int status;
|
||||
int parent = 0;
|
||||
int timeout;
|
||||
int timeout = 10;
|
||||
pid_t pid;
|
||||
#if !BB_MMU
|
||||
char *sv1, *sv2;
|
||||
@@ -63,29 +63,24 @@ int timeout_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
/* -t SECONDS; -p PARENT_PID */
|
||||
/* '+': stop at first non-option */
|
||||
getopt32(argv, "+s:" USE_FOR_NOMMU("p:+"), &opt_s, &parent);
|
||||
getopt32(argv, "+s:t:+" USE_FOR_NOMMU("p:+"), &opt_s, &timeout, &parent);
|
||||
/*argv += optind; - no, wait for bb_daemonize_or_rexec! */
|
||||
|
||||
signo = get_signum(opt_s);
|
||||
if (signo < 0)
|
||||
bb_error_msg_and_die("unknown signal '%s'", opt_s);
|
||||
|
||||
if (!argv[optind])
|
||||
bb_show_usage();
|
||||
timeout = parse_duration_str(argv[optind++]);
|
||||
if (!argv[optind]) /* no PROG? */
|
||||
bb_show_usage();
|
||||
|
||||
/* We want to create a grandchild which will watch
|
||||
* and kill the grandparent. Other methods:
|
||||
* making parent watch child disrupts parent<->child link
|
||||
* (example: "tcpsvd 0.0.0.0 1234 timeout service_prog" -
|
||||
* it's better if service_prog is a child of tcpsvd!),
|
||||
* making child watch parent results in programs having
|
||||
* unexpected children. */
|
||||
* unexpected children. */
|
||||
|
||||
if (parent) /* we were re-execed, already grandchild */
|
||||
goto grandchild;
|
||||
if (!argv[optind]) /* no PROG? */
|
||||
bb_show_usage();
|
||||
|
||||
#if !BB_MMU
|
||||
sv1 = argv[optind];
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* Also, exiting on a failure was a bug. All args should be processed.
|
||||
*/
|
||||
//config:config TOUCH
|
||||
//config: bool "touch (5.9 kb)"
|
||||
//config: bool "touch (5.8 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: touch is used to create or change the access and/or
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
* TODO: graph, print
|
||||
*/
|
||||
//config:config TR
|
||||
//config: bool "tr (5.1 kb)"
|
||||
//config: bool "tr (5.5 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: tr is used to squeeze, and/or delete characters from standard
|
||||
|
||||
Loaded 100 of 670 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user