Compare commits
231
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db726ae0c6 | ||
|
|
bb61205290 | ||
|
|
56a335378a | ||
|
|
5b939a6d29 | ||
|
|
d326be2850 | ||
|
|
bcc5b0e6ca | ||
|
|
611bbfc148 | ||
|
|
23dd1c75b7 | ||
|
|
89358a7131 | ||
|
|
39b71881b8 | ||
|
|
67cc582d42 | ||
|
|
ee1e0987e4 | ||
|
|
a4c3a34139 | ||
|
|
ec9a5e6083 | ||
|
|
fecb1693cc | ||
|
|
40f9fe2160 | ||
|
|
77a51a2709 | ||
|
|
c7ef818768 | ||
|
|
1462673dde | ||
|
|
cad20ced86 | ||
|
|
1237d627e9 | ||
|
|
46a71dc30c | ||
|
|
6cfec7dd02 | ||
|
|
51a471d05d | ||
|
|
521220ed1a | ||
|
|
18bcaf374c | ||
|
|
649acb9e23 | ||
|
|
a7b52d26c4 | ||
|
|
93e2a22482 | ||
|
|
0ab2dd4f28 | ||
|
|
6297d66eda | ||
|
|
6452c30036 | ||
|
|
96717d9fb4 | ||
|
|
fae7332ebf | ||
|
|
00eb23b47a | ||
|
|
e4202df091 | ||
|
|
07abc7c6f7 | ||
|
|
901d2c3862 | ||
|
|
3e544d6ec7 | ||
|
|
f079f91371 | ||
|
|
bb4e32befa | ||
|
|
c8f6c1d775 | ||
|
|
bc2c1b4f86 | ||
|
|
2124c0ec97 | ||
|
|
4152b41183 | ||
|
|
ddc6dfdb4d | ||
|
|
b164cdb854 | ||
|
|
8cc3a744fb | ||
|
|
a2f18d950a | ||
|
|
15733cb48e | ||
|
|
251e08ffa6 | ||
|
|
a4c5cb2335 | ||
|
|
ff4ca18501 | ||
|
|
4bc59a4cf7 | ||
|
|
cd48f07117 | ||
|
|
b0e7cb4c3f | ||
|
|
b6237c0657 | ||
|
|
25b2680056 | ||
|
|
91e330a53f | ||
|
|
0723131628 | ||
|
|
bb15969333 | ||
|
|
39646dce32 | ||
|
|
eb0c2e218c | ||
|
|
d3c36882dc | ||
|
|
9e262f13c2 | ||
|
|
a97a795dcb | ||
|
|
1d180cd749 | ||
|
|
eaced1ec85 | ||
|
|
8baa643a34 | ||
|
|
8506dd6730 | ||
|
|
caba1a16ec | ||
|
|
9b44deac01 | ||
|
|
73d93d9f83 | ||
|
|
f3d6711c97 | ||
|
|
b817699e6c | ||
|
|
01004f9796 | ||
|
|
4a9ec95565 | ||
|
|
fad8d6b6c0 | ||
|
|
2aaacc1453 | ||
|
|
c7b858ff8d | ||
|
|
fd3c512f88 | ||
|
|
db793480cb | ||
|
|
a8e19608fc | ||
|
|
84d5eddb25 | ||
|
|
63139b531f | ||
|
|
1b367cbeda | ||
|
|
5d553bc558 | ||
|
|
11f1a2553e | ||
|
|
49142d48bd | ||
|
|
9cabd17e55 | ||
|
|
31df5a3eee | ||
|
|
6c5f4296dc | ||
|
|
623e55a396 | ||
|
|
d067acb005 | ||
|
|
b4b1828076 | ||
|
|
8055173128 | ||
|
|
724c7df683 | ||
|
|
e76f03b267 | ||
|
|
df5c5394b0 | ||
|
|
cc55bbef75 | ||
|
|
70726640b3 | ||
|
|
d0dea17900 | ||
|
|
3978adc445 | ||
|
|
ef2366cdca | ||
|
|
030fe31760 | ||
|
|
56ee576507 | ||
|
|
e7d853b4eb | ||
|
|
abaee4aada | ||
|
|
c9b93cf290 | ||
|
|
34c5115a7f | ||
|
|
696c38ddca | ||
|
|
b1eedfcfa1 | ||
|
|
758c2bd58e | ||
|
|
f4f6e5144b | ||
|
|
0622416fec | ||
|
|
2075aa93e0 | ||
|
|
b4f93f562d | ||
|
|
665a659530 | ||
|
|
50ead33c45 | ||
|
|
6599e380ed | ||
|
|
6cc4962b60 | ||
|
|
965b795b87 | ||
|
|
2fba2f5bb9 | ||
|
|
33e955ab91 | ||
|
|
eb773054e4 | ||
|
|
6a55b4e403 | ||
|
|
b86a9ed699 | ||
|
|
ec16c030bd | ||
|
|
87bd558f3f | ||
|
|
32a8f70ac1 | ||
|
|
4dee016059 | ||
|
|
56a5731a1a | ||
|
|
f26c5660c2 | ||
|
|
900eae1738 | ||
|
|
ab6991c6f5 | ||
|
|
818a4aa2ef | ||
|
|
ae04ce82cf | ||
|
|
885121e25d | ||
|
|
fc6faac84e | ||
|
|
f140b49f5f | ||
|
|
7467e905e5 | ||
|
|
2cd37d65e2 | ||
|
|
170b8628fa | ||
|
|
dc68a5ddac | ||
|
|
cdab3c4fac | ||
|
|
c8b3d9a145 | ||
|
|
fc63549352 | ||
|
|
20900489a1 | ||
|
|
03eb6eba43 | ||
|
|
cb143b9793 | ||
|
|
1c9cd9b71b | ||
|
|
768153bf8c | ||
|
|
e9003caf6d | ||
|
|
d560030548 | ||
|
|
e3f4759019 | ||
|
|
a569fd37fe | ||
|
|
3cd55d49a2 | ||
|
|
12aa68d10f | ||
|
|
9bf4499dd7 | ||
|
|
4323ac861e | ||
|
|
2c92d1ec58 | ||
|
|
ddfdf68ca1 | ||
|
|
c20e42e320 | ||
|
|
bd46f64dcb | ||
|
|
4ac35a30db | ||
|
|
dc9c10a7b2 | ||
|
|
efe99b59c6 | ||
|
|
a4747230ab | ||
|
|
5323af7f51 | ||
|
|
89f063b900 | ||
|
|
64981b4c8e | ||
|
|
a7c065354f | ||
|
|
b259e97d47 | ||
|
|
d2241f5902 | ||
|
|
112453acf2 | ||
|
|
32e1f69ae0 | ||
|
|
e16f7eb596 | ||
|
|
b65d6cb00f | ||
|
|
079487b487 | ||
|
|
dac5b83142 | ||
|
|
085f19cdff | ||
|
|
2496616b0a | ||
|
|
535a509846 | ||
|
|
eecd6f7a6c | ||
|
|
16e82c61d4 | ||
|
|
a90a54aead | ||
|
|
689d0650ab | ||
|
|
3c3928fc65 | ||
|
|
4a0eb0370c | ||
|
|
aaa0709e7b | ||
|
|
841878e7ee | ||
|
|
b1c7a66ca6 | ||
|
|
6561e07460 | ||
|
|
abefc3c276 | ||
|
|
bd202a5ec1 | ||
|
|
d4dd48f294 | ||
|
|
91e11eba6e | ||
|
|
8d5f465a20 | ||
|
|
777a6357c0 | ||
|
|
afb5d8b2db | ||
|
|
a949399d17 | ||
|
|
4864a68596 | ||
|
|
b6efac31d8 | ||
|
|
68f75bb9ce | ||
|
|
b414cdf5b4 | ||
|
|
1a5d6fcbb5 | ||
|
|
a77f3ecf68 | ||
|
|
5c69ad0ecd | ||
|
|
9914d8b861 | ||
|
|
8a485b0a36 | ||
|
|
31d34f3bd8 | ||
|
|
39925026f6 | ||
|
|
a088da4476 | ||
|
|
197ae0f9ae | ||
|
|
2dd82f465e | ||
|
|
9a2d899273 | ||
|
|
06a407c628 | ||
|
|
79a4032eef | ||
|
|
4468c569f7 | ||
|
|
051665ef69 | ||
|
|
d21a63f9fc | ||
|
|
c9fc15359e | ||
|
|
ac79db6a3b | ||
|
|
1f86ecb729 | ||
|
|
acdc8eed89 | ||
|
|
fc2ce04a38 | ||
|
|
79bd7c3f7b | ||
|
|
05faa6103b | ||
|
|
86a633ef9a | ||
|
|
a16c8ef212 | ||
|
|
c918ea1673 |
No files matched your search
@@ -312,7 +312,6 @@ config BUSYBOX_EXEC_PATH
|
||||
config SELINUX
|
||||
bool "Support NSA Security Enhanced Linux"
|
||||
default n
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
Enable support for SELinux in applets ls, ps, and id. Also provide
|
||||
the option of compiling in SELinux applets.
|
||||
@@ -358,17 +357,6 @@ config FEATURE_SYSLOG
|
||||
#This option is auto-selected when you select any applet which may
|
||||
#send its output to syslog. You do not need to select it manually.
|
||||
|
||||
config PLATFORM_LINUX
|
||||
bool #No description makes it a hidden option
|
||||
default n
|
||||
#help
|
||||
#For the most part, busybox requires only POSIX compatibility
|
||||
#from the target system, but some applets and features use
|
||||
#Linux-specific interfaces.
|
||||
#
|
||||
#This is automatically selected if any applet or feature requires
|
||||
#Linux-specific interfaces. You do not need to select it manually.
|
||||
|
||||
comment 'Build Options'
|
||||
|
||||
config STATIC
|
||||
@@ -541,6 +529,14 @@ config STACK_OPTIMIZATION_386
|
||||
do not work with it (they use SSE instructions without
|
||||
ensuring stack alignment).
|
||||
|
||||
config STATIC_LIBGCC
|
||||
bool "Use -static-libgcc"
|
||||
default y
|
||||
help
|
||||
This option instructs gcc to link in a static version of its
|
||||
support library, libgcc. This means that the binary will require
|
||||
one fewer dynamic library at run time.
|
||||
|
||||
comment 'Installation Options ("make install" behavior)'
|
||||
|
||||
choice
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 32
|
||||
SUBLEVEL = 0
|
||||
PATCHLEVEL = 33
|
||||
SUBLEVEL = 2
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
|
||||
|
||||
+2
-1
@@ -58,7 +58,8 @@ CFLAGS += $(call cc-option,-fno-builtin-strlen -fomit-frame-pointer -ffunction-s
|
||||
CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
|
||||
CFLAGS += $(call cc-option,-funsigned-char,)
|
||||
|
||||
ifneq ($(CC),clang)
|
||||
ifeq ($(CONFIG_STATIC_LIBGCC),y)
|
||||
# Disable it, for example, if you get
|
||||
# "clang-9: warning: argument unused during compilation: '-static-libgcc'"
|
||||
CFLAGS += $(call cc-option,-static-libgcc,)
|
||||
endif
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
#undef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024
|
||||
#endif
|
||||
|
||||
#include "../include/autoconf.h"
|
||||
#include "../include/applet_metadata.h"
|
||||
|
||||
|
||||
@@ -11,3 +11,11 @@ ifeq ($(CONFIG_STACK_OPTIMIZATION_386),y)
|
||||
# from aligning stack to 16 bytes. (Which is gcc's way of supporting SSE).
|
||||
CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2,)
|
||||
endif
|
||||
|
||||
# "Control how GCC aligns variables.
|
||||
# Supported values for type are compat uses increased alignment value
|
||||
# compatible uses GCC 4.8 and earlier, abi uses alignment value as specified by the psABI,
|
||||
# and cacheline uses increased alignment value to match the cache line size.
|
||||
# compat is the default."
|
||||
# "abi" seems to be somewhat successful in preventing oversealous data alignment.
|
||||
CFLAGS += $(call cc-option,-malign-data=abi,)
|
||||
@@ -0,0 +1,11 @@
|
||||
# ==========================================================================
|
||||
# Build system
|
||||
# ==========================================================================
|
||||
|
||||
# "Control how GCC aligns variables.
|
||||
# Supported values for type are compat uses increased alignment value
|
||||
# compatible uses GCC 4.8 and earlier, abi uses alignment value as specified by the psABI,
|
||||
# and cacheline uses increased alignment value to match the cache line size.
|
||||
# compat is the default."
|
||||
# "abi" seems to be somewhat successful in preventing oversealous data alignment.
|
||||
CFLAGS += $(call cc-option,-malign-data=abi,)
|
||||
+32
-29
@@ -48,19 +48,9 @@
|
||||
|
||||
//kbuild:lib-$(CONFIG_AR) += ar.o
|
||||
|
||||
//usage:#define ar_trivial_usage
|
||||
//usage: "[-o] [-v] [-p] [-t] [-x] ARCHIVE FILES"
|
||||
//usage:#define ar_full_usage "\n\n"
|
||||
//usage: "Extract or list FILES from an ar archive\n"
|
||||
//usage: "\n -o Preserve original dates"
|
||||
//usage: "\n -p Extract to stdout"
|
||||
//usage: "\n -t List"
|
||||
//usage: "\n -x Extract"
|
||||
//usage: "\n -v Verbose"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
#include "ar.h"
|
||||
#include "ar_.h"
|
||||
|
||||
#if ENABLE_FEATURE_AR_CREATE
|
||||
/* filter out entries with same names as specified on the command line */
|
||||
@@ -220,23 +210,36 @@ static void FAST_FUNC header_verbose_list_ar(const file_header_t *file_header)
|
||||
);
|
||||
}
|
||||
|
||||
#define AR_OPT_VERBOSE (1 << 0)
|
||||
#define AR_OPT_PRESERVE_DATE (1 << 1)
|
||||
/* "ar r" implies create, but warns about it. c suppresses warning.
|
||||
* bbox accepts but ignores it: */
|
||||
#define AR_OPT_CREATE (1 << 2)
|
||||
|
||||
#define AR_CMD_PRINT (1 << 3)
|
||||
#define FIRST_CMD AR_CMD_PRINT
|
||||
#define AR_CMD_LIST (1 << 4)
|
||||
#define AR_CMD_EXTRACT (1 << 5)
|
||||
#define AR_CMD_INSERT (1 << 6)
|
||||
//usage:#define ar_trivial_usage
|
||||
//usage: "x|p|t"IF_FEATURE_AR_CREATE("|r")" [-ov] ARCHIVE [FILE]..."
|
||||
//usage:#define ar_full_usage "\n\n"
|
||||
//usage: "Extract or list FILEs from an ar archive"IF_FEATURE_AR_CREATE(", or create it")"\n"
|
||||
//usage: "\n x Extract"
|
||||
//usage: "\n p Extract to stdout"
|
||||
//usage: "\n t List"
|
||||
//usage: IF_FEATURE_AR_CREATE(
|
||||
//usage: "\n r Create"
|
||||
//usage: )
|
||||
//usage: "\n -o Restore mtime"
|
||||
//usage: "\n -v Verbose"
|
||||
|
||||
int ar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int ar_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned opt, t;
|
||||
enum {
|
||||
OPT_VERBOSE = (1 << 0),
|
||||
OPT_PRESERVE_DATE = (1 << 1),
|
||||
/* "ar r" implies create, but warns about it. c suppresses warning.
|
||||
* bbox accepts but ignores it: */
|
||||
OPT_CREATE = (1 << 2),
|
||||
CMD_PRINT = (1 << 3),
|
||||
FIRST_CMD = CMD_PRINT,
|
||||
CMD_LIST = (1 << 4),
|
||||
CMD_EXTRACT = (1 << 5),
|
||||
CMD_INSERT = ((1 << 6) * ENABLE_FEATURE_AR_CREATE),
|
||||
};
|
||||
|
||||
archive_handle = init_handle();
|
||||
|
||||
@@ -256,26 +259,26 @@ int ar_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (t & (t-1)) /* more than one of p,t,x[,r] are specified */
|
||||
bb_show_usage();
|
||||
|
||||
if (opt & AR_CMD_PRINT) {
|
||||
if (opt & CMD_PRINT) {
|
||||
archive_handle->action_data = data_extract_to_stdout;
|
||||
}
|
||||
if (opt & AR_CMD_LIST) {
|
||||
if (opt & CMD_LIST) {
|
||||
archive_handle->action_header = header_list;
|
||||
}
|
||||
if (opt & AR_CMD_EXTRACT) {
|
||||
if (opt & CMD_EXTRACT) {
|
||||
archive_handle->action_data = data_extract_all;
|
||||
}
|
||||
if (opt & AR_OPT_PRESERVE_DATE) {
|
||||
if (opt & OPT_PRESERVE_DATE) {
|
||||
archive_handle->ah_flags |= ARCHIVE_RESTORE_DATE;
|
||||
}
|
||||
if (opt & AR_OPT_VERBOSE) {
|
||||
if (opt & OPT_VERBOSE) {
|
||||
archive_handle->action_header = header_verbose_list_ar;
|
||||
}
|
||||
#if ENABLE_FEATURE_AR_CREATE
|
||||
archive_handle->ar__name = *argv;
|
||||
#endif
|
||||
archive_handle->src_fd = xopen(*argv++,
|
||||
(opt & AR_CMD_INSERT)
|
||||
(opt & CMD_INSERT)
|
||||
? O_RDWR | O_CREAT
|
||||
: O_RDONLY
|
||||
);
|
||||
@@ -287,7 +290,7 @@ int ar_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_AR_CREATE
|
||||
if (opt & AR_CMD_INSERT)
|
||||
if (opt & CMD_INSERT)
|
||||
return write_ar_archive(archive_handle);
|
||||
#endif
|
||||
|
||||
|
||||
+5
-5
@@ -219,7 +219,7 @@ char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext)
|
||||
//usage:#define uncompress_trivial_usage
|
||||
//usage: "[-cf] [FILE]..."
|
||||
//usage:#define uncompress_full_usage "\n\n"
|
||||
//usage: "Decompress .Z file[s]\n"
|
||||
//usage: "Decompress FILEs (or stdin)\n"
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Overwrite"
|
||||
|
||||
@@ -461,7 +461,7 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
//usage:#define unlzma_trivial_usage
|
||||
//usage: "[-cfk] [FILE]..."
|
||||
//usage:#define unlzma_full_usage "\n\n"
|
||||
//usage: "Decompress FILE (or stdin)\n"
|
||||
//usage: "Decompress FILEs (or stdin)\n"
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage: "\n -k Keep input files"
|
||||
@@ -469,7 +469,7 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
//usage:#define lzma_trivial_usage
|
||||
//usage: "-d [-cfk] [FILE]..."
|
||||
//usage:#define lzma_full_usage "\n\n"
|
||||
//usage: "Decompress FILE (or stdin)\n"
|
||||
//usage: "Decompress FILEs (or stdin)\n"
|
||||
//usage: "\n -d Decompress"
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
@@ -532,7 +532,7 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv)
|
||||
//usage:#define unxz_trivial_usage
|
||||
//usage: "[-cfk] [FILE]..."
|
||||
//usage:#define unxz_full_usage "\n\n"
|
||||
//usage: "Decompress FILE (or stdin)\n"
|
||||
//usage: "Decompress FILEs (or stdin)\n"
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage: "\n -k Keep input files"
|
||||
@@ -541,7 +541,7 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv)
|
||||
//usage:#define xz_trivial_usage
|
||||
//usage: "-d [-cfk] [FILE]..."
|
||||
//usage:#define xz_full_usage "\n\n"
|
||||
//usage: "Decompress FILE (or stdin)\n"
|
||||
//usage: "Decompress FILEs (or stdin)\n"
|
||||
//usage: "\n -d Decompress"
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@
|
||||
//kbuild:lib-$(CONFIG_BZIP2) += bzip2.o
|
||||
|
||||
//usage:#define bzip2_trivial_usage
|
||||
//usage: "[OPTIONS] [FILE]..."
|
||||
//usage: "[-cfk" IF_FEATURE_BZIP2_DECOMPRESS("dt") "123456789] [FILE]..."
|
||||
//usage:#define bzip2_full_usage "\n\n"
|
||||
//usage: "Compress FILEs (or stdin) with bzip2 algorithm\n"
|
||||
//usage: "\n -1..9 Compression level"
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@
|
||||
//usage: "\n -H newc Archive format"
|
||||
//usage: )
|
||||
//usage: "\n -d Make leading directories"
|
||||
//usage: "\n -m Preserve mtime"
|
||||
//usage: "\n -m Restore mtime"
|
||||
//usage: "\n -v Verbose"
|
||||
//usage: "\n -u Overwrite"
|
||||
//usage: "\n -F FILE Input (-t,-i,-p) or output (-o) file"
|
||||
|
||||
+24
-1
@@ -1204,6 +1204,27 @@ static char **create_list(const char *filename)
|
||||
return file_list;
|
||||
}
|
||||
|
||||
/** This tests if the filename is an "important" directory, which might be symlinked.
|
||||
* Debians dpkg test if directories are used by other packages, this
|
||||
* implementation doesn't and would remove for ex. an lib -> usr/lib symlink.
|
||||
*/
|
||||
static int is_builtin_exclude(const char *name)
|
||||
{
|
||||
if (*name++ != '/')
|
||||
return 0;
|
||||
if (index_in_strings(".\0" "etc\0" "opt\0" "srv\0" "var\0" "var/lib\0",
|
||||
name) >= 0)
|
||||
return 1;
|
||||
if (is_prefixed_with(name, "usr/")) {
|
||||
name += sizeof("usr/") - 1;
|
||||
if (is_prefixed_with(name, "local/"))
|
||||
name += sizeof("local/") - 1;
|
||||
}
|
||||
|
||||
return index_in_strings("bin\0" "lib\0" "lib32\0" "lib64\0" "sbin\0",
|
||||
name) >= 0;
|
||||
}
|
||||
|
||||
/* maybe i should try and hook this into remove_file.c somehow */
|
||||
static int remove_file_array(char **remove_names, char **exclude_names)
|
||||
{
|
||||
@@ -1215,6 +1236,8 @@ static int remove_file_array(char **remove_names, char **exclude_names)
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; remove_names[i] != NULL; i++) {
|
||||
if (is_builtin_exclude(remove_names[i]))
|
||||
continue;
|
||||
if (exclude_names != NULL) {
|
||||
for (j = 0; exclude_names[j] != NULL; j++) {
|
||||
if (strcmp(remove_names[i], exclude_names[j]) == 0) {
|
||||
@@ -1281,7 +1304,7 @@ postrm abort-install <old_version>
|
||||
postrm abort-upgrade <old_version>
|
||||
postrm disappear <overwriter> <version>
|
||||
*/
|
||||
static const char *const all_control_files[] = {
|
||||
static const char *const all_control_files[] ALIGN_PTR = {
|
||||
"preinst", "postinst", "prerm", "postrm",
|
||||
"list", "md5sums", "shlibs", "conffiles",
|
||||
"config", "templates"
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
//usage: "\n -f Print control fields"
|
||||
//usage: "\n -e Extract control files to DIR (default: ./DEBIAN)"
|
||||
//usage: "\n -x Extract files to DIR (no default)"
|
||||
//usage: "\n -X Verbose -x"
|
||||
//usage: "\n -X Verbose extract"
|
||||
//usage:
|
||||
//usage:#define dpkg_deb_example_usage
|
||||
//usage: "$ dpkg-deb -X ./busybox_0.48-1_i386.deb /tmp\n"
|
||||
|
||||
@@ -459,7 +459,7 @@ int mainGtU(EState* state,
|
||||
* usually small, typically <= 20.
|
||||
*/
|
||||
static
|
||||
const uint32_t incs[14] = {
|
||||
const uint32_t incs[14] ALIGN4 = {
|
||||
1, 4, 13, 40, 121, 364, 1093, 3280,
|
||||
9841, 29524, 88573, 265720,
|
||||
797161, 2391484
|
||||
|
||||
@@ -20,7 +20,7 @@ enum {
|
||||
TAR_MAX,
|
||||
};
|
||||
|
||||
static const char *const tar_var[] = {
|
||||
static const char *const tar_var[] ALIGN_PTR = {
|
||||
// "FILETYPE",
|
||||
"MODE",
|
||||
"FILENAME",
|
||||
|
||||
@@ -194,14 +194,14 @@ struct cp_ext {
|
||||
};
|
||||
/* Copy lengths and extra bits for literal codes 257..285 */
|
||||
/* note: see note #13 above about the 258 in this list. */
|
||||
static const struct cp_ext lit = {
|
||||
static const struct cp_ext lit ALIGN2 = {
|
||||
/*257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 */
|
||||
/*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 */
|
||||
{ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99 } /* 99 == invalid */
|
||||
};
|
||||
/* Copy offsets and extra bits for distance codes 0..29 */
|
||||
static const struct cp_ext dist = {
|
||||
static const struct cp_ext dist ALIGN2 = {
|
||||
/*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 */
|
||||
{ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 },
|
||||
{ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 }
|
||||
@@ -220,10 +220,20 @@ static const uint8_t border[] ALIGN1 = {
|
||||
* each table.
|
||||
* t: table to free
|
||||
*/
|
||||
#define BAD_HUFT(p) ((uintptr_t)(p) & 1)
|
||||
#define ERR_RET ((huft_t*)(uintptr_t)1)
|
||||
static void huft_free(huft_t *p)
|
||||
{
|
||||
huft_t *q;
|
||||
|
||||
/*
|
||||
* If 'p' has the error bit set we have to clear it, otherwise we might run
|
||||
* into a segmentation fault or an invalid pointer to free(p)
|
||||
*/
|
||||
if (BAD_HUFT(p)) {
|
||||
p = (huft_t*)((uintptr_t)(p) ^ (uintptr_t)(ERR_RET));
|
||||
}
|
||||
|
||||
/* Go through linked list, freeing from the malloced (t[-1]) address. */
|
||||
while (p) {
|
||||
q = (--p)->v.t;
|
||||
@@ -289,8 +299,6 @@ static unsigned fill_bitbuffer(STATE_PARAM unsigned bitbuffer, unsigned *current
|
||||
* or a valid pointer to a Huffman table, ORed with 0x1 if incompete table
|
||||
* is given: "fixed inflate" decoder feeds us such data.
|
||||
*/
|
||||
#define BAD_HUFT(p) ((uintptr_t)(p) & 1)
|
||||
#define ERR_RET ((huft_t*)(uintptr_t)1)
|
||||
static huft_t* huft_build(const unsigned *b, const unsigned n,
|
||||
const unsigned s, const struct cp_ext *cp_ext,
|
||||
unsigned *m)
|
||||
|
||||
@@ -290,8 +290,11 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||
uint32_t pos;
|
||||
|
||||
pos = buffer_pos - rep0;
|
||||
if ((int32_t)pos < 0)
|
||||
if ((int32_t)pos < 0) {
|
||||
pos += header.dict_size;
|
||||
if ((int32_t)pos < 0)
|
||||
goto bad;
|
||||
}
|
||||
match_byte = buffer[pos];
|
||||
do {
|
||||
int bit;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
#include "ar.h"
|
||||
#include "ar_.h"
|
||||
|
||||
/* WARNING: Clobbers str[len], so fields must be read in reverse order! */
|
||||
static unsigned read_num(char *str, int base, int len)
|
||||
|
||||
@@ -352,7 +352,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
/* case 0: */
|
||||
case '0':
|
||||
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
if (last_char_is(file_header->name, '/')) {
|
||||
if (file_header->name && last_char_is(file_header->name, '/')) {
|
||||
goto set_dir;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
#include "ar.h"
|
||||
#include "ar_.h"
|
||||
|
||||
void FAST_FUNC unpack_ar_archive(archive_handle_t *ar_archive)
|
||||
{
|
||||
|
||||
+7
-5
@@ -83,7 +83,9 @@ struct globals {
|
||||
void *map;
|
||||
rpm_index *mytags;
|
||||
int tagcount;
|
||||
unsigned mapsize, pagesize;
|
||||
unsigned mapsize;
|
||||
IF_VARIABLE_ARCH_PAGESIZE(unsigned pagesize;)
|
||||
#define G_pagesize cached_pagesize(G.pagesize)
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)bb_common_bufsiz1)
|
||||
#define INIT_G() do { setup_common_bufsiz(); } while (0)
|
||||
@@ -141,11 +143,11 @@ static int rpm_gettags(const char *filename)
|
||||
G.mytags = tags;
|
||||
|
||||
/* Map the store */
|
||||
storepos = (storepos + G.pagesize) & -(int)G.pagesize;
|
||||
storepos = (storepos + G_pagesize) & -(int)G_pagesize;
|
||||
/* remember size for munmap */
|
||||
G.mapsize = storepos;
|
||||
/* some NOMMU systems prefer MAP_PRIVATE over MAP_SHARED */
|
||||
G.map = mmap(0, storepos, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
G.map = mmap_read(fd, storepos);
|
||||
if (G.map == MAP_FAILED)
|
||||
bb_perror_msg_and_die("mmap '%s'", filename);
|
||||
|
||||
@@ -356,7 +358,7 @@ int rpm_main(int argc, char **argv)
|
||||
int opt, func = 0;
|
||||
|
||||
INIT_G();
|
||||
G.pagesize = getpagesize();
|
||||
INIT_PAGESIZE(G.pagesize);
|
||||
|
||||
while ((opt = getopt(argc, argv, "iqpldc")) != -1) {
|
||||
switch (opt) {
|
||||
@@ -523,7 +525,7 @@ int rpm2cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
int rpm_fd;
|
||||
|
||||
INIT_G();
|
||||
G.pagesize = getpagesize();
|
||||
INIT_PAGESIZE(G.pagesize);
|
||||
|
||||
rpm_fd = rpm_gettags(argv[1]);
|
||||
|
||||
|
||||
+23
-16
@@ -297,7 +297,8 @@ static void writeLongname(int fd, int type, const char *name, int dir)
|
||||
header.typeflag = type;
|
||||
strcpy(header.name, "././@LongLink");
|
||||
/* This sets mode/uid/gid/mtime to "00...00<NUL>" strings */
|
||||
memset(header.mode, '0', sizeof(struct prefilled));
|
||||
memset((char*)&header + offsetof(struct tar_header_t, mode), /* make gcc-9.x happy */
|
||||
'0', sizeof(struct prefilled));
|
||||
header.mode [sizeof(header.mode ) - 1] = '\0';
|
||||
header.uid [sizeof(header.uid ) - 1] = '\0';
|
||||
header.gid [sizeof(header.gid ) - 1] = '\0';
|
||||
@@ -490,10 +491,11 @@ static int exclude_file(const llist_t *excluded_files, const char *file)
|
||||
# define exclude_file(excluded_files, file) 0
|
||||
# endif
|
||||
|
||||
static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statbuf,
|
||||
void *userData, int depth UNUSED_PARAM)
|
||||
static int FAST_FUNC writeFileToTarball(struct recursive_state *state,
|
||||
const char *fileName,
|
||||
struct stat *statbuf)
|
||||
{
|
||||
struct TarBallInfo *tbInfo = (struct TarBallInfo *) userData;
|
||||
struct TarBallInfo *tbInfo = (struct TarBallInfo *) state->userData;
|
||||
const char *header_name;
|
||||
int inputFileFd = -1;
|
||||
|
||||
@@ -699,7 +701,7 @@ static NOINLINE int writeTarFile(
|
||||
/* Read the directory/files and iterate over them one at a time */
|
||||
while (filelist) {
|
||||
if (!recursive_action(filelist->data, recurseFlags,
|
||||
writeFileToTarball, writeFileToTarball, tbInfo, 0)
|
||||
writeFileToTarball, writeFileToTarball, tbInfo)
|
||||
) {
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
@@ -773,7 +775,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
|
||||
//usage: IF_FEATURE_TAR_NOPRESERVE_TIME("m")
|
||||
//usage: "vokO] "
|
||||
//usage: "[-f TARFILE] [-C DIR] "
|
||||
//usage: IF_FEATURE_TAR_FROM("[-T FILE] [-X FILE] "IF_FEATURE_TAR_LONG_OPTIONS("[--exclude PATTERN]... "))
|
||||
//usage: IF_FEATURE_TAR_FROM("[-T FILE] [-X FILE] "IF_FEATURE_TAR_LONG_OPTIONS("[OPTION]... "))
|
||||
//usage: "[FILE]..."
|
||||
//usage:#define tar_full_usage "\n\n"
|
||||
//usage: IF_FEATURE_TAR_CREATE("Create, extract, ")
|
||||
@@ -807,6 +809,11 @@ static llist_t *append_file_list_to_list(llist_t *list)
|
||||
//usage: IF_FEATURE_SEAMLESS_BZ2(
|
||||
//usage: "\n -j (De)compress using bzip2"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_SEAMLESS_LZMA(
|
||||
//usage: IF_FEATURE_TAR_LONG_OPTIONS(
|
||||
//usage: "\n --lzma (De)compress using lzma"
|
||||
//usage: )
|
||||
//usage: )
|
||||
//usage: "\n -a (De)compress based on extension"
|
||||
//usage: IF_FEATURE_TAR_CREATE(
|
||||
//usage: "\n -h Follow symlinks"
|
||||
@@ -818,21 +825,21 @@ static llist_t *append_file_list_to_list(llist_t *list)
|
||||
//usage: "\n --exclude PATTERN Glob pattern to exclude"
|
||||
//usage: )
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_TAR_LONG_OPTIONS(
|
||||
//usage: "\n --overwrite Replace existing files"
|
||||
//usage: "\n --strip-components NUM NUM of leading components to strip"
|
||||
//usage: "\n --no-recursion Don't descend in directories"
|
||||
//usage: "\n --numeric-owner Use numeric user:group"
|
||||
//usage: "\n --no-same-permissions Don't restore access permissions"
|
||||
//usage: IF_FEATURE_TAR_TO_COMMAND(
|
||||
//usage: "\n --to-command COMMAND Pipe files to COMMAND"
|
||||
//usage: )
|
||||
//usage: )
|
||||
//usage:
|
||||
//usage:#define tar_example_usage
|
||||
//usage: "$ zcat /tmp/tarball.tar.gz | tar -xf -\n"
|
||||
//usage: "$ tar -cf /tmp/tarball.tar /usr/local\n"
|
||||
|
||||
// Supported but aren't in --help:
|
||||
// lzma
|
||||
// no-recursion
|
||||
// numeric-owner
|
||||
// no-same-permissions
|
||||
// overwrite
|
||||
//IF_FEATURE_TAR_TO_COMMAND(
|
||||
// to-command
|
||||
//)
|
||||
|
||||
enum {
|
||||
OPTBIT_KEEP_OLD = 8,
|
||||
IF_FEATURE_TAR_CREATE( OPTBIT_CREATE ,)
|
||||
|
||||
@@ -16,7 +16,6 @@ CONFIG_HAVE_DOT_CONFIG=y
|
||||
# CONFIG_EXTRA_COMPAT is not set
|
||||
# CONFIG_INCLUDE_SUSv2 is not set
|
||||
# CONFIG_USE_PORTABLE_CODE is not set
|
||||
CONFIG_PLATFORM_LINUX=y
|
||||
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
|
||||
|
||||
@@ -87,7 +87,6 @@ CONFIG_DESKTOP=y
|
||||
# CONFIG_EXTRA_COMPAT is not set
|
||||
CONFIG_INCLUDE_SUSv2=y
|
||||
# CONFIG_USE_PORTABLE_CODE is not set
|
||||
CONFIG_PLATFORM_LINUX=y
|
||||
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
|
||||
|
||||
@@ -16,7 +16,6 @@ CONFIG_DESKTOP=y
|
||||
# CONFIG_EXTRA_COMPAT is not set
|
||||
# CONFIG_INCLUDE_SUSv2 is not set
|
||||
# CONFIG_USE_PORTABLE_CODE is not set
|
||||
CONFIG_PLATFORM_LINUX=y
|
||||
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
|
||||
|
||||
@@ -16,7 +16,6 @@ CONFIG_DESKTOP=y
|
||||
# CONFIG_EXTRA_COMPAT is not set
|
||||
# CONFIG_INCLUDE_SUSv2 is not set
|
||||
# CONFIG_USE_PORTABLE_CODE is not set
|
||||
CONFIG_PLATFORM_LINUX=y
|
||||
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
|
||||
|
||||
@@ -16,7 +16,6 @@ CONFIG_DESKTOP=y
|
||||
# CONFIG_EXTRA_COMPAT is not set
|
||||
CONFIG_INCLUDE_SUSv2=y
|
||||
# CONFIG_USE_PORTABLE_CODE is not set
|
||||
CONFIG_PLATFORM_LINUX=y
|
||||
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
|
||||
|
||||
@@ -16,7 +16,6 @@ CONFIG_HAVE_DOT_CONFIG=y
|
||||
# CONFIG_EXTRA_COMPAT is not set
|
||||
CONFIG_INCLUDE_SUSv2=y
|
||||
CONFIG_USE_PORTABLE_CODE=y
|
||||
# CONFIG_PLATFORM_LINUX is not set
|
||||
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
//config:config CHVT
|
||||
//config: bool "chvt (2 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program is used to change to another terminal.
|
||||
//config: Example: chvt 4 (change to terminal /dev/tty4)
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
//config:config DEALLOCVT
|
||||
//config: bool "deallocvt (1.9 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program deallocates unused virtual consoles.
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
//config:config DUMPKMAP
|
||||
//config: bool "dumpkmap (1.6 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program dumps the kernel's keyboard translation table to
|
||||
//config: stdout, in binary format. You can then use loadkmap to load it.
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
//config:config FGCONSOLE
|
||||
//config: bool "fgconsole (1.5 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program prints active (foreground) console number.
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
//config:config KBD_MODE
|
||||
//config: bool "kbd_mode (4.1 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program reports and sets keyboard mode.
|
||||
|
||||
|
||||
@@ -12,14 +12,12 @@
|
||||
//config:config LOADFONT
|
||||
//config: bool "loadfont (5.2 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: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: Allows to load console screen map. Useful for i18n.
|
||||
//config:
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
//config:config LOADKMAP
|
||||
//config: bool "loadkmap (1.8 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program loads a keyboard translation table from
|
||||
//config: standard input.
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
//config:config OPENVT
|
||||
//config: bool "openvt (7.2 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program is used to start a command on an unused
|
||||
//config: virtual terminal.
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
//config:config SETCONSOLE
|
||||
//config: bool "setconsole (3.6 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: Redirect writes to /dev/console to another device,
|
||||
//config: like the current tty while logged in via telnet.
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
//config:config SETKEYCODES
|
||||
//config: bool "setkeycodes (2.1 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program loads entries into the kernel's scancode-to-keycode
|
||||
//config: map, allowing unusual keyboards to generate usable keycodes.
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
//config:config SETLOGCONS
|
||||
//config: bool "setlogcons (1.8 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: This program redirects the output console of kernel messages.
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
//config:config SHOWKEY
|
||||
//config: bool "showkey (4.7 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: Shows keys pressed.
|
||||
|
||||
|
||||
+7
-6
@@ -65,12 +65,14 @@
|
||||
* symbolic links encountered during recursive directory traversals.
|
||||
*/
|
||||
|
||||
static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf, void* param, int depth)
|
||||
static int FAST_FUNC fileAction(struct recursive_state *state,
|
||||
const char *fileName,
|
||||
struct stat *statbuf)
|
||||
{
|
||||
mode_t newmode;
|
||||
|
||||
/* match coreutils behavior */
|
||||
if (depth == 0) {
|
||||
if (state->depth == 0) {
|
||||
/* statbuf holds lstat result, but we need stat (follow link) */
|
||||
if (stat(fileName, statbuf))
|
||||
goto err;
|
||||
@@ -79,9 +81,9 @@ static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf, void
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
newmode = bb_parse_mode((char *)param, statbuf->st_mode);
|
||||
newmode = bb_parse_mode((char *)state->userData, statbuf->st_mode);
|
||||
if (newmode == (mode_t)-1)
|
||||
bb_error_msg_and_die("invalid mode '%s'", (char *)param);
|
||||
bb_error_msg_and_die("invalid mode '%s'", (char *)state->userData);
|
||||
|
||||
if (chmod(fileName, newmode) == 0) {
|
||||
if (OPT_VERBOSE
|
||||
@@ -136,8 +138,7 @@ int chmod_main(int argc UNUSED_PARAM, char **argv)
|
||||
OPT_RECURSE, // recurse
|
||||
fileAction, // file action
|
||||
fileAction, // dir action
|
||||
smode, // user data
|
||||
0) // depth
|
||||
smode) // user data
|
||||
) {
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
+4
-5
@@ -97,10 +97,10 @@ struct param_t {
|
||||
chown_fptr chown_func;
|
||||
};
|
||||
|
||||
static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf,
|
||||
void *vparam, int depth UNUSED_PARAM)
|
||||
static int FAST_FUNC fileAction(struct recursive_state *state UNUSED_PARAM,
|
||||
const char *fileName, struct stat *statbuf)
|
||||
{
|
||||
#define param (*(struct param_t*)vparam)
|
||||
#define param (*(struct param_t*)state->userData)
|
||||
#define opt option_mask32
|
||||
uid_t u = (param.ugid.uid == (uid_t)-1L) ? statbuf->st_uid : param.ugid.uid;
|
||||
gid_t g = (param.ugid.gid == (gid_t)-1L) ? statbuf->st_gid : param.ugid.gid;
|
||||
@@ -159,8 +159,7 @@ int chown_main(int argc UNUSED_PARAM, char **argv)
|
||||
flags, /* flags */
|
||||
fileAction, /* file action */
|
||||
fileAction, /* dir action */
|
||||
¶m, /* user data */
|
||||
0) /* depth */
|
||||
¶m) /* user data */
|
||||
) {
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cp.html */
|
||||
|
||||
//usage:#define cp_trivial_usage
|
||||
//usage: "[OPTIONS] SOURCE... DEST"
|
||||
//usage: "[-arPLHpfilsTu] SOURCE... DEST"
|
||||
//usage:#define cp_full_usage "\n\n"
|
||||
//usage: "Copy SOURCE(s) to DEST\n"
|
||||
//usage: "\n -a Same as -dpR"
|
||||
|
||||
+44
-55
@@ -37,7 +37,6 @@
|
||||
//config: bool "Support %[num]N nanosecond format specifier"
|
||||
//config: default n # stat's nanosecond field is a bit non-portable
|
||||
//config: depends on DATE
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: Support %[num]N format specifier. Adds ~250 bytes of code.
|
||||
//config:
|
||||
@@ -94,36 +93,25 @@
|
||||
*/
|
||||
|
||||
//usage:#define date_trivial_usage
|
||||
//usage: "[OPTIONS] [+FMT] [TIME]"
|
||||
//usage: "[OPTIONS] [+FMT] [[-s] TIME]"
|
||||
//usage:#define date_full_usage "\n\n"
|
||||
//usage: "Display time (using +FMT), or set time\n"
|
||||
//usage: IF_NOT_LONG_OPTS(
|
||||
//usage: "\n [-s] TIME Set time to TIME"
|
||||
//usage: "\n -u Work in UTC (don't convert to local time)"
|
||||
//usage: "\n -R Output RFC-2822 compliant date string"
|
||||
//usage: ) IF_LONG_OPTS(
|
||||
//usage: "\n [-s,--set] TIME Set time to TIME"
|
||||
//usage: "\n -u,--utc Work in UTC (don't convert to local time)"
|
||||
//usage: "\n -R,--rfc-2822 Output RFC-2822 compliant date string"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_DATE_ISOFMT(
|
||||
//usage: "\n -I[SPEC] Output ISO-8601 compliant date string"
|
||||
//usage: "\n SPEC='date' (default) for date only,"
|
||||
//usage: "\n 'hours', 'minutes', or 'seconds' for date and"
|
||||
//usage: "\n time to the indicated precision"
|
||||
//usage: )
|
||||
//usage: IF_NOT_LONG_OPTS(
|
||||
//usage: "\n -r FILE Display last modification time of FILE"
|
||||
//usage: "\n [-s] TIME Set time to TIME"
|
||||
//usage: "\n -d TIME Display TIME, not 'now'"
|
||||
//usage: ) IF_LONG_OPTS(
|
||||
//usage: "\n -r,--reference FILE Display last modification time of FILE"
|
||||
//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 FMT (strptime format) for -s/-d TIME conversion"
|
||||
////////^^^^^^^^^^^^^^^^^^^^^^ busybox invention, not compat
|
||||
//usage: )
|
||||
//usage: "\n -r FILE Display last modification time of FILE"
|
||||
//usage: "\n -R Output RFC-2822 date"
|
||||
//usage: IF_FEATURE_DATE_ISOFMT(
|
||||
//usage: "\n -I[SPEC] Output ISO-8601 date"
|
||||
//usage: "\n SPEC=date (default), hours, minutes, seconds or ns"
|
||||
//usage: )
|
||||
//usage: "\n"
|
||||
//usage: "\nRecognized TIME formats:"
|
||||
//usage: "\n @seconds_since_1970"
|
||||
//usage: "\n hh:mm[:ss]"
|
||||
//usage: "\n [YYYY.]MM.DD-hh:mm[:ss]"
|
||||
//usage: "\n YYYY-MM-DD hh:mm[:ss]"
|
||||
@@ -148,8 +136,8 @@ enum {
|
||||
OPT_UTC = (1 << 2), /* u */
|
||||
OPT_DATE = (1 << 3), /* d */
|
||||
OPT_REFERENCE = (1 << 4), /* r */
|
||||
OPT_TIMESPEC = (1 << 5) * ENABLE_FEATURE_DATE_ISOFMT, /* I */
|
||||
OPT_HINT = (1 << 6) * ENABLE_FEATURE_DATE_ISOFMT, /* D */
|
||||
OPT_ISO8601 = (1 << 5) * ENABLE_FEATURE_DATE_ISOFMT, /* I */
|
||||
OPT_STR2DT = (1 << 6) * ENABLE_FEATURE_DATE_ISOFMT, /* D */
|
||||
};
|
||||
|
||||
#if ENABLE_LONG_OPTS
|
||||
@@ -171,12 +159,6 @@ static const char date_longopts[] ALIGN1 =
|
||||
* - after xasprintf we use other xfuncs
|
||||
*/
|
||||
|
||||
static void maybe_set_utc(int opt)
|
||||
{
|
||||
if (opt & OPT_UTC)
|
||||
putenv((char*)"TZ=UTC0");
|
||||
}
|
||||
|
||||
int date_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
@@ -184,7 +166,7 @@ int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
struct tm tm_time;
|
||||
char buf_fmt_dt2str[64];
|
||||
unsigned opt;
|
||||
int ifmt = -1;
|
||||
int isofmt = -1;
|
||||
char *date_str;
|
||||
char *fmt_dt2str;
|
||||
char *fmt_str2dt;
|
||||
@@ -203,15 +185,16 @@ int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
);
|
||||
argv += optind;
|
||||
|
||||
maybe_set_utc(opt);
|
||||
if (opt & OPT_UTC)
|
||||
putenv((char*)"TZ=UTC0");
|
||||
|
||||
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & OPT_TIMESPEC)) {
|
||||
ifmt = 0; /* default is date */
|
||||
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & OPT_ISO8601)) {
|
||||
isofmt = 0; /* default is date */
|
||||
if (isofmt_arg) {
|
||||
static const char isoformats[] ALIGN1 =
|
||||
"date\0""hours\0""minutes\0""seconds\0"; /* ns? */
|
||||
ifmt = index_in_substrings(isoformats, isofmt_arg);
|
||||
if (ifmt < 0)
|
||||
"date\0""hours\0""minutes\0""seconds\0ns\0";
|
||||
isofmt = index_in_substrings(isoformats, isofmt_arg);
|
||||
if (isofmt < 0)
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
@@ -221,7 +204,7 @@ int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
fmt_dt2str = &argv[0][1]; /* skip over the '+' */
|
||||
argv++;
|
||||
}
|
||||
if (!(opt & (OPT_SET | OPT_DATE))) {
|
||||
if (!(opt & (OPT_SET | OPT_DATE))) { /* neither -s TIME nor -d TIME? */
|
||||
opt |= OPT_SET;
|
||||
date_str = argv[0]; /* can be NULL */
|
||||
if (date_str) {
|
||||
@@ -289,7 +272,7 @@ int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
tm_time.tm_hour = 0;
|
||||
|
||||
/* Process any date input to UNIX time since 1 Jan 1970 */
|
||||
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & OPT_HINT)) {
|
||||
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & OPT_STR2DT)) {
|
||||
if (strptime(date_str, fmt_str2dt, &tm_time) == NULL)
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
|
||||
} else {
|
||||
@@ -315,24 +298,34 @@ int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (fmt_dt2str == NULL) {
|
||||
int i;
|
||||
fmt_dt2str = buf_fmt_dt2str;
|
||||
if (ENABLE_FEATURE_DATE_ISOFMT && ifmt >= 0) {
|
||||
/* -I[SPEC]: 0:date 1:hours 2:minutes 3:seconds */
|
||||
if (ENABLE_FEATURE_DATE_ISOFMT && isofmt >= 0) {
|
||||
/* -I[SPEC]: 0:date 1:hours 2:minutes 3:seconds 4:ns*/
|
||||
strcpy(fmt_dt2str, "%Y-%m-%dT%H:%M:%S");
|
||||
i = 8 + 3 * ifmt;
|
||||
if (ifmt != 0) {
|
||||
/* TODO: if (ifmt==4) i += sprintf(&fmt_dt2str[i], ",%09u", nanoseconds); */
|
||||
format_utc:
|
||||
fmt_dt2str[i++] = '%';
|
||||
fmt_dt2str[i++] = (opt & OPT_UTC) ? 'Z' : 'z';
|
||||
i = 8 + 3 * isofmt;
|
||||
if (isofmt != 0) {
|
||||
int n;
|
||||
if (isofmt == 4) {
|
||||
i -= 3;
|
||||
i += sprintf(&fmt_dt2str[i], ",%09u", (unsigned)ts.tv_nsec);
|
||||
}
|
||||
/* %z prints "+hhmm" timezone, but coreutils-8.30 prints "+hh:mm"! */
|
||||
/* ...therefore this atrocity: */
|
||||
n = strftime(&fmt_dt2str[i], 8, "%z", &tm_time);
|
||||
i += n;
|
||||
if (n == 5 && (fmt_dt2str[i-5] == '+' || fmt_dt2str[i-5] == '-')) {
|
||||
/* "mm" -> ":mm" */
|
||||
fmt_dt2str[i ] = fmt_dt2str[i - 1];
|
||||
fmt_dt2str[i - 1] = fmt_dt2str[i - 2];
|
||||
fmt_dt2str[i - 2] = ':';
|
||||
i++;
|
||||
}
|
||||
}
|
||||
fmt_dt2str[i] = '\0';
|
||||
} else if (opt & OPT_RFC2822) {
|
||||
/* -R. undo busybox.c setlocale */
|
||||
if (ENABLE_LOCALE_SUPPORT)
|
||||
setlocale(LC_TIME, "C");
|
||||
strcpy(fmt_dt2str, "%a, %d %b %Y %H:%M:%S ");
|
||||
i = sizeof("%a, %d %b %Y %H:%M:%S ")-1;
|
||||
goto format_utc;
|
||||
fmt_dt2str = (char*)"%a, %d %b %Y %H:%M:%S %z";
|
||||
} else { /* default case */
|
||||
fmt_dt2str = (char*)"%a %b %e %H:%M:%S %Z %Y";
|
||||
}
|
||||
@@ -384,10 +377,6 @@ int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* With no format string, just print a blank line */
|
||||
date_buf[0] = '\0';
|
||||
} else {
|
||||
/* Handle special conversions */
|
||||
if (is_prefixed_with(fmt_dt2str, "%f")) {
|
||||
fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S";
|
||||
}
|
||||
/* Generate output string */
|
||||
strftime(date_buf, COMMON_BUFSIZE, fmt_dt2str, &tm_time);
|
||||
}
|
||||
|
||||
+80
-31
@@ -59,7 +59,7 @@
|
||||
//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: " [iflag=skip_bytes|fullblock|direct] [oflag=seek_bytes|append|direct]"
|
||||
//usage: )
|
||||
//usage:#define dd_full_usage "\n\n"
|
||||
//usage: "Copy a file with converting and formatting\n"
|
||||
@@ -82,9 +82,11 @@
|
||||
//usage: "\n conv=fsync Physically write data out before finishing"
|
||||
//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: "\n iflag=direct O_DIRECT input"
|
||||
//usage: "\n oflag=direct O_DIRECT output"
|
||||
//usage: "\n iflag=fullblock Read full blocks"
|
||||
//usage: "\n oflag=append Open output in append mode"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_DD_STATUS(
|
||||
//usage: "\n status=noxfer Suppress rate output"
|
||||
@@ -137,16 +139,18 @@ enum {
|
||||
FLAG_IFLAG_SHIFT = 5,
|
||||
FLAG_SKIP_BYTES = (1 << 5) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
FLAG_FULLBLOCK = (1 << 6) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
FLAG_IDIRECT = (1 << 7) * 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,
|
||||
FLAG_OFLAG_SHIFT = 8,
|
||||
FLAG_SEEK_BYTES = (1 << 8) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
FLAG_APPEND = (1 << 9) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
FLAG_ODIRECT = (1 << 10) * 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 << 11) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
FLAG_COUNT = 1 << 12,
|
||||
FLAG_STATUS_NONE = 1 << 13,
|
||||
FLAG_STATUS_NOXFER = 1 << 14,
|
||||
};
|
||||
|
||||
static void dd_output_status(int UNUSED_PARAM cur_signal)
|
||||
@@ -192,12 +196,50 @@ static void dd_output_status(int UNUSED_PARAM cur_signal)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
static int clear_O_DIRECT(int fd)
|
||||
{
|
||||
if (errno == EINVAL) {
|
||||
int fl = fcntl(fd, F_GETFL);
|
||||
if (fl & O_DIRECT) {
|
||||
fcntl(fd, F_SETFL, fl & ~O_DIRECT);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static ssize_t dd_read(void *ibuf, size_t ibs)
|
||||
{
|
||||
ssize_t n;
|
||||
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
read_again:
|
||||
if (G.flags & FLAG_FULLBLOCK)
|
||||
n = full_read(ifd, ibuf, ibs);
|
||||
else
|
||||
#endif
|
||||
n = safe_read(ifd, ibuf, ibs);
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
if (n < 0 && (G.flags & FLAG_IDIRECT) && clear_O_DIRECT(ifd))
|
||||
goto read_again;
|
||||
#endif
|
||||
return n;
|
||||
}
|
||||
|
||||
static bool write_and_stats(const void *buf, size_t len, size_t obs,
|
||||
const char *filename)
|
||||
{
|
||||
ssize_t n;
|
||||
|
||||
IF_FEATURE_DD_IBS_OBS(write_again:)
|
||||
n = full_write(ofd, buf, len);
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
if (n < 0 && (G.flags & FLAG_ODIRECT) && clear_O_DIRECT(ofd))
|
||||
goto write_again;
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_DD_THIRD_STATUS_LINE
|
||||
if (n > 0)
|
||||
G.total_bytes += n;
|
||||
@@ -254,6 +296,14 @@ static int parse_comma_flags(char *val, const char *words, const char *error_in)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void *alloc_buf(size_t size)
|
||||
{
|
||||
/* Important for "{i,o}flag=direct" - buffers must be page aligned */
|
||||
if (size >= bb_getpagesize())
|
||||
return xmmap_anon(size);
|
||||
return xmalloc(size);
|
||||
}
|
||||
|
||||
int dd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
@@ -267,9 +317,9 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
static const char conv_words[] ALIGN1 =
|
||||
"notrunc\0""sync\0""noerror\0""fsync\0""swab\0";
|
||||
static const char iflag_words[] ALIGN1 =
|
||||
"skip_bytes\0""fullblock\0";
|
||||
"skip_bytes\0""fullblock\0""direct\0";
|
||||
static const char oflag_words[] ALIGN1 =
|
||||
"seek_bytes\0append\0";
|
||||
"seek_bytes\0append\0""direct\0";
|
||||
#endif
|
||||
#if ENABLE_FEATURE_DD_STATUS
|
||||
static const char status_words[] ALIGN1 =
|
||||
@@ -310,7 +360,9 @@ 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_iflag_direct,
|
||||
OP_oflag_seek_bytes,
|
||||
OP_oflag_direct,
|
||||
#endif
|
||||
};
|
||||
smallint exitcode = EXIT_FAILURE;
|
||||
@@ -426,13 +478,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
#endif
|
||||
} /* end of "for (argv[i])" */
|
||||
|
||||
//XXX:FIXME for huge ibs or obs, malloc'ing them isn't the brightest idea ever
|
||||
ibuf = xmalloc(ibs);
|
||||
ibuf = alloc_buf(ibs);
|
||||
obuf = ibuf;
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
if (ibs != obs) {
|
||||
G.flags |= FLAG_TWOBUFS;
|
||||
obuf = xmalloc(obs);
|
||||
obuf = alloc_buf(obs);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -444,7 +495,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
#endif
|
||||
|
||||
if (infile) {
|
||||
xmove_fd(xopen(infile, O_RDONLY), ifd);
|
||||
int iflag = O_RDONLY;
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
if (G.flags & FLAG_IDIRECT)
|
||||
iflag |= O_DIRECT;
|
||||
#endif
|
||||
xmove_fd(xopen(infile, iflag), ifd);
|
||||
} else {
|
||||
infile = bb_msg_standard_input;
|
||||
}
|
||||
@@ -455,7 +511,10 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
oflag |= O_TRUNC;
|
||||
if (G.flags & FLAG_APPEND)
|
||||
oflag |= O_APPEND;
|
||||
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
if (G.flags & FLAG_ODIRECT)
|
||||
oflag |= O_DIRECT;
|
||||
#endif
|
||||
xmove_fd(xopen(outfile, oflag), ofd);
|
||||
|
||||
if (seek && !(G.flags & FLAG_NOTRUNC)) {
|
||||
@@ -478,13 +537,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
size_t blocksz = (G.flags & FLAG_SKIP_BYTES) ? 1 : ibs;
|
||||
if (lseek(ifd, skip * blocksz, SEEK_CUR) < 0) {
|
||||
do {
|
||||
ssize_t n;
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
if (G.flags & FLAG_FULLBLOCK)
|
||||
n = full_read(ifd, ibuf, blocksz);
|
||||
else
|
||||
#endif
|
||||
n = safe_read(ifd, ibuf, blocksz);
|
||||
ssize_t n = dd_read(ibuf, blocksz);
|
||||
if (n < 0)
|
||||
goto die_infile;
|
||||
if (n == 0)
|
||||
@@ -499,13 +552,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
|
||||
while (!(G.flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) {
|
||||
ssize_t n;
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
if (G.flags & FLAG_FULLBLOCK)
|
||||
n = full_read(ifd, ibuf, ibs);
|
||||
else
|
||||
#endif
|
||||
n = safe_read(ifd, ibuf, ibs);
|
||||
ssize_t n = dd_read(ibuf, ibs);
|
||||
if (n == 0)
|
||||
break;
|
||||
if (n < 0) {
|
||||
@@ -600,11 +647,13 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (!ENABLE_FEATURE_DD_STATUS || !(G.flags & FLAG_STATUS_NONE))
|
||||
dd_output_status(0);
|
||||
|
||||
#if 0 /* can't just free(), they can be mmap()ed */
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
free(obuf);
|
||||
if (G.flags & FLAG_TWOBUFS)
|
||||
free(ibuf);
|
||||
}
|
||||
#endif
|
||||
|
||||
return exitcode;
|
||||
}
|
||||
+132
-77
@@ -19,6 +19,7 @@
|
||||
//usage: "Print prime factors"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
#if 0
|
||||
# define dbg(...) bb_error_msg(__VA_ARGS__)
|
||||
@@ -42,9 +43,116 @@ typedef unsigned long half_t;
|
||||
#error Cant find an integer type which is half as wide as ullong
|
||||
#endif
|
||||
|
||||
/* The trial divisor increment wheel. Use it to skip over divisors that
|
||||
* are composites of 2, 3, 5, 7, or 11.
|
||||
* Larger wheels improve sieving only slightly, but quickly grow in size
|
||||
* (adding just one prime, 13, results in 5766 element sieve).
|
||||
*/
|
||||
#define R(a,b,c,d,e,f,g,h,i,j,A,B,C,D,E,F,G,H,I,J) \
|
||||
(((uint64_t)(a<<0) | (b<<3) | (c<<6) | (d<<9) | (e<<12) | (f<<15) | (g<<18) | (h<<21) | (i<<24) | (j<<27)) << 1) | \
|
||||
(((uint64_t)(A<<0) | (B<<3) | (C<<6) | (D<<9) | (E<<12) | (F<<15) | (G<<18) | (H<<21) | (I<<24) | (J<<27)) << 31)
|
||||
#define P(a,b,c,d,e,f,g,h,i,j,A,B,C,D,E,F,G,H,I,J) \
|
||||
R( (a/2),(b/2),(c/2),(d/2),(e/2),(f/2),(g/2),(h/2),(i/2),(j/2), \
|
||||
(A/2),(B/2),(C/2),(D/2),(E/2),(F/2),(G/2),(H/2),(I/2),(J/2) )
|
||||
static const uint64_t packed_wheel[] = {
|
||||
/*1, 2, 2, 4, 2,*/
|
||||
P( 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6, 4, 2, 6, 4, 6, 8, 4), //01
|
||||
P( 2, 4, 2, 4,14, 4, 6, 2,10, 2, 6, 6, 4, 2, 4, 6, 2,10, 2, 4), //02
|
||||
P( 2,12,10, 2, 4, 2, 4, 6, 2, 6, 4, 6, 6, 6, 2, 6, 4, 2, 6, 4), //03
|
||||
P( 6, 8, 4, 2, 4, 6, 8, 6,10, 2, 4, 6, 2, 6, 6, 4, 2, 4, 6, 2), //04
|
||||
P( 6, 4, 2, 6,10, 2,10, 2, 4, 2, 4, 6, 8, 4, 2, 4,12, 2, 6, 4), //05
|
||||
P( 2, 6, 4, 6,12, 2, 4, 2, 4, 8, 6, 4, 6, 2, 4, 6, 2, 6,10, 2), //06
|
||||
P( 4, 6, 2, 6, 4, 2, 4, 2,10, 2,10, 2, 4, 6, 6, 2, 6, 6, 4, 6), //07
|
||||
P( 6, 2, 6, 4, 2, 6, 4, 6, 8, 4, 2, 6, 4, 8, 6, 4, 6, 2, 4, 6), //08
|
||||
P( 8, 6, 4, 2,10, 2, 6, 4, 2, 4, 2,10, 2,10, 2, 4, 2, 4, 8, 6), //09
|
||||
P( 4, 2, 4, 6, 6, 2, 6, 4, 8, 4, 6, 8, 4, 2, 4, 2, 4, 8, 6, 4), //10
|
||||
P( 6, 6, 6, 2, 6, 6, 4, 2, 4, 6, 2, 6, 4, 2, 4, 2,10, 2,10, 2), //11
|
||||
P( 6, 4, 6, 2, 6, 4, 2, 4, 6, 6, 8, 4, 2, 6,10, 8, 4, 2, 4, 2), //12
|
||||
P( 4, 8,10, 6, 2, 4, 8, 6, 6, 4, 2, 4, 6, 2, 6, 4, 6, 2,10, 2), //13
|
||||
P(10, 2, 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6, 6, 6, 4, 6, 8), //14
|
||||
P( 4, 2, 4, 2, 4, 8, 6, 4, 8, 4, 6, 2, 6, 6, 4, 2, 4, 6, 8, 4), //15
|
||||
P( 2, 4, 2,10, 2,10, 2, 4, 2, 4, 6, 2,10, 2, 4, 6, 8, 6, 4, 2), //16
|
||||
P( 6, 4, 6, 8, 4, 6, 2, 4, 8, 6, 4, 6, 2, 4, 6, 2, 6, 6, 4, 6), //17
|
||||
P( 6, 2, 6, 6, 4, 2,10, 2,10, 2, 4, 2, 4, 6, 2, 6, 4, 2,10, 6), //18
|
||||
P( 2, 6, 4, 2, 6, 4, 6, 8, 4, 2, 4, 2,12, 6, 4, 6, 2, 4, 6, 2), //19
|
||||
P(12, 4, 2, 4, 8, 6, 4, 2, 4, 2,10, 2,10, 6, 2, 4, 6, 2, 6, 4), //20
|
||||
P( 2, 4, 6, 6, 2, 6, 4, 2,10, 6, 8, 6, 4, 2, 4, 8, 6, 4, 6, 2), //21
|
||||
P( 4, 6, 2, 6, 6, 6, 4, 6, 2, 6, 4, 2, 4, 2,10,12, 2, 4, 2,10), //22
|
||||
P( 2, 6, 4, 2, 4, 6, 6, 2,10, 2, 6, 4,14, 4, 2, 4, 2, 4, 8, 6), //23
|
||||
P( 4, 6, 2, 4, 6, 2, 6, 6, 4, 2, 4, 6, 2, 6, 4, 2, 4,12, 2,12), //24
|
||||
};
|
||||
#undef P
|
||||
#undef R
|
||||
#define WHEEL_START 5
|
||||
#define WHEEL_SIZE (5 + 24 * 20)
|
||||
#define square_count (((uint8_t*)&bb_common_bufsiz1)[0])
|
||||
#define wheel_tab (((uint8_t*)&bb_common_bufsiz1) + 1)
|
||||
/*
|
||||
* Why, you ask?
|
||||
* plain byte array:
|
||||
* function old new delta
|
||||
* wheel_tab - 485 +485
|
||||
* 3-bit-packed insanity:
|
||||
* packed_wheel - 192 +192
|
||||
* factor_main 108 171 +63
|
||||
*/
|
||||
static void unpack_wheel(void)
|
||||
{
|
||||
int i;
|
||||
uint8_t *p;
|
||||
|
||||
setup_common_bufsiz();
|
||||
wheel_tab[0] = 1;
|
||||
wheel_tab[1] = 2;
|
||||
wheel_tab[2] = 2;
|
||||
wheel_tab[3] = 4;
|
||||
wheel_tab[4] = 2;
|
||||
p = &wheel_tab[5];
|
||||
for (i = 0; i < ARRAY_SIZE(packed_wheel); i++) {
|
||||
uint64_t v = packed_wheel[i];
|
||||
while ((v & 0xe) != 0) {
|
||||
*p = v & 0xe;
|
||||
//printf("%2u,", *p);
|
||||
p++;
|
||||
v >>= 3;
|
||||
}
|
||||
//printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Prevent inlining, factorize() needs all help it can get with reducing register pressure */
|
||||
static NOINLINE void print_w(wide_t n)
|
||||
{
|
||||
unsigned rep = square_count;
|
||||
do
|
||||
printf(" %llu", n);
|
||||
while (--rep != 0);
|
||||
}
|
||||
static NOINLINE void print_h(half_t n)
|
||||
{
|
||||
print_w(n);
|
||||
}
|
||||
|
||||
static void factorize(wide_t N);
|
||||
|
||||
static half_t isqrt_odd(wide_t N)
|
||||
{
|
||||
half_t s = isqrt(N);
|
||||
/* s^2 is <= N, (s+1)^2 > N */
|
||||
|
||||
/* If s^2 in fact is EQUAL to N, it's very lucky.
|
||||
* Examples:
|
||||
* factor 18446743988964486098 = 2 * 3037000493 * 3037000493
|
||||
* factor 18446743902517389507 = 3 * 2479700513 * 2479700513
|
||||
*/
|
||||
if ((wide_t)s * s == N) {
|
||||
/* factorize sqrt(N), printing each factor twice */
|
||||
square_count *= 2;
|
||||
factorize(s);
|
||||
/* Let caller know we recursed */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Subtract 1 from even s, odd s won't change: */
|
||||
/* (doesnt work for zero, but we know that s != 0 here) */
|
||||
s = (s - 1) | 1;
|
||||
@@ -53,43 +161,20 @@ static half_t isqrt_odd(wide_t N)
|
||||
|
||||
static NOINLINE void factorize(wide_t N)
|
||||
{
|
||||
unsigned w;
|
||||
half_t factor;
|
||||
half_t max_factor;
|
||||
// unsigned count3;
|
||||
// unsigned count5;
|
||||
// unsigned count7;
|
||||
// ^^^^^^^^^^^^^^^ commented-out simple sieving code (easier to grasp).
|
||||
// Faster sieving, using one word for potentially up to 6 counters:
|
||||
// count upwards in each mask, counter "triggers" when it sets its mask to "100[0]..."
|
||||
// 10987654321098765432109876543210 - bits 31-0 in 32-bit word
|
||||
// 17777713333311111777775555333 - bit masks for counters for primes 3,5,7,11,13,17
|
||||
// 100000100001000010001001 - value for adding 1 to each mask
|
||||
// 10000010000010000100001000100 - value for checking that any mask reached msb
|
||||
enum {
|
||||
SHIFT_3 = 1 << 0,
|
||||
SHIFT_5 = 1 << 3,
|
||||
SHIFT_7 = 1 << 7,
|
||||
INCREMENT_EACH = SHIFT_3 | SHIFT_5 | SHIFT_7,
|
||||
MULTIPLE_OF_3 = 1 << 2,
|
||||
MULTIPLE_OF_5 = 1 << 6,
|
||||
MULTIPLE_OF_7 = 1 << 11,
|
||||
MULTIPLE_DETECTED = MULTIPLE_OF_3 | MULTIPLE_OF_5 | MULTIPLE_OF_7,
|
||||
};
|
||||
unsigned sieve_word;
|
||||
|
||||
if (N < 4)
|
||||
goto end;
|
||||
|
||||
while (!(N & 1)) {
|
||||
printf(" 2");
|
||||
N >>= 1;
|
||||
}
|
||||
|
||||
/* The code needs to be optimized for the case where
|
||||
* there are large prime factors. For example,
|
||||
* this is not hard:
|
||||
* 8262075252869367027 = 3 7 17 23 47 101 113 127 131 137 823
|
||||
* (the largest factor to test is only ~sqrt(823) = 28)
|
||||
* (the largest divisor to test for largest factor 823
|
||||
* is only ~sqrt(823) = 28, the entire factorization needs
|
||||
* only ~33 trial divisions)
|
||||
* but this is:
|
||||
* 18446744073709551601 = 53 348051774975651917
|
||||
* the last factor requires testing up to
|
||||
@@ -98,70 +183,37 @@ static NOINLINE void factorize(wide_t N)
|
||||
* factor 18446744073709551557 (0xffffffffffffffc5).
|
||||
*/
|
||||
max_factor = isqrt_odd(N);
|
||||
// count3 = 3;
|
||||
// count5 = 6;
|
||||
// count7 = 9;
|
||||
sieve_word = 0
|
||||
/* initial count for SHIFT_n is (n-1)/2*3: */
|
||||
+ (MULTIPLE_OF_3 - 3 * SHIFT_3)
|
||||
+ (MULTIPLE_OF_5 - 6 * SHIFT_5)
|
||||
+ (MULTIPLE_OF_7 - 9 * SHIFT_7)
|
||||
//+ (MULTIPLE_OF_11 - 15 * SHIFT_11)
|
||||
//+ (MULTIPLE_OF_13 - 18 * SHIFT_13)
|
||||
//+ (MULTIPLE_OF_17 - 24 * SHIFT_17)
|
||||
;
|
||||
factor = 3;
|
||||
if (!max_factor)
|
||||
return; /* square was detected and recursively factored */
|
||||
factor = 2;
|
||||
w = 0;
|
||||
for (;;) {
|
||||
half_t fw;
|
||||
|
||||
/* The division is the most costly part of the loop.
|
||||
* On 64bit CPUs, takes at best 12 cycles, often ~20.
|
||||
*/
|
||||
while ((N % factor) == 0) { /* not likely */
|
||||
N = N / factor;
|
||||
printf(" %"HALF_FMT"u", factor);
|
||||
print_h(factor);
|
||||
max_factor = isqrt_odd(N);
|
||||
if (!max_factor)
|
||||
return; /* square was detected */
|
||||
}
|
||||
next_factor:
|
||||
if (factor >= max_factor)
|
||||
break;
|
||||
factor += 2;
|
||||
/* Rudimentary wheel sieving: skip multiples of 3, 5 and 7:
|
||||
* Every third odd number is divisible by three and thus isn't a prime:
|
||||
* 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47...
|
||||
* ^ ^ ^ ^ ^ ^ ^ _ ^ ^ _ ^ ^ ^ ^
|
||||
* (^ = primes, _ = would-be-primes-if-not-divisible-by-5)
|
||||
* The numbers with space under them are excluded by sieve 3.
|
||||
*/
|
||||
// count7--;
|
||||
// count5--;
|
||||
// count3--;
|
||||
// if (count3 && count5 && count7)
|
||||
// continue;
|
||||
sieve_word += INCREMENT_EACH;
|
||||
if (!(sieve_word & MULTIPLE_DETECTED))
|
||||
fw = factor + wheel_tab[w];
|
||||
if (fw < factor)
|
||||
break; /* overflow */
|
||||
factor = fw;
|
||||
w++;
|
||||
if (w < WHEEL_SIZE)
|
||||
continue;
|
||||
/*
|
||||
* "factor" is multiple of 3 33% of the time (count3 reached 0),
|
||||
* else, multiple of 5 13% of the time,
|
||||
* else, multiple of 7 7.6% of the time.
|
||||
* Cumulatively, with 3,5,7 sieving we are here 54.3% of the time.
|
||||
*/
|
||||
// if (count3 == 0)
|
||||
// count3 = 3;
|
||||
if (sieve_word & MULTIPLE_OF_3)
|
||||
sieve_word -= SHIFT_3 * 3;
|
||||
// if (count5 == 0)
|
||||
// count5 = 5;
|
||||
if (sieve_word & MULTIPLE_OF_5)
|
||||
sieve_word -= SHIFT_5 * 5;
|
||||
// if (count7 == 0)
|
||||
// count7 = 7;
|
||||
if (sieve_word & MULTIPLE_OF_7)
|
||||
sieve_word -= SHIFT_7 * 7;
|
||||
goto next_factor;
|
||||
w = WHEEL_START;
|
||||
}
|
||||
end:
|
||||
if (N > 1)
|
||||
printf(" %llu", N);
|
||||
print_w(N);
|
||||
bb_putchar('\n');
|
||||
}
|
||||
|
||||
@@ -176,12 +228,15 @@ static void factorize_numstr(const char *numstr)
|
||||
if (errno)
|
||||
bb_show_usage();
|
||||
printf("%llu:", N);
|
||||
square_count = 1;
|
||||
factorize(N);
|
||||
}
|
||||
|
||||
int factor_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int factor_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
unpack_wheel();
|
||||
|
||||
//// coreutils has undocumented option ---debug (three dashes)
|
||||
//getopt32(argv, "");
|
||||
//argv += optind;
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@
|
||||
/* BB_AUDIT SUSv3 compliant. */
|
||||
|
||||
//usage:#define id_trivial_usage
|
||||
//usage: "[OPTIONS] [USER]"
|
||||
//usage: "[-ugGnr"IF_SELINUX("Z")"] [USER]"
|
||||
//usage:#define id_full_usage "\n\n"
|
||||
//usage: "Print information about USER or the current user\n"
|
||||
//usage: IF_SELINUX(
|
||||
|
||||
+2
-2
@@ -21,14 +21,14 @@
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/ln.html */
|
||||
|
||||
//usage:#define ln_trivial_usage
|
||||
//usage: "[OPTIONS] TARGET... LINK|DIR"
|
||||
//usage: "[-sfnbtv] [-S SUF] TARGET... LINK|DIR"
|
||||
//usage:#define ln_full_usage "\n\n"
|
||||
//usage: "Create a link LINK or DIR/TARGET to the specified TARGET(s)\n"
|
||||
//usage: "\n -s Make symlinks instead of hardlinks"
|
||||
//usage: "\n -f Remove existing destinations"
|
||||
//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 -S SUF Use suffix instead of ~ when making backup files"
|
||||
//usage: "\n -T Treat LINK as a file, not DIR"
|
||||
//usage: "\n -v Verbose"
|
||||
//usage:
|
||||
|
||||
@@ -117,8 +117,8 @@
|
||||
//usage: "\n -c Check sums against list in FILEs"
|
||||
//usage: "\n -s Don't output anything, status code shows success"
|
||||
//usage: "\n -w Warn about improperly formatted checksum lines"
|
||||
//usage: "\n -a BITS 224 (default), 256, 384, 512"
|
||||
//usage: )
|
||||
//usage: "\n -a BITS 224 (default), 256, 384, 512"
|
||||
|
||||
//FIXME: GNU coreutils 8.25 has no -s option, it has only these two long opts:
|
||||
// --quiet don't print OK for each successfully verified file
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/mkdir.html */
|
||||
|
||||
//usage:#define mkdir_trivial_usage
|
||||
//usage: "[OPTIONS] DIRECTORY..."
|
||||
//usage: "[-m MODE] [-p] DIRECTORY..."
|
||||
//usage:#define mkdir_full_usage "\n\n"
|
||||
//usage: "Create DIRECTORY\n"
|
||||
//usage: "\n -m MODE Mode"
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
//usage:#define nl_full_usage "\n\n"
|
||||
//usage: "Write FILEs to standard output with line numbers added\n"
|
||||
//usage: "\n -b STYLE Which lines to number - a: all, t: nonempty, n: none"
|
||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^TODO: support "pBRE": number only lines thatmatch regexp BRE"
|
||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^TODO: support "pBRE": number only lines that match regexp BRE"
|
||||
////usage: "\n -f STYLE footer lines"
|
||||
////usage: "\n -h STYLE header lines"
|
||||
////usage: "\n -d CC use CC for separating logical pages"
|
||||
|
||||
@@ -627,7 +627,7 @@ decode_one_format(const char *s_orig, const char *s, struct tspec *tspec)
|
||||
bytes_to_unsigned_dec_digits,
|
||||
bytes_to_hex_digits,
|
||||
};
|
||||
static const char doux_fmtstring[][sizeof(" %%0%u%s")] = {
|
||||
static const char doux_fmtstring[][sizeof(" %%0%u%s")] ALIGN1 = {
|
||||
" %%%u%s",
|
||||
" %%0%u%s",
|
||||
" %%%u%s",
|
||||
@@ -1148,7 +1148,7 @@ dump_strings(off_t address, off_t end_offset)
|
||||
static int
|
||||
parse_old_offset(const char *s, off_t *offset)
|
||||
{
|
||||
static const struct suffix_mult Bb[] = {
|
||||
static const struct suffix_mult Bb[] ALIGN_SUFFIX = {
|
||||
{ "B", 1024 },
|
||||
{ "b", 512 },
|
||||
{ "", 0 }
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
//kbuild:lib-$(CONFIG_PASTE) += paste.o
|
||||
|
||||
//usage:#define paste_trivial_usage
|
||||
//usage: "[OPTIONS] [FILE]..."
|
||||
//usage: "[-d LIST] [-s] [FILE]..."
|
||||
//usage:#define paste_full_usage "\n\n"
|
||||
//usage: "Paste lines from each input file, separated with tab\n"
|
||||
//usage: "\n -d LIST Use delimiters from LIST, not tab"
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/rmdir.html */
|
||||
|
||||
//usage:#define rmdir_trivial_usage
|
||||
//usage: "[OPTIONS] DIRECTORY..."
|
||||
//usage: "[-p] DIRECTORY..."
|
||||
//usage:#define rmdir_full_usage "\n\n"
|
||||
//usage: "Remove DIRECTORY if it is empty\n"
|
||||
//usage: "\n -p Include parents"
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@
|
||||
|
||||
//usage:#define sort_trivial_usage
|
||||
//usage: "[-nru"
|
||||
//usage: IF_FEATURE_SORT_BIG("gMcszbdfiokt] [-o FILE] [-k start[.offset][opts][,end[.offset][opts]] [-t CHAR")
|
||||
//usage: IF_FEATURE_SORT_BIG("gMcszbdfiokt] [-o FILE] [-k START[.OFS][OPTS][,END[.OFS][OPTS]] [-t CHAR")
|
||||
//usage: "] [FILE]..."
|
||||
//usage:#define sort_full_usage "\n\n"
|
||||
//usage: "Sort lines of text\n"
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
#if ENABLE_FEATURE_SPLIT_FANCY
|
||||
static const struct suffix_mult split_suffixes[] = {
|
||||
static const struct suffix_mult split_suffixes[] ALIGN_SUFFIX = {
|
||||
{ "b", 512 },
|
||||
{ "k", 1024 },
|
||||
{ "m", 1024*1024 },
|
||||
|
||||
+2
-3
@@ -31,7 +31,6 @@
|
||||
//config: bool "Enable display of filesystem status (-f)"
|
||||
//config: default y
|
||||
//config: depends on STAT
|
||||
//config: select PLATFORM_LINUX # statfs()
|
||||
//config: help
|
||||
//config: Without this, stat will not support the '-f' option to display
|
||||
//config: information about filesystem status.
|
||||
@@ -41,7 +40,7 @@
|
||||
//kbuild:lib-$(CONFIG_STAT) += stat.o
|
||||
|
||||
//usage:#define stat_trivial_usage
|
||||
//usage: "[OPTIONS] FILE..."
|
||||
//usage: "[-lt"IF_FEATURE_STAT_FILESYSTEM("f")"] "IF_FEATURE_STAT_FORMAT("[-c FMT] ")"FILE..."
|
||||
//usage:#define stat_full_usage "\n\n"
|
||||
//usage: "Display file"
|
||||
//usage: IF_FEATURE_STAT_FILESYSTEM(" (default) or filesystem")
|
||||
@@ -209,7 +208,7 @@ FS_TYPE(0x62656572, "sysfs")
|
||||
static const char *human_fstype(uint32_t f_type)
|
||||
{
|
||||
# define FS_TYPE(type, name) type,
|
||||
static const uint32_t fstype[] = {
|
||||
static const uint32_t fstype[] ALIGN4 = {
|
||||
FS_TYPE_LIST
|
||||
};
|
||||
# undef FS_TYPE
|
||||
|
||||
+2
-2
@@ -487,7 +487,7 @@ static const char mode_name[] ALIGN1 =
|
||||
#undef MI_ENTRY
|
||||
#define MI_ENTRY(N,T,F,B,M) { T, F, M, B },
|
||||
|
||||
static const struct mode_info mode_info[] = {
|
||||
static const struct mode_info mode_info[] ALIGN4 = {
|
||||
/* This should be verbatim cut-n-paste copy of the above MI_ENTRYs */
|
||||
MI_ENTRY("evenp", combination, REV | OMIT, 0, 0 )
|
||||
MI_ENTRY("parity", combination, REV | OMIT, 0, 0 )
|
||||
@@ -905,7 +905,7 @@ static void display_window_size(int fancy)
|
||||
}
|
||||
}
|
||||
|
||||
static const struct suffix_mult stty_suffixes[] = {
|
||||
static const struct suffix_mult stty_suffixes[] ALIGN_SUFFIX = {
|
||||
{ "b", 512 },
|
||||
{ "k", 1024 },
|
||||
{ "B", 1024 },
|
||||
|
||||
+83
-1
@@ -76,6 +76,8 @@
|
||||
//usage: "1\n"
|
||||
|
||||
#include "libbb.h"
|
||||
#include <regex.h>
|
||||
#include <fnmatch.h>
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
@@ -146,6 +148,14 @@
|
||||
|
||||
#define TEST_DEBUG 0
|
||||
|
||||
#if ENABLE_TEST2 \
|
||||
|| (ENABLE_ASH_BASH_COMPAT && ENABLE_ASH_TEST) \
|
||||
|| (ENABLE_HUSH_BASH_COMPAT && ENABLE_HUSH_TEST)
|
||||
# define BASH_TEST2 1
|
||||
#else
|
||||
# define BASH_TEST2 0
|
||||
#endif
|
||||
|
||||
enum token {
|
||||
EOI,
|
||||
|
||||
@@ -184,6 +194,10 @@ enum token {
|
||||
STRLT,
|
||||
STRGT,
|
||||
|
||||
#if BASH_TEST2
|
||||
REGEX,
|
||||
#endif
|
||||
|
||||
INTEQ, /* int ops */
|
||||
INTNE,
|
||||
INTGE,
|
||||
@@ -257,6 +271,9 @@ static const char *const TOKSTR[] = {
|
||||
"STRNE",
|
||||
"STRLT",
|
||||
"STRGT",
|
||||
#if BASH_TEST2
|
||||
"REGEX",
|
||||
#endif
|
||||
"INTEQ",
|
||||
"INTNE",
|
||||
"INTGE",
|
||||
@@ -289,7 +306,7 @@ struct operator_t {
|
||||
unsigned char op_num, op_type;
|
||||
};
|
||||
|
||||
static const struct operator_t ops_table[] = {
|
||||
static const struct operator_t ops_table[] ALIGN2 = {
|
||||
{ /* "-r" */ FILRD , UNOP },
|
||||
{ /* "-w" */ FILWR , UNOP },
|
||||
{ /* "-x" */ FILEX , UNOP },
|
||||
@@ -320,6 +337,9 @@ static const struct operator_t ops_table[] = {
|
||||
{ /* "!=" */ STRNE , BINOP },
|
||||
{ /* "<" */ STRLT , BINOP },
|
||||
{ /* ">" */ STRGT , BINOP },
|
||||
#if BASH_TEST2
|
||||
{ /* "=~" */ REGEX , BINOP },
|
||||
#endif
|
||||
{ /* "-eq"*/ INTEQ , BINOP },
|
||||
{ /* "-ne"*/ INTNE , BINOP },
|
||||
{ /* "-ge"*/ INTGE , BINOP },
|
||||
@@ -332,6 +352,10 @@ static const struct operator_t ops_table[] = {
|
||||
{ /* "!" */ UNOT , BUNOP },
|
||||
{ /* "-a" */ BAND , BBINOP },
|
||||
{ /* "-o" */ BOR , BBINOP },
|
||||
#if BASH_TEST2
|
||||
{ /* "&&" */ BAND , BBINOP },
|
||||
{ /* "||" */ BOR , BBINOP },
|
||||
#endif
|
||||
{ /* "(" */ LPAREN , PAREN },
|
||||
{ /* ")" */ RPAREN , PAREN },
|
||||
};
|
||||
@@ -365,6 +389,9 @@ static const char ops_texts[] ALIGN1 =
|
||||
"!=" "\0"
|
||||
"<" "\0"
|
||||
">" "\0"
|
||||
#if BASH_TEST2
|
||||
"=~" "\0"
|
||||
#endif
|
||||
"-eq" "\0"
|
||||
"-ne" "\0"
|
||||
"-ge" "\0"
|
||||
@@ -377,6 +404,10 @@ static const char ops_texts[] ALIGN1 =
|
||||
"!" "\0"
|
||||
"-a" "\0"
|
||||
"-o" "\0"
|
||||
#if BASH_TEST2
|
||||
"&&" "\0"
|
||||
"||" "\0"
|
||||
#endif
|
||||
"(" "\0"
|
||||
")" "\0"
|
||||
;
|
||||
@@ -397,6 +428,9 @@ struct test_statics {
|
||||
const struct operator_t *last_operator;
|
||||
gid_t *group_array;
|
||||
int ngroups;
|
||||
#if BASH_TEST2
|
||||
bool bash_test2;
|
||||
#endif
|
||||
jmp_buf leaving;
|
||||
};
|
||||
|
||||
@@ -408,6 +442,7 @@ extern struct test_statics *const test_ptr_to_statics;
|
||||
#define last_operator (S.last_operator)
|
||||
#define group_array (S.group_array )
|
||||
#define ngroups (S.ngroups )
|
||||
#define bash_test2 (S.bash_test2 )
|
||||
#define leaving (S.leaving )
|
||||
|
||||
#define INIT_S() do { \
|
||||
@@ -501,6 +536,20 @@ static enum token check_operator(const char *s)
|
||||
n = index_in_strings(ops_texts, s);
|
||||
if (n < 0)
|
||||
return OPERAND;
|
||||
|
||||
#if BASH_TEST2
|
||||
if (ops_table[n].op_num == REGEX && !bash_test2) {
|
||||
/* =~ is only for [[ ]] */
|
||||
return OPERAND;
|
||||
}
|
||||
if (ops_table[n].op_num == BAND || ops_table[n].op_num == BOR) {
|
||||
/* [ ] accepts -a and -o but not && and || */
|
||||
/* [[ ]] accepts && and || but not -a and -o */
|
||||
if (bash_test2 == (s[0] == '-'))
|
||||
return OPERAND;
|
||||
}
|
||||
#endif
|
||||
|
||||
last_operator = &ops_table[n];
|
||||
return ops_table[n].op_num;
|
||||
}
|
||||
@@ -536,6 +585,29 @@ static int binop(void)
|
||||
/*if (op->op_num == INTLT)*/
|
||||
return val1 < val2;
|
||||
}
|
||||
#if BASH_TEST2
|
||||
if (bash_test2) {
|
||||
if (op->op_num == STREQ) {
|
||||
val1 = fnmatch(opnd2, opnd1, 0);
|
||||
return val1 == 0;
|
||||
}
|
||||
if (op->op_num == STRNE) {
|
||||
val1 = fnmatch(opnd2, opnd1, 0);
|
||||
return val1 != 0;
|
||||
}
|
||||
if (op->op_num == REGEX) {
|
||||
regex_t re_buffer;
|
||||
memset(&re_buffer, 0, sizeof(re_buffer));
|
||||
if (regcomp(&re_buffer, opnd2, REG_EXTENDED)) { // REG_NEWLINE?
|
||||
/* Bad regex */
|
||||
longjmp(leaving, 2); /* [[ a =~ * ]]; echo $? - prints 2 (silently, no error msg) */
|
||||
}
|
||||
val1 = regexec(&re_buffer, opnd1, 0, NULL, 0);
|
||||
regfree(&re_buffer);
|
||||
return val1 == 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (is_str_op(op->op_num)) {
|
||||
val1 = strcmp(opnd1, opnd2);
|
||||
if (op->op_num == STREQ)
|
||||
@@ -824,6 +896,9 @@ int test_main(int argc, char **argv)
|
||||
{
|
||||
int res;
|
||||
const char *arg0;
|
||||
#if BASH_TEST2
|
||||
bool bt2 = 0;
|
||||
#endif
|
||||
|
||||
arg0 = bb_basename(argv[0]);
|
||||
if ((ENABLE_TEST1 || ENABLE_TEST2 || ENABLE_ASH_TEST || ENABLE_HUSH_TEST)
|
||||
@@ -840,6 +915,9 @@ int test_main(int argc, char **argv)
|
||||
bb_simple_error_msg("missing ]]");
|
||||
return 2;
|
||||
}
|
||||
#if BASH_TEST2
|
||||
bt2 = 1;
|
||||
#endif
|
||||
}
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
@@ -848,6 +926,10 @@ int test_main(int argc, char **argv)
|
||||
/* We must do DEINIT_S() prior to returning */
|
||||
INIT_S();
|
||||
|
||||
#if BASH_TEST2
|
||||
bash_test2 = bt2;
|
||||
#endif
|
||||
|
||||
res = setjmp(leaving);
|
||||
if (res)
|
||||
goto ret;
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@
|
||||
//usage:#define timeout_trivial_usage
|
||||
//usage: "[-s SIG] SECS 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: "Run PROG. Send SIG to it if it is not gone in SECS seconds.\n"
|
||||
//usage: "Default SIG: TERM."
|
||||
|
||||
#include "libbb.h"
|
||||
@@ -105,7 +105,7 @@ int timeout_main(int argc UNUSED_PARAM, char **argv)
|
||||
grandchild:
|
||||
/* Just sleep(HUGE_NUM); kill(parent) may kill wrong process! */
|
||||
while (1) {
|
||||
sleep(1);
|
||||
sleep1();
|
||||
if (--timeout <= 0)
|
||||
break;
|
||||
if (kill(parent, 0)) {
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/uniq.html */
|
||||
|
||||
//usage:#define uniq_trivial_usage
|
||||
//usage: "[-cdu][-f,s,w N] [INPUT [OUTPUT]]"
|
||||
//usage: "[-cdui] [-f,s,w N] [INPUT [OUTPUT]]"
|
||||
//usage:#define uniq_full_usage "\n\n"
|
||||
//usage: "Discard duplicate lines\n"
|
||||
//usage: "\n -c Prefix lines by the number of occurrences"
|
||||
|
||||
+140
-24
@@ -110,9 +110,7 @@ static void FAST_FUNC read_stduu(FILE *src_stream, FILE *dst_stream, int flags U
|
||||
}
|
||||
bb_simple_error_msg_and_die("short file");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLE_UUDECODE
|
||||
int uudecode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int uudecode_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
@@ -170,9 +168,11 @@ int uudecode_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
//applet:IF_BASE64(APPLET(base64, BB_DIR_BIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_BASE64) += uudecode.o
|
||||
//config:config BASE32
|
||||
//config: bool "base32 (4.9 kb)"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Base32 encode and decode
|
||||
|
||||
//config:config BASE64
|
||||
//config: bool "base64 (4.9 kb)"
|
||||
@@ -180,49 +180,165 @@ int uudecode_main(int argc UNUSED_PARAM, char **argv)
|
||||
//config: help
|
||||
//config: Base64 encode and decode
|
||||
|
||||
//usage:#define base32_trivial_usage
|
||||
//usage: "[-d] [-w COL] [FILE]"
|
||||
//usage:#define base32_full_usage "\n\n"
|
||||
//usage: "Base32 encode or decode FILE to standard output"
|
||||
//usage: "\n -d Decode data"
|
||||
//usage: "\n -w COL Wrap lines at COL (default 76, 0 disables)"
|
||||
////usage: "\n -i When decoding, ignore non-alphabet characters"
|
||||
|
||||
//usage:#define base64_trivial_usage
|
||||
//usage: "[-d] [FILE]"
|
||||
//usage: "[-d] [-w COL] [FILE]"
|
||||
//usage:#define base64_full_usage "\n\n"
|
||||
//usage: "Base64 encode or decode FILE to standard output"
|
||||
//usage: "\n -d Decode data"
|
||||
////usage: "\n -w COL Wrap lines at COL (default 76, 0 disables)"
|
||||
//usage: "\n -w COL Wrap lines at COL (default 76, 0 disables)"
|
||||
////usage: "\n -i When decoding, ignore non-alphabet characters"
|
||||
|
||||
#if ENABLE_BASE64
|
||||
int base64_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int base64_main(int argc UNUSED_PARAM, char **argv)
|
||||
// APPLET_ODDNAME:name main location suid_type help
|
||||
//applet:IF_BASE32(APPLET_ODDNAME(base32, baseNUM, BB_DIR_BIN, BB_SUID_DROP, base32))
|
||||
//applet:IF_BASE64(APPLET_ODDNAME(base64, baseNUM, BB_DIR_BIN, BB_SUID_DROP, base64))
|
||||
|
||||
//kbuild:lib-$(CONFIG_BASE64) += uudecode.o
|
||||
//kbuild:lib-$(CONFIG_BASE32) += uudecode.o
|
||||
|
||||
#if ENABLE_BASE32 || ENABLE_BASE64
|
||||
|
||||
# if ENABLE_BASE32
|
||||
static void bb_b32encode(char *p, const void *src, int length)
|
||||
{
|
||||
#define tbl bb_uuenc_tbl_base32
|
||||
const unsigned char *s = src;
|
||||
|
||||
/* Transform 5x8 bits to 8x5 bits */
|
||||
while (length > 0) {
|
||||
unsigned cur, next;
|
||||
|
||||
length--;
|
||||
cur = *s++;
|
||||
*p++ = tbl[cur >> 3]; // xxxxx--- -------- -------- -------- --------
|
||||
cur &= 7;
|
||||
|
||||
next = 0;
|
||||
if (--length >= 0)
|
||||
next = *s++;
|
||||
*p++ = tbl[(cur << 2) + (next >> 6)]; // -----xxx xx------ -------- -------- --------
|
||||
cur = next & 0x3f;
|
||||
|
||||
*p++ = tbl[cur >> 1]; // -------- --xxxxx- -------- -------- --------
|
||||
cur &= 1;
|
||||
|
||||
next = 0;
|
||||
if (--length >= 0)
|
||||
next = *s++;
|
||||
*p++ = tbl[(cur << 4) + (next >> 4)]; // -------- -------x xxxx---- -------- --------
|
||||
cur = next & 0xf;
|
||||
|
||||
next = 0;
|
||||
if (--length >= 0)
|
||||
next = *s++;
|
||||
*p++ = tbl[(cur << 1) + (next >> 7)]; // -------- -------- ----xxxx x------- --------
|
||||
cur = next & 0x7f;
|
||||
|
||||
*p++ = tbl[cur >> 2]; // -------- -------- -------- -xxxxx-- --------
|
||||
cur &= 3;
|
||||
|
||||
next = 0;
|
||||
if (--length >= 0)
|
||||
next = *s++;
|
||||
*p++ = tbl[(cur << 3) + (next >> 5)]; // -------- -------- -------- ------xx xxx-----
|
||||
cur = next & 0x1f;
|
||||
|
||||
*p++ = tbl[cur]; // -------- -------- -------- -------- ---xxxxx
|
||||
}
|
||||
#undef tbl
|
||||
/* Zero-terminate */
|
||||
*p = '\0';
|
||||
/* Pad as necessary */
|
||||
length = ((-length) * 3) >> 1; /* -4 => 6 pad chars, -3 => 4, -2 => 3, -1 => 1 */
|
||||
while (length--) {
|
||||
*--p = '=';
|
||||
}
|
||||
}
|
||||
# else
|
||||
void bb_b32encode(char *p, const void *src, int length); /* undefined */
|
||||
# endif
|
||||
|
||||
int baseNUM_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int baseNUM_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
FILE *src_stream;
|
||||
unsigned opts;
|
||||
unsigned col = 76;
|
||||
|
||||
opts = getopt32(argv, "^" "d" "\0" "?1"/* 1 arg max*/);
|
||||
opts = getopt32(argv, "^" "dw:+" "\0" "?1"/* 1 arg max*/, &col);
|
||||
argv += optind;
|
||||
|
||||
if (!argv[0])
|
||||
*--argv = (char*)"-";
|
||||
src_stream = xfopen_stdin(argv[0]);
|
||||
if (opts) {
|
||||
read_base64(src_stream, stdout, /*flags:*/ (char)EOF);
|
||||
if (opts & 1) {
|
||||
/* -d: decode */
|
||||
int flags = (unsigned char)EOF;
|
||||
if (ENABLE_BASE32 && (!ENABLE_BASE64 || applet_name[4] == '3'))
|
||||
flags = ((unsigned char)EOF) | BASE64_32;
|
||||
read_base64(src_stream, stdout, flags);
|
||||
} else {
|
||||
enum {
|
||||
SRC_BUF_SIZE = 76/4*3, /* This *MUST* be a multiple of 3 */
|
||||
DST_BUF_SIZE = 4 * ((SRC_BUF_SIZE + 2) / 3),
|
||||
SRC_BUF_SIZE = 3 * 5 * 32, /* this *MUST* be a multiple of 3 and 5 */
|
||||
DST_BUF_SIZE = 8 * ((SRC_BUF_SIZE + 4) / 5), /* max growth on encode (base32 case) */
|
||||
};
|
||||
char src_buf[SRC_BUF_SIZE];
|
||||
char dst_buf[DST_BUF_SIZE + 1];
|
||||
int src_fd = fileno(src_stream);
|
||||
/* Use one buffer for both input and output:
|
||||
* encoding reads input "left-to-right",
|
||||
* it's safe to place source at the end of the buffer and
|
||||
* overwrite it while encoding, just be careful to have a gap.
|
||||
*/
|
||||
char dst_buf[((DST_BUF_SIZE + /*gap:*/ 16) /*round up to 16:*/ | 0xf) + 1];
|
||||
#define src_buf (dst_buf + sizeof(dst_buf) - SRC_BUF_SIZE)
|
||||
int src_fd, rem;
|
||||
|
||||
src_fd = fileno(src_stream);
|
||||
rem = 0;
|
||||
while (1) {
|
||||
size_t size = full_read(src_fd, src_buf, SRC_BUF_SIZE);
|
||||
if (!size)
|
||||
break;
|
||||
if ((ssize_t)size < 0)
|
||||
bb_simple_perror_msg_and_die(bb_msg_read_error);
|
||||
if (size == 0) {
|
||||
if (rem != 0) bb_putchar('\n');
|
||||
break;
|
||||
}
|
||||
|
||||
/* Encode the buffer we just read in */
|
||||
bb_uuencode(dst_buf, src_buf, size, bb_uuenc_tbl_base64);
|
||||
xwrite(STDOUT_FILENO, dst_buf, 4 * ((size + 2) / 3));
|
||||
bb_putchar('\n');
|
||||
fflush(stdout);
|
||||
if (ENABLE_BASE32 && (!ENABLE_BASE64 || applet_name[4] == '3')) {
|
||||
bb_b32encode(dst_buf, src_buf, size);
|
||||
size = 8 * ((size + 4) / 5);
|
||||
} else {
|
||||
bb_uuencode(dst_buf, src_buf, size, bb_uuenc_tbl_base64);
|
||||
size = 4 * ((size + 2) / 3);
|
||||
}
|
||||
|
||||
if (col == 0) {
|
||||
fputs(dst_buf, stdout);
|
||||
} else {
|
||||
char *result = dst_buf;
|
||||
if (rem == 0)
|
||||
rem = col;
|
||||
while (1) {
|
||||
int out = size < rem ? size : rem;
|
||||
rem -= out;
|
||||
printf(rem != 0 ? "%.*s" : "%.*s\n", out, result);
|
||||
if (rem != 0)
|
||||
break;
|
||||
size -= out;
|
||||
if (size == 0)
|
||||
break;
|
||||
result += out;
|
||||
rem = col;
|
||||
}
|
||||
}
|
||||
}
|
||||
#undef src_buf
|
||||
}
|
||||
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
|
||||
@@ -131,12 +131,13 @@ static int bb_alphasort(const void *p1, const void *p2)
|
||||
return (option_mask32 & OPT_r) ? -r : r;
|
||||
}
|
||||
|
||||
static int FAST_FUNC act(const char *file, struct stat *statbuf, void *args UNUSED_PARAM, int depth)
|
||||
static int FAST_FUNC act(struct recursive_state *state,
|
||||
const char *file, struct stat *statbuf)
|
||||
{
|
||||
if (depth == 1)
|
||||
if (state->depth == 0)
|
||||
return TRUE;
|
||||
|
||||
if (depth == 2
|
||||
if (state->depth == 1
|
||||
&& ( !(statbuf->st_mode & (S_IFREG | S_IFLNK))
|
||||
|| invalid_name(file)
|
||||
|| (!(option_mask32 & OPT_l) && access(file, X_OK) != 0))
|
||||
@@ -199,9 +200,8 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv)
|
||||
ACTION_RECURSE|ACTION_FOLLOWLINKS,
|
||||
act, /* file action */
|
||||
act, /* dir action */
|
||||
NULL, /* user data */
|
||||
1 /* depth */
|
||||
);
|
||||
NULL /* user data */
|
||||
);
|
||||
|
||||
if (!names)
|
||||
return 0;
|
||||
|
||||
+2
-2
@@ -17,9 +17,9 @@
|
||||
//kbuild:lib-$(CONFIG_WHICH) += which.o
|
||||
|
||||
//usage:#define which_trivial_usage
|
||||
//usage: "[COMMAND]..."
|
||||
//usage: "COMMAND..."
|
||||
//usage:#define which_full_usage "\n\n"
|
||||
//usage: "Locate a COMMAND"
|
||||
//usage: "Locate COMMAND"
|
||||
//usage:
|
||||
//usage:#define which_example_usage
|
||||
//usage: "$ which login\n"
|
||||
|
||||
@@ -127,7 +127,7 @@ int fgetsetflags(const char *name, unsigned long *get_flags, unsigned long set_f
|
||||
|
||||
|
||||
/* Print file attributes on an ext2 file system */
|
||||
const uint32_t e2attr_flags_value[] = {
|
||||
const uint32_t e2attr_flags_value[] ALIGN4 = {
|
||||
#ifdef ENABLE_COMPRESSION
|
||||
EXT2_COMPRBLK_FL,
|
||||
EXT2_DIRTY_FL,
|
||||
|
||||
+1
-1
@@ -480,7 +480,7 @@ static int wait_one(int flags)
|
||||
* time to set up the signal handler
|
||||
*/
|
||||
if (inst2->start_time >= time(NULL) - 1)
|
||||
sleep(1);
|
||||
sleep1();
|
||||
kill(inst2->pid, SIGUSR1);
|
||||
inst2->flags |= FLAG_PROGRESS;
|
||||
break;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
//config:config LSATTR
|
||||
//config: bool "lsattr (5.5 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: lsattr lists the file attributes on a second extended file system.
|
||||
|
||||
|
||||
+39
-15
@@ -405,7 +405,7 @@ static const char tokenlist[] ALIGN1 =
|
||||
|
||||
#define OC_B OC_BUILTIN
|
||||
|
||||
static const uint32_t tokeninfo[] = {
|
||||
static const uint32_t tokeninfo[] ALIGN4 = {
|
||||
0,
|
||||
0,
|
||||
OC_REGEXP,
|
||||
@@ -1763,12 +1763,34 @@ static void fsrealloc(int size)
|
||||
nfields = size;
|
||||
}
|
||||
|
||||
static int regexec1_nonempty(const regex_t *preg, const char *s, regmatch_t pmatch[])
|
||||
{
|
||||
int r = regexec(preg, s, 1, pmatch, 0);
|
||||
if (r == 0 && pmatch[0].rm_eo == 0) {
|
||||
/* For example, happens when FS can match
|
||||
* an empty string (awk -F ' *'). Logically,
|
||||
* this should split into one-char fields.
|
||||
* However, gawk 5.0.1 searches for first
|
||||
* _non-empty_ separator string match:
|
||||
*/
|
||||
size_t ofs = 0;
|
||||
do {
|
||||
ofs++;
|
||||
if (!s[ofs])
|
||||
return REG_NOMATCH;
|
||||
regexec(preg, s + ofs, 1, pmatch, 0);
|
||||
} while (pmatch[0].rm_eo == 0);
|
||||
pmatch[0].rm_so += ofs;
|
||||
pmatch[0].rm_eo += ofs;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
static int awk_split(const char *s, node *spl, char **slist)
|
||||
{
|
||||
int l, n;
|
||||
int n;
|
||||
char c[4];
|
||||
char *s1;
|
||||
regmatch_t pmatch[2]; // TODO: why [2]? [1] is enough...
|
||||
|
||||
/* in worst case, each char would be a separate field */
|
||||
*slist = s1 = xzalloc(strlen(s) * 2 + 3);
|
||||
@@ -1785,29 +1807,31 @@ static int awk_split(const char *s, node *spl, char **slist)
|
||||
return n; /* "": zero fields */
|
||||
n++; /* at least one field will be there */
|
||||
do {
|
||||
int l;
|
||||
regmatch_t pmatch[2]; // TODO: why [2]? [1] is enough...
|
||||
|
||||
l = strcspn(s, c+2); /* len till next NUL or \n */
|
||||
if (regexec(icase ? spl->r.ire : spl->l.re, s, 1, pmatch, 0) == 0
|
||||
if (regexec1_nonempty(icase ? spl->r.ire : spl->l.re, s, pmatch) == 0
|
||||
&& pmatch[0].rm_so <= l
|
||||
) {
|
||||
/* if (pmatch[0].rm_eo == 0) ... - impossible */
|
||||
l = pmatch[0].rm_so;
|
||||
if (pmatch[0].rm_eo == 0) {
|
||||
l++;
|
||||
pmatch[0].rm_eo++;
|
||||
}
|
||||
n++; /* we saw yet another delimiter */
|
||||
} else {
|
||||
pmatch[0].rm_eo = l;
|
||||
if (s[l])
|
||||
pmatch[0].rm_eo++;
|
||||
}
|
||||
memcpy(s1, s, l);
|
||||
/* make sure we remove *all* of the separator chars */
|
||||
do {
|
||||
s1[l] = '\0';
|
||||
} while (++l < pmatch[0].rm_eo);
|
||||
nextword(&s1);
|
||||
s1 = mempcpy(s1, s, l);
|
||||
*s1++ = '\0';
|
||||
s += pmatch[0].rm_eo;
|
||||
} while (*s);
|
||||
|
||||
/* echo a-- | awk -F-- '{ print NF, length($NF), $NF }'
|
||||
* should print "2 0 ":
|
||||
*/
|
||||
*s1 = '\0';
|
||||
|
||||
return n;
|
||||
}
|
||||
if (c[0] == '\0') { /* null split */
|
||||
@@ -2011,7 +2035,7 @@ static int ptest(node *pattern)
|
||||
static int awk_getline(rstream *rsm, var *v)
|
||||
{
|
||||
char *b;
|
||||
regmatch_t pmatch[2];
|
||||
regmatch_t pmatch[2]; // TODO: why [2]? [1] is enough...
|
||||
int size, a, p, pp = 0;
|
||||
int fd, so, eo, r, rp;
|
||||
char c, *m, *s;
|
||||
|
||||
+11
-11
@@ -803,11 +803,11 @@ struct dlist {
|
||||
};
|
||||
|
||||
/* This function adds a filename to dl, the directory listing. */
|
||||
static int FAST_FUNC add_to_dirlist(const char *filename,
|
||||
struct stat *sb UNUSED_PARAM,
|
||||
void *userdata, int depth UNUSED_PARAM)
|
||||
static int FAST_FUNC add_to_dirlist(struct recursive_state *state,
|
||||
const char *filename,
|
||||
struct stat *sb UNUSED_PARAM)
|
||||
{
|
||||
struct dlist *const l = userdata;
|
||||
struct dlist *const l = state->userData;
|
||||
const char *file = filename + l->len;
|
||||
while (*file == '/')
|
||||
file++;
|
||||
@@ -820,12 +820,12 @@ static int FAST_FUNC add_to_dirlist(const char *filename,
|
||||
/* If recursion is not set, this function adds the directory
|
||||
* to the list and prevents recursive_action from recursing into it.
|
||||
*/
|
||||
static int FAST_FUNC skip_dir(const char *filename,
|
||||
struct stat *sb, void *userdata,
|
||||
int depth)
|
||||
static int FAST_FUNC skip_dir(struct recursive_state *state,
|
||||
const char *filename,
|
||||
struct stat *sb)
|
||||
{
|
||||
if (!(option_mask32 & FLAG(r)) && depth) {
|
||||
add_to_dirlist(filename, sb, userdata, depth);
|
||||
if (!(option_mask32 & FLAG(r)) && state->depth) {
|
||||
add_to_dirlist(state, filename, sb);
|
||||
return SKIP;
|
||||
}
|
||||
if (!(option_mask32 & FLAG(N))) {
|
||||
@@ -833,7 +833,7 @@ static int FAST_FUNC skip_dir(const char *filename,
|
||||
* which do not exist on the "other side".
|
||||
* Testcase: diff -r /tmp /
|
||||
* (it would recurse deep into /proc without this code) */
|
||||
struct dlist *const l = userdata;
|
||||
struct dlist *const l = state->userData;
|
||||
filename += l->len;
|
||||
if (filename[0]) {
|
||||
struct stat osb;
|
||||
@@ -868,7 +868,7 @@ static void diffdir(char *p[2], const char *s_start)
|
||||
* add_to_dirlist will remove it. */
|
||||
list[i].len = strlen(p[i]);
|
||||
recursive_action(p[i], ACTION_RECURSE | ACTION_FOLLOWLINKS,
|
||||
add_to_dirlist, skip_dir, &list[i], 0);
|
||||
add_to_dirlist, skip_dir, &list[i]);
|
||||
/* Sort dl alphabetically.
|
||||
* GNU diff does this ignoring any number of trailing dots.
|
||||
* We don't, so for us dotted files almost always are
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
//kbuild:lib-$(CONFIG_PATCH) += patch.o
|
||||
|
||||
//usage:#define patch_trivial_usage
|
||||
//usage: "[OPTIONS] [ORIGFILE [PATCHFILE]]"
|
||||
//usage: "[-RNE] [-p N] [-i DIFF] [ORIGFILE [PATCHFILE]]"
|
||||
//usage:#define patch_full_usage "\n\n"
|
||||
//usage: " -p N Strip N leading components from file names"
|
||||
//usage: "\n -i DIFF Read DIFF instead of stdin"
|
||||
|
||||
+1
-1
@@ -166,7 +166,7 @@
|
||||
//kbuild:lib-$(CONFIG_VI) += vi.o
|
||||
|
||||
//usage:#define vi_trivial_usage
|
||||
//usage: "[OPTIONS] [FILE]..."
|
||||
//usage: IF_FEATURE_VI_COLON("[-c CMD] ")IF_FEATURE_VI_READONLY("[-R] ")"[FILE]..."
|
||||
//usage:#define vi_full_usage "\n\n"
|
||||
//usage: "Edit FILE\n"
|
||||
//usage: IF_FEATURE_VI_COLON(
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ time dgram udp wait root internal
|
||||
#ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd
|
||||
#telnet stream tcp nowait root /sbin/telnetd /sbin/telnetd
|
||||
#nntp stream tcp nowait root tcpd in.nntpd
|
||||
#smtp stream tcp nowait root tcpd sendmail -v
|
||||
#smtp stream tcp nowait root tcpd sendmail -v
|
||||
#
|
||||
# Shell, login, exec and talk are BSD protocols.
|
||||
#
|
||||
|
||||
@@ -6,12 +6,12 @@ RESOLV_CONF="/etc/udhcpc/resolv.conf"
|
||||
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
|
||||
[ -n "$subnet" ] && NETMASK="netmask $subnet"
|
||||
|
||||
/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
|
||||
ifconfig $interface $ip $BROADCAST $NETMASK
|
||||
|
||||
if [ -n "$router" ]
|
||||
then
|
||||
echo "deleting routers"
|
||||
while /sbin/route del default gw 0.0.0.0 dev $interface
|
||||
while route del default gw 0.0.0.0 dev $interface
|
||||
do :
|
||||
done
|
||||
|
||||
@@ -23,9 +23,9 @@ then
|
||||
# /32 instructs kernel to always use routing for all outgoing packets
|
||||
# (they can never be sent to local subnet - there is no local subnet for /32).
|
||||
# Used in datacenters, avoids the need for private ip-addresses between two hops.
|
||||
/sbin/ip route add $i dev $interface
|
||||
ip route add $i dev $interface
|
||||
fi
|
||||
/sbin/route add default gw $i dev $interface metric $((metric++))
|
||||
route add default gw $i dev $interface metric $((metric++))
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
# Sample udhcpc deconfig script
|
||||
|
||||
/sbin/ifconfig $interface 0.0.0.0
|
||||
ifconfig $interface 0.0.0.0
|
||||
@@ -6,12 +6,12 @@ RESOLV_CONF="/etc/udhcpc/resolv.conf"
|
||||
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
|
||||
[ -n "$subnet" ] && NETMASK="netmask $subnet"
|
||||
|
||||
/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
|
||||
ifconfig $interface $ip $BROADCAST $NETMASK
|
||||
|
||||
if [ -n "$router" ]
|
||||
then
|
||||
echo "deleting routers"
|
||||
while /sbin/route del default gw 0.0.0.0 dev $interface
|
||||
while route del default gw 0.0.0.0 dev $interface
|
||||
do :
|
||||
done
|
||||
|
||||
@@ -23,9 +23,9 @@ then
|
||||
# /32 instructs kernel to always use routing for all outgoing packets
|
||||
# (they can never be sent to local subnet - there is no local subnet for /32).
|
||||
# Used in datacenters, avoids the need for private ip-addresses between two hops.
|
||||
/sbin/ip route add $i dev $interface
|
||||
ip route add $i dev $interface
|
||||
fi
|
||||
/sbin/route add default gw $i dev $interface metric $((metric++))
|
||||
route add default gw $i dev $interface metric $((metric++))
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
+10
-11
@@ -889,10 +889,10 @@ ACTF(links)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int FAST_FUNC fileAction(const char *fileName,
|
||||
struct stat *statbuf,
|
||||
void *userData UNUSED_PARAM,
|
||||
int depth IF_NOT_FEATURE_FIND_MAXDEPTH(UNUSED_PARAM))
|
||||
static int FAST_FUNC fileAction(
|
||||
struct recursive_state *state IF_NOT_FEATURE_FIND_MAXDEPTH(UNUSED_PARAM),
|
||||
const char *fileName,
|
||||
struct stat *statbuf)
|
||||
{
|
||||
int r;
|
||||
int same_fs = 1;
|
||||
@@ -911,12 +911,12 @@ static int FAST_FUNC fileAction(const char *fileName,
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_FIND_MAXDEPTH
|
||||
if (depth < G.minmaxdepth[0]) {
|
||||
if (state->depth < G.minmaxdepth[0]) {
|
||||
if (same_fs)
|
||||
return TRUE; /* skip this, continue recursing */
|
||||
return SKIP; /* stop recursing */
|
||||
}
|
||||
if (depth > G.minmaxdepth[1])
|
||||
if (state->depth > G.minmaxdepth[1])
|
||||
return SKIP; /* stop recursing */
|
||||
#endif
|
||||
|
||||
@@ -927,7 +927,7 @@ static int FAST_FUNC fileAction(const char *fileName,
|
||||
|
||||
#if ENABLE_FEATURE_FIND_MAXDEPTH
|
||||
if (S_ISDIR(statbuf->st_mode)) {
|
||||
if (depth == G.minmaxdepth[1])
|
||||
if (state->depth == G.minmaxdepth[1])
|
||||
return SKIP;
|
||||
}
|
||||
#endif
|
||||
@@ -1441,7 +1441,7 @@ static action*** parse_params(char **argv)
|
||||
#else
|
||||
#define XATOU_SFX xatoul_sfx
|
||||
#endif
|
||||
static const struct suffix_mult find_suffixes[] = {
|
||||
static const struct suffix_mult find_suffixes[] ALIGN_SUFFIX = {
|
||||
{ "c", 1 },
|
||||
{ "w", 2 },
|
||||
{ "", 512 },
|
||||
@@ -1522,7 +1522,7 @@ int find_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
*past_HLP = NULL;
|
||||
/* "+": stop on first non-option */
|
||||
i = getopt32(argv, "+HLP");
|
||||
i = getopt32(argv, "+""HLP");
|
||||
if (i & (1<<0))
|
||||
G.recurse_flags |= ACTION_FOLLOWLINKS_L0 | ACTION_DANGLING_OK;
|
||||
if (i & (1<<1))
|
||||
@@ -1570,8 +1570,7 @@ int find_main(int argc UNUSED_PARAM, char **argv)
|
||||
G.recurse_flags,/* flags */
|
||||
fileAction, /* file action */
|
||||
fileAction, /* dir action */
|
||||
NULL, /* user data */
|
||||
0) /* depth */
|
||||
NULL) /* user data */
|
||||
) {
|
||||
G.exitstatus |= EXIT_FAILURE;
|
||||
}
|
||||
|
||||
+25
-26
@@ -167,13 +167,11 @@ enum {
|
||||
OPT_z = IF_EXTRA_COMPAT( (1 << OPTBIT_z)) + 0,
|
||||
};
|
||||
|
||||
#define PRINT_FILES_WITH_MATCHES (option_mask32 & OPT_l)
|
||||
#define PRINT_LINE_NUM (option_mask32 & OPT_n)
|
||||
#define BE_QUIET (option_mask32 & OPT_q)
|
||||
#define SUPPRESS_ERR_MSGS (option_mask32 & OPT_s)
|
||||
#define PRINT_MATCH_COUNTS (option_mask32 & OPT_c)
|
||||
#define FGREP_FLAG (option_mask32 & OPT_F)
|
||||
#define PRINT_FILES_WITHOUT_MATCHES (option_mask32 & OPT_L)
|
||||
#define NUL_DELIMITED (option_mask32 & OPT_z)
|
||||
|
||||
struct globals {
|
||||
@@ -476,13 +474,13 @@ static int grep_file(FILE *file)
|
||||
* even if errors were detected" */
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
/* if we're just printing filenames, we stop after the first match */
|
||||
if (PRINT_FILES_WITH_MATCHES) {
|
||||
/* -l "print filenames with matches": stop after the first match */
|
||||
if (option_mask32 & OPT_l) {
|
||||
puts(cur_file);
|
||||
/* fall through to "return 1" */
|
||||
return 1;
|
||||
}
|
||||
/* OPT_L aka PRINT_FILES_WITHOUT_MATCHES: return early */
|
||||
return 1; /* one match */
|
||||
/* -L "print filenames without matches": return early too */
|
||||
return 0; /* 0: we do not print fname, hence it's "not a match" */
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_GREP_CONTEXT
|
||||
@@ -602,15 +600,16 @@ static int grep_file(FILE *file)
|
||||
printf("%d\n", nmatches);
|
||||
}
|
||||
|
||||
/* grep -L: print just the filename */
|
||||
if (PRINT_FILES_WITHOUT_MATCHES) {
|
||||
/* grep -L: "print filenames without matches" */
|
||||
if (option_mask32 & OPT_L) {
|
||||
/* nmatches is zero, no need to check it:
|
||||
* we return 1 early if we detected a match
|
||||
* and PRINT_FILES_WITHOUT_MATCHES is set */
|
||||
* we return 0 early if -L and we detect a match
|
||||
*/
|
||||
puts(cur_file);
|
||||
return 1; /* 1: we printed fname, hence it's "a match" */
|
||||
}
|
||||
|
||||
return nmatches;
|
||||
return nmatches != 0; /* we return not a count, but a boolean */
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_CLEAN_UP
|
||||
@@ -657,10 +656,9 @@ static void load_pattern_list(llist_t **lst, char *pattern)
|
||||
llist_add_to(lst, new_grep_list_data(p, 0));
|
||||
}
|
||||
|
||||
static int FAST_FUNC file_action_grep(const char *filename,
|
||||
struct stat *statbuf,
|
||||
void* matched,
|
||||
int depth UNUSED_PARAM)
|
||||
static int FAST_FUNC file_action_grep(struct recursive_state *state UNUSED_PARAM,
|
||||
const char *filename,
|
||||
struct stat *statbuf)
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
@@ -687,7 +685,7 @@ static int FAST_FUNC file_action_grep(const char *filename,
|
||||
return 0;
|
||||
}
|
||||
cur_file = filename;
|
||||
*(int*)matched += grep_file(file);
|
||||
*(int*)state->userData |= grep_file(file);
|
||||
fclose(file);
|
||||
return 1;
|
||||
}
|
||||
@@ -695,15 +693,16 @@ static int FAST_FUNC file_action_grep(const char *filename,
|
||||
static int grep_dir(const char *dir)
|
||||
{
|
||||
int matched = 0;
|
||||
recursive_action(dir,
|
||||
/* recurse=yes */ ACTION_RECURSE |
|
||||
/* followLinks=always */ ((option_mask32 & OPT_R) ? ACTION_FOLLOWLINKS : 0) |
|
||||
/* followLinks=command line only */ ACTION_FOLLOWLINKS_L0 |
|
||||
/* depthFirst=yes */ ACTION_DEPTHFIRST,
|
||||
recursive_action(dir, 0
|
||||
| ACTION_RECURSE
|
||||
| ((option_mask32 & OPT_R) ? ACTION_FOLLOWLINKS : 0)
|
||||
| ACTION_FOLLOWLINKS_L0 /* grep -r ... SYMLINK follows it */
|
||||
| ACTION_DEPTHFIRST
|
||||
| 0,
|
||||
/* fileAction= */ file_action_grep,
|
||||
/* dirAction= */ NULL,
|
||||
/* userData= */ &matched,
|
||||
/* depth= */ 0);
|
||||
/* userData= */ &matched
|
||||
);
|
||||
return matched;
|
||||
}
|
||||
|
||||
@@ -844,7 +843,7 @@ int grep_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (stat(cur_file, &st) == 0 && S_ISDIR(st.st_mode)) {
|
||||
if (!(option_mask32 & OPT_h))
|
||||
print_filename = 1;
|
||||
matched += grep_dir(cur_file);
|
||||
matched |= grep_dir(cur_file);
|
||||
goto grep_done;
|
||||
}
|
||||
}
|
||||
@@ -857,7 +856,7 @@ int grep_main(int argc UNUSED_PARAM, char **argv)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
matched += grep_file(file);
|
||||
matched |= grep_file(file);
|
||||
fclose_if_not_stdin(file);
|
||||
grep_done: ;
|
||||
} while (*argv && *++argv);
|
||||
|
||||
+16
-5
@@ -80,9 +80,11 @@
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
|
||||
//#define dbg_msg(...) bb_error_msg(__VA_ARGS__)
|
||||
#define dbg_msg(...) ((void)0)
|
||||
|
||||
#if 0
|
||||
# define dbg_msg(...) bb_error_msg(__VA_ARGS__)
|
||||
#else
|
||||
# define dbg_msg(...) ((void)0)
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
# ifndef ENABLE_FEATURE_XARGS_SUPPORT_CONFIRMATION
|
||||
@@ -466,9 +468,18 @@ static char* FAST_FUNC process_stdin_with_replace(int n_max_chars, int n_max_arg
|
||||
|
||||
while (1) {
|
||||
int c = getchar();
|
||||
if (p == buf) {
|
||||
if (c == EOF)
|
||||
goto ret; /* last line is empty, return "" */
|
||||
if (c == G.eol_ch)
|
||||
continue; /* empty line, ignore */
|
||||
/* Skip leading whitespace of each line: try
|
||||
* echo -e ' \t\v1 2 3 ' | xargs -I% echo '[%]'
|
||||
*/
|
||||
if (ISSPACE(c))
|
||||
continue;
|
||||
}
|
||||
if (c == EOF || c == G.eol_ch) {
|
||||
if (p == buf)
|
||||
goto ret; /* empty line */
|
||||
c = '\0';
|
||||
}
|
||||
*p++ = c;
|
||||
|
||||
File renamed without changes.
+1
-14
@@ -2,20 +2,6 @@
|
||||
|
||||
PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
|
||||
|
||||
#define F_IGNORE 0x01 /* %_A */
|
||||
#define F_SETREP 0x02 /* rep count set, not default */
|
||||
#define F_ADDRESS 0x001 /* print offset */
|
||||
#define F_BPAD 0x002 /* blank pad */
|
||||
#define F_C 0x004 /* %_c */
|
||||
#define F_CHAR 0x008 /* %c */
|
||||
#define F_DBL 0x010 /* %[EefGf] */
|
||||
#define F_INT 0x020 /* %[di] */
|
||||
#define F_P 0x040 /* %_p */
|
||||
#define F_STR 0x080 /* %s */
|
||||
#define F_U 0x100 /* %_u */
|
||||
#define F_UINT 0x200 /* %[ouXx] */
|
||||
#define F_TEXT 0x400 /* no conversions */
|
||||
|
||||
enum dump_vflag_t { ALL, DUP, FIRST, WAIT }; /* -v values */
|
||||
|
||||
typedef struct PR {
|
||||
@@ -46,6 +32,7 @@ typedef struct dumper_t {
|
||||
off_t dump_skip; /* bytes to skip */
|
||||
int dump_length; /* max bytes to read */
|
||||
smallint dump_vflag; /*enum dump_vflag_t*/
|
||||
const char *eofstring;
|
||||
FS *fshead;
|
||||
} dumper_t;
|
||||
|
||||
|
||||
+86
-26
@@ -339,12 +339,13 @@ struct BUG_off_t_size_is_misdetected {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__GLIBC__)
|
||||
/* glibc uses __errno_location() to get a ptr to errno */
|
||||
/* We can just memorize it once - no multithreading in busybox :) */
|
||||
#if defined(errno)
|
||||
/* If errno is a define, assume it's "define errno (*__errno_location())"
|
||||
* and we will cache it's result in this variable */
|
||||
extern int *const bb_errno;
|
||||
#undef errno
|
||||
#define errno (*bb_errno)
|
||||
#define bb_cached_errno_ptr 1
|
||||
#endif
|
||||
|
||||
#if !(ULONG_MAX > 0xffffffff)
|
||||
@@ -386,6 +387,32 @@ void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) F
|
||||
char *xstrdup(const char *s) FAST_FUNC RETURNS_MALLOC;
|
||||
char *xstrndup(const char *s, int n) FAST_FUNC RETURNS_MALLOC;
|
||||
void *xmemdup(const void *s, int n) FAST_FUNC RETURNS_MALLOC;
|
||||
void *mmap_read(int fd, size_t size) FAST_FUNC;
|
||||
void *mmap_anon(size_t size) FAST_FUNC;
|
||||
void *xmmap_anon(size_t size) FAST_FUNC;
|
||||
|
||||
#if defined(__x86_64__) || defined(i386)
|
||||
# define BB_ARCH_FIXED_PAGESIZE 4096
|
||||
#elif defined(__arm__) /* only 32bit, 64bit ARM has variable page size */
|
||||
# define BB_ARCH_FIXED_PAGESIZE 4096
|
||||
#else /* if defined(ARCH) */
|
||||
/* add you favorite arch today! */
|
||||
//From Linux kernel inspection:
|
||||
//xtenza,s390[x],riscv,nios2,csky,sparc32: fixed 4k pages
|
||||
//sparc64,alpha,openrisc: fixed 8k pages
|
||||
#endif
|
||||
|
||||
#if defined BB_ARCH_FIXED_PAGESIZE
|
||||
# define IF_VARIABLE_ARCH_PAGESIZE(...) /*nothing*/
|
||||
# define bb_getpagesize() BB_ARCH_FIXED_PAGESIZE
|
||||
# define INIT_PAGESIZE(var) ((void)0)
|
||||
# define cached_pagesize(var) BB_ARCH_FIXED_PAGESIZE
|
||||
#else
|
||||
# define IF_VARIABLE_ARCH_PAGESIZE(...) __VA_ARGS__
|
||||
# define bb_getpagesize() getpagesize()
|
||||
# define INIT_PAGESIZE(var) ((var) = getpagesize())
|
||||
# define cached_pagesize(var) (var)
|
||||
#endif
|
||||
|
||||
|
||||
//TODO: supply a pointer to char[11] buffer (avoid statics)?
|
||||
@@ -436,15 +463,23 @@ enum {
|
||||
ACTION_FOLLOWLINKS = (1 << 1),
|
||||
ACTION_FOLLOWLINKS_L0 = (1 << 2),
|
||||
ACTION_DEPTHFIRST = (1 << 3),
|
||||
/*ACTION_REVERSE = (1 << 4), - unused */
|
||||
ACTION_QUIET = (1 << 5),
|
||||
ACTION_DANGLING_OK = (1 << 6),
|
||||
ACTION_QUIET = (1 << 4),
|
||||
ACTION_DANGLING_OK = (1 << 5),
|
||||
};
|
||||
typedef uint8_t recurse_flags_t;
|
||||
extern int recursive_action(const char *fileName, unsigned flags,
|
||||
int FAST_FUNC (*fileAction)(const char *fileName, struct stat* statbuf, void* userData, int depth),
|
||||
int FAST_FUNC (*dirAction)(const char *fileName, struct stat* statbuf, void* userData, int depth),
|
||||
void* userData, unsigned depth) FAST_FUNC;
|
||||
typedef struct recursive_state {
|
||||
unsigned flags;
|
||||
unsigned depth;
|
||||
void *userData;
|
||||
int FAST_FUNC (*fileAction)(struct recursive_state *state, const char *fileName, struct stat* statbuf);
|
||||
int FAST_FUNC (*dirAction)(struct recursive_state *state, const char *fileName, struct stat* statbuf);
|
||||
} recursive_state_t;
|
||||
int recursive_action(const char *fileName, unsigned flags,
|
||||
int FAST_FUNC (*fileAction)(struct recursive_state *state, const char *fileName, struct stat* statbuf),
|
||||
int FAST_FUNC (*dirAction)(struct recursive_state *state, const char *fileName, struct stat* statbuf),
|
||||
void *userData
|
||||
) FAST_FUNC;
|
||||
|
||||
extern int device_open(const char *device, int mode) FAST_FUNC;
|
||||
enum { GETPTY_BUFSIZE = 16 }; /* more than enough for "/dev/ttyXXX" */
|
||||
extern int xgetpty(char *line) FAST_FUNC;
|
||||
@@ -622,6 +657,8 @@ void parse_datestr(const char *date_str, struct tm *ptm) FAST_FUNC;
|
||||
time_t validate_tm_time(const char *date_str, struct tm *ptm) FAST_FUNC;
|
||||
char *strftime_HHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC;
|
||||
char *strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC;
|
||||
void xsettimeofday(const struct timeval *tv) FAST_FUNC;
|
||||
|
||||
|
||||
int xsocket(int domain, int type, int protocol) FAST_FUNC;
|
||||
void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) FAST_FUNC;
|
||||
@@ -817,7 +854,7 @@ ssize_t recv_from_to(int fd, void *buf, size_t len, int flags,
|
||||
struct sockaddr *to,
|
||||
socklen_t sa_size) FAST_FUNC;
|
||||
|
||||
uint16_t inet_cksum(uint16_t *addr, int len) FAST_FUNC;
|
||||
uint16_t inet_cksum(const void *addr, int len) FAST_FUNC;
|
||||
int parse_pasv_epsv(char *buf) FAST_FUNC;
|
||||
|
||||
/* 0 if argv[0] is NULL: */
|
||||
@@ -1017,8 +1054,9 @@ void generate_uuid(uint8_t *buf) FAST_FUNC;
|
||||
/* Last element is marked by mult == 0 */
|
||||
struct suffix_mult {
|
||||
char suffix[4];
|
||||
unsigned mult;
|
||||
uint32_t mult;
|
||||
};
|
||||
#define ALIGN_SUFFIX ALIGN4
|
||||
extern const struct suffix_mult bkm_suffixes[];
|
||||
#define km_suffixes (bkm_suffixes + 1)
|
||||
extern const struct suffix_mult cwbkMG_suffixes[];
|
||||
@@ -1130,7 +1168,6 @@ int BB_EXECVP(const char *file, char *const argv[]) FAST_FUNC;
|
||||
#define BB_EXECLP(prog,cmd,...) execlp(prog,cmd,__VA_ARGS__)
|
||||
#endif
|
||||
void BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC;
|
||||
void exec_prog_or_SHELL(char **argv) NORETURN FAST_FUNC;
|
||||
|
||||
/* xvfork() can't be a _function_, return after vfork in child mangles stack
|
||||
* in the parent. It must be a macro. */
|
||||
@@ -1515,7 +1552,8 @@ int del_loop(const char *device) FAST_FUNC;
|
||||
* malloc and return it in *devname.
|
||||
* return value is the opened fd to the loop device, or < on error
|
||||
*/
|
||||
int set_loop(char **devname, const char *file, unsigned long long offset, unsigned flags) FAST_FUNC;
|
||||
int set_loop(char **devname, const char *file, unsigned long long offset,
|
||||
unsigned long long sizelimit, unsigned flags) FAST_FUNC;
|
||||
/* These constants match linux/loop.h (without BB_ prefix): */
|
||||
#define BB_LO_FLAGS_READ_ONLY 1
|
||||
#define BB_LO_FLAGS_AUTOCLEAR 4
|
||||
@@ -1591,12 +1629,14 @@ char *bb_simplify_path(const char *path) FAST_FUNC;
|
||||
/* Returns ptr to NUL */
|
||||
char *bb_simplify_abs_path_inplace(char *path) FAST_FUNC;
|
||||
|
||||
#ifndef LOGIN_FAIL_DELAY
|
||||
#define LOGIN_FAIL_DELAY 3
|
||||
#endif
|
||||
extern void bb_do_delay(int seconds) FAST_FUNC;
|
||||
extern void change_identity(const struct passwd *pw) FAST_FUNC;
|
||||
extern void run_shell(const char *shell, int loginshell, const char **args) NORETURN FAST_FUNC;
|
||||
void pause_after_failed_login(void) FAST_FUNC;
|
||||
void bb_do_delay(unsigned seconds) FAST_FUNC;
|
||||
void msleep(unsigned ms) FAST_FUNC;
|
||||
void sleep1(void) FAST_FUNC;
|
||||
void change_identity(const struct passwd *pw) FAST_FUNC;
|
||||
void exec_shell(const char *shell, int loginshell, const char **args) NORETURN FAST_FUNC;
|
||||
void exec_login_shell(const char *shell) NORETURN FAST_FUNC;
|
||||
void exec_prog_or_SHELL(char **argv) NORETURN FAST_FUNC;
|
||||
|
||||
/* Returns $SHELL, getpwuid(getuid())->pw_shell, or DEFAULT_SHELL.
|
||||
* Note that getpwuid result might need xstrdup'ing
|
||||
@@ -1825,14 +1865,20 @@ typedef const char *get_exe_name_t(int i) FAST_FUNC;
|
||||
typedef struct line_input_t {
|
||||
int flags;
|
||||
int timeout;
|
||||
# if ENABLE_FEATURE_TAB_COMPLETION
|
||||
# if ENABLE_SHELL_ASH
|
||||
const char *path_lookup;
|
||||
# if ENABLE_FEATURE_TAB_COMPLETION \
|
||||
&& (ENABLE_ASH || ENABLE_SH_IS_ASH || ENABLE_BASH_IS_ASH \
|
||||
|| ENABLE_HUSH || ENABLE_SH_IS_HUSH || ENABLE_BASH_IS_HUSH \
|
||||
)
|
||||
# define EDITING_HAS_path_lookup 1
|
||||
# else
|
||||
# define EDITING_HAS_path_lookup 0
|
||||
# endif
|
||||
# if ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH
|
||||
/* function to fetch additional application-specific names to match */
|
||||
get_exe_name_t *get_exe_name;
|
||||
# define EDITING_HAS_get_exe_name 1
|
||||
# define EDITING_HAS_get_exe_name 1
|
||||
# else
|
||||
# define EDITING_HAS_get_exe_name 0
|
||||
# endif
|
||||
# endif
|
||||
# if MAX_HISTORY
|
||||
int cnt_history;
|
||||
@@ -1860,7 +1906,11 @@ enum {
|
||||
FOR_SHELL = DO_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
|
||||
};
|
||||
line_input_t *new_line_input_t(int flags) FAST_FUNC;
|
||||
#if ENABLE_FEATURE_EDITING_SAVEHISTORY
|
||||
void free_line_input_t(line_input_t *n) FAST_FUNC;
|
||||
#else
|
||||
# define free_line_input_t(n) free(n)
|
||||
#endif
|
||||
/*
|
||||
* maxsize must be >= 2.
|
||||
* Returns:
|
||||
@@ -2016,14 +2066,17 @@ char *percent_decode_in_place(char *str, int strict) FAST_FUNC;
|
||||
|
||||
|
||||
extern const char bb_uuenc_tbl_base64[] ALIGN1;
|
||||
extern const char bb_uuenc_tbl_base32[] ALIGN1;
|
||||
extern const char bb_uuenc_tbl_std[] ALIGN1;
|
||||
void bb_uuencode(char *store, const void *s, int length, const char *tbl) FAST_FUNC;
|
||||
enum {
|
||||
BASE64_FLAG_UU_STOP = 0x100,
|
||||
BASE64_32 = 0x200, /* base32 */
|
||||
/* Sign-extends to a value which never matches fgetc result: */
|
||||
BASE64_FLAG_NO_STOP_CHAR = 0x80,
|
||||
};
|
||||
const char *decode_base64(char **pp_dst, const char *src) FAST_FUNC;
|
||||
char *decode_base64(char *dst, const char **pp_src) FAST_FUNC;
|
||||
char *decode_base32(char *dst, const char **pp_src) FAST_FUNC;
|
||||
void read_base64(FILE *src_stream, FILE *dst_stream, int flags) FAST_FUNC;
|
||||
|
||||
typedef struct md5_ctx_t {
|
||||
@@ -2063,6 +2116,13 @@ unsigned sha3_end(sha3_ctx_t *ctx, void *resbuf) FAST_FUNC;
|
||||
typedef struct md5_ctx_t md5sha_ctx_t;
|
||||
#define md5sha_hash md5_hash
|
||||
#define sha_end sha1_end
|
||||
enum {
|
||||
MD5_OUTSIZE = 16,
|
||||
SHA1_OUTSIZE = 20,
|
||||
SHA256_OUTSIZE = 32,
|
||||
SHA512_OUTSIZE = 64,
|
||||
SHA3_OUTSIZE = 28,
|
||||
};
|
||||
|
||||
extern uint32_t *global_crc32_table;
|
||||
uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC;
|
||||
|
||||
@@ -342,6 +342,8 @@ typedef unsigned smalluint;
|
||||
# define ALIGN2
|
||||
# define ALIGN4
|
||||
#endif
|
||||
#define ALIGN8 __attribute__((aligned(8)))
|
||||
#define ALIGN_PTR __attribute__((aligned(sizeof(void*))))
|
||||
|
||||
/*
|
||||
* For 0.9.29 and svn, __ARCH_USE_MMU__ indicates no-mmu reliably.
|
||||
|
||||
@@ -11,6 +11,12 @@
|
||||
|
||||
PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
|
||||
|
||||
#if ENABLE_FEATURE_HWCLOCK_ADJTIME_FHS
|
||||
# define ADJTIME_PATH "/var/lib/hwclock/adjtime"
|
||||
#else
|
||||
# define ADJTIME_PATH "/etc/adjtime"
|
||||
#endif
|
||||
|
||||
int rtc_adjtime_is_utc(void) FAST_FUNC;
|
||||
int rtc_xopen(const char **default_rtc, int flags) FAST_FUNC;
|
||||
void rtc_read_tm(struct tm *ptm, int fd) FAST_FUNC;
|
||||
|
||||
@@ -25,6 +25,12 @@
|
||||
" (default "CONFIG_FEATURE_DEFAULT_PASSWD_ALGO")"
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_HWCLOCK_ADJTIME_FHS
|
||||
# define ADJTIME_PATH "/var/lib/hwclock/adjtime"
|
||||
#else
|
||||
# define ADJTIME_PATH "/etc/adjtime"
|
||||
#endif
|
||||
|
||||
INSERT
|
||||
|
||||
#define busybox_notes_usage \
|
||||
|
||||
+5
-5
@@ -65,7 +65,7 @@
|
||||
//kbuild:lib-$(CONFIG_REBOOT) += halt.o
|
||||
|
||||
//usage:#define halt_trivial_usage
|
||||
//usage: "[-d DELAY] [-n] [-f]" IF_FEATURE_WTMP(" [-w]")
|
||||
//usage: "[-d DELAY] [-nf"IF_FEATURE_WTMP("w")"]"
|
||||
//usage:#define halt_full_usage "\n\n"
|
||||
//usage: "Halt the system\n"
|
||||
//usage: "\n -d SEC Delay interval"
|
||||
@@ -76,7 +76,7 @@
|
||||
//usage: )
|
||||
//usage:
|
||||
//usage:#define poweroff_trivial_usage
|
||||
//usage: "[-d DELAY] [-n] [-f]"
|
||||
//usage: "[-d DELAY] [-nf]"
|
||||
//usage:#define poweroff_full_usage "\n\n"
|
||||
//usage: "Halt and shut off power\n"
|
||||
//usage: "\n -d SEC Delay interval"
|
||||
@@ -84,7 +84,7 @@
|
||||
//usage: "\n -f Force (don't go through init)"
|
||||
//usage:
|
||||
//usage:#define reboot_trivial_usage
|
||||
//usage: "[-d DELAY] [-n] [-f]"
|
||||
//usage: "[-d DELAY] [-nf]"
|
||||
//usage:#define reboot_full_usage "\n\n"
|
||||
//usage: "Reboot the system\n"
|
||||
//usage: "\n -d SEC Delay interval"
|
||||
@@ -144,14 +144,14 @@ static int init_was_not_there(void)
|
||||
*/
|
||||
#if 0
|
||||
while (kill(1, 0) != 0 && --cnt >= 0)
|
||||
sleep(1);
|
||||
sleep1();
|
||||
#endif
|
||||
/* ... so let's wait for some evidence a usual startup event,
|
||||
* mounting of /proc, happened. By that time init should be ready
|
||||
* for signals.
|
||||
*/
|
||||
while (access("/proc/meminfo", F_OK) != 0 && --cnt >= 0)
|
||||
sleep(1);
|
||||
sleep1();
|
||||
|
||||
/* Does it look like init wasn't there? */
|
||||
return (cnt != initial - 1);
|
||||
|
||||
+6
-6
@@ -736,7 +736,7 @@ static void pause_and_low_level_reboot(unsigned magic)
|
||||
pid_t pid;
|
||||
|
||||
/* Allow time for last message to reach serial console, etc */
|
||||
sleep(1);
|
||||
sleep1();
|
||||
|
||||
/* We have to fork here, since the kernel calls do_exit(EXIT_SUCCESS)
|
||||
* in linux/kernel/sys.c, which can cause the machine to panic when
|
||||
@@ -751,7 +751,7 @@ static void pause_and_low_level_reboot(unsigned magic)
|
||||
* we would eternally sleep here - not what we want.
|
||||
*/
|
||||
waitpid(pid, NULL, 0);
|
||||
sleep(1); /* paranoia */
|
||||
sleep1(); /* paranoia */
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -768,12 +768,12 @@ static void run_shutdown_and_kill_processes(void)
|
||||
kill(-1, SIGTERM);
|
||||
message(L_CONSOLE, "Sent SIG%s to all processes", "TERM");
|
||||
sync();
|
||||
sleep(1);
|
||||
sleep1();
|
||||
|
||||
kill(-1, SIGKILL);
|
||||
message(L_CONSOLE, "Sent SIG%s to all processes", "KILL");
|
||||
sync();
|
||||
/*sleep(1); - callers take care about making a pause */
|
||||
/*sleep1(); - callers take care about making a pause */
|
||||
}
|
||||
|
||||
/* Signal handling by init:
|
||||
@@ -904,7 +904,7 @@ static void stop_handler(int sig UNUSED_PARAM)
|
||||
wpid = wait_any_nohang(NULL);
|
||||
mark_terminated(wpid);
|
||||
if (wpid <= 0) /* no processes exited? sleep a bit */
|
||||
sleep(1);
|
||||
sleep1();
|
||||
}
|
||||
|
||||
signal(SIGCONT, SIG_DFL);
|
||||
@@ -1209,7 +1209,7 @@ int init_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
|
||||
/* Don't consume all CPU time - sleep a bit */
|
||||
sleep(1);
|
||||
sleep1();
|
||||
} /* while (1) */
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
//config:config RUN_INIT
|
||||
//config: bool "run-init (7.7 kb)"
|
||||
//config: default y
|
||||
//config: select PLATFORM_LINUX
|
||||
//config: help
|
||||
//config: The run-init utility is used from initramfs to select a new
|
||||
//config: root device. Under initramfs, you have to use this instead of
|
||||
|
||||
@@ -334,7 +334,6 @@ config FEATURE_VERBOSE_CP_MESSAGE
|
||||
config FEATURE_USE_SENDFILE
|
||||
bool "Use sendfile system call"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
When enabled, busybox will use the kernel sendfile() function
|
||||
instead of read/write loops to copy data between file descriptors
|
||||
@@ -376,7 +375,6 @@ config FEATURE_SKIP_ROOTFS
|
||||
config MONOTONIC_SYSCALL
|
||||
bool "Use clock_gettime(CLOCK_MONOTONIC) syscall"
|
||||
default y
|
||||
select PLATFORM_LINUX
|
||||
help
|
||||
Use clock_gettime(CLOCK_MONOTONIC) syscall for measuring
|
||||
time intervals (time, ping, traceroute etc need this).
|
||||
|
||||
+2
-1
@@ -112,7 +112,8 @@ lib-y += xgethostbyname.o
|
||||
lib-y += xreadlink.o
|
||||
lib-y += xrealloc_vector.o
|
||||
|
||||
lib-$(CONFIG_PLATFORM_LINUX) += match_fstype.o
|
||||
lib-$(CONFIG_MOUNT) += match_fstype.o
|
||||
lib-$(CONFIG_UMOUNT) += match_fstype.o
|
||||
|
||||
lib-$(CONFIG_FEATURE_UTMP) += utmp.o
|
||||
|
||||
|
||||
+7
-2
@@ -25,6 +25,11 @@
|
||||
*
|
||||
* FEATURE_INSTALLER or FEATURE_SUID will still link printf routines in. :(
|
||||
*/
|
||||
|
||||
/* Define this accessor before we #define "errno" our way */
|
||||
#include <errno.h>
|
||||
static inline int *get_perrno(void) { return &errno; }
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \
|
||||
@@ -303,8 +308,8 @@ void lbb_prepare(const char *applet
|
||||
void lbb_prepare(const char *applet
|
||||
IF_FEATURE_INDIVIDUAL(, char **argv))
|
||||
{
|
||||
#ifdef __GLIBC__
|
||||
(*(int **)not_const_pp(&bb_errno)) = __errno_location();
|
||||
#ifdef bb_cached_errno_ptr
|
||||
(*(int **)not_const_pp(&bb_errno)) = get_perrno();
|
||||
barrier();
|
||||
#endif
|
||||
applet_name = applet;
|
||||
|
||||
+54
-7
@@ -8,13 +8,60 @@
|
||||
*/
|
||||
#include "libbb.h"
|
||||
|
||||
void FAST_FUNC bb_do_delay(int seconds)
|
||||
{
|
||||
time_t start, now;
|
||||
/* void FAST_FUNC bb_do_delay(unsigned seconds) { ... } - no users yet */
|
||||
|
||||
start = time(NULL);
|
||||
#ifndef LOGIN_FAIL_DELAY
|
||||
#define LOGIN_FAIL_DELAY 3
|
||||
#endif
|
||||
void FAST_FUNC pause_after_failed_login(void)
|
||||
{
|
||||
#if 0 /* over-engineered madness */
|
||||
time_t end, diff;
|
||||
|
||||
end = time(NULL) + LOGIN_FAIL_DELAY;
|
||||
diff = LOGIN_FAIL_DELAY;
|
||||
do {
|
||||
sleep(seconds);
|
||||
now = time(NULL);
|
||||
} while ((now - start) < seconds);
|
||||
sleep(diff);
|
||||
diff = end - time(NULL);
|
||||
} while (diff > 0);
|
||||
#else
|
||||
sleep(LOGIN_FAIL_DELAY);
|
||||
#endif
|
||||
}
|
||||
|
||||
void FAST_FUNC sleep1(void)
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
void FAST_FUNC msleep(unsigned ms)
|
||||
{
|
||||
#if 0
|
||||
/* 1. usleep(n) is not guaranteed by standards to accept n >= 1000000
|
||||
* 2. multiplication in usleep(ms * 1000) can overflow if ms > 4294967
|
||||
* (sleep of ~71.5 minutes)
|
||||
* Let's play safe and loop:
|
||||
*/
|
||||
while (ms > 500) {
|
||||
usleep(500000);
|
||||
ms -= 500;
|
||||
}
|
||||
usleep(ms * 1000);
|
||||
#else
|
||||
//usleep is often implemented as a call to nanosleep.
|
||||
//Simply do the same to implement msleep.
|
||||
//it's marginally larger, but wakes your CPU less often:
|
||||
//function old new delta
|
||||
//msleep 45 52 +7
|
||||
struct timespec ts;
|
||||
ts.tv_sec = ms / 1000;
|
||||
ts.tv_nsec = (ms % 1000) * 1000000;
|
||||
/*
|
||||
* If a signal has non-default handler, nanosleep returns early.
|
||||
* Our version of msleep doesn't return early
|
||||
* if interrupted by such signals:
|
||||
*/
|
||||
while (nanosleep(&ts, &ts) != 0)
|
||||
continue;
|
||||
#endif
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@ extern int capget(cap_user_header_t header, const cap_user_data_t data);
|
||||
// This way, libcap needs not be installed in build environment.
|
||||
#include "libbb.h"
|
||||
|
||||
static const char *const capabilities[] = {
|
||||
static const char *const capabilities[] ALIGN_PTR = {
|
||||
"chown",
|
||||
"dac_override",
|
||||
"dac_read_search",
|
||||
|
||||
@@ -117,8 +117,11 @@ int FAST_FUNC index_in_substrings(const char *strings, const char *key)
|
||||
const char* FAST_FUNC nth_string(const char *strings, int n)
|
||||
{
|
||||
while (n) {
|
||||
n--;
|
||||
strings += strlen(strings) + 1;
|
||||
if (*strings++ == '\0') {
|
||||
if (*strings == '\0') /* reached end of strings */
|
||||
break;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
|
||||
+1
-4
@@ -75,10 +75,7 @@ static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size)
|
||||
goto use_small_buf;
|
||||
/* We want page-aligned buffer, just in case kernel is clever
|
||||
* and can do page-aligned io more efficiently */
|
||||
buffer = mmap(NULL, CONFIG_FEATURE_COPYBUF_KB * 1024,
|
||||
PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANON,
|
||||
/* ignored: */ -1, 0);
|
||||
buffer = mmap_anon(CONFIG_FEATURE_COPYBUF_KB * 1024);
|
||||
buffer_size = CONFIG_FEATURE_COPYBUF_KB * 1024;
|
||||
if (buffer == MAP_FAILED) {
|
||||
use_small_buf:
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
*/
|
||||
#include "libbb.h"
|
||||
|
||||
#ifndef LOGIN_NAME_MAX
|
||||
#define LOGIN_NAME_MAX 256
|
||||
#endif
|
||||
|
||||
/* To avoid problems, the username should consist only of
|
||||
* letters, digits, underscores, periods, at signs and dashes,
|
||||
* and not start with a dash (as defined by IEEE Std 1003.1-2001).
|
||||
|
||||
+47
-23
@@ -13,13 +13,19 @@
|
||||
#include "libbb.h"
|
||||
#include "dump.h"
|
||||
|
||||
static const char dot_flags_width_chars[] ALIGN1 = ".#-+ 0123456789";
|
||||
|
||||
static const char size_conv_str[] ALIGN1 =
|
||||
"\x1\x4\x4\x4\x4\x4\x4\x8\x8\x8\x8\010cdiouxXeEfgG";
|
||||
|
||||
static const char int_convs[] ALIGN1 = "diouxX";
|
||||
|
||||
#define F_IGNORE 0x01 /* %_A */
|
||||
#define F_SETREP 0x02 /* rep count set, not default */
|
||||
#define F_ADDRESS 0x001 /* print offset */
|
||||
#define F_BPAD 0x002 /* blank pad */
|
||||
#define F_C 0x004 /* %_c */
|
||||
#define F_CHAR 0x008 /* %c */
|
||||
#define F_DBL 0x010 /* %[EefGf] */
|
||||
#define F_INT 0x020 /* %[di] */
|
||||
#define F_P 0x040 /* %_p */
|
||||
#define F_STR 0x080 /* %s */
|
||||
#define F_U 0x100 /* %_u */
|
||||
#define F_UINT 0x200 /* %[ouXx] */
|
||||
#define F_TEXT 0x400 /* no conversions */
|
||||
|
||||
typedef struct priv_dumper_t {
|
||||
dumper_t pub;
|
||||
@@ -39,6 +45,13 @@ typedef struct priv_dumper_t {
|
||||
unsigned char *get__savp;
|
||||
} priv_dumper_t;
|
||||
|
||||
static const char dot_flags_width_chars[] ALIGN1 = ".#-+ 0123456789";
|
||||
|
||||
static const char size_conv_str[] ALIGN1 =
|
||||
"\x1\x4\x4\x4\x4\x4\x4\x8\x8\x8\x8\010cdiouxXeEfgG";
|
||||
|
||||
static const char int_convs[] ALIGN1 = "diouxX";
|
||||
|
||||
dumper_t* FAST_FUNC alloc_dumper(void)
|
||||
{
|
||||
priv_dumper_t *dumper = xzalloc(sizeof(*dumper));
|
||||
@@ -48,7 +61,6 @@ dumper_t* FAST_FUNC alloc_dumper(void)
|
||||
return &dumper->pub;
|
||||
}
|
||||
|
||||
|
||||
static NOINLINE int bb_dump_size(FS *fs)
|
||||
{
|
||||
FU *fu;
|
||||
@@ -284,7 +296,9 @@ static NOINLINE void rewrite(priv_dumper_t *dumper, FS *fs)
|
||||
* repeat it as necessary.
|
||||
*
|
||||
* if rep count is greater than 1, no trailing whitespace
|
||||
* gets output from the last iteration of the format unit.
|
||||
* gets output from the last iteration of the format unit:
|
||||
* 2/1 "%02x " prints "XX XX", not "XX XX "
|
||||
* 2/1 "%02x\n" prints "XX\nXX", not "XX\nXX\n"
|
||||
*/
|
||||
for (fu = fs->nextfu; fu; fu = fu->nextfu) {
|
||||
if (!fu->nextfu
|
||||
@@ -394,7 +408,6 @@ static unsigned char *get(priv_dumper_t *dumper)
|
||||
if (dumper->pub.dump_vflag != DUP) {
|
||||
puts("*");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
memset(dumper->get__curp + nread, 0, need);
|
||||
dumper->eaddress = dumper->address + nread;
|
||||
@@ -453,7 +466,7 @@ static void bpad(PR *pr)
|
||||
for (p2 = ++p1; *p1 && strchr(" -0+#", *p1); ++p1)
|
||||
if (pr->nospace)
|
||||
pr->nospace--;
|
||||
while ((*p2++ = *p1++) != 0)
|
||||
while ((*p2++ = *p1++) != '\0')
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -520,36 +533,43 @@ static void conv_u(PR *pr, unsigned char *p)
|
||||
|
||||
static void display(priv_dumper_t* dumper)
|
||||
{
|
||||
FS *fs;
|
||||
FU *fu;
|
||||
PR *pr;
|
||||
int cnt;
|
||||
unsigned char *bp, *savebp;
|
||||
off_t saveaddress;
|
||||
unsigned char *bp;
|
||||
unsigned char savech = '\0';
|
||||
|
||||
while ((bp = get(dumper)) != NULL) {
|
||||
FS *fs;
|
||||
unsigned char *savebp;
|
||||
off_t saveaddress;
|
||||
|
||||
fs = dumper->pub.fshead;
|
||||
savebp = bp;
|
||||
saveaddress = dumper->address;
|
||||
for (; fs; fs = fs->nextfs, bp = savebp, dumper->address = saveaddress) {
|
||||
FU *fu;
|
||||
for (fu = fs->nextfu; fu; fu = fu->nextfu) {
|
||||
int cnt;
|
||||
if (fu->flags & F_IGNORE) {
|
||||
break;
|
||||
}
|
||||
for (cnt = fu->reps; cnt; --cnt) {
|
||||
PR *pr;
|
||||
for (pr = fu->nextpr; pr; dumper->address += pr->bcnt,
|
||||
bp += pr->bcnt, pr = pr->nextpr) {
|
||||
if (dumper->eaddress && dumper->address >= dumper->eaddress
|
||||
&& !(pr->flags & (F_TEXT | F_BPAD))
|
||||
if (dumper->eaddress
|
||||
&& dumper->address >= dumper->eaddress
|
||||
) {
|
||||
bpad(pr);
|
||||
if (dumper->pub.eofstring) {
|
||||
/* xxd support: requested to not pad incomplete blocks */
|
||||
fputs(dumper->pub.eofstring, stdout);
|
||||
return;
|
||||
}
|
||||
if (!(pr->flags & (F_TEXT | F_BPAD)))
|
||||
bpad(pr);
|
||||
}
|
||||
if (cnt == 1 && pr->nospace) {
|
||||
savech = *pr->nospace;
|
||||
*pr->nospace = '\0';
|
||||
}
|
||||
/* PRINT; */
|
||||
switch (pr->flags) {
|
||||
case F_ADDRESS:
|
||||
printf(pr->fmt, (unsigned) dumper->address);
|
||||
@@ -638,7 +658,9 @@ static void display(priv_dumper_t* dumper)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dumper->endfu) {
|
||||
PR *pr;
|
||||
/*
|
||||
* if eaddress not set, error or file size was multiple
|
||||
* of blocksize, and no partial block ever found.
|
||||
@@ -695,8 +717,7 @@ void FAST_FUNC bb_dump_add(dumper_t* pub_dumper, const char *fmt)
|
||||
{
|
||||
const char *p;
|
||||
FS *tfs;
|
||||
FU *tfu, **nextfupp;
|
||||
const char *savep;
|
||||
FU **nextfupp;
|
||||
|
||||
/* start new linked list of format units */
|
||||
tfs = xzalloc(sizeof(FS)); /*DBU:[dave@cray.com] start out NULL */
|
||||
@@ -713,6 +734,9 @@ void FAST_FUNC bb_dump_add(dumper_t* pub_dumper, const char *fmt)
|
||||
/* take the format string and break it up into format units */
|
||||
p = fmt;
|
||||
for (;;) {
|
||||
FU *tfu;
|
||||
const char *savep;
|
||||
|
||||
p = skip_whitespace(p);
|
||||
if (*p == '\0') {
|
||||
break;
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
static const struct suffix_mult duration_suffixes[] = {
|
||||
static const struct suffix_mult duration_suffixes[] ALIGN_SUFFIX = {
|
||||
{ "s", 1 },
|
||||
{ "m", 60 },
|
||||
{ "h", 60*60 },
|
||||
|
||||
@@ -91,12 +91,3 @@ void FAST_FUNC BB_EXECVP_or_die(char **argv)
|
||||
xfunc_error_retval = (errno == ENOENT) ? 127 : 126;
|
||||
bb_perror_msg_and_die("can't execute '%s'", argv[0]);
|
||||
}
|
||||
|
||||
/* Typical idiom for applets which exec *optional* PROG [ARGS] */
|
||||
void FAST_FUNC exec_prog_or_SHELL(char **argv)
|
||||
{
|
||||
if (argv[0]) {
|
||||
BB_EXECVP_or_die(argv);
|
||||
}
|
||||
run_shell(getenv("SHELL"), /*login:*/ 1, NULL);
|
||||
}
|
||||
+39
-58
@@ -38,35 +38,6 @@ static ALWAYS_INLINE uint64_t rotl64(uint64_t x, unsigned n)
|
||||
return (x << n) | (x >> (64 - n));
|
||||
}
|
||||
|
||||
/* Feed data through a temporary buffer.
|
||||
* The internal buffer remembers previous data until it has 64
|
||||
* bytes worth to pass on.
|
||||
*/
|
||||
static void FAST_FUNC common64_hash(md5_ctx_t *ctx, const void *buffer, size_t len)
|
||||
{
|
||||
unsigned bufpos = ctx->total64 & 63;
|
||||
|
||||
ctx->total64 += len;
|
||||
|
||||
while (1) {
|
||||
unsigned remaining = 64 - bufpos;
|
||||
if (remaining > len)
|
||||
remaining = len;
|
||||
/* Copy data into aligned buffer */
|
||||
memcpy(ctx->wbuffer + bufpos, buffer, remaining);
|
||||
len -= remaining;
|
||||
buffer = (const char *)buffer + remaining;
|
||||
bufpos += remaining;
|
||||
/* Clever way to do "if (bufpos != N) break; ... ; bufpos = 0;" */
|
||||
bufpos -= 64;
|
||||
if (bufpos != 0)
|
||||
break;
|
||||
/* Buffer is filled up, process it */
|
||||
ctx->process_block(ctx);
|
||||
/*bufpos = 0; - already is */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process the remaining bytes in the buffer */
|
||||
static void FAST_FUNC common64_end(md5_ctx_t *ctx, int swap_needed)
|
||||
{
|
||||
@@ -140,7 +111,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx)
|
||||
They are defined in RFC 1321 as
|
||||
T[i] = (int)(2^32 * fabs(sin(i))), i=1..64
|
||||
*/
|
||||
static const uint32_t C_array[] = {
|
||||
static const uint32_t C_array[] ALIGN4 = {
|
||||
/* round 1 */
|
||||
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
|
||||
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
|
||||
@@ -449,7 +420,29 @@ void FAST_FUNC md5_begin(md5_ctx_t *ctx)
|
||||
/* Used also for sha1 and sha256 */
|
||||
void FAST_FUNC md5_hash(md5_ctx_t *ctx, const void *buffer, size_t len)
|
||||
{
|
||||
common64_hash(ctx, buffer, len);
|
||||
unsigned bufpos = ctx->total64 & 63;
|
||||
|
||||
ctx->total64 += len;
|
||||
|
||||
while (1) {
|
||||
unsigned remaining = 64 - bufpos;
|
||||
if (remaining > len)
|
||||
remaining = len;
|
||||
/* Copy data into aligned buffer */
|
||||
memcpy(ctx->wbuffer + bufpos, buffer, remaining);
|
||||
len -= remaining;
|
||||
buffer = (const char *)buffer + remaining;
|
||||
bufpos += remaining;
|
||||
|
||||
/* Clever way to do "if (bufpos != N) break; ... ; bufpos = 0;" */
|
||||
bufpos -= 64;
|
||||
if (bufpos != 0)
|
||||
break;
|
||||
|
||||
/* Buffer is filled up, process it */
|
||||
ctx->process_block(ctx);
|
||||
/*bufpos = 0; - already is */
|
||||
}
|
||||
}
|
||||
|
||||
/* Process the remaining bytes in the buffer and put result from CTX
|
||||
@@ -499,7 +492,7 @@ unsigned FAST_FUNC md5_end(md5_ctx_t *ctx, void *resbuf)
|
||||
|
||||
static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx)
|
||||
{
|
||||
static const uint32_t rconsts[] = {
|
||||
static const uint32_t rconsts[] ALIGN4 = {
|
||||
0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6
|
||||
};
|
||||
int i, j;
|
||||
@@ -574,7 +567,7 @@ typedef uint64_t sha_K_int;
|
||||
typedef uint32_t sha_K_int;
|
||||
# define K(v) (uint32_t)(v >> 32)
|
||||
#endif
|
||||
static const sha_K_int sha_K[] = {
|
||||
static const sha_K_int sha_K[] ALIGN8 = {
|
||||
K(0x428a2f98d728ae22ULL), K(0x7137449123ef65cdULL),
|
||||
K(0xb5c0fbcfec4d3b2fULL), K(0xe9b5dba58189dbbcULL),
|
||||
K(0x3956c25bf348b538ULL), K(0x59f111f1b605d019ULL),
|
||||
@@ -767,7 +760,7 @@ void FAST_FUNC sha1_begin(sha1_ctx_t *ctx)
|
||||
ctx->process_block = sha1_process_block64;
|
||||
}
|
||||
|
||||
static const uint32_t init256[] = {
|
||||
static const uint32_t init256[] ALIGN4 = {
|
||||
0,
|
||||
0,
|
||||
0x6a09e667,
|
||||
@@ -780,7 +773,7 @@ static const uint32_t init256[] = {
|
||||
0x5be0cd19,
|
||||
};
|
||||
#if NEED_SHA512
|
||||
static const uint32_t init512_lo[] = {
|
||||
static const uint32_t init512_lo[] ALIGN4 = {
|
||||
0,
|
||||
0,
|
||||
0xf3bcc908,
|
||||
@@ -816,7 +809,7 @@ void FAST_FUNC sha512_begin(sha512_ctx_t *ctx)
|
||||
int i;
|
||||
/* Two extra iterations zero out ctx->total64[2] */
|
||||
uint64_t *tp = ctx->total64;
|
||||
for (i = 0; i < 2+8; i++)
|
||||
for (i = 0; i < 8 + 2; i++)
|
||||
tp[i] = ((uint64_t)(init256[i]) << 32) + init512_lo[i];
|
||||
/*ctx->total64[0] = ctx->total64[1] = 0; - already done */
|
||||
}
|
||||
@@ -832,22 +825,7 @@ void FAST_FUNC sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len)
|
||||
ctx->total64[0] += len;
|
||||
if (ctx->total64[0] < len)
|
||||
ctx->total64[1]++;
|
||||
# if 0
|
||||
remaining = 128 - bufpos;
|
||||
|
||||
/* Hash whole blocks */
|
||||
while (len >= remaining) {
|
||||
memcpy(ctx->wbuffer + bufpos, buffer, remaining);
|
||||
buffer = (const char *)buffer + remaining;
|
||||
len -= remaining;
|
||||
remaining = 128;
|
||||
bufpos = 0;
|
||||
sha512_process_block128(ctx);
|
||||
}
|
||||
|
||||
/* Save last, partial blosk */
|
||||
memcpy(ctx->wbuffer + bufpos, buffer, len);
|
||||
# else
|
||||
while (1) {
|
||||
remaining = 128 - bufpos;
|
||||
if (remaining > len)
|
||||
@@ -857,15 +835,16 @@ void FAST_FUNC sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len)
|
||||
len -= remaining;
|
||||
buffer = (const char *)buffer + remaining;
|
||||
bufpos += remaining;
|
||||
|
||||
/* Clever way to do "if (bufpos != N) break; ... ; bufpos = 0;" */
|
||||
bufpos -= 128;
|
||||
if (bufpos != 0)
|
||||
break;
|
||||
|
||||
/* Buffer is filled up, process it */
|
||||
sha512_process_block128(ctx);
|
||||
/*bufpos = 0; - already is */
|
||||
}
|
||||
# endif
|
||||
}
|
||||
#endif /* NEED_SHA512 */
|
||||
|
||||
@@ -1030,7 +1009,7 @@ static void sha3_process_block72(uint64_t *state)
|
||||
|
||||
#if OPTIMIZE_SHA3_FOR_32
|
||||
/*
|
||||
static const uint32_t IOTA_CONST_0[NROUNDS] = {
|
||||
static const uint32_t IOTA_CONST_0[NROUNDS] ALIGN4 = {
|
||||
0x00000001UL,
|
||||
0x00000000UL,
|
||||
0x00000000UL,
|
||||
@@ -1059,7 +1038,7 @@ static void sha3_process_block72(uint64_t *state)
|
||||
** bits are in lsb: 0101 0000 1111 0100 1111 0001
|
||||
*/
|
||||
uint32_t IOTA_CONST_0bits = (uint32_t)(0x0050f4f1);
|
||||
static const uint32_t IOTA_CONST_1[NROUNDS] = {
|
||||
static const uint32_t IOTA_CONST_1[NROUNDS] ALIGN4 = {
|
||||
0x00000000UL,
|
||||
0x00000089UL,
|
||||
0x8000008bUL,
|
||||
@@ -1195,7 +1174,7 @@ static void sha3_process_block72(uint64_t *state)
|
||||
combine_halves(state);
|
||||
#else
|
||||
/* Native 64-bit algorithm */
|
||||
static const uint16_t IOTA_CONST[NROUNDS] = {
|
||||
static const uint16_t IOTA_CONST[NROUNDS] ALIGN2 = {
|
||||
/* Elements should be 64-bit, but top half is always zero
|
||||
* or 0x80000000. We encode 63rd bits in a separate word below.
|
||||
* Same is true for 31th bits, which lets us use 16-bit table
|
||||
@@ -1231,15 +1210,15 @@ static void sha3_process_block72(uint64_t *state)
|
||||
/* bit for CONST[0] is in msb: 0001 0110 0011 1000 0001 1011 */
|
||||
const uint32_t IOTA_CONST_bit31 = (uint32_t)(0x16381b00);
|
||||
|
||||
static const uint8_t ROT_CONST[24] = {
|
||||
static const uint8_t ROT_CONST[24] ALIGN1 = {
|
||||
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14,
|
||||
27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44,
|
||||
};
|
||||
static const uint8_t PI_LANE[24] = {
|
||||
static const uint8_t PI_LANE[24] ALIGN1 = {
|
||||
10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4,
|
||||
15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1,
|
||||
};
|
||||
/*static const uint8_t MOD5[10] = { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, };*/
|
||||
/*static const uint8_t MOD5[10] ALIGN1 = { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, };*/
|
||||
|
||||
unsigned x;
|
||||
unsigned round;
|
||||
@@ -1398,10 +1377,12 @@ void FAST_FUNC sha3_hash(sha3_ctx_t *ctx, const void *buffer, size_t len)
|
||||
bufpos++;
|
||||
remaining--;
|
||||
}
|
||||
|
||||
/* Clever way to do "if (bufpos != N) break; ... ; bufpos = 0;" */
|
||||
bufpos -= ctx->input_block_bytes;
|
||||
if (bufpos != 0)
|
||||
break;
|
||||
|
||||
/* Buffer is filled up, process it */
|
||||
sha3_process_block72(ctx->state);
|
||||
/*bufpos = 0; - already is */
|
||||
|
||||
+3
-1
@@ -6,8 +6,10 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
uint16_t FAST_FUNC inet_cksum(uint16_t *addr, int nleft)
|
||||
uint16_t FAST_FUNC inet_cksum(const void *ptr, int nleft)
|
||||
{
|
||||
const uint16_t *addr = ptr;
|
||||
|
||||
/*
|
||||
* Our algorithm is simple, using a 32 bit accumulator,
|
||||
* we add sequential 16 bit words to it, and at the end, fold
|
||||
|
||||
+11
-9
@@ -19,15 +19,17 @@ int FAST_FUNC get_linux_version_code(void)
|
||||
{
|
||||
struct utsname name;
|
||||
char *t;
|
||||
int i, r;
|
||||
int r;
|
||||
|
||||
uname(&name); /* never fails */
|
||||
t = name.release;
|
||||
r = 0;
|
||||
for (i = 0; i < 3; i++) {
|
||||
t = strtok(t, ".");
|
||||
r = r * 256 + (t ? atoi(t) : 0);
|
||||
t = NULL;
|
||||
}
|
||||
return r;
|
||||
t = name.release - 1;
|
||||
r = 1;
|
||||
do {
|
||||
r <<= 8;
|
||||
if (t) {
|
||||
r += atoi(++t);
|
||||
t = strchr(t, '.');
|
||||
}
|
||||
} while (r < 0x1000000);
|
||||
return r - 0x1000000;
|
||||
}
|
||||
Loaded 100 of 352 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user