[-]
[+]
|
Changed |
busybox.changes
|
|
[-]
[+]
|
Changed |
busybox.spec
^
|
|
[-]
[+]
|
Deleted |
busybox-1.20.2-install.patch
^
|
@@ -1,13 +0,0 @@
---- busybox-1.19.0/applets/install.sh.orig 2011-08-11 02:23:58.000000000 +0200
-+++ busybox-1.19.0/applets/install.sh 2011-08-19 22:29:20.824991244 +0200
-@@ -9,7 +9,7 @@
- exit 1
- fi
-
--h=`sort busybox.links | uniq`
-+h=`sort /usr/share/busybox/busybox.links | uniq`
-
- linkopts=""
- scriptwrapper="n"
-
-
|
[-]
[+]
|
Deleted |
busybox-1.20.2-kernel_ver.patch
^
|
@@ -1,25 +0,0 @@
---- busybox-1.20.2/libbb/kernel_version.c
-+++ busybox-1.20.2-kernel_ver/libbb/kernel_version.c
-@@ -20,18 +20,15 @@
- int FAST_FUNC get_linux_version_code(void)
- {
- struct utsname name;
-- char *s;
-+ char *s, *t;
- int i, r;
-
-- if (uname(&name) == -1) {
-- bb_perror_msg("can't get system information");
-- return 0;
-- }
--
-+ uname(&name); /* never fails */
- s = name.release;
- r = 0;
- for (i = 0; i < 3; i++) {
-- r = r * 256 + atoi(strtok(s, "."));
-+ t = strtok(s, ".");
-+ r = r * 256 + (t ? atoi(t) : 0);
- s = NULL;
- }
- return r;
|
[-]
[+]
|
Deleted |
busybox-1.20.2-pkg-config-selinux.patch
^
|
@@ -1,67 +0,0 @@
-From b1cec5003b73080a8aa7ea277621bf1c71c3e8d6 Mon Sep 17 00:00:00 2001
-From: Mike Frysinger <vapier@gentoo.org>
-Date: Sat, 20 Oct 2012 15:01:26 -0400
-Subject: [PATCH] build system: use pkg-config to look up selinux libs
-
-Newer versions of libselinux has started linking against more libs.
-Rather than continuing hardcoding things, switch to using pkg-config
-to query for its dependencies.
-
-Signed-off-by: Mike Frysinger <vapier@gentoo.org>
----
- Makefile | 1 +
- Makefile.flags | 12 +++++++++++-
- 2 files changed, 12 insertions(+), 1 deletion(-)
-
-diff --git a/Makefile b/Makefile
-index fccde4a..3a0a5e1 100644
---- a/Makefile
-+++ b/Makefile
-@@ -297,6 +297,7 @@ NM = $(CROSS_COMPILE)nm
- STRIP = $(CROSS_COMPILE)strip
- OBJCOPY = $(CROSS_COMPILE)objcopy
- OBJDUMP = $(CROSS_COMPILE)objdump
-+PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
- AWK = awk
- GENKSYMS = scripts/genksyms/genksyms
- DEPMOD = /sbin/depmod
-diff --git a/Makefile.flags b/Makefile.flags
-index c43c8dc..15dcc1f 100644
---- a/Makefile.flags
-+++ b/Makefile.flags
-@@ -74,6 +74,12 @@ ARCH_FPIC ?= -fpic
- ARCH_FPIE ?= -fpie
- ARCH_PIE ?= -pie
-
-+# Usage: $(eval $(call pkg_check_modules,VARIABLE-PREFIX,MODULES))
-+define pkg_check_modules
-+$(1)_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags $(2))
-+$(1)_LIBS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs $(2))
-+endef
-+
- ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
- # on i386: 14% smaller libbusybox.so
- # (code itself is 9% bigger, we save on relocs/PLT/GOT)
-@@ -85,6 +91,7 @@ endif
-
- ifeq ($(CONFIG_STATIC),y)
- CFLAGS_busybox += -static
-+PKG_CONFIG_FLAGS += --static
- endif
-
- ifeq ($(CONFIG_PIE),y)
-@@ -127,7 +134,10 @@ LDLIBS += pam pam_misc pthread
- endif
-
- ifeq ($(CONFIG_SELINUX),y)
--LDLIBS += selinux sepol
-+SELINUX_PC_MODULES = libselinux libsepol
-+$(eval $(call pkg_check_modules,SELINUX,$(SELINUX_PC_MODULES)))
-+CPPFLAGS += $(SELINUX_CFLAGS)
-+LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=%))
- endif
-
- ifeq ($(CONFIG_EFENCE),y)
---
-1.7.12
-
|
[-]
[+]
|
Deleted |
busybox-1.20.2-sys-resource.patch
^
|
@@ -1,123 +0,0 @@
-From 5a5dfcad6ba96d12d68bd7b39279215a8fee70d3 Mon Sep 17 00:00:00 2001
-From: Tias Guns <tias@ulyssis.org>
-Date: Sun, 10 Jun 2012 14:19:01 +0200
-Subject: [PATCH] inetd: fix build failure in Android
-
-Signed-off-by: Tias Guns <tias@ulyssis.org>
-Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-(cherry picked from commit 64f763b42a43cbf36e401690ff6767c25575e520)
----
- networking/inetd.c | 1 +
- 1 file changed, 1 insertion(+)
---
-1.7.12
-
-From 246ea72843d5b7e9d4cd902dc5e9d71359196303 Mon Sep 17 00:00:00 2001
-From: Mike Frysinger <vapier@gentoo.org>
-Date: Thu, 5 Jul 2012 23:19:09 -0400
-Subject: [PATCH] include sys/resource.h where needed
-
-We use functions from sys/resource.h in misc applets, but don't include
-the header. This breaks building with newer glibc versions, so add the
-include where needed.
-
-Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-(cherry picked from commit c5fe9f7b723f949457263ef8e22ab807d5b549ce)
----
- loginutils/passwd.c | 1 +
- miscutils/time.c | 1 +
- networking/inetd.c | 1 +
- networking/ntpd.c | 1 +
- networking/ntpd_simple.c | 1 +
- runit/chpst.c | 1 +
- shell/shell_common.c | 1 +
- 7 files changed, 7 insertions(+)
-
-diff --git a/loginutils/passwd.c b/loginutils/passwd.c
-index b83db00..a7006f0 100644
---- a/loginutils/passwd.c
-+++ b/loginutils/passwd.c
-@@ -15,6 +15,7 @@
-
- #include "libbb.h"
- #include <syslog.h>
-+#include <sys/resource.h> /* setrlimit */
-
- static void nuke_str(char *str)
- {
-diff --git a/miscutils/time.c b/miscutils/time.c
-index 945f15f..ffed386 100644
---- a/miscutils/time.c
-+++ b/miscutils/time.c
-@@ -16,6 +16,7 @@
- //usage: "\n -v Verbose"
-
- #include "libbb.h"
-+#include <sys/resource.h> /* getrusage */
-
- /* Information on the resources used by a child process. */
- typedef struct {
-diff --git a/networking/inetd.c b/networking/inetd.c
-index 1308d74..00baf69 100644
---- a/networking/inetd.c
-+++ b/networking/inetd.c
-@@ -165,6 +165,8 @@
- //usage: "\n (default: 0 - disabled)"
-
- #include <syslog.h>
-+#include <sys/resource.h> /* setrlimit */
-+#include <sys/socket.h> /* un.h may need this */
- #include <sys/un.h>
-
- #include "libbb.h"
-diff --git a/networking/ntpd.c b/networking/ntpd.c
-index 603801e..b885215 100644
---- a/networking/ntpd.c
-+++ b/networking/ntpd.c
-@@ -46,6 +46,7 @@
- #include "libbb.h"
- #include <math.h>
- #include <netinet/ip.h> /* For IPTOS_LOWDELAY definition */
-+#include <sys/resource.h> /* setpriority */
- #include <sys/timex.h>
- #ifndef IPTOS_LOWDELAY
- # define IPTOS_LOWDELAY 0x10
-diff --git a/networking/ntpd_simple.c b/networking/ntpd_simple.c
-index 4ad44e4..1b7c66b 100644
---- a/networking/ntpd_simple.c
-+++ b/networking/ntpd_simple.c
-@@ -7,6 +7,7 @@
- */
- #include "libbb.h"
- #include <netinet/ip.h> /* For IPTOS_LOWDELAY definition */
-+#include <sys/resource.h> /* setpriority */
- #ifndef IPTOS_LOWDELAY
- # define IPTOS_LOWDELAY 0x10
- #endif
-diff --git a/runit/chpst.c b/runit/chpst.c
-index ac296ba..ed72c8b 100644
---- a/runit/chpst.c
-+++ b/runit/chpst.c
-@@ -91,6 +91,7 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- //usage: "\n a SIGXCPU after N seconds"
-
- #include "libbb.h"
-+#include <sys/resource.h> /* getrlimit */
-
- /*
- Five applets here: chpst, envdir, envuidgid, setuidgid, softlimit.
-diff --git a/shell/shell_common.c b/shell/shell_common.c
-index 51c92d6..780e27e 100644
---- a/shell/shell_common.c
-+++ b/shell/shell_common.c
-@@ -18,6 +18,7 @@
- */
- #include "libbb.h"
- #include "shell_common.h"
-+#include <sys/resource.h> /* getrlimit */
-
- const char defifsvar[] ALIGN1 = "IFS= \t\n";
-
---
-1.7.12
-
|
[-]
[+]
|
Deleted |
busybox-1.20.2-udhcp-services.patch
^
|
@@ -1,24 +0,0 @@
---- networking/udhcp/common.c.orig 2010-08-23 02:44:35.000000000 +0200
-+++ networking/udhcp/common.c 2010-09-29 12:15:08.514367497 +0200
-@@ -49,6 +49,10 @@
- { OPTION_STRING , 0x43 }, /* DHCP_BOOT_FILE */
- //TODO: not a string, but a set of LASCII strings:
- // { OPTION_STRING , 0x4D }, /* DHCP_USER_CLASS */
-+ { OPTION_IP | OPTION_LIST , 0x45 }, /* DHCP_SMTP_SERVER */
-+ { OPTION_IP | OPTION_LIST , 0x46 }, /* DHCP_POP3_SERVER */
-+ { OPTION_IP | OPTION_LIST , 0x4a }, /* DHCP_IRC_SERVER */
-+ { OPTION_IP | OPTION_LIST , 0x48 }, /* DHCP_WWW_SERVER */
- #if ENABLE_FEATURE_UDHCP_RFC3397
- { OPTION_DNS_STRING | OPTION_LIST , 0x77 }, /* DHCP_DOMAIN_SEARCH */
- { OPTION_SIP_SERVERS , 0x78 }, /* DHCP_SIP_SERVERS */
-@@ -105,6 +109,10 @@
- "tftp" "\0" /* DHCP_TFTP_SERVER_NAME */
- "bootfile" "\0" /* DHCP_BOOT_FILE */
- // "userclass" "\0" /* DHCP_USER_CLASS */
-+ "smtpsrv" "\0" /* DHCP_SMTP_SERVER */
-+ "pop3srv" "\0" /* DHCP_POP3_SERVER */
-+ "ircsrv" "\0" /* DHCP_IRC_SERVER */
-+ "wwwsrv" "\0" /* DHCP_WWW_SERVER */
- #if ENABLE_FEATURE_UDHCP_RFC3397
- "search" "\0" /* DHCP_DOMAIN_SEARCH */
- // doesn't work in udhcpd.conf since OPTION_SIP_SERVERS
|
[-]
[+]
|
Added |
busybox-1.21.0-install.patch
^
|
@@ -0,0 +1,13 @@
+--- busybox-1.19.0/applets/install.sh.orig 2011-08-11 02:23:58.000000000 +0200
++++ busybox-1.19.0/applets/install.sh 2011-08-19 22:29:20.824991244 +0200
+@@ -9,7 +9,7 @@
+ exit 1
+ fi
+
+-h=`sort busybox.links | uniq`
++h=`sort /usr/share/busybox/busybox.links | uniq`
+
+ linkopts=""
+ scriptwrapper="n"
+
+
|
[-]
[+]
|
Added |
busybox-1.21.0-mdev.patch
^
|
@@ -0,0 +1,35 @@
+--- busybox-1.21.0/util-linux/mdev.c
++++ busybox-1.21.0-mdev/util-linux/mdev.c
+@@ -661,6 +661,8 @@ static void make_device(char *device_nam
+ if (mknod(node_name, rule->mode | type, makedev(major, minor)) && errno != EEXIST)
+ bb_perror_msg("can't create '%s'", node_name);
+ if (ENABLE_FEATURE_MDEV_CONF) {
++ if (G.verbose)
++ bb_error_msg("chmod: %o chown: %u:%u", rule->mode, rule->ugid.uid, rule->ugid.gid);
+ chmod(node_name, rule->mode);
+ chown(node_name, rule->ugid.uid, rule->ugid.gid);
+ }
+@@ -813,6 +815,7 @@ static void load_firmware(const char *fi
+ full_write(loading_fd, "-1", 2);
+
+ out:
++ xchdir("/dev");
+ if (ENABLE_FEATURE_CLEAN_UP) {
+ close(firmware_fd);
+ close(loading_fd);
+@@ -919,11 +922,13 @@ int mdev_main(int argc UNUSED_PARAM, cha
+ }
+
+ {
+- int logfd = open("/dev/mdev.log", O_WRONLY | O_APPEND);
++ int logfd = open("mdev.log", O_WRONLY | O_APPEND);
+ if (logfd >= 0) {
+ xmove_fd(logfd, STDERR_FILENO);
+ G.verbose = 1;
+- bb_error_msg("seq: %s action: %s", seq, action);
++ if (seq)
++ applet_name = xasprintf("%s[%s]", applet_name, seq);
++ bb_error_msg("action: %s", action);
+ }
+ }
+
|
[-]
[+]
|
Added |
busybox-1.21.0-udhcp-services.patch
^
|
@@ -0,0 +1,24 @@
+--- networking/udhcp/common.c.orig 2010-08-23 02:44:35.000000000 +0200
++++ networking/udhcp/common.c 2010-09-29 12:15:08.514367497 +0200
+@@ -49,6 +49,10 @@
+ { OPTION_STRING , 0x43 }, /* DHCP_BOOT_FILE */
+ //TODO: not a string, but a set of LASCII strings:
+ // { OPTION_STRING , 0x4D }, /* DHCP_USER_CLASS */
++ { OPTION_IP | OPTION_LIST , 0x45 }, /* DHCP_SMTP_SERVER */
++ { OPTION_IP | OPTION_LIST , 0x46 }, /* DHCP_POP3_SERVER */
++ { OPTION_IP | OPTION_LIST , 0x4a }, /* DHCP_IRC_SERVER */
++ { OPTION_IP | OPTION_LIST , 0x48 }, /* DHCP_WWW_SERVER */
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+ { OPTION_DNS_STRING | OPTION_LIST , 0x77 }, /* DHCP_DOMAIN_SEARCH */
+ { OPTION_SIP_SERVERS , 0x78 }, /* DHCP_SIP_SERVERS */
+@@ -105,6 +109,10 @@
+ "tftp" "\0" /* DHCP_TFTP_SERVER_NAME */
+ "bootfile" "\0" /* DHCP_BOOT_FILE */
+ // "userclass" "\0" /* DHCP_USER_CLASS */
++ "smtpsrv" "\0" /* DHCP_SMTP_SERVER */
++ "pop3srv" "\0" /* DHCP_POP3_SERVER */
++ "ircsrv" "\0" /* DHCP_IRC_SERVER */
++ "wwwsrv" "\0" /* DHCP_WWW_SERVER */
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+ "search" "\0" /* DHCP_DOMAIN_SEARCH */
+ // doesn't work in udhcpd.conf since OPTION_SIP_SERVERS
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/Config.in
^
|
@@ -310,7 +310,18 @@
default y
help
This option makes some applets (e.g. crond, syslogd, inetd) write
- a pidfile in /var/run. Some applications rely on them.
+ a pidfile at the configured PID_FILE_PATH. It has no effect
+ on applets which require pidfiles to run.
+
+config PID_FILE_PATH
+ string "Path to directory for pidfile"
+ default "/var/run"
+ depends on FEATURE_PIDFILE
+ help
+ This is the default path where pidfiles are created. Applets which
+ allow you to set the pidfile path on the command line will override
+ this value. The option has no effect on applets that require you to
+ specify a pidfile path.
config FEATURE_SUID
bool "Support for SUID/SGID handling"
@@ -321,7 +332,7 @@
root-level operations even when run by ordinary users
(for example, mounting of user mounts in fstab needs this).
- Busybox will automatically drop priviledges for applets
+ Busybox will automatically drop privileges for applets
that don't need root access.
If you are really paranoid and don't want to do this, build two
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/Makefile
^
|
@@ -1,6 +1,6 @@
VERSION = 1
-PATCHLEVEL = 20
-SUBLEVEL = 2
+PATCHLEVEL = 21
+SUBLEVEL = 0
EXTRAVERSION =
NAME = Unnamed
@@ -297,6 +297,7 @@
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
+PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
AWK = awk
GENKSYMS = scripts/genksyms/genksyms
DEPMOD = /sbin/depmod
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/Makefile.flags
^
|
@@ -25,6 +25,7 @@
CFLAGS += $(call cc-option,-Wunused -Wunused-parameter,)
CFLAGS += $(call cc-option,-Wunused-function -Wunused-value,)
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
+CFLAGS += $(call cc-option,-Wno-format-security,)
# warn about C99 declaration after statement
CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
# If you want to add more -Wsomething above, make sure that it is
@@ -52,6 +53,9 @@
CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
+# Defeat .eh_frame bloat (gcc 4.6.3 x86-32 defconfig: 20% smaller busybox binary):
+CFLAGS += $(call cc-option,-fno-unwind-tables,)
+CFLAGS += $(call cc-option,-fno-asynchronous-unwind-tables,)
# FIXME: These warnings are at least partially to be concerned about and should
# be fixed..
@@ -74,6 +78,12 @@
ARCH_FPIE ?= -fpie
ARCH_PIE ?= -pie
+# Usage: $(eval $(call pkg_check_modules,VARIABLE-PREFIX,MODULES))
+define pkg_check_modules
+$(1)_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags $(2))
+$(1)_LIBS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs $(2))
+endef
+
ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
# on i386: 14% smaller libbusybox.so
# (code itself is 9% bigger, we save on relocs/PLT/GOT)
@@ -85,6 +95,7 @@
ifeq ($(CONFIG_STATIC),y)
CFLAGS_busybox += -static
+PKG_CONFIG_FLAGS += --static
endif
ifeq ($(CONFIG_PIE),y)
@@ -127,7 +138,10 @@
endif
ifeq ($(CONFIG_SELINUX),y)
-LDLIBS += selinux sepol
+SELINUX_PC_MODULES = libselinux libsepol
+$(eval $(call pkg_check_modules,SELINUX,$(SELINUX_PC_MODULES)))
+CPPFLAGS += $(SELINUX_CFLAGS)
+LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=%))
endif
ifeq ($(CONFIG_EFENCE),y)
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/applets/individual.c
^
|
@@ -14,7 +14,7 @@
int main(int argc, char **argv)
{
applet_name = argv[0];
- return APPLET_main(argc,argv);
+ return APPLET_main(argc, argv);
}
void bb_show_usage(void)
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/archival/cpio.c
^
|
@@ -253,24 +253,24 @@
}
bytes += printf("070701"
- "%08X%08X%08X%08X%08X%08X%08X"
- "%08X%08X%08X%08X" /* GNU cpio uses uppercase hex */
+ "%08X%08X%08X%08X%08X%08X%08X"
+ "%08X%08X%08X%08X" /* GNU cpio uses uppercase hex */
/* strlen+1: */ "%08X"
/* chksum: */ "00000000" /* (only for "070702" files) */
/* name,NUL: */ "%s%c",
- (unsigned)(uint32_t) st.st_ino,
- (unsigned)(uint32_t) st.st_mode,
- (unsigned)(uint32_t) st.st_uid,
- (unsigned)(uint32_t) st.st_gid,
- (unsigned)(uint32_t) st.st_nlink,
- (unsigned)(uint32_t) st.st_mtime,
- (unsigned)(uint32_t) st.st_size,
- (unsigned)(uint32_t) major(st.st_dev),
- (unsigned)(uint32_t) minor(st.st_dev),
- (unsigned)(uint32_t) major(st.st_rdev),
- (unsigned)(uint32_t) minor(st.st_rdev),
- (unsigned)(strlen(name) + 1),
- name, '\0');
+ (unsigned)(uint32_t) st.st_ino,
+ (unsigned)(uint32_t) st.st_mode,
+ (unsigned)(uint32_t) st.st_uid,
+ (unsigned)(uint32_t) st.st_gid,
+ (unsigned)(uint32_t) st.st_nlink,
+ (unsigned)(uint32_t) st.st_mtime,
+ (unsigned)(uint32_t) st.st_size,
+ (unsigned)(uint32_t) major(st.st_dev),
+ (unsigned)(uint32_t) minor(st.st_dev),
+ (unsigned)(uint32_t) major(st.st_rdev),
+ (unsigned)(uint32_t) minor(st.st_rdev),
+ (unsigned)(strlen(name) + 1),
+ name, '\0');
bytes = cpio_pad4(bytes);
if (st.st_size) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/archival/dpkg.c
^
|
@@ -1026,8 +1026,8 @@
if (package_edge->type == EDGE_CONFLICTS) {
const unsigned package_num =
search_package_hashtable(package_edge->name,
- package_edge->version,
- package_edge->operator);
+ package_edge->version,
+ package_edge->operator);
int result = 0;
if (package_hashtable[package_num] != NULL) {
status_num = search_status_hashtable(name_hashtable[package_hashtable[package_num]->name]);
@@ -1114,7 +1114,7 @@
*/
if (root_of_alternatives && package_edge->type != root_of_alternatives->type - 1)
bb_error_msg_and_die("fatal error, package dependencies corrupt: %d != %d - 1",
- package_edge->type, root_of_alternatives->type);
+ package_edge->type, root_of_alternatives->type);
if (package_hashtable[package_num] != NULL)
result = !package_satisfies_dependency(package_num, package_edge->type);
@@ -1665,20 +1665,25 @@
archive_handle = init_archive_deb_ar(deb_file->filename);
init_archive_deb_data(archive_handle);
archive_handle->dpkg__sub_archive->accept = conffile_list;
+ /* Why ARCHIVE_REMEMBER_NAMES?
+ * We want names collected in ->passed list even if conffile_list
+ * is NULL (otherwise get_header_tar may optimize name saving out):
+ */
+ archive_handle->dpkg__sub_archive->ah_flags |= ARCHIVE_REMEMBER_NAMES | ARCHIVE_UNLINK_OLD;
archive_handle->dpkg__sub_archive->filter = filter_rename_config;
archive_handle->dpkg__sub_archive->action_data = data_extract_all_prefix;
archive_handle->dpkg__sub_archive->dpkg__buffer = (char*)"/"; /* huh? */
- archive_handle->dpkg__sub_archive->ah_flags |= ARCHIVE_UNLINK_OLD;
unpack_ar_archive(archive_handle);
/* Create the list file */
list_filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "list");
out_stream = xfopen_for_write(list_filename);
+ archive_handle->dpkg__sub_archive->passed = llist_rev(archive_handle->dpkg__sub_archive->passed);
while (archive_handle->dpkg__sub_archive->passed) {
+ char *filename = llist_pop(&archive_handle->dpkg__sub_archive->passed);
/* the leading . has been stripped by data_extract_all_prefix already */
- fputs(archive_handle->dpkg__sub_archive->passed->data, out_stream);
- fputc('\n', out_stream);
- archive_handle->dpkg__sub_archive->passed = archive_handle->dpkg__sub_archive->passed->link;
+ fprintf(out_stream, "%s\n", filename);
+ free(filename);
}
fclose(out_stream);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/archival/gzip.c
^
|
@@ -1179,7 +1179,7 @@
* must be all ones.
*/
Assert(code + G2.bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1,
- "inconsistent bit counts");
+ "inconsistent bit counts");
Tracev((stderr, "\ngen_codes: max_code %d ", max_code));
for (n = 0; n <= max_code; n++) {
@@ -1527,9 +1527,9 @@
}
out_length >>= 3;
Trace((stderr,
- "\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ",
- G2.last_lit, G2.last_dist, in_length, out_length,
- 100L - out_length * 100L / in_length));
+ "\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ",
+ G2.last_lit, G2.last_dist, in_length, out_length,
+ 100L - out_length * 100L / in_length));
if (G2.last_dist < G2.last_lit / 2 && out_length < in_length / 2)
return 1;
}
@@ -1621,9 +1621,9 @@
static_lenb = (G2.static_len + 3 + 7) >> 3;
Trace((stderr,
- "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ",
- opt_lenb, G2.opt_len, static_lenb, G2.static_len, stored_len,
- G2.last_lit, G2.last_dist));
+ "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ",
+ opt_lenb, G2.opt_len, static_lenb, G2.static_len, stored_len,
+ G2.last_lit, G2.last_dist));
if (static_lenb <= opt_lenb)
opt_lenb = static_lenb;
@@ -1661,7 +1661,7 @@
} else {
send_bits((DYN_TREES << 1) + eof, 3);
send_all_trees(G2.l_desc.max_code + 1, G2.d_desc.max_code + 1,
- max_blindex + 1);
+ max_blindex + 1);
compress_block((ct_data *) G2.dyn_ltree, (ct_data *) G2.dyn_dtree);
G2.compressed_len += 3 + G2.opt_len;
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/archival/libarchive/decompress_gunzip.c
^
|
@@ -293,8 +293,8 @@
* m: maximum lookup bits, returns actual
*/
static int huft_build(const unsigned *b, const unsigned n,
- const unsigned s, const unsigned short *d,
- const unsigned char *e, huft_t **t, unsigned *m)
+ const unsigned s, const unsigned short *d,
+ const unsigned char *e, huft_t **t, unsigned *m)
{
unsigned a; /* counter for codes of length k */
unsigned c[BMAX + 1]; /* bit length count table */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/archival/libarchive/decompress_uncompress.c
^
|
@@ -78,7 +78,6 @@
IF_DESKTOP(long long total_written = 0;)
IF_DESKTOP(long long) int retval = -1;
unsigned char *stackp;
- long code;
int finchar;
long oldcode;
long incode;
@@ -143,8 +142,10 @@
/* As above, initialize the first 256 entries in the table. */
/*clear_tab_prefixof(); - done by xzalloc */
- for (code = 255; code >= 0; --code) {
- tab_suffixof(code) = (unsigned char) code;
+ {
+ int i;
+ for (i = 255; i >= 0; --i)
+ tab_suffixof(i) = (unsigned char) i;
}
do {
@@ -175,6 +176,8 @@
(insize << 3) - (n_bits - 1));
while (inbits > posbits) {
+ long code;
+
if (free_ent > maxcode) {
posbits =
((posbits - 1) +
@@ -191,13 +194,12 @@
}
{
unsigned char *p = &inbuf[posbits >> 3];
-
- code = ((((long) (p[0])) | ((long) (p[1]) << 8) |
- ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
+ code = ((p[0]
+ | ((long) (p[1]) << 8)
+ | ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
}
posbits += n_bits;
-
if (oldcode == -1) {
if (code >= 256)
bb_error_msg_and_die("corrupted data"); /* %ld", code); */
@@ -226,15 +228,16 @@
/* Special case for KwKwK string. */
if (code >= free_ent) {
if (code > free_ent) {
+/*
unsigned char *p;
posbits -= n_bits;
p = &inbuf[posbits >> 3];
-
bb_error_msg
("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)",
- insize, posbits, p[-1], p[0], p[1], p[2], p[3],
- (posbits & 07));
+ insize, posbits, p[-1], p[0], p[1], p[2], p[3],
+ (posbits & 07));
+*/
bb_error_msg("corrupted data");
goto err;
}
@@ -244,7 +247,7 @@
}
/* Generate output characters in reverse order */
- while ((long) code >= (long) 256) {
+ while (code >= 256) {
if (stackp <= &htabof(0))
bb_error_msg_and_die("corrupted data");
*--stackp = tab_suffixof(code);
@@ -285,11 +288,10 @@
}
/* Generate the new entry. */
- code = free_ent;
- if (code < maxmaxcode) {
- tab_prefixof(code) = (unsigned short) oldcode;
- tab_suffixof(code) = (unsigned char) finchar;
- free_ent = code + 1;
+ if (free_ent < maxmaxcode) {
+ tab_prefixof(free_ent) = (unsigned short) oldcode;
+ tab_suffixof(free_ent) = (unsigned char) finchar;
+ free_ent++;
}
/* Remember previous code. */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/archival/libarchive/filter_accept_reject_list.c
^
|
@@ -24,11 +24,13 @@
if (reject_entry) {
return EXIT_FAILURE;
}
- accept_entry = find_list_entry2(archive_handle->accept, key);
/* Fail if an accept list was specified and the key wasnt in there */
- if ((accept_entry == NULL) && archive_handle->accept) {
- return EXIT_FAILURE;
+ if (archive_handle->accept) {
+ accept_entry = find_list_entry2(archive_handle->accept, key);
+ if (!accept_entry) {
+ return EXIT_FAILURE;
+ }
}
/* Accepted */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/archival/libarchive/lzo1x_9x.c
^
|
@@ -644,7 +644,7 @@
static int min_gain(unsigned ahead, unsigned lit1,
- unsigned lit2, int l1, int l2, int l3)
+ unsigned lit2, int l1, int l2, int l3)
{
int lazy_match_min_gain = 0;
@@ -673,7 +673,7 @@
#if defined(SWD_BEST_OFF)
static void better_match(const lzo_swd_p swd,
- unsigned *m_len, unsigned *m_off)
+ unsigned *m_len, unsigned *m_off)
{
if (*m_len <= M2_MIN_LEN)
return;
@@ -914,8 +914,8 @@
compression_level -= 7;
return lzo1x_999_compress_internal(in, in_len, out, out_len, wrkmem,
- c[compression_level].good_length,
- c[compression_level].max_lazy,
- c[compression_level].max_chain,
- c[compression_level].use_best_off);
+ c[compression_level].good_length,
+ c[compression_level].max_lazy,
+ c[compression_level].max_chain,
+ c[compression_level].use_best_off);
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/archival/libarchive/lzo1x_c.c
^
|
@@ -15,7 +15,7 @@
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/archival/libarchive/lzo1x_d.c
^
|
@@ -15,7 +15,7 @@
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/archival/lzop.c
^
|
@@ -14,7 +14,7 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
@@ -116,7 +116,7 @@
unsigned nl;
unsigned long o_m1_a = 0, o_m1_b = 0, o_m2 = 0, o_m3_a = 0, o_m3_b = 0;
-// LZO_UNUSED(wrkmem);
+// LZO_UNUSED(wrkmem);
*out_len = 0;
@@ -346,11 +346,11 @@
return LZO_E_EOF_NOT_FOUND;
eof_found:
-// LZO_UNUSED(o_m1_a); LZO_UNUSED(o_m1_b); LZO_UNUSED(o_m2);
-// LZO_UNUSED(o_m3_a); LZO_UNUSED(o_m3_b);
+// LZO_UNUSED(o_m1_a); LZO_UNUSED(o_m1_b); LZO_UNUSED(o_m2);
+// LZO_UNUSED(o_m3_a); LZO_UNUSED(o_m3_b);
*out_len = pd(op, out);
return (ip == ip_end ? LZO_E_OK :
- (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
+ (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
}
/**********************************************************************/
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/archival/tar.c
^
|
@@ -60,8 +60,8 @@
#if !ENABLE_FEATURE_SEAMLESS_GZ && !ENABLE_FEATURE_SEAMLESS_BZ2
/* Do not pass gzip flag to writeTarFile() */
-#define writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude, gzip) \
- writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude)
+#define writeTarFile(tar_fd, verboseFlag, recurseFlags, include, exclude, gzip) \
+ writeTarFile(tar_fd, verboseFlag, recurseFlags, include, exclude)
#endif
@@ -333,13 +333,13 @@
&& (filesize <= 0x3fffffffffffffffffffffffLL)
#endif
) {
- /* GNU tar uses "base-256 encoding" for very large numbers.
- * Encoding is binary, with highest bit always set as a marker
- * and sign in next-highest bit:
- * 80 00 .. 00 - zero
- * bf ff .. ff - largest positive number
- * ff ff .. ff - minus 1
- * c0 00 .. 00 - smallest negative number
+ /* GNU tar uses "base-256 encoding" for very large numbers.
+ * Encoding is binary, with highest bit always set as a marker
+ * and sign in next-highest bit:
+ * 80 00 .. 00 - zero
+ * bf ff .. ff - largest positive number
+ * ff ff .. ff - minus 1
+ * c0 00 .. 00 - smallest negative number
*/
char *p8 = header.size + sizeof(header.size);
do {
@@ -598,7 +598,7 @@
/* gcc 4.2.1 inlines it, making code bigger */
static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
- int dereferenceFlag, const llist_t *include,
+ int recurseFlags, const llist_t *include,
const llist_t *exclude, int gzip)
{
int errorFlag = FALSE;
@@ -621,8 +621,7 @@
/* Read the directory/files and iterate over them one at a time */
while (include) {
- if (!recursive_action(include->data, ACTION_RECURSE |
- (dereferenceFlag ? ACTION_FOLLOWLINKS : 0),
+ if (!recursive_action(include->data, recurseFlags,
writeFileToTarball, writeFileToTarball, &tbInfo, 0)
) {
errorFlag = TRUE;
@@ -662,7 +661,7 @@
}
#else
int writeTarFile(int tar_fd, int verboseFlag,
- int dereferenceFlag, const llist_t *include,
+ int recurseFlags, const llist_t *include,
const llist_t *exclude, int gzip);
#endif /* FEATURE_TAR_CREATE */
@@ -694,6 +693,7 @@
//usage: "-[" IF_FEATURE_TAR_CREATE("c") "xt"
//usage: IF_FEATURE_SEAMLESS_Z("Z")
//usage: IF_FEATURE_SEAMLESS_GZ("z")
+//usage: IF_FEATURE_SEAMLESS_XZ("J")
//usage: IF_FEATURE_SEAMLESS_BZ2("j")
//usage: IF_FEATURE_SEAMLESS_LZMA("a")
//usage: IF_FEATURE_TAR_CREATE("h")
@@ -720,6 +720,9 @@
//usage: IF_FEATURE_SEAMLESS_GZ(
//usage: "\n z (De)compress using gzip"
//usage: )
+//usage: IF_FEATURE_SEAMLESS_XZ(
+//usage: "\n J (De)compress using xz"
+//usage: )
//usage: IF_FEATURE_SEAMLESS_BZ2(
//usage: "\n j (De)compress using bzip2"
//usage: )
@@ -749,6 +752,7 @@
// o no-same-owner
// p same-permissions
// k keep-old
+// no-recursion
// numeric-owner
// no-same-permissions
// overwrite
@@ -765,9 +769,11 @@
IF_FEATURE_TAR_FROM( OPTBIT_INCLUDE_FROM,)
IF_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,)
IF_FEATURE_SEAMLESS_GZ( OPTBIT_GZIP ,)
- IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) // 16th bit
+ IF_FEATURE_SEAMLESS_XZ( OPTBIT_XZ ,) // 16th bit
+ IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,)
IF_FEATURE_TAR_NOPRESERVE_TIME(OPTBIT_NOPRESERVE_TIME,)
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
+ OPTBIT_NORECURSION,
IF_FEATURE_TAR_TO_COMMAND(OPTBIT_2COMMAND ,)
OPTBIT_NUMERIC_OWNER,
OPTBIT_NOPRESERVE_PERM,
@@ -789,14 +795,16 @@
OPT_INCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_INCLUDE_FROM)) + 0, // T
OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X
OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z
+ OPT_XZ = IF_FEATURE_SEAMLESS_XZ( (1 << OPTBIT_XZ )) + 0, // J
OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z
OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m
+ OPT_NORECURSION = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NORECURSION )) + 0, // no-recursion
OPT_2COMMAND = IF_FEATURE_TAR_TO_COMMAND( (1 << OPTBIT_2COMMAND )) + 0, // to-command
OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner
OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions
OPT_OVERWRITE = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_OVERWRITE )) + 0, // overwrite
- OPT_ANY_COMPRESS = (OPT_BZIP2 | OPT_LZMA | OPT_GZIP | OPT_COMPRESS),
+ OPT_ANY_COMPRESS = (OPT_BZIP2 | OPT_LZMA | OPT_GZIP | OPT_XZ | OPT_COMPRESS),
};
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
static const char tar_longopts[] ALIGN1 =
@@ -829,12 +837,16 @@
# if ENABLE_FEATURE_SEAMLESS_GZ
"gzip\0" No_argument "z"
# endif
+# if ENABLE_FEATURE_SEAMLESS_XZ
+ "xz\0" No_argument "J"
+# endif
# if ENABLE_FEATURE_SEAMLESS_Z
"compress\0" No_argument "Z"
# endif
# if ENABLE_FEATURE_TAR_NOPRESERVE_TIME
"touch\0" No_argument "m"
# endif
+ "no-recursion\0" No_argument "\xfa"
# if ENABLE_FEATURE_TAR_TO_COMMAND
"to-command\0" Required_argument "\xfb"
# endif
@@ -921,6 +933,7 @@
IF_FEATURE_SEAMLESS_LZMA("a" )
IF_FEATURE_TAR_FROM( "T:X:")
IF_FEATURE_SEAMLESS_GZ( "z" )
+ IF_FEATURE_SEAMLESS_XZ( "J" )
IF_FEATURE_SEAMLESS_Z( "Z" )
IF_FEATURE_TAR_NOPRESERVE_TIME("m")
, &base_dir // -C dir
@@ -1050,7 +1063,9 @@
zipMode = 2;
#endif
/* NB: writeTarFile() closes tar_handle->src_fd */
- return writeTarFile(tar_handle->src_fd, verboseFlag, opt & OPT_DEREFERENCE,
+ return writeTarFile(tar_handle->src_fd, verboseFlag,
+ (opt & OPT_DEREFERENCE ? ACTION_FOLLOWLINKS : 0)
+ | (opt & OPT_NORECURSION ? 0 : ACTION_RECURSE),
tar_handle->accept,
tar_handle->reject, zipMode);
}
@@ -1071,6 +1086,9 @@
if (opt & OPT_LZMA)
USE_FOR_MMU(xformer = unpack_lzma_stream;)
USE_FOR_NOMMU(xformer_prog = "unlzma";)
+ if (opt & OPT_XZ)
+ USE_FOR_MMU(xformer = unpack_xz_stream;)
+ USE_FOR_NOMMU(xformer_prog = "unxz";)
open_transformer_with_sig(tar_handle->src_fd, xformer, xformer_prog);
/* Can't lseek over pipes */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/archival/unzip.c
^
|
@@ -20,16 +20,16 @@
*/
//usage:#define unzip_trivial_usage
-//usage: "[-opts[modifiers]] FILE[.zip] [LIST] [-x XLIST] [-d DIR]"
+//usage: "[-lnopq] FILE[.zip] [FILE]... [-x FILE...] [-d DIR]"
//usage:#define unzip_full_usage "\n\n"
-//usage: "Extract files from ZIP archives\n"
-//usage: "\n -l List archive contents (with -q for short form)"
-//usage: "\n -n Never overwrite files (default)"
+//usage: "Extract FILEs from ZIP archive\n"
+//usage: "\n -l List contents (with -q for short form)"
+//usage: "\n -n Never overwrite files (default: ask)"
//usage: "\n -o Overwrite"
-//usage: "\n -p Send output to stdout"
+//usage: "\n -p Print to stdout"
//usage: "\n -q Quiet"
-//usage: "\n -x XLST Exclude these files"
-//usage: "\n -d DIR Extract files into DIR"
+//usage: "\n -x FILE Exclude FILEs"
+//usage: "\n -d DIR Extract into DIR"
#include "libbb.h"
#include "bb_archive.h"
@@ -277,6 +277,7 @@
IF_NOT_DESKTOP(const) smallint verbose = 0;
smallint listing = 0;
smallint overwrite = O_PROMPT;
+ smallint x_opt_seen;
#if ENABLE_DESKTOP
uint32_t cdf_offset;
#endif
@@ -290,7 +291,6 @@
llist_t *zreject = NULL;
char *base_dir = NULL;
int i, opt;
- int opt_range = 0;
char key_buf[80];
struct stat stat_buf;
@@ -335,81 +335,81 @@
* 204372 1 file
*/
+ x_opt_seen = 0;
/* '-' makes getopt return 1 for non-options */
while ((opt = getopt(argc, argv, "-d:lnopqxv")) != -1) {
- switch (opt_range) {
- case 0: /* Options */
- switch (opt) {
- case 'l': /* List */
- listing = 1;
- break;
+ switch (opt) {
+ case 'd': /* Extract to base directory */
+ base_dir = optarg;
+ break;
- case 'n': /* Never overwrite existing files */
- overwrite = O_NEVER;
- break;
+ case 'l': /* List */
+ listing = 1;
+ break;
- case 'o': /* Always overwrite existing files */
- overwrite = O_ALWAYS;
- break;
+ case 'n': /* Never overwrite existing files */
+ overwrite = O_NEVER;
+ break;
- case 'p': /* Extract files to stdout and fall through to set verbosity */
- dst_fd = STDOUT_FILENO;
+ case 'o': /* Always overwrite existing files */
+ overwrite = O_ALWAYS;
+ break;
- case 'q': /* Be quiet */
- quiet++;
- break;
+ case 'p': /* Extract files to stdout and fall through to set verbosity */
+ dst_fd = STDOUT_FILENO;
- case 'v': /* Verbose list */
- IF_DESKTOP(verbose++;)
- listing = 1;
- break;
+ case 'q': /* Be quiet */
+ quiet++;
+ break;
- case 1: /* The zip file */
- /* +5: space for ".zip" and NUL */
- src_fn = xmalloc(strlen(optarg) + 5);
- strcpy(src_fn, optarg);
- opt_range++;
- break;
+ case 'v': /* Verbose list */
+ IF_DESKTOP(verbose++;)
+ listing = 1;
+ break;
- default:
- bb_show_usage();
- }
+ case 'x':
+ x_opt_seen = 1;
break;
- case 1: /* Include files */
- if (opt == 1) {
+ case 1:
+ if (!src_fn) {
+ /* The zip file */
+ /* +5: space for ".zip" and NUL */
+ src_fn = xmalloc(strlen(optarg) + 5);
+ strcpy(src_fn, optarg);
+ } else if (!x_opt_seen) {
+ /* Include files */
llist_add_to(&zaccept, optarg);
- break;
- }
- if (opt == 'd') {
- base_dir = optarg;
- opt_range += 2;
- break;
- }
- if (opt == 'x') {
- opt_range++;
- break;
- }
- bb_show_usage();
-
- case 2 : /* Exclude files */
- if (opt == 1) {
+ } else {
+ /* Exclude files */
llist_add_to(&zreject, optarg);
- break;
}
- if (opt == 'd') { /* Extract to base directory */
- base_dir = optarg;
- opt_range++;
- break;
- }
- /* fall through */
+ break;
default:
bb_show_usage();
}
}
- if (src_fn == NULL) {
+#ifndef __GLIBC__
+ /*
+ * This code is needed for non-GNU getopt
+ * which doesn't understand "-" in option string.
+ * The -x option won't work properly in this case:
+ * "unzip a.zip q -x w e" will be interpreted as
+ * "unzip a.zip q w e -x" = "unzip a.zip q w e"
+ */
+ argv += optind;
+ if (argv[0]) {
+ /* +5: space for ".zip" and NUL */
+ src_fn = xmalloc(strlen(argv[0]) + 5);
+ strcpy(src_fn, argv[0]);
+ while (*++argv)
+ llist_add_to(&zaccept, *argv);
+ }
+#endif
+
+ if (!src_fn) {
bb_show_usage();
}
@@ -420,17 +420,20 @@
if (overwrite == O_PROMPT)
overwrite = O_NEVER;
} else {
- static const char extn[][5] = {"", ".zip", ".ZIP"};
- int orig_src_fn_len = strlen(src_fn);
- int src_fd = -1;
+ static const char extn[][5] = { ".zip", ".ZIP" };
+ char *ext = src_fn + strlen(src_fn);
+ int src_fd;
- for (i = 0; (i < 3) && (src_fd == -1); i++) {
- strcpy(src_fn + orig_src_fn_len, extn[i]);
+ i = 0;
+ for (;;) {
src_fd = open(src_fn, O_RDONLY);
- }
- if (src_fd == -1) {
- src_fn[orig_src_fn_len] = '\0';
- bb_error_msg_and_die("can't open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
+ if (src_fd >= 0)
+ break;
+ if (++i > 2) {
+ *ext = '\0';
+ bb_error_msg_and_die("can't open %s[.zip]", src_fn);
+ }
+ strcpy(ext, extn[i - 1]);
}
xmove_fd(src_fd, zip_fd);
}
@@ -596,7 +599,7 @@
printf(" creating: %s\n", dst_fn);
}
unzip_create_leading_dirs(dst_fn);
- if (bb_make_directory(dst_fn, dir_mode, 0)) {
+ if (bb_make_directory(dst_fn, dir_mode, FILEUTILS_IGNORE_CHMOD_ERR)) {
xfunc_die();
}
} else {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/configs/TEST_nommu_defconfig
^
|
@@ -341,7 +341,6 @@
CONFIG_FEATURE_VI_SETOPTS=y
CONFIG_FEATURE_VI_SET=y
CONFIG_FEATURE_VI_WIN_RESIZE=y
-CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
CONFIG_FEATURE_ALLOW_EXEC=y
#
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/configs/TEST_noprintf_defconfig
^
|
@@ -346,7 +346,6 @@
# CONFIG_FEATURE_VI_SET is not set
# CONFIG_FEATURE_VI_WIN_RESIZE is not set
# CONFIG_FEATURE_VI_ASK_TERMINAL is not set
-# CONFIG_FEATURE_VI_OPTIMIZE_CURSOR is not set
# CONFIG_FEATURE_ALLOW_EXEC is not set
#
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/configs/TEST_rh9_defconfig
^
|
@@ -358,7 +358,6 @@
CONFIG_FEATURE_VI_SETOPTS=y
CONFIG_FEATURE_VI_SET=y
CONFIG_FEATURE_VI_WIN_RESIZE=y
-CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
CONFIG_FEATURE_ALLOW_EXEC=y
#
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/configs/android2_defconfig
^
|
@@ -363,7 +363,6 @@
# CONFIG_FEATURE_VI_SET is not set
# CONFIG_FEATURE_VI_WIN_RESIZE is not set
# CONFIG_FEATURE_VI_ASK_TERMINAL is not set
-# CONFIG_FEATURE_VI_OPTIMIZE_CURSOR is not set
# CONFIG_AWK is not set
# CONFIG_FEATURE_AWK_LIBM is not set
CONFIG_CMP=y
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/configs/android_defconfig
^
|
@@ -386,7 +386,6 @@
CONFIG_FEATURE_VI_SET=y
CONFIG_FEATURE_VI_WIN_RESIZE=y
CONFIG_FEATURE_VI_ASK_TERMINAL=y
-CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
CONFIG_AWK=y
CONFIG_FEATURE_AWK_LIBM=y
CONFIG_CMP=y
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/configs/android_ndk_defconfig
^
|
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
-# Busybox version: 1.20.0.git
-# Fri Mar 2 16:53:26 2012
+# Busybox version: 1.21.0.git
+# Mon May 28 21:51:18 2012
#
CONFIG_HAVE_DOT_CONFIG=y
@@ -20,11 +20,11 @@
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
-# CONFIG_SHOW_USAGE is not set
-# CONFIG_FEATURE_VERBOSE_USAGE is not set
-# CONFIG_FEATURE_COMPRESS_USAGE is not set
-# CONFIG_FEATURE_INSTALLER is not set
-# CONFIG_INSTALL_NO_USR is not set
+CONFIG_SHOW_USAGE=y
+CONFIG_FEATURE_VERBOSE_USAGE=y
+CONFIG_FEATURE_COMPRESS_USAGE=y
+CONFIG_FEATURE_INSTALLER=y
+CONFIG_INSTALL_NO_USR=y
# CONFIG_LOCALE_SUPPORT is not set
# CONFIG_UNICODE_SUPPORT is not set
# CONFIG_UNICODE_USING_LOCALE is not set
@@ -36,7 +36,7 @@
# CONFIG_UNICODE_BIDI_SUPPORT is not set
# CONFIG_UNICODE_NEUTRAL_TABLE is not set
# CONFIG_UNICODE_PRESERVE_BROKEN is not set
-# CONFIG_LONG_OPTS is not set
+CONFIG_LONG_OPTS=y
# CONFIG_FEATURE_DEVPTS is not set
# CONFIG_FEATURE_CLEAN_UP is not set
# CONFIG_FEATURE_UTMP is not set
@@ -67,7 +67,6 @@
CONFIG_EXTRA_LDFLAGS="-Xlinker -z -Xlinker muldefs -nostdlib -Bdynamic -Xlinker -dynamic-linker -Xlinker /system/bin/linker -Xlinker -z -Xlinker nocopyreloc -Xlinker --no-undefined ${SYSROOT}/usr/lib/crtbegin_dynamic.o ${SYSROOT}/usr/lib/crtend_android.o"
CONFIG_EXTRA_LDLIBS="dl m c gcc"
-
#
# Debugging Options
#
@@ -112,7 +111,7 @@
# CONFIG_FEATURE_EDITING_FANCY_PROMPT is not set
# CONFIG_FEATURE_EDITING_ASK_TERMINAL is not set
# CONFIG_FEATURE_NON_POSIX_CP is not set
-# CONFIG_FEATURE_VERBOSE_CP_MESSAGE is not set
+CONFIG_FEATURE_VERBOSE_CP_MESSAGE=y
CONFIG_FEATURE_COPYBUF_KB=4
# CONFIG_FEATURE_SKIP_ROOTFS is not set
# CONFIG_MONOTONIC_SYSCALL is not set
@@ -239,7 +238,7 @@
CONFIG_FEATURE_LS_SORTFILES=y
CONFIG_FEATURE_LS_TIMESTAMPS=y
CONFIG_FEATURE_LS_USERNAME=y
-# CONFIG_FEATURE_LS_COLOR is not set
+CONFIG_FEATURE_LS_COLOR=y
# CONFIG_FEATURE_LS_COLOR_IS_DEFAULT is not set
CONFIG_MD5SUM=y
CONFIG_MKDIR=y
@@ -372,7 +371,6 @@
CONFIG_FEATURE_VI_SET=y
CONFIG_FEATURE_VI_WIN_RESIZE=y
CONFIG_FEATURE_VI_ASK_TERMINAL=y
-CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
CONFIG_AWK=y
CONFIG_FEATURE_AWK_LIBM=y
CONFIG_CMP=y
@@ -516,7 +514,7 @@
# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
# CONFIG_FEATURE_MODUTILS_ALIAS is not set
# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
-CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
+CONFIG_DEFAULT_MODULES_DIR="/system/lib/modules"
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
#
@@ -647,8 +645,8 @@
# CONFIG_UBIRSVOL is not set
# CONFIG_UBIUPDATEVOL is not set
# CONFIG_ADJTIMEX is not set
-# CONFIG_BBCONFIG is not set
-# CONFIG_FEATURE_COMPRESS_BBCONFIG is not set
+CONFIG_BBCONFIG=y
+CONFIG_FEATURE_COMPRESS_BBCONFIG=y
CONFIG_BEEP=y
CONFIG_FEATURE_BEEP_FREQ=4000
CONFIG_FEATURE_BEEP_LENGTH_MS=30
@@ -883,6 +881,7 @@
# Process Utilities
#
CONFIG_IOSTAT=y
+CONFIG_LSOF=y
CONFIG_MPSTAT=y
CONFIG_NMETER=y
CONFIG_PMAP=y
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/configs/cygwin_defconfig
^
|
@@ -363,7 +363,6 @@
CONFIG_FEATURE_VI_SET=y
CONFIG_FEATURE_VI_WIN_RESIZE=y
CONFIG_FEATURE_VI_ASK_TERMINAL=y
-CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
CONFIG_AWK=y
CONFIG_FEATURE_AWK_LIBM=y
CONFIG_CMP=y
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/configs/freebsd_defconfig
^
|
@@ -367,7 +367,6 @@
CONFIG_FEATURE_VI_SET=y
CONFIG_FEATURE_VI_WIN_RESIZE=y
CONFIG_FEATURE_VI_ASK_TERMINAL=y
-CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
CONFIG_FEATURE_ALLOW_EXEC=y
#
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/console-tools/loadfont.c
^
|
@@ -229,7 +229,7 @@
}
/* Note: after PIO_UNIMAPCLR and before PIO_UNIMAP
- this printf did not work on many kernels */
+ * this printf did not work on many kernels */
advice.advised_hashsize = 0;
advice.advised_hashstep = 0;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/console-tools/setlogcons.c
^
|
@@ -22,9 +22,10 @@
struct {
char fn;
char subarg;
- } arg = { 11, /* redirect kernel messages */
- 0 /* to specified console (current as default) */
- };
+ } arg = {
+ 11, /* redirect kernel messages */
+ 0 /* to specified console (current as default) */
+ };
if (argv[1])
arg.subarg = xatou_range(argv[1], 0, 63);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/Config.src
^
|
@@ -514,6 +514,12 @@
help
Compute and check SHA512 message digest
+config SHA3SUM
+ bool "sha3sum"
+ default y
+ help
+ Compute and check SHA3 (512-bit) message digest
+
config SLEEP
bool "sleep"
default y
@@ -766,13 +772,13 @@
help
Allow df, du, and ls to have human readable output.
-comment "Common options for md5sum, sha1sum, sha256sum, sha512sum"
- depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM
+comment "Common options for md5sum, sha1sum, sha256sum, sha512sum, sha3sum"
+ depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM || SHA3SUM
config FEATURE_MD5_SHA1_SUM_CHECK
bool "Enable -c, -s and -w options"
default y
- depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM
+ depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM || SHA3SUM
help
Enabling the -c options allows files to be checked
against pre-calculated hash values.
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/Kbuild.src
^
|
@@ -62,6 +62,7 @@
lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
lib-$(CONFIG_SHA256SUM) += md5_sha1_sum.o
lib-$(CONFIG_SHA512SUM) += md5_sha1_sum.o
+lib-$(CONFIG_SHA3SUM) += md5_sha1_sum.o
lib-$(CONFIG_SLEEP) += sleep.o
lib-$(CONFIG_SPLIT) += split.o
lib-$(CONFIG_SORT) += sort.o
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/cal.c
^
|
@@ -43,7 +43,7 @@
};
static const unsigned char sep1752[] ALIGN1 = {
- 1, 2, 14, 15, 16,
+ 1, 2, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30
};
@@ -167,8 +167,8 @@
day_array(month, year, dp);
len = sprintf(lineout, "%s %d", month_names[month - 1], year);
printf("%*s%s\n%s\n",
- ((7*julian + WEEK_LEN) - len) / 2, "",
- lineout, day_headings);
+ ((7*julian + WEEK_LEN) - len) / 2, "",
+ lineout, day_headings);
for (row = 0; row < 6; row++) {
build_row(lineout, dp)[0] = '\0';
dp += 7;
@@ -181,10 +181,11 @@
sprintf(lineout, "%u", year);
center(lineout,
- (WEEK_LEN * 3 + HEAD_SEP * 2)
- + julian * (J_WEEK_LEN * 2 + HEAD_SEP
- - (WEEK_LEN * 3 + HEAD_SEP * 2)),
- 0);
+ (WEEK_LEN * 3 + HEAD_SEP * 2)
+ + julian * (J_WEEK_LEN * 2 + HEAD_SEP
+ - (WEEK_LEN * 3 + HEAD_SEP * 2)),
+ 0
+ );
puts("\n"); /* two \n's */
for (i = 0; i < 12; i++) {
day_array(i + 1, year, days[i]);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/chown.c
^
|
@@ -126,8 +126,8 @@
/* This matches coreutils behavior (almost - see below) */
param.chown_func = chown;
if (OPT_NODEREF
- /* || (OPT_RECURSE && !OPT_TRAVERSE_TOP): */
- IF_DESKTOP( || (opt & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
+ /* || (OPT_RECURSE && !OPT_TRAVERSE_TOP): */
+ IF_DESKTOP( || (opt & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
) {
param.chown_func = lchown;
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/cut.c
^
|
@@ -212,7 +212,7 @@
if (opt & CUT_OPT_SUPPRESS_FLGS) {
bb_error_msg_and_die
("suppressing non-delimited lines makes sense%s",
- _op_on_field);
+ _op_on_field);
}
if (delim != '\t') {
bb_error_msg_and_die
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/df.c
^
|
@@ -110,9 +110,9 @@
df_disp_hr = xatoul_range(chp, 1, ULONG_MAX); /* disallow 0 */
/* From the manpage of df from coreutils-6.10:
- Disk space is shown in 1K blocks by default, unless the environment
- variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.
- */
+ * Disk space is shown in 1K blocks by default, unless the environment
+ * variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.
+ */
if (getenv("POSIXLY_CORRECT")) /* TODO - a new libbb function? */
df_disp_hr = 512;
@@ -221,7 +221,7 @@
}
#else
if (printf("\n%-20s" + 1, device) > 20 && !(opt & OPT_POSIX))
- printf("\n%-20s", "");
+ printf("\n%-20s", "");
#endif
#if ENABLE_FEATURE_HUMAN_READABLE
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/du.c
^
|
@@ -89,6 +89,10 @@
#define INIT_G() do { } while (0)
+/* FIXME? coreutils' du rounds sizes up:
+ * for example, 1025k file is shown as "2" by du -m.
+ * We round to nearest.
+ */
static void print(unsigned long long size, const char *filename)
{
/* TODO - May not want to defer error checking here. */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/id.c
^
|
@@ -174,7 +174,7 @@
/* Don't allow -n -r -nr -ug -rug -nug -rnug -uZ -gZ -GZ*/
/* Don't allow more than one username */
opt_complementary = "?1:u--g:g--u:G--u:u--G:g--G:G--g:r?ugG:n?ugG"
- IF_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");
+ IF_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");
opt = getopt32(argv, "rnugG" IF_SELINUX("Z"));
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/ln.c
^
|
@@ -20,6 +20,8 @@
//usage: "\n -n Don't dereference symlinks - treat like normal file"
//usage: "\n -b Make a backup of the target (if exists) before link operation"
//usage: "\n -S suf Use suffix instead of ~ when making backup files"
+//usage: "\n -T 2nd arg must be a DIR"
+//usage: "\n -v Verbose"
//usage:
//usage:#define ln_example_usage
//usage: "$ ln -s BusyBox /tmp/ls\n"
@@ -31,11 +33,13 @@
/* This is a NOEXEC applet. Be very careful! */
-#define LN_SYMLINK 1
-#define LN_FORCE 2
-#define LN_NODEREFERENCE 4
-#define LN_BACKUP 8
-#define LN_SUFFIX 16
+#define LN_SYMLINK (1 << 0)
+#define LN_FORCE (1 << 1)
+#define LN_NODEREFERENCE (1 << 2)
+#define LN_BACKUP (1 << 3)
+#define LN_SUFFIX (1 << 4)
+#define LN_VERBOSE (1 << 5)
+#define LN_LINKFILE (1 << 6)
int ln_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ln_main(int argc, char **argv)
@@ -50,10 +54,15 @@
int (*link_func)(const char *, const char *);
opt_complementary = "-1"; /* min one arg */
- opts = getopt32(argv, "sfnbS:", &suffix);
+ opts = getopt32(argv, "sfnbS:vT", &suffix);
last = argv[argc - 1];
argv += optind;
+ argc -= optind;
+
+ if ((opts & LN_LINKFILE) && argc > 2) {
+ bb_error_msg_and_die("-T accepts 2 args max");
+ }
if (!argv[1]) {
/* "ln PATH/TO/FILE" -> "ln PATH/TO/FILE FILE" */
@@ -72,6 +81,9 @@
(opts & LN_NODEREFERENCE) ^ LN_NODEREFERENCE
)
) {
+ if (opts & LN_LINKFILE) {
+ bb_error_msg_and_die("'%s' is a directory", src);
+ }
src_name = xstrdup(*argv);
src = concat_path_file(src, bb_get_last_path_component_strip(src_name));
free(src_name);
@@ -112,6 +124,10 @@
link_func = symlink;
}
+ if (opts & LN_VERBOSE) {
+ printf("'%s' -> '%s'\n", src, *argv);
+ }
+
if (link_func(*argv, src) != 0) {
bb_simple_perror_msg(src);
status = EXIT_FAILURE;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/ls.c
^
|
@@ -260,7 +260,7 @@
/* TODO: simple toggles may be stored as OPT_xxx bits instead */
static const uint32_t opt_flags[] = {
- STYLE_COLUMNAR, /* C */
+ STYLE_COLUMNAR, /* C */
DISP_HIDDEN | DISP_DOT, /* a */
DISP_NOLIST, /* d */
LIST_INO, /* i */
@@ -720,7 +720,7 @@
if ((option_mask32 & OPT_L) || force_follow) {
#if ENABLE_SELINUX
if (is_selinux_enabled()) {
- getfilecon(fullname, &cur->sid);
+ getfilecon(fullname, &cur->sid);
}
#endif
if (stat(fullname, &statbuf)) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/md5_sha1_sum.c
^
|
@@ -55,6 +55,16 @@
//usage: "\n -s Don't output anything, status code shows success"
//usage: "\n -w Warn about improperly formatted checksum lines"
//usage: )
+//usage:
+//usage:#define sha3sum_trivial_usage
+//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK("[-c[sw]] ")"[FILE]..."
+//usage:#define sha3sum_full_usage "\n\n"
+//usage: "Print" IF_FEATURE_MD5_SHA1_SUM_CHECK(" or check") " SHA3-512 checksums"
+//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK( "\n"
+//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: )
#include "libbb.h"
@@ -65,6 +75,7 @@
HASH_MD5 = 's', /* "md5>s<um" */
HASH_SHA1 = '1',
HASH_SHA256 = '2',
+ HASH_SHA3 = '3',
HASH_SHA512 = '5',
};
@@ -86,6 +97,7 @@
{
int src_fd, hash_len, count;
union _ctx_ {
+ sha3_ctx_t sha3;
sha512_ctx_t sha512;
sha256_ctx_t sha256;
sha1_ctx_t sha1;
@@ -124,6 +136,11 @@
update = (void*)sha512_hash;
final = (void*)sha512_end;
hash_len = 64;
+ } else if (ENABLE_SHA3SUM && hash_algo == HASH_SHA3) {
+ sha3_begin(&context.sha3);
+ update = (void*)sha3_hash;
+ final = (void*)sha3_end;
+ hash_len = 64;
} else {
xfunc_die(); /* can't reach this */
}
@@ -223,7 +240,7 @@
}
if (count_failed && !(flags & FLAG_SILENT)) {
bb_error_msg("WARNING: %d of %d computed checksums did NOT match",
- count_failed, count_total);
+ count_failed, count_total);
}
fclose_if_not_stdin(pre_computed_stream);
} else {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/mkdir.c
^
|
@@ -48,6 +48,7 @@
#if ENABLE_SELINUX
"context\0" Required_argument "Z"
#endif
+ "verbose\0" No_argument "v"
;
#endif
@@ -66,7 +67,7 @@
#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
applet_long_options = mkdir_longopts;
#endif
- opt = getopt32(argv, "m:p" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext));
+ opt = getopt32(argv, "m:p" IF_SELINUX("Z:") "v", &smode IF_SELINUX(,&scontext));
if (opt & 1) {
mode_t mmode = 0777;
if (!bb_parse_mode(smode, &mmode)) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/mknod.c
^
|
@@ -59,7 +59,7 @@
/* Autodetect what the system supports; these macros should
* optimize out to two constants. */
dev = makedev(xatoul_range(argv[2], 0, major(UINT_MAX)),
- xatoul_range(argv[3], 0, minor(UINT_MAX)));
+ xatoul_range(argv[3], 0, minor(UINT_MAX)));
}
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/mv.c
^
|
@@ -33,12 +33,13 @@
"interactive\0" No_argument "i"
"force\0" No_argument "f"
"no-clobber\0" No_argument "n"
+ "verbose\0" No_argument "v"
;
#endif
-#define OPT_FILEUTILS_FORCE 1
-#define OPT_FILEUTILS_INTERACTIVE 2
-#define OPT_FILEUTILS_NOCLOBBER 4
+#define OPT_FORCE (1 << 0)
+#define OPT_INTERACTIVE (1 << 1)
+#define OPT_NOCLOBBER (1 << 2)
int mv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int mv_main(int argc, char **argv)
@@ -56,9 +57,11 @@
#endif
/* Need at least two arguments.
* If more than one of -f, -i, -n is specified , only the final one
- * takes effect (it unsets previous options). */
+ * takes effect (it unsets previous options).
+ * -v is accepted but ignored.
+ */
opt_complementary = "-2:f-in:i-fn:n-fi";
- flags = getopt32(argv, "fin");
+ flags = getopt32(argv, "finv");
argc -= optind;
argv += optind;
last = argv[argc - 1];
@@ -84,11 +87,11 @@
DO_MOVE:
if (dest_exists) {
- if (flags & OPT_FILEUTILS_NOCLOBBER)
+ if (flags & OPT_NOCLOBBER)
goto RET_0;
- if (!(flags & OPT_FILEUTILS_FORCE)
+ if (!(flags & OPT_FORCE)
&& ((access(dest, W_OK) < 0 && isatty(0))
- || (flags & OPT_FILEUTILS_INTERACTIVE))
+ || (flags & OPT_INTERACTIVE))
) {
if (fprintf(stderr, "mv: overwrite '%s'? ", dest) < 0) {
goto RET_1; /* Ouch! fprintf failed! */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/od_bloaty.c
^
|
@@ -25,7 +25,7 @@
//usage:#if ENABLE_DESKTOP
//usage:#define od_trivial_usage
-//usage: "[-abcdfhilovxs] [-t TYPE] [-A RADIX] [-N SIZE] [-j SKIP] [-S MINSTR] [-w WIDTH] [FILE...]"
+//usage: "[-abcdfhilovxs] [-t TYPE] [-A RADIX] [-N SIZE] [-j SKIP] [-S MINSTR] [-w WIDTH] [FILE]..."
// We don't support:
// ... [FILE] [[+]OFFSET[.][b]]
// Support is buggy for:
@@ -1021,12 +1021,12 @@
l_c_m = get_lcm();
/* Make bytes_to_write the smallest multiple of l_c_m that
- is at least as large as n_bytes_read. */
+ is at least as large as n_bytes_read. */
bytes_to_write = l_c_m * ((n_bytes_read + l_c_m - 1) / l_c_m);
memset(block[idx] + n_bytes_read, 0, bytes_to_write - n_bytes_read);
write_block(current_offset, bytes_to_write,
- block[idx ^ 1], block[idx]);
+ block[idx ^ 1], block[idx]);
current_offset += n_bytes_read;
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/rmdir.c
^
|
@@ -30,8 +30,9 @@
/* This is a NOFORK applet. Be very careful! */
-#define PARENTS 0x01
-#define IGNORE_NON_EMPTY 0x02
+#define PARENTS (1 << 0)
+//efine VERBOSE (1 << 1) //accepted but ignored
+#define IGNORE_NON_EMPTY (1 << 2)
int rmdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int rmdir_main(int argc UNUSED_PARAM, char **argv)
@@ -43,13 +44,14 @@
#if ENABLE_FEATURE_RMDIR_LONG_OPTIONS
static const char rmdir_longopts[] ALIGN1 =
"parents\0" No_argument "p"
+ "verbose\0" No_argument "v"
/* Debian etch: many packages fail to be purged or installed
* because they desperately want this option: */
"ignore-fail-on-non-empty\0" No_argument "\xff"
;
applet_long_options = rmdir_longopts;
#endif
- flags = getopt32(argv, "p");
+ flags = getopt32(argv, "pv");
argv += optind;
if (!*argv) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/sort.c
^
|
@@ -219,7 +219,7 @@
y = get_key(*(char **)yarg, key, flags);
#else
/* This curly bracket serves no purpose but to match the nesting
- level of the for () loop we're not using */
+ * level of the for () loop we're not using */
{
x = *(char **)xarg;
y = *(char **)yarg;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/stat.c
^
|
@@ -99,9 +99,15 @@
if (S_ISFIFO(st->st_mode)) return "fifo";
if (S_ISLNK(st->st_mode)) return "symbolic link";
if (S_ISSOCK(st->st_mode)) return "socket";
+#ifdef S_TYPEISMQ
if (S_TYPEISMQ(st)) return "message queue";
+#endif
+#ifdef S_TYPEISSEM
if (S_TYPEISSEM(st)) return "semaphore";
+#endif
+#ifdef S_TYPEISSHM
if (S_TYPEISSHM(st)) return "shared memory object";
+#endif
#ifdef S_TYPEISTMO
if (S_TYPEISTMO(st)) return "typed memory object";
#endif
@@ -436,7 +442,7 @@
: getfilecon(filename, &scontext)
) < 0
) {
- bb_perror_msg(filename);
+ bb_simple_perror_msg(filename);
return 0;
}
}
@@ -549,7 +555,7 @@
: getfilecon(filename, &scontext)
) < 0
) {
- bb_perror_msg(filename);
+ bb_simple_perror_msg(filename);
return 0;
}
}
@@ -585,37 +591,43 @@
# else
if (option_mask32 & OPT_TERSE) {
format = (option_mask32 & OPT_SELINUX ?
- "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o %C\n":
- "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o\n");
+ "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o %C\n"
+ :
+ "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o\n"
+ );
} else {
if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode)) {
format = (option_mask32 & OPT_SELINUX ?
- " File: %N\n"
- " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
- "Device: %Dh/%dd\tInode: %-10i Links: %-5h"
- " Device type: %t,%T\n"
- "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
- " S_Context: %C\n"
- "Access: %x\n" "Modify: %y\n" "Change: %z\n":
- " File: %N\n"
- " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
- "Device: %Dh/%dd\tInode: %-10i Links: %-5h"
- " Device type: %t,%T\n"
- "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
- "Access: %x\n" "Modify: %y\n" "Change: %z\n");
+ " File: %N\n"
+ " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
+ "Device: %Dh/%dd\tInode: %-10i Links: %-5h"
+ " Device type: %t,%T\n"
+ "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
+ " S_Context: %C\n"
+ "Access: %x\n" "Modify: %y\n" "Change: %z\n"
+ :
+ " File: %N\n"
+ " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
+ "Device: %Dh/%dd\tInode: %-10i Links: %-5h"
+ " Device type: %t,%T\n"
+ "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
+ "Access: %x\n" "Modify: %y\n" "Change: %z\n"
+ );
} else {
format = (option_mask32 & OPT_SELINUX ?
- " File: %N\n"
- " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
- "Device: %Dh/%dd\tInode: %-10i Links: %h\n"
- "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
- "S_Context: %C\n"
- "Access: %x\n" "Modify: %y\n" "Change: %z\n":
- " File: %N\n"
- " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
- "Device: %Dh/%dd\tInode: %-10i Links: %h\n"
- "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
- "Access: %x\n" "Modify: %y\n" "Change: %z\n");
+ " File: %N\n"
+ " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
+ "Device: %Dh/%dd\tInode: %-10i Links: %h\n"
+ "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
+ "S_Context: %C\n"
+ "Access: %x\n" "Modify: %y\n" "Change: %z\n"
+ :
+ " File: %N\n"
+ " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
+ "Device: %Dh/%dd\tInode: %-10i Links: %h\n"
+ "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
+ "Access: %x\n" "Modify: %y\n" "Change: %z\n"
+ );
}
}
# endif
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/stty.c
^
|
@@ -1056,7 +1056,7 @@
}
#endif
wrapf("%s = %s;", nth_string(control_name, i),
- visible(mode->c_cc[control_info[i].offset]));
+ visible(mode->c_cc[control_info[i].offset]));
}
#if VEOF == VMIN
if ((mode->c_lflag & ICANON) == 0)
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/sum.c
^
|
@@ -94,8 +94,8 @@
n = sum_file("-", type);
} else {
/* Need to print the name if either
- - more than one file given
- - doing sysv */
+ * - more than one file given
+ * - doing sysv */
type += (argv[1] || type == SUM_SYSV);
n = 1;
do {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/coreutils/test.c
^
|
@@ -610,7 +610,7 @@
return 0;
/* Root can execute any file that has any one of the execute
- bits set. */
+ * bits set. */
if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
return 0;
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/debianutils/mktemp.c
^
|
@@ -38,7 +38,7 @@
//usage: "TEMPLATE must end with XXXXXX (e.g. [/dir/]nameXXXXXX).\n"
//usage: "Without TEMPLATE, -t tmp.XXXXXX is assumed.\n"
//usage: "\n -d Make directory, not file"
-////usage: "\n -q Fail silently on errors" - we ignore this opt
+//usage: "\n -q Fail silently on errors"
//usage: "\n -t Prepend base directory name to TEMPLATE"
//usage: "\n -p DIR Use DIR as a base directory (implies -t)"
//usage: "\n -u Do not create anything; print a name"
@@ -71,7 +71,6 @@
if (!path || path[0] == '\0')
path = "/tmp";
- /* -q is ignored */
opt_complementary = "?1"; /* 1 argument max */
opts = getopt32(argv, "dqtp:u", &path);
@@ -83,33 +82,32 @@
chp = xstrdup("tmp.XXXXXX");
opts |= OPT_t;
}
-
- if (opts & OPT_u) {
- /* Remove (up to) 6 X's */
- unsigned len = strlen(chp);
- int cnt = len > 6 ? 6 : len;
- while (--cnt >= 0 && chp[--len] == 'X')
- chp[len] = '\0';
-
- chp = tempnam(opts & (OPT_t|OPT_p) ? path : "./", chp);
- if (!chp)
- return EXIT_FAILURE;
- if (!(opts & (OPT_t|OPT_p)))
- chp += 2;
- goto ret;
+#if 0
+ /* Don't allow directory separator in template */
+ if ((opts & OPT_t) && bb_basename(chp) != chp) {
+ errno = EINVAL;
+ goto error;
}
-
+#endif
if (opts & (OPT_t|OPT_p))
chp = concat_path_file(path, chp);
- if (opts & OPT_d) {
+ if (opts & OPT_u) {
+ chp = mktemp(chp);
+ if (chp[0] == '\0')
+ goto error;
+ } else if (opts & OPT_d) {
if (mkdtemp(chp) == NULL)
- return EXIT_FAILURE;
+ goto error;
} else {
if (mkstemp(chp) < 0)
- return EXIT_FAILURE;
+ goto error;
}
- ret:
puts(chp);
return EXIT_SUCCESS;
+ error:
+ if (opts & OPT_q)
+ return EXIT_FAILURE;
+ /* don't use chp as it gets mangled in case of error */
+ bb_perror_nomsg_and_die();
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/debianutils/run_parts.c
^
|
@@ -4,14 +4,13 @@
*
* Copyright (C) 2007 Bernhard Reutner-Fischer
*
- * Based on a older version that was in busybox which was 1k big..
+ * Based on a older version that was in busybox which was 1k big.
* Copyright (C) 2001 by Emanuele Aina <emanuele.aina@tiscali.it>
*
* Based on the Debian run-parts program, version 1.15
* Copyright (C) 1996 Jeff Noxon <jeff@router.patch.net>,
* Copyright (C) 1996-1999 Guy Maor <maor@debian.org>
*
- *
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
@@ -19,7 +18,7 @@
* attempt to write a program! :-) . */
/* This piece of code is heavily based on the original version of run-parts,
- * taken from debian-utils. I've only removed the long options and a the
+ * taken from debian-utils. I've only removed the long options and the
* report mode. As the original run-parts support only long options, I've
* broken compatibility because the BusyBox policy doesn't allow them.
* The supported options are:
@@ -31,15 +30,15 @@
*/
//usage:#define run_parts_trivial_usage
-//usage: "[-t] "IF_FEATURE_RUN_PARTS_FANCY("[-l] ")"[-a ARG] [-u MASK] DIRECTORY"
+//usage: "[-t"IF_FEATURE_RUN_PARTS_FANCY("l")"] [-a ARG]... [-u MASK] DIRECTORY"
//usage:#define run_parts_full_usage "\n\n"
//usage: "Run a bunch of scripts in DIRECTORY\n"
-//usage: "\n -t Print what would be run, but don't actually run anything"
-//usage: "\n -a ARG Pass ARG as argument for every program"
-//usage: "\n -u MASK Set the umask to MASK before running every program"
+//usage: "\n -t Dry run"
//usage: IF_FEATURE_RUN_PARTS_FANCY(
-//usage: "\n -l Print names of all matching files even if they are not executable"
+//usage: "\n -l Print names of matching files even if they are not executable"
//usage: )
+//usage: "\n -a ARG Pass ARG as argument to programs"
+//usage: "\n -u MASK Set umask to MASK before running programs"
//usage:
//usage:#define run_parts_example_usage
//usage: "$ run-parts -a start /etc/init.d\n"
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/e2fsprogs/fsck.c
^
|
@@ -478,7 +478,7 @@
instance_list = inst->next;
if (verbose > 1)
printf("Finished with %s (exit status %d)\n",
- inst->device, status);
+ inst->device, status);
num_running--;
free_instance(inst);
@@ -844,7 +844,7 @@
if (verbose > 1)
printf("--waiting-- (pass %d)\n", passno);
status |= wait_many(pass_done ? FLAG_WAIT_ALL :
- FLAG_WAIT_ATLEAST_ONE);
+ FLAG_WAIT_ATLEAST_ONE);
if (pass_done) {
if (verbose > 1)
puts("----------------------------------");
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/e2fsprogs/old_e2fsprogs/lsattr.c
^
|
@@ -93,7 +93,7 @@
path = concat_path_file(dir_name, de->d_name);
if (lstat(path, &st) == -1)
- bb_perror_msg(path);
+ bb_simple_perror_msg(path);
else {
if (de->d_name[0] != '.' || (flags & OPT_ALL)) {
list_attributes(path);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/editors/awk.c
^
|
@@ -155,7 +155,7 @@
/* simple token classes */
/* Order and hex values are very important!!! See next_token() */
-#define TC_SEQSTART 1 /* ( */
+#define TC_SEQSTART 1 /* ( */
#define TC_SEQTERM (1 << 1) /* ) */
#define TC_REGEXP (1 << 2) /* /.../ */
#define TC_OUTRDR (1 << 3) /* | > >> */
@@ -696,6 +696,10 @@
pps = *s;
if (c == '\\')
c = bb_process_escape_sequence((const char**)s);
+ /* Example awk statement:
+ * s = "abc\"def"
+ * we must treat \" as "
+ */
if (c == '\\' && *s == pps) { /* unrecognized \z? */
c = *(*s); /* yes, fetch z */
if (c)
@@ -704,6 +708,15 @@
return c;
}
+/* TODO: merge with strcpy_and_process_escape_sequences()?
+ */
+static void unescape_string_in_place(char *s1)
+{
+ char *s = s1;
+ while ((*s1 = nextchar(&s)) != '\0')
+ s1++;
+}
+
static ALWAYS_INLINE int isalnum_(int c)
{
return (isalnum(c) || c == '_');
@@ -1799,6 +1812,18 @@
is_f0_split = FALSE;
} else if (v == intvar[FS]) {
+ /*
+ * The POSIX-2008 standard says that changing FS should have no effect on the
+ * current input line, but only on the next one. The language is:
+ *
+ * > Before the first reference to a field in the record is evaluated, the record
+ * > shall be split into fields, according to the rules in Regular Expressions,
+ * > using the value of FS that was current at the time the record was read.
+ *
+ * So, split up current line before assignment to FS:
+ */
+ split_f0();
+
mk_splitter(getvar_s(v), &fsplitter);
} else if (v == intvar[RS]) {
@@ -2992,7 +3017,7 @@
* otherwise return 0 */
static int is_assignment(const char *expr)
{
- char *exprc, *val, *s, *s1;
+ char *exprc, *val;
if (!isalnum_(*expr) || (val = strchr(expr, '=')) == NULL) {
return FALSE;
@@ -3002,10 +3027,7 @@
val = exprc + (val - expr);
*val++ = '\0';
- s = s1 = val;
- while ((*s1 = nextchar(&s)) != '\0')
- s1++;
-
+ unescape_string_in_place(val);
setvar_u(newvar(exprc), val);
free(exprc);
return TRUE;
@@ -3118,8 +3140,10 @@
opt = getopt32(argv, "F:v:f:W:", &opt_F, &list_v, &list_f, NULL);
argv += optind;
argc -= optind;
- if (opt & 0x1)
- setvar_s(intvar[FS], opt_F); // -F
+ if (opt & 0x1) { /* -F */
+ unescape_string_in_place(opt_F);
+ setvar_s(intvar[FS], opt_F);
+ }
while (list_v) { /* -v */
if (!is_assignment(llist_pop(&list_v)))
bb_show_usage();
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/editors/diff.c
^
|
@@ -843,7 +843,7 @@
* 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], 0);
/* Sort dl alphabetically.
* GNU diff does this ignoring any number of trailing dots.
* We don't, so for us dotted files almost always are
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/editors/sed.c
^
|
@@ -53,7 +53,9 @@
* Todo:
* - Create a wrapper around regex to make libc's regex conform with sed
*
- * Reference http://www.opengroup.org/onlinepubs/007904975/utilities/sed.html
+ * Reference
+ * http://www.opengroup.org/onlinepubs/007904975/utilities/sed.html
+ * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html
*/
//usage:#define sed_trivial_usage
@@ -62,7 +64,8 @@
//usage:#define sed_full_usage "\n\n"
//usage: " -e CMD Add CMD to sed commands to be executed"
//usage: "\n -f FILE Add FILE contents to sed commands to be executed"
-//usage: "\n -i Edit files in-place (else sends result to stdout)"
+//usage: "\n -i[SFX] Edit files in-place (otherwise sends to stdout)"
+//usage: "\n Optionally back files up, appending SFX"
//usage: "\n -n Suppress automatic printing of pattern space"
//usage: "\n -r Use extended regex syntax"
//usage: "\n"
@@ -491,8 +494,10 @@
}
/* handle edit cmds: (a)ppend, (i)nsert, and (c)hange */
else if (idx <= IDX_c) { /* a,i,c */
- if ((sed_cmd->end_line || sed_cmd->end_match) && sed_cmd->cmd != 'c')
- bb_error_msg_and_die("only a beginning address can be specified for edit commands");
+ if (idx < IDX_c) { /* a,i */
+ if (sed_cmd->end_line || sed_cmd->end_match)
+ bb_error_msg_and_die("command '%c' uses only one address", sed_cmd->cmd);
+ }
for (;;) {
if (*cmdstr == '\n' || *cmdstr == '\\') {
cmdstr++;
@@ -509,8 +514,10 @@
}
/* handle file cmds: (r)ead */
else if (idx <= IDX_w) { /* r,w */
- if (sed_cmd->end_line || sed_cmd->end_match)
- bb_error_msg_and_die("command only uses one address");
+ if (idx < IDX_w) { /* r */
+ if (sed_cmd->end_line || sed_cmd->end_match)
+ bb_error_msg_and_die("command '%c' uses only one address", sed_cmd->cmd);
+ }
cmdstr += parse_file_cmd(/*sed_cmd,*/ cmdstr, &sed_cmd->string);
if (sed_cmd->cmd == 'w') {
sed_cmd->sw_file = xfopen_for_write(sed_cmd->string);
@@ -672,7 +679,7 @@
/* go through the replacement string */
for (i = 0; replace[i]; i++) {
- /* if we find a backreference (\1, \2, etc.) print the backref'ed * text */
+ /* if we find a backreference (\1, \2, etc.) print the backref'ed text */
if (replace[i] == '\\') {
unsigned backref = replace[++i] - '0';
if (backref <= 9) {
@@ -706,8 +713,10 @@
static int do_subst_command(sed_cmd_t *sed_cmd, char **line_p)
{
char *line = *line_p;
- int altered = 0;
unsigned match_count = 0;
+ bool altered = 0;
+ bool prev_match_empty = 1;
+ bool tried_at_eol = 0;
regex_t *current_regex;
current_regex = sed_cmd->sub_match;
@@ -734,50 +743,75 @@
/* Now loop through, substituting for matches */
do {
+ int start = G.regmatch[0].rm_so;
+ int end = G.regmatch[0].rm_eo;
int i;
- /* Work around bug in glibc regexec, demonstrated by:
- * echo " a.b" | busybox sed 's [^ .]* x g'
- * The match_count check is so not to break
- * echo "hi" | busybox sed 's/^/!/g'
- */
- if (!G.regmatch[0].rm_so && !G.regmatch[0].rm_eo && match_count) {
- pipe_putc(*line++);
- goto next;
- }
-
match_count++;
/* If we aren't interested in this match, output old line to
- end of match and continue */
+ * end of match and continue */
if (sed_cmd->which_match
&& (sed_cmd->which_match != match_count)
) {
- for (i = 0; i < G.regmatch[0].rm_eo; i++)
+ for (i = 0; i < end; i++)
+ pipe_putc(*line++);
+ /* Null match? Print one more char */
+ if (start == end && *line)
pipe_putc(*line++);
goto next;
}
- /* print everything before the match */
- for (i = 0; i < G.regmatch[0].rm_so; i++)
+ /* Print everything before the match */
+ for (i = 0; i < start; i++)
pipe_putc(line[i]);
- /* then print the substitution string */
- do_subst_w_backrefs(line, sed_cmd->string);
+ /* Then print the substitution string,
+ * unless we just matched empty string after non-empty one.
+ * Example: string "cccd", pattern "c*", repl "R":
+ * result is "RdR", not "RRdR": first match "ccc",
+ * second is "" before "d", third is "" after "d".
+ * Second match is NOT replaced!
+ */
+ if (prev_match_empty || start != 0 || start != end) {
+ //dbg("%d %d %d", prev_match_empty, start, end);
+ dbg("inserting replacement at %d in '%s'", start, line);
+ do_subst_w_backrefs(line, sed_cmd->string);
+ /* Flag that something has changed */
+ altered = 1;
+ } else {
+ dbg("NOT inserting replacement at %d in '%s'", start, line);
+ }
+
+ /* If matched string is empty (f.e. "c*" pattern),
+ * copy verbatim one char after it before attempting more matches
+ */
+ prev_match_empty = (start == end);
+ if (prev_match_empty) {
+ if (!line[end]) {
+ tried_at_eol = 1;
+ } else {
+ pipe_putc(line[end]);
+ end++;
+ }
+ }
- /* advance past the match */
- line += G.regmatch[0].rm_eo;
- /* flag that something has changed */
- altered++;
+ /* Advance past the match */
+ dbg("line += %d", end);
+ line += end;
/* if we're not doing this globally, get out now */
if (sed_cmd->which_match != 0)
break;
next:
- if (*line == '\0')
- break;
+ /* Exit if we are at EOL and already tried matching at it */
+ if (*line == '\0') {
+ if (tried_at_eol)
+ break;
+ tried_at_eol = 1;
+ }
-//maybe (G.regmatch[0].rm_eo ? REG_NOTBOL : 0) instead of unconditional REG_NOTBOL?
+//maybe (end ? REG_NOTBOL : 0) instead of unconditional REG_NOTBOL?
} while (regexec(current_regex, line, 10, G.regmatch, REG_NOTBOL) != REG_NOMATCH);
/* Copy rest of string into output pipeline */
@@ -1043,7 +1077,7 @@
/* or does this line matches our last address regex */
|| (sed_cmd->end_match && old_matched
&& (regexec(sed_cmd->end_match,
- pattern_space, 0, NULL, 0) == 0)
+ pattern_space, 0, NULL, 0) == 0)
)
);
}
@@ -1126,7 +1160,7 @@
case 's':
if (!do_subst_command(sed_cmd, &pattern_space))
break;
- dbg("do_subst_command succeeeded:'%s'", pattern_space);
+ dbg("do_subst_command succeeded:'%s'", pattern_space);
substituted |= 1;
/* handle p option */
@@ -1374,6 +1408,19 @@
{
unsigned opt;
llist_t *opt_e, *opt_f;
+ char *opt_i;
+
+#if ENABLE_LONG_OPTS
+ static const char sed_longopts[] ALIGN1 =
+ /* name has_arg short */
+ "in-place\0" Optional_argument "i"
+ "regexp-extended\0" No_argument "r"
+ "quiet\0" No_argument "n"
+ "silent\0" No_argument "n"
+ "expression\0" Required_argument "e"
+ "file\0" Required_argument "f";
+#endif
+
int status = EXIT_SUCCESS;
INIT_G();
@@ -1382,17 +1429,21 @@
if (ENABLE_FEATURE_CLEAN_UP) atexit(sed_free_and_close_stuff);
/* Lie to autoconf when it starts asking stupid questions. */
- if (argv[1] && !strcmp(argv[1], "--version")) {
+ if (argv[1] && strcmp(argv[1], "--version") == 0) {
puts("This is not GNU sed version 4.0");
return 0;
}
/* do normal option parsing */
opt_e = opt_f = NULL;
+ opt_i = NULL;
opt_complementary = "e::f::" /* can occur multiple times */
"nn"; /* count -n */
+
+ IF_LONG_OPTS(applet_long_options = sed_longopts);
+
/* -i must be first, to match OPT_in_place definition */
- opt = getopt32(argv, "irne:f:", &opt_e, &opt_f,
+ opt = getopt32(argv, "i::rne:f:", &opt_i, &opt_e, &opt_f,
&G.be_quiet); /* counter for -n */
//argc -= optind;
argv += optind;
@@ -1474,8 +1525,13 @@
fclose(G.nonstdout);
G.nonstdout = stdout;
- /* unlink(argv[i]); */
- xrename(G.outname, argv[i]);
+ if (opt_i) {
+ char *backupname = xasprintf("%s%s", argv[i], opt_i);
+ xrename(argv[i], backupname);
+ free(backupname);
+ }
+ /* else unlink(argv[i]); - rename below does this */
+ xrename(G.outname, argv[i]); //TODO: rollback backup on error?
free(G.outname);
G.outname = NULL;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/editors/vi.c
^
|
@@ -14,7 +14,7 @@
* add :help command
* :map macros
* if mark[] values were line numbers rather than pointers
- * it would be easier to change the mark when add/delete lines
+ * it would be easier to change the mark when add/delete lines
* More intelligence in refresh()
* ":r !cmd" and "!cmd" to filter text through an external command
* A true "undo" facility
@@ -136,14 +136,6 @@
//config: cursor position using "ESC [ 6 n" escape sequence, then read stdin.
//config:
//config: This is not clean but helps a lot on serial lines and such.
-//config:
-//config:config FEATURE_VI_OPTIMIZE_CURSOR
-//config: bool "Optimize cursor movement"
-//config: default y
-//config: depends on VI
-//config: help
-//config: This will make the cursor movement faster, but requires more memory
-//config: and it makes the applet a tiny bit larger.
//applet:IF_VI(APPLET(vi, BB_DIR_BIN, BB_SUID_DROP))
@@ -154,12 +146,12 @@
//usage:#define vi_full_usage "\n\n"
//usage: "Edit FILE\n"
//usage: IF_FEATURE_VI_COLON(
-//usage: "\n -c Initial command to run ($EXINIT also available)"
+//usage: "\n -c CMD Initial command to run ($EXINIT also available)"
//usage: )
//usage: IF_FEATURE_VI_READONLY(
//usage: "\n -R Read-only"
//usage: )
-//usage: "\n -H Short help regarding available features"
+//usage: "\n -H List available features"
#include "libbb.h"
/* Should be after libbb.h: on some systems regex.h needs sys/types.h: */
@@ -202,20 +194,29 @@
MAX_SCR_ROWS = CONFIG_FEATURE_VI_MAX_LEN,
};
-/* vt102 typical ESC sequence */
-/* terminal standout start/normal ESC sequence */
-#define SOs "\033[7m"
-#define SOn "\033[0m"
-/* terminal bell sequence */
-#define bell "\007"
-/* Clear-end-of-line and Clear-end-of-screen ESC sequence */
-#define Ceol "\033[K"
-#define Ceos "\033[J"
-/* Cursor motion arbitrary destination ESC sequence */
-#define CMrc "\033[%u;%uH"
-/* Cursor motion up and down ESC sequence */
-#define CMup "\033[A"
-#define CMdown "\n"
+/* VT102 ESC sequences.
+ * See "Xterm Control Sequences"
+ * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+ */
+/* Inverse/Normal text */
+#define ESC_BOLD_TEXT "\033[7m"
+#define ESC_NORM_TEXT "\033[0m"
+/* Bell */
+#define ESC_BELL "\007"
+/* Clear-to-end-of-line */
+#define ESC_CLEAR2EOL "\033[K"
+/* Clear-to-end-of-screen.
+ * (We use default param here.
+ * Full sequence is "ESC [ <num> J",
+ * <num> is 0/1/2 = "erase below/above/all".)
+ */
+#define ESC_CLEAR2EOS "\033[J"
+/* Cursor to given coordinate (1,1: top left) */
+#define ESC_SET_CURSOR_POS "\033[%u;%uH"
+//UNUSED
+///* Cursor up and down */
+//#define ESC_CURSOR_UP "\033[A"
+//#define ESC_CURSOR_DOWN "\n"
#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
// cmds modifying text[]
@@ -303,9 +304,6 @@
int lmc_len; // length of last_modifying_cmd
char *ioq, *ioq_start; // pointer to string for get_one_char to "read"
#endif
-#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
- int last_row; // where the cursor was last moved to
-#endif
#if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME
int my_pid;
#endif
@@ -389,7 +387,6 @@
#define lmc_len (G.lmc_len )
#define ioq (G.ioq )
#define ioq_start (G.ioq_start )
-#define last_row (G.last_row )
#define my_pid (G.my_pid )
#define last_search_pattern (G.last_search_pattern)
@@ -470,10 +467,7 @@
// file_insert might reallocate text[]!
static int file_insert(const char *, char *, int);
static int file_write(char *, char *, char *);
-#if !ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
-#define place_cursor(a, b, optimize) place_cursor(a, b)
-#endif
-static void place_cursor(int, int, int);
+static void place_cursor(int, int);
static void screen_erase(void);
static void clear_to_eol(void);
static void clear_to_eos(void);
@@ -558,7 +552,8 @@
}
#endif
- vi_setops = VI_AUTOINDENT | VI_SHOWMATCH | VI_IGNORECASE;
+ // autoindent is not default in vim 7.3
+ vi_setops = /*VI_AUTOINDENT |*/ VI_SHOWMATCH | VI_IGNORECASE;
// 1- process $HOME/.exrc file (not inplemented yet)
// 2- process EXINIT variable from environment
// 3- process command line args
@@ -584,7 +579,7 @@
#if ENABLE_FEATURE_VI_COLON
case 'c': // cmd line vi command
if (*optarg)
- initial_cmds[initial_cmds[0] != 0] = xstrndup(optarg, MAX_INPUT_LEN);
+ initial_cmds[initial_cmds[0] != NULL] = xstrndup(optarg, MAX_INPUT_LEN);
break;
#endif
case 'H':
@@ -599,15 +594,19 @@
// The argv array can be used by the ":next" and ":rewind" commands
argv += optind;
argc -= optind;
- save_argc = argc;
- optind = 0;
//----- This is the main file handling loop --------------
+ save_argc = argc;
+ optind = 0;
+ // "Save cursor, use alternate screen buffer, clear screen"
+ write1("\033[?1049h");
while (1) {
edit_file(argv[optind]); /* param might be NULL */
if (++optind >= argc)
break;
}
+ // "Use normal screen buffer, restore cursor"
+ write1("\033[?1049l");
//-----------------------------------------------------------
return 0;
@@ -1191,7 +1190,7 @@
char *argp;
#endif
i = 0; // offset into args
- // only blank is regarded as args delmiter. What about tab '\t' ?
+ // only blank is regarded as args delimiter. What about tab '\t'?
if (!args[0] || strcasecmp(args, "all") == 0) {
// print out values of all options
#if ENABLE_FEATURE_VI_SETOPTS
@@ -1930,11 +1929,11 @@
dot_end(); // find NL
q = dot;
} else {
- // nothing -- this causes any other values of c to
- // represent the one-character range under the
- // cursor. this is correct for ' ' and 'l', but
- // perhaps no others.
- //
+ // nothing -- this causes any other values of c to
+ // represent the one-character range under the
+ // cursor. this is correct for ' ' and 'l', but
+ // perhaps no others.
+ //
}
if (q < p) {
t = q;
@@ -2176,7 +2175,7 @@
"\n\tPattern searches with / and ?"
#endif
#if ENABLE_FEATURE_VI_DOT_CMD
- "\n\tLast command repeat with \'.\'"
+ "\n\tLast command repeat with ."
#endif
#if ENABLE_FEATURE_VI_YANKMARK
"\n\tLine marking with 'x"
@@ -2187,7 +2186,7 @@
//redundant: usage text says this too: "\n\tReadonly with -R command line arg"
#endif
#if ENABLE_FEATURE_VI_SET
- "\n\tSome colon mode commands with \':\'"
+ "\n\tSome colon mode commands with :"
#endif
#if ENABLE_FEATURE_VI_SETOPTS
"\n\tSettable options with \":set\""
@@ -2592,107 +2591,56 @@
// 23,0 ... 23,79 <- status line
//----- Move the cursor to row x col (count from 0, not 1) -------
-static void place_cursor(int row, int col, int optimize)
+static void place_cursor(int row, int col)
{
- char cm1[sizeof(CMrc) + sizeof(int)*3 * 2];
-#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
- enum {
- SZ_UP = sizeof(CMup),
- SZ_DN = sizeof(CMdown),
- SEQ_SIZE = SZ_UP > SZ_DN ? SZ_UP : SZ_DN,
- };
- char cm2[SEQ_SIZE * 5 + 32]; // bigger than worst case size
-#endif
- char *cm;
+ char cm1[sizeof(ESC_SET_CURSOR_POS) + sizeof(int)*3 * 2];
if (row < 0) row = 0;
if (row >= rows) row = rows - 1;
if (col < 0) col = 0;
if (col >= columns) col = columns - 1;
- //----- 1. Try the standard terminal ESC sequence
- sprintf(cm1, CMrc, row + 1, col + 1);
- cm = cm1;
-
-#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
- if (optimize && col < 16) {
- char *screenp;
- int Rrow = last_row;
- int diff = Rrow - row;
-
- if (diff < -5 || diff > 5)
- goto skip;
-
- //----- find the minimum # of chars to move cursor -------------
- //----- 2. Try moving with discreet chars (Newline, [back]space, ...)
- cm2[0] = '\0';
-
- // move to the correct row
- while (row < Rrow) {
- // the cursor has to move up
- strcat(cm2, CMup);
- Rrow--;
- }
- while (row > Rrow) {
- // the cursor has to move down
- strcat(cm2, CMdown);
- Rrow++;
- }
-
- // now move to the correct column
- strcat(cm2, "\r"); // start at col 0
- // just send out orignal source char to get to correct place
- screenp = &screen[row * columns]; // start of screen line
- strncat(cm2, screenp, col);
-
- // pick the shortest cursor motion to send out
- if (strlen(cm2) < strlen(cm)) {
- cm = cm2;
- }
- skip: ;
- }
- last_row = row;
-#endif /* FEATURE_VI_OPTIMIZE_CURSOR */
- write1(cm);
+ sprintf(cm1, ESC_SET_CURSOR_POS, row + 1, col + 1);
+ write1(cm1);
}
//----- Erase from cursor to end of line -----------------------
static void clear_to_eol(void)
{
- write1(Ceol); // Erase from cursor to end of line
+ write1(ESC_CLEAR2EOL);
}
static void go_bottom_and_clear_to_eol(void)
{
- place_cursor(rows - 1, 0, FALSE); // go to bottom of screen
- clear_to_eol(); // erase to end of line
+ place_cursor(rows - 1, 0);
+ clear_to_eol();
}
//----- Erase from cursor to end of screen -----------------------
static void clear_to_eos(void)
{
- write1(Ceos); // Erase from cursor to end of screen
+ write1(ESC_CLEAR2EOS);
}
//----- Start standout mode ------------------------------------
-static void standout_start(void) // send "start reverse video" sequence
+static void standout_start(void)
{
- write1(SOs); // Start reverse video mode
+ write1(ESC_BOLD_TEXT);
}
//----- End standout mode --------------------------------------
-static void standout_end(void) // send "end reverse video" sequence
+static void standout_end(void)
{
- write1(SOn); // End reverse video mode
+ write1(ESC_NORM_TEXT);
}
//----- Flash the screen --------------------------------------
static void flash(int h)
{
- standout_start(); // send "start reverse video" sequence
+ standout_start();
redraw(TRUE);
mysleep(h);
- standout_end(); // send "end reverse video" sequence
+ standout_end();
redraw(TRUE);
}
@@ -2703,7 +2651,7 @@
return; // generate a random command
#endif
if (!err_method) {
- write1(bell); // send out a bell character
+ write1(ESC_BELL);
} else {
flash(10);
}
@@ -2749,7 +2697,7 @@
}
have_status_msg = 0;
}
- place_cursor(crow, ccol, FALSE); // put cursor back in correct place
+ place_cursor(crow, ccol); // put cursor back in correct place
}
fflush_all();
}
@@ -2761,12 +2709,12 @@
va_list args;
va_start(args, format);
- strcpy(status_buffer, SOs); // Terminal standout mode on
- vsprintf(status_buffer + sizeof(SOs)-1, format, args);
- strcat(status_buffer, SOn); // Terminal standout mode off
+ strcpy(status_buffer, ESC_BOLD_TEXT);
+ vsprintf(status_buffer + sizeof(ESC_BOLD_TEXT)-1, format, args);
+ strcat(status_buffer, ESC_NORM_TEXT);
va_end(args);
- have_status_msg = 1 + sizeof(SOs) + sizeof(SOn) - 2;
+ have_status_msg = 1 + sizeof(ESC_BOLD_TEXT) + sizeof(ESC_NORM_TEXT) - 2;
}
// format status buffer
@@ -2798,8 +2746,8 @@
c = *s;
c_is_no_print = (c & 0x80) && !Isprint(c);
if (c_is_no_print) {
- strcpy(d, SOn);
- d += sizeof(SOn)-1;
+ strcpy(d, ESC_NORM_TEXT);
+ d += sizeof(ESC_NORM_TEXT)-1;
c = '.';
}
if (c < ' ' || c == 0x7f) {
@@ -2811,8 +2759,8 @@
*d++ = c;
*d = '\0';
if (c_is_no_print) {
- strcpy(d, SOs);
- d += sizeof(SOs)-1;
+ strcpy(d, ESC_BOLD_TEXT);
+ d += sizeof(ESC_BOLD_TEXT)-1;
}
if (*s == '\n') {
*d++ = '$';
@@ -2894,8 +2842,8 @@
//----- Force refresh of all Lines -----------------------------
static void redraw(int full_screen)
{
- place_cursor(0, 0, FALSE); // put cursor in correct place
- clear_to_eos(); // tell terminal to erase display
+ place_cursor(0, 0);
+ clear_to_eos();
screen_erase(); // erase the internal screen buffer
last_status_cksum = 0; // force status update
refresh(full_screen); // this will redraw the entire display
@@ -3035,22 +2983,13 @@
if (changed) {
// copy changed part of buffer to virtual screen
memcpy(sp+cs, out_buf+cs, ce-cs+1);
-
- // move cursor to column of first change
- //if (offset != old_offset) {
- // // place_cursor is still too stupid
- // // to handle offsets correctly
- // place_cursor(li, cs, FALSE);
- //} else {
- place_cursor(li, cs, TRUE);
- //}
-
+ place_cursor(li, cs);
// write line out to terminal
fwrite(&sp[cs], ce - cs + 1, 1, stdout);
}
}
- place_cursor(crow, ccol, TRUE);
+ place_cursor(crow, ccol);
old_offset = offset;
#undef old_offset
@@ -3220,9 +3159,9 @@
break;
case 12: // ctrl-L force redraw whole screen
case 18: // ctrl-R force redraw
- place_cursor(0, 0, FALSE); // put cursor in correct place
- clear_to_eos(); // tel terminal to erase display
- mysleep(10);
+ place_cursor(0, 0);
+ clear_to_eos();
+ //mysleep(10); // why???
screen_erase(); // erase the internal screen buffer
last_status_cksum = 0; // force status update
refresh(TRUE); // this will redraw the entire display
@@ -4141,7 +4080,7 @@
if (msg[0]) {
printf("\n\n%d: \'%c\' %s\n\n\n%s[Hit return to continue]%s",
- totalcmds, last_input_char, msg, SOs, SOn);
+ totalcmds, last_input_char, msg, ESC_BOLD_TEXT, ESC_NORM_TEXT);
fflush_all();
while (safe_read(STDIN_FILENO, d, 1) > 0) {
if (d[0] == '\n' || d[0] == '\r')
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/examples/mdev.conf
^
|
@@ -7,8 +7,14 @@
# instead of the default 0:0 660.
#
# Syntax:
-# %s %d:%d %s
-# devicename_regex user:group mode
+# [-]devicename_regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
+# [-]$ENVVAR=regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
+# [-]@maj,min[-min2] user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
+#
+# [-]: do not stop on this match, continue reading mdev.conf
+# =: move, >: move and create a symlink
+# !: do not create device node
+# @|$|*: run@cmd if $ACTION=add, $cmd if $ACTION=remove, *cmd in all cases
null 0:0 666
zero 0:0 666
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/examples/mdev_fat.conf
^
|
@@ -7,10 +7,14 @@
# instead of the default 0:0 660.
#
# Syntax:
-# [-]devicename_regex user:group mode [>|=path] [@|$|*cmd args...]
+# [-]devicename_regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
+# [-]$ENVVAR=regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
+# [-]@maj,min[-min2] user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
#
+# [-]: do not stop on this match, continue reading mdev.conf
# =: move, >: move and create a symlink
-# @|$|*: run $cmd on delete, @cmd on create, *cmd on both
+# !: do not create device node
+# @|$|*: run cmd if $ACTION=remove, @cmd if $ACTION=add, *cmd in all cases
# support module loading on hotplug
$MODALIAS=.* root:root 660 @modprobe "$MODALIAS"
@@ -49,7 +53,6 @@
fd[0-9]* root:floppy 660
# net devices
--net/.* root:root 600 @nameif
tun[0-9]* root:root 600 =net/
tap[0-9]* root:root 600 =net/
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/findutils/find.c
^
|
@@ -728,10 +728,27 @@
int depth IF_NOT_FEATURE_FIND_MAXDEPTH(UNUSED_PARAM))
{
int r;
+ int same_fs = 1;
+
+#if ENABLE_FEATURE_FIND_XDEV
+ if (S_ISDIR(statbuf->st_mode) && G.xdev_count) {
+ int i;
+ for (i = 0; i < G.xdev_count; i++) {
+ if (G.xdev_dev[i] == statbuf->st_dev)
+ goto found;
+ }
+ //bb_error_msg("'%s': not same fs", fileName);
+ same_fs = 0;
+ found: ;
+ }
+#endif
#if ENABLE_FEATURE_FIND_MAXDEPTH
- if (depth < G.minmaxdepth[0])
- return TRUE; /* skip this, continue recursing */
+ if (depth < G.minmaxdepth[0]) {
+ if (same_fs)
+ return TRUE; /* skip this, continue recursing */
+ return SKIP; /* stop recursing */
+ }
if (depth > G.minmaxdepth[1])
return SKIP; /* stop recursing */
#endif
@@ -747,21 +764,11 @@
return SKIP;
}
#endif
-#if ENABLE_FEATURE_FIND_XDEV
/* -xdev stops on mountpoints, but AFTER mountpoit itself
* is processed as usual */
- if (S_ISDIR(statbuf->st_mode)) {
- if (G.xdev_count) {
- int i;
- for (i = 0; i < G.xdev_count; i++) {
- if (G.xdev_dev[i] == statbuf->st_dev)
- goto found;
- }
- return SKIP;
- found: ;
- }
+ if (!same_fs) {
+ return SKIP;
}
-#endif
/* Cannot return 0: our caller, recursive_action(),
* will perror() and skip dirs (if called on dir) */
@@ -871,8 +878,8 @@
IF_FEATURE_FIND_EXEC( "-exec\0" )
IF_FEATURE_FIND_PAREN( "(\0" )
/* All options/actions starting from here require argument */
- "-name\0"
- "-iname\0"
+ "-name\0"
+ "-iname\0"
IF_FEATURE_FIND_PATH( "-path\0" )
#if ENABLE_DESKTOP
IF_FEATURE_FIND_PATH( "-wholename\0")
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/findutils/grep.c
^
|
@@ -344,10 +344,34 @@
while (pattern_ptr) {
gl = (grep_list_data_t *)pattern_ptr->data;
if (FGREP_FLAG) {
- found |= (((option_mask32 & OPT_i)
- ? strcasestr(line, gl->pattern)
- : strstr(line, gl->pattern)
- ) != NULL);
+ char *match;
+ char *str = line;
+ opt_f_again:
+ match = ((option_mask32 & OPT_i)
+ ? strcasestr(str, gl->pattern)
+ : strstr(str, gl->pattern)
+ );
+ if (match) {
+ if (option_mask32 & OPT_x) {
+ if (match != str)
+ goto opt_f_not_found;
+ if (str[strlen(gl->pattern)] != '\0')
+ goto opt_f_not_found;
+ } else
+ if (option_mask32 & OPT_w) {
+ char c = (match != str) ? match[-1] : ' ';
+ if (!isalnum(c) && c != '_') {
+ c = match[strlen(gl->pattern)];
+ if (!c || (!isalnum(c) && c != '_'))
+ goto opt_f_found;
+ }
+ str = match + 1;
+ goto opt_f_again;
+ }
+ opt_f_found:
+ found = 1;
+ opt_f_not_found: ;
+ }
} else {
if (!(gl->flg_mem_alocated_compiled & COMPILED)) {
gl->flg_mem_alocated_compiled |= COMPILED;
@@ -376,7 +400,8 @@
if (option_mask32 & OPT_x) {
found = (gl->matched_range.rm_so == 0
&& line[gl->matched_range.rm_eo] == '\0');
- } else if (!(option_mask32 & OPT_w)) {
+ } else
+ if (!(option_mask32 & OPT_w)) {
found = 1;
} else {
char c = ' ';
@@ -387,6 +412,8 @@
if (!c || (!isalnum(c) && c != '_'))
found = 1;
}
+//BUG: "echo foop foo | grep -w foo" should match, but doesn't:
+//we bail out on first "mismatch" because it's not a word.
}
}
}
@@ -638,7 +665,7 @@
if (opts & OPT_C) {
/* -C unsets prev -A and -B, but following -A or -B
- may override it */
+ * may override it */
if (!(opts & OPT_A)) /* not overridden */
lines_after = Copt;
if (!(opts & OPT_B)) /* not overridden */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/include/applets.src.h
^
|
@@ -70,12 +70,12 @@
IF_TEST(APPLET_NOFORK([, test, BB_DIR_USR_BIN, BB_SUID_DROP, test))
IF_TEST(APPLET_NOFORK([[, test, BB_DIR_USR_BIN, BB_SUID_DROP, test))
IF_ACPID(APPLET(acpid, BB_DIR_SBIN, BB_SUID_DROP))
-IF_ADDGROUP(APPLET(addgroup, BB_DIR_BIN, BB_SUID_DROP))
-IF_ADDUSER(APPLET(adduser, BB_DIR_BIN, BB_SUID_DROP))
+IF_ADDGROUP(APPLET(addgroup, BB_DIR_USR_SBIN, BB_SUID_DROP))
+IF_ADDUSER(APPLET(adduser, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_ADJTIMEX(APPLET(adjtimex, BB_DIR_SBIN, BB_SUID_DROP))
IF_AR(APPLET(ar, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_ARP(APPLET(arp, BB_DIR_SBIN, BB_SUID_DROP))
-IF_ARPING(APPLET(arping, BB_DIR_USR_BIN, BB_SUID_DROP))
+IF_ARPING(APPLET(arping, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_AWK(APPLET_NOEXEC(awk, awk, BB_DIR_USR_BIN, BB_SUID_DROP, awk))
IF_BASENAME(APPLET_NOFORK(basename, basename, BB_DIR_USR_BIN, BB_SUID_DROP, basename))
IF_BBCONFIG(APPLET(bbconfig, BB_DIR_BIN, BB_SUID_DROP))
@@ -86,7 +86,7 @@
IF_CAL(APPLET(cal, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_CAT(APPLET_NOFORK(cat, cat, BB_DIR_BIN, BB_SUID_DROP, cat))
IF_CATV(APPLET(catv, BB_DIR_BIN, BB_SUID_DROP))
-IF_CHAT(APPLET(chat, BB_DIR_USR_BIN, BB_SUID_DROP))
+IF_CHAT(APPLET(chat, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_CHATTR(APPLET(chattr, BB_DIR_BIN, BB_SUID_DROP))
IF_CHCON(APPLET(chcon, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_CHGRP(APPLET_NOEXEC(chgrp, chgrp, BB_DIR_BIN, BB_SUID_DROP, chgrp))
@@ -111,8 +111,8 @@
IF_DC(APPLET(dc, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_DD(APPLET_NOEXEC(dd, dd, BB_DIR_BIN, BB_SUID_DROP, dd))
IF_DEALLOCVT(APPLET(deallocvt, BB_DIR_USR_BIN, BB_SUID_DROP))
-IF_DELGROUP(APPLET_ODDNAME(delgroup, deluser, BB_DIR_BIN, BB_SUID_DROP, delgroup))
-IF_DELUSER(APPLET(deluser, BB_DIR_BIN, BB_SUID_DROP))
+IF_DELGROUP(APPLET_ODDNAME(delgroup, deluser, BB_DIR_USR_SBIN, BB_SUID_DROP, delgroup))
+IF_DELUSER(APPLET(deluser, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_DEVFSD(APPLET(devfsd, BB_DIR_SBIN, BB_SUID_DROP))
IF_DEVMEM(APPLET(devmem, BB_DIR_SBIN, BB_SUID_DROP))
IF_DF(APPLET(df, BB_DIR_BIN, BB_SUID_DROP))
@@ -136,7 +136,7 @@
IF_ENV(APPLET_NOEXEC(env, env, BB_DIR_USR_BIN, BB_SUID_DROP, env))
IF_ENVDIR(APPLET_ODDNAME(envdir, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envdir))
IF_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envuidgid))
-IF_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, BB_DIR_USR_BIN, BB_SUID_DROP, ether_wake))
+IF_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, BB_DIR_USR_SBIN, BB_SUID_DROP, ether_wake))
IF_EXPAND(APPLET(expand, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_EXPR(APPLET(expr, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_FAKEIDENTD(APPLET(fakeidentd, BB_DIR_USR_SBIN, BB_SUID_DROP))
@@ -144,7 +144,7 @@
IF_FBSET(APPLET(fbset, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_FBSPLASH(APPLET(fbsplash, BB_DIR_SBIN, BB_SUID_DROP))
IF_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, BB_DIR_BIN, BB_SUID_DROP, fdflush))
-IF_FDFORMAT(APPLET(fdformat, BB_DIR_USR_BIN, BB_SUID_DROP))
+IF_FDFORMAT(APPLET(fdformat, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_FDISK(APPLET(fdisk, BB_DIR_SBIN, BB_SUID_DROP))
IF_FGCONSOLE(APPLET(fgconsole, BB_DIR_USR_BIN, BB_SUID_DROP))
/* Benefits from suid root: better access to /dev/BLOCKDEVs: */
@@ -182,7 +182,7 @@
IF_IFCONFIG(APPLET(ifconfig, BB_DIR_SBIN, BB_SUID_DROP))
IF_IFUPDOWN(APPLET_ODDNAME(ifdown, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifdown))
IF_IFENSLAVE(APPLET(ifenslave, BB_DIR_SBIN, BB_SUID_DROP))
-IF_IFPLUGD(APPLET(ifplugd, BB_DIR_USR_BIN, BB_SUID_DROP))
+IF_IFPLUGD(APPLET(ifplugd, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_IFUPDOWN(APPLET_ODDNAME(ifup, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifup))
IF_INETD(APPLET(inetd, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_INOTIFYD(APPLET(inotifyd, BB_DIR_SBIN, BB_SUID_DROP))
@@ -193,20 +193,20 @@
|| ENABLE_FEATURE_IP_LINK \
|| ENABLE_FEATURE_IP_TUNNEL \
|| ENABLE_FEATURE_IP_RULE
-IF_IP(APPLET(ip, BB_DIR_BIN, BB_SUID_DROP))
+IF_IP(APPLET(ip, BB_DIR_SBIN, BB_SUID_DROP))
#endif
-IF_IPADDR(APPLET(ipaddr, BB_DIR_BIN, BB_SUID_DROP))
+IF_IPADDR(APPLET(ipaddr, BB_DIR_SBIN, BB_SUID_DROP))
IF_IPCALC(APPLET(ipcalc, BB_DIR_BIN, BB_SUID_DROP))
IF_IPCRM(APPLET(ipcrm, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_IPCS(APPLET(ipcs, BB_DIR_USR_BIN, BB_SUID_DROP))
-IF_IPLINK(APPLET(iplink, BB_DIR_BIN, BB_SUID_DROP))
-IF_IPROUTE(APPLET(iproute, BB_DIR_BIN, BB_SUID_DROP))
-IF_IPRULE(APPLET(iprule, BB_DIR_BIN, BB_SUID_DROP))
-IF_IPTUNNEL(APPLET(iptunnel, BB_DIR_BIN, BB_SUID_DROP))
-IF_KBD_MODE(APPLET(kbd_mode, BB_DIR_USR_BIN, BB_SUID_DROP))
+IF_IPLINK(APPLET(iplink, BB_DIR_SBIN, BB_SUID_DROP))
+IF_IPROUTE(APPLET(iproute, BB_DIR_SBIN, BB_SUID_DROP))
+IF_IPRULE(APPLET(iprule, BB_DIR_SBIN, BB_SUID_DROP))
+IF_IPTUNNEL(APPLET(iptunnel, BB_DIR_SBIN, BB_SUID_DROP))
+IF_KBD_MODE(APPLET(kbd_mode, BB_DIR_BIN, BB_SUID_DROP))
IF_KILL(APPLET(kill, BB_DIR_BIN, BB_SUID_DROP))
IF_KILLALL(APPLET_ODDNAME(killall, kill, BB_DIR_USR_BIN, BB_SUID_DROP, killall))
-IF_KILLALL5(APPLET_ODDNAME(killall5, kill, BB_DIR_USR_BIN, BB_SUID_DROP, killall5))
+IF_KILLALL5(APPLET_ODDNAME(killall5, kill, BB_DIR_USR_SBIN, BB_SUID_DROP, killall5))
IF_KLOGD(APPLET(klogd, BB_DIR_SBIN, BB_SUID_DROP))
IF_LAST(APPLET(last, BB_DIR_USR_BIN, BB_SUID_DROP))
//IF_LENGTH(APPLET_NOFORK(length, length, BB_DIR_USR_BIN, BB_SUID_DROP, length))
@@ -288,7 +288,7 @@
IF_RAIDAUTORUN(APPLET(raidautorun, BB_DIR_SBIN, BB_SUID_DROP))
IF_RDATE(APPLET(rdate, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_RDEV(APPLET(rdev, BB_DIR_USR_SBIN, BB_SUID_DROP))
-IF_READAHEAD(APPLET(readahead, BB_DIR_USR_BIN, BB_SUID_DROP))
+IF_READAHEAD(APPLET(readahead, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_READLINK(APPLET(readlink, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_READPROFILE(APPLET(readprofile, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_REALPATH(APPLET(realpath, BB_DIR_USR_BIN, BB_SUID_DROP))
@@ -303,7 +303,7 @@
IF_ROUTE(APPLET(route, BB_DIR_SBIN, BB_SUID_DROP))
IF_RPM(APPLET(rpm, BB_DIR_BIN, BB_SUID_DROP))
IF_RPM2CPIO(APPLET(rpm2cpio, BB_DIR_USR_BIN, BB_SUID_DROP))
-IF_RTCWAKE(APPLET(rtcwake, BB_DIR_USR_BIN, BB_SUID_DROP))
+IF_RTCWAKE(APPLET(rtcwake, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_RUN_PARTS(APPLET_ODDNAME(run-parts, run_parts, BB_DIR_BIN, BB_SUID_DROP, run_parts))
IF_RUNCON(APPLET(runcon, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_RUNLEVEL(APPLET(runlevel, BB_DIR_SBIN, BB_SUID_DROP))
@@ -328,6 +328,7 @@
IF_SETSID(APPLET(setsid, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_SETUIDGID(APPLET_ODDNAME(setuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, setuidgid))
IF_SHA1SUM(APPLET_NOEXEC(sha1sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha1sum))
+IF_SHA3SUM(APPLET_NOEXEC(sha3sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha3sum))
IF_SHA256SUM(APPLET_NOEXEC(sha256sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha256sum))
IF_SHA512SUM(APPLET_NOEXEC(sha512sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha512sum))
IF_SHOWKEY(APPLET(showkey, BB_DIR_USR_BIN, BB_SUID_DROP))
@@ -365,7 +366,7 @@
IF_TEST(APPLET_NOFORK(test, test, BB_DIR_USR_BIN, BB_SUID_DROP, test))
#if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT
IF_TFTP(APPLET(tftp, BB_DIR_USR_BIN, BB_SUID_DROP))
-IF_TFTPD(APPLET(tftpd, BB_DIR_USR_BIN, BB_SUID_DROP))
+IF_TFTPD(APPLET(tftpd, BB_DIR_USR_SBIN, BB_SUID_DROP))
#endif
IF_TIME(APPLET(time, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_TIMEOUT(APPLET(timeout, BB_DIR_USR_BIN, BB_SUID_DROP))
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/include/bb_archive.h
^
|
@@ -121,6 +121,7 @@
#define ARCHIVE_DONT_RESTORE_PERM (1 << 6)
#define ARCHIVE_NUMERIC_OWNER (1 << 7)
#define ARCHIVE_O_TRUNC (1 << 8)
+#define ARCHIVE_REMEMBER_NAMES (1 << 9)
/* POSIX tar Header Block, from POSIX 1003.1-1990 */
@@ -219,9 +220,9 @@
char* append_ext(char *filename, const char *expected_ext) FAST_FUNC;
int bbunpack(char **argv,
- IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_aux_data_t *aux),
- char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext),
- const char *expected_ext
+ IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_aux_data_t *aux),
+ char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext),
+ const char *expected_ext
) FAST_FUNC;
void check_errors_in_children(int signo);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/include/bb_e2fs_defs.h
^
|
@@ -406,21 +406,21 @@
* Performance hints. Directory preallocation should only
* happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
*/
- uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
- uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
+ uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
+ uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */
/*
* Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
*/
- uint8_t s_journal_uuid[16]; /* uuid of journal superblock */
- uint32_t s_journal_inum; /* inode number of journal file */
+/*D0*/ uint8_t s_journal_uuid[16]; /* uuid of journal superblock */
+/*E0*/ uint32_t s_journal_inum; /* inode number of journal file */
uint32_t s_journal_dev; /* device number of journal file */
uint32_t s_last_orphan; /* start of list of inodes to delete */
uint32_t s_hash_seed[4]; /* HTREE hash seed */
uint8_t s_def_hash_version; /* Default hash version to use */
uint8_t s_jnl_backup_type; /* Default type of journal backup */
uint16_t s_reserved_word_pad;
- uint32_t s_default_mount_opts;
+/*100*/ uint32_t s_default_mount_opts;
uint32_t s_first_meta_bg; /* First metablock group */
/* ext3 additions */
uint32_t s_mkfs_time; /* When the filesystem was created */
@@ -481,6 +481,7 @@
#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
( EXT2_SB(sb)->s_feature_incompat & (mask) )
+/* for s_feature_compat */
#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
@@ -488,23 +489,45 @@
#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
+/* for s_feature_ro_compat */
#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
-/* #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 not used */
+#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 /* not used */
+#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
+#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
+#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
+#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
+/* for s_feature_incompat */
#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
-#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
-#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
+#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
+#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
-#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040
+#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040
+#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
+#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
+#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
#define EXT2_FEATURE_COMPAT_SUPP 0
-#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE)
#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
+#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
+ EXT2_FEATURE_INCOMPAT_META_BG)
+#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED (~EXT2_FEATURE_INCOMPAT_SUPP)
+#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED (~EXT2_FEATURE_RO_COMPAT_SUPP)
+
+#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
+ EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
+ EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
+#define EXT3_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
+ EXT3_FEATURE_INCOMPAT_RECOVER| \
+ EXT2_FEATURE_INCOMPAT_META_BG)
+#define EXT3_FEATURE_INCOMPAT_UNSUPPORTED (~EXT3_FEATURE_INCOMPAT_SUPP)
+#define EXT3_FEATURE_RO_COMPAT_UNSUPPORTED (~EXT3_FEATURE_RO_COMPAT_SUPP)
+
/*
* Default values for user and/or group using reserved blocks
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/include/busybox.h
^
|
@@ -13,10 +13,10 @@
/* Defined in appletlib.c (by including generated applet_tables.h) */
/* Keep in sync with applets/applet_tables.c! */
-extern const char applet_names[];
+extern const char applet_names[] ALIGN1;
extern int (*const applet_main[])(int argc, char **argv);
extern const uint16_t applet_nameofs[];
-extern const uint8_t applet_install_loc[];
+extern const uint8_t applet_install_loc[] ALIGN1;
#if ENABLE_FEATURE_SUID || ENABLE_FEATURE_PREFER_APPLETS
# define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x0fff))
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/include/grp_.h
^
|
@@ -64,7 +64,7 @@
/* Write the given entry onto the given stream. */
extern int putgrent(const struct group *__restrict __p,
- FILE *__restrict __f);
+ FILE *__restrict __f);
#endif
/* Search for an entry with a matching group ID. */
@@ -82,32 +82,32 @@
POSIX people would choose. */
extern int getgrent_r(struct group *__restrict __resultbuf,
- char *__restrict __buffer, size_t __buflen,
- struct group **__restrict __result);
+ char *__restrict __buffer, size_t __buflen,
+ struct group **__restrict __result);
/* Search for an entry with a matching group ID. */
extern int getgrgid_r(gid_t __gid, struct group *__restrict __resultbuf,
- char *__restrict __buffer, size_t __buflen,
- struct group **__restrict __result);
+ char *__restrict __buffer, size_t __buflen,
+ struct group **__restrict __result);
/* Search for an entry with a matching group name. */
extern int getgrnam_r(const char *__restrict __name,
- struct group *__restrict __resultbuf,
- char *__restrict __buffer, size_t __buflen,
- struct group **__restrict __result);
+ struct group *__restrict __resultbuf,
+ char *__restrict __buffer, size_t __buflen,
+ struct group **__restrict __result);
/* Read a group entry from STREAM. This function is not standardized
an probably never will. */
extern int fgetgrent_r(FILE *__restrict __stream,
- struct group *__restrict __resultbuf,
- char *__restrict __buffer, size_t __buflen,
- struct group **__restrict __result);
+ struct group *__restrict __resultbuf,
+ char *__restrict __buffer, size_t __buflen,
+ struct group **__restrict __result);
/* Store at most *NGROUPS members of the group set for USER into
*GROUPS. Also include GROUP. The actual number of groups found is
returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */
extern int getgrouplist(const char *__user, gid_t __group,
- gid_t *__groups, int *__ngroups);
+ gid_t *__groups, int *__ngroups);
/* Initialize the group set for the current user
by reading the group database and using all groups
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/include/libbb.h
^
|
@@ -333,6 +333,7 @@
FILEUTILS_PRESERVE_SECURITY_CONTEXT = 1 << 9, /* -c */
FILEUTILS_SET_SECURITY_CONTEXT = 1 << 10,
#endif
+ FILEUTILS_IGNORE_CHMOD_ERR = 1 << 11,
};
#define FILEUTILS_CP_OPTSTR "pdRfilsLH" IF_SELINUX("c")
extern int remove_file(const char *path, int flags) FAST_FUNC;
@@ -795,7 +796,6 @@
int safe_poll(struct pollfd *ufds, nfds_t nfds, int timeout_ms) FAST_FUNC;
char *safe_gethostname(void) FAST_FUNC;
-char *safe_getdomainname(void) FAST_FUNC;
/* Convert each alpha char in str to lower-case */
char* str_tolower(char *str) FAST_FUNC;
@@ -1248,7 +1248,7 @@
* Note that getpwuid result might need xstrdup'ing
* if there is a possibility of intervening getpwxxx() calls.
*/
-const char *get_shell_name(void);
+const char *get_shell_name(void) FAST_FUNC;
#if ENABLE_SELINUX
extern void renew_current_security_context(void) FAST_FUNC;
@@ -1286,6 +1286,7 @@
#define SETUP_ENV_CHANGEENV (1 << 0)
#define SETUP_ENV_CLEARENV (1 << 1)
#define SETUP_ENV_TO_TMP (1 << 2)
+#define SETUP_ENV_NO_CHDIR (1 << 4)
extern void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC;
extern int correct_password(const struct passwd *pw) FAST_FUNC;
/* Returns a malloced string */
@@ -1515,7 +1516,7 @@
procps_read_smaps(pid, total)
#endif
int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total,
- void (*cb)(struct smaprec *, void *), void *data);
+ void (*cb)(struct smaprec *, void *), void *data);
typedef struct procps_status_t {
DIR *dir;
@@ -1611,8 +1612,8 @@
char *percent_decode_in_place(char *str, int strict) FAST_FUNC;
-extern const char bb_uuenc_tbl_base64[];
-extern const char bb_uuenc_tbl_std[];
+extern const char bb_uuenc_tbl_base64[] 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,
@@ -1635,8 +1636,12 @@
uint64_t hash[8];
uint8_t wbuffer[128]; /* always correctly aligned for uint64_t */
} sha512_ctx_t;
+typedef struct sha3_ctx_t {
+ uint64_t state[25];
+ unsigned bytes_queued;
+} sha3_ctx_t;
void md5_begin(md5_ctx_t *ctx) FAST_FUNC;
-void md5_hash(md5_ctx_t *ctx, const void *data, size_t length) FAST_FUNC;
+void md5_hash(md5_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC;
void md5_end(md5_ctx_t *ctx, void *resbuf) FAST_FUNC;
void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC;
#define sha1_hash md5_hash
@@ -1647,6 +1652,9 @@
void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC;
void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC;
void sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC;
+void sha3_begin(sha3_ctx_t *ctx) FAST_FUNC;
+void sha3_hash(sha3_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC;
+void sha3_end(sha3_ctx_t *ctx, void *resbuf) FAST_FUNC;
extern uint32_t *global_crc32_table;
uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC;
@@ -1693,24 +1701,24 @@
* Therefore now we use #defines.
*/
/* "BusyBox vN.N.N (timestamp or extra_version)" */
-extern const char bb_banner[];
-extern const char bb_msg_memory_exhausted[];
-extern const char bb_msg_invalid_date[];
+extern const char bb_banner[] ALIGN1;
+extern const char bb_msg_memory_exhausted[] ALIGN1;
+extern const char bb_msg_invalid_date[] ALIGN1;
#define bb_msg_read_error "read error"
#define bb_msg_write_error "write error"
-extern const char bb_msg_unknown[];
-extern const char bb_msg_can_not_create_raw_socket[];
-extern const char bb_msg_perm_denied_are_you_root[];
-extern const char bb_msg_you_must_be_root[];
-extern const char bb_msg_requires_arg[];
-extern const char bb_msg_invalid_arg[];
-extern const char bb_msg_standard_input[];
-extern const char bb_msg_standard_output[];
+extern const char bb_msg_unknown[] ALIGN1;
+extern const char bb_msg_can_not_create_raw_socket[] ALIGN1;
+extern const char bb_msg_perm_denied_are_you_root[] ALIGN1;
+extern const char bb_msg_you_must_be_root[] ALIGN1;
+extern const char bb_msg_requires_arg[] ALIGN1;
+extern const char bb_msg_invalid_arg[] ALIGN1;
+extern const char bb_msg_standard_input[] ALIGN1;
+extern const char bb_msg_standard_output[] ALIGN1;
/* NB: (bb_hexdigits_upcase[i] | 0x20) -> lowercase hex digit */
-extern const char bb_hexdigits_upcase[];
+extern const char bb_hexdigits_upcase[] ALIGN1;
-extern const char bb_path_wtmp_file[];
+extern const char bb_path_wtmp_file[] ALIGN1;
/* Busybox mount uses either /proc/mounts or /etc/mtab to
* get the list of currently mounted filesystems */
@@ -1724,10 +1732,10 @@
#define bb_path_motd_file "/etc/motd"
#define bb_dev_null "/dev/null"
-extern const char bb_busybox_exec_path[];
+extern const char bb_busybox_exec_path[] ALIGN1;
/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin,
* but I want to save a few bytes here */
-extern const char bb_PATH_root_path[]; /* "PATH=/sbin:/usr/sbin:/bin:/usr/bin" */
+extern const char bb_PATH_root_path[] ALIGN1; /* "PATH=/sbin:/usr/sbin:/bin:/usr/bin" */
#define bb_default_root_path (bb_PATH_root_path + sizeof("PATH"))
#define bb_default_path (bb_PATH_root_path + sizeof("PATH=/sbin:/usr/sbin"))
@@ -1757,7 +1765,7 @@
* If you change LIBBB_DEFAULT_LOGIN_SHELL,
* don't forget to change increment constant. */
#define LIBBB_DEFAULT_LOGIN_SHELL "-/bin/sh"
-extern const char bb_default_login_shell[];
+extern const char bb_default_login_shell[] ALIGN1;
/* "/bin/sh" */
#define DEFAULT_SHELL (bb_default_login_shell+1)
/* "sh" */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/include/platform.h
^
|
@@ -205,6 +205,7 @@
#include <stdint.h>
typedef int bb__aliased_int FIX_ALIASING;
+typedef long bb__aliased_long FIX_ALIASING;
typedef uint16_t bb__aliased_uint16_t FIX_ALIASING;
typedef uint32_t bb__aliased_uint32_t FIX_ALIASING;
@@ -212,7 +213,8 @@
* a lvalue. This makes it more likely to not swap them by mistake
*/
#if defined(i386) || defined(__x86_64__) || defined(__powerpc__)
-# define move_from_unaligned_int(v, intp) ((v) = *(bb__aliased_int*)(intp))
+# define move_from_unaligned_int(v, intp) ((v) = *(bb__aliased_int*)(intp))
+# define move_from_unaligned_long(v, longp) ((v) = *(bb__aliased_long*)(longp))
# define move_from_unaligned16(v, u16p) ((v) = *(bb__aliased_uint16_t*)(u16p))
# define move_from_unaligned32(v, u32p) ((v) = *(bb__aliased_uint32_t*)(u32p))
# define move_to_unaligned16(u16p, v) (*(bb__aliased_uint16_t*)(u16p) = (v))
@@ -221,6 +223,7 @@
#else
/* performs reasonably well (gcc usually inlines memcpy here) */
# define move_from_unaligned_int(v, intp) (memcpy(&(v), (intp), sizeof(int)))
+# define move_from_unaligned_long(v, longp) (memcpy(&(v), (longp), sizeof(long)))
# define move_from_unaligned16(v, u16p) (memcpy(&(v), (u16p), 2))
# define move_from_unaligned32(v, u32p) (memcpy(&(v), (u32p), 4))
# define move_to_unaligned16(u16p, v) do { \
@@ -284,7 +287,8 @@
#define fdprintf dprintf
/* Useful for defeating gcc's alignment of "char message[]"-like data */
-#if 1 /* if needed: !defined(arch1) && !defined(arch2) */
+#if !defined(__s390__)
+ /* on s390[x], non-word-aligned data accesses require larger code */
# define ALIGN1 __attribute__((aligned(1)))
# define ALIGN2 __attribute__((aligned(2)))
# define ALIGN4 __attribute__((aligned(4)))
@@ -334,6 +338,12 @@
# define MAXSYMLINKS SYMLOOP_MAX
#endif
+#if defined(ANDROID) || defined(__ANDROID__)
+# define BB_ADDITIONAL_PATH ":/system/sbin:/system/bin:/system/xbin"
+# define SYS_ioprio_set __NR_ioprio_set
+# define SYS_ioprio_get __NR_ioprio_get
+#endif
+
/* ---- Who misses what? ------------------------------------ */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/include/pwd_.h
^
|
@@ -63,7 +63,7 @@
/* Write the given entry onto the given stream. */
extern int putpwent(const struct passwd *__restrict __p,
- FILE *__restrict __f);
+ FILE *__restrict __f);
#endif
/* Search for an entry with a matching user ID. */
@@ -81,25 +81,25 @@
POSIX people would choose. */
extern int getpwent_r(struct passwd *__restrict __resultbuf,
- char *__restrict __buffer, size_t __buflen,
- struct passwd **__restrict __result);
+ char *__restrict __buffer, size_t __buflen,
+ struct passwd **__restrict __result);
extern int getpwuid_r(uid_t __uid,
- struct passwd *__restrict __resultbuf,
- char *__restrict __buffer, size_t __buflen,
- struct passwd **__restrict __result);
+ struct passwd *__restrict __resultbuf,
+ char *__restrict __buffer, size_t __buflen,
+ struct passwd **__restrict __result);
extern int getpwnam_r(const char *__restrict __name,
- struct passwd *__restrict __resultbuf,
- char *__restrict __buffer, size_t __buflen,
- struct passwd **__restrict __result);
+ struct passwd *__restrict __resultbuf,
+ char *__restrict __buffer, size_t __buflen,
+ struct passwd **__restrict __result);
/* Read an entry from STREAM. This function is not standardized and
probably never will. */
extern int fgetpwent_r(FILE *__restrict __stream,
- struct passwd *__restrict __resultbuf,
- char *__restrict __buffer, size_t __buflen,
- struct passwd **__restrict __result);
+ struct passwd *__restrict __resultbuf,
+ char *__restrict __buffer, size_t __buflen,
+ struct passwd **__restrict __result);
POP_SAVED_FUNCTION_VISIBILITY
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/include/shadow_.h
^
|
@@ -79,21 +79,21 @@
/* Reentrant versions of some of the functions above */
extern int getspent_r(struct spwd *__result_buf, char *__buffer,
- size_t __buflen, struct spwd **__result);
+ size_t __buflen, struct spwd **__result);
#endif
extern int getspnam_r(const char *__name, struct spwd *__result_buf,
- char *__buffer, size_t __buflen,
- struct spwd **__result);
+ char *__buffer, size_t __buflen,
+ struct spwd **__result);
#ifdef UNUSED_FOR_NOW
extern int sgetspent_r(const char *__string, struct spwd *__result_buf,
- char *__buffer, size_t __buflen,
- struct spwd **__result);
+ char *__buffer, size_t __buflen,
+ struct spwd **__result);
extern int fgetspent_r(FILE *__stream, struct spwd *__result_buf,
- char *__buffer, size_t __buflen,
- struct spwd **__result);
+ char *__buffer, size_t __buflen,
+ struct spwd **__result);
/* Protect password file against multi writers */
extern int lckpwdf(void);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/init/init.c
^
|
@@ -520,7 +520,7 @@
/* Log the process name and args */
message(L_LOG, "starting pid %d, tty '%s': '%s'",
- getpid(), a->terminal, a->command);
+ getpid(), a->terminal, a->command);
/* Now run it. The new program will take over this PID,
* so nothing further in init.c should be run. */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/Config.src
^
|
@@ -28,6 +28,16 @@
2 3.0 5088
3 (smallest) 5.1 4912
+config SHA3_SMALL
+ int "SHA3: Trade bytes for speed (0:fast, 1:slow)"
+ default 1
+ range 0 1
+ help
+ Trade binary size versus speed for the sha3sum algorithm.
+ SHA3_SMALL=0 compared to SHA3_SMALL=1 (approximate):
+ 64-bit x86: +270 bytes of code, 45% faster
+ 32-bit x86: +450 bytes of code, 75% faster
+
config FEATURE_FAST_TOP
bool "Faster /proc scanning code (+100 bytes)"
default y
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/appletlib.c
^
|
@@ -140,10 +140,9 @@
}
#if NUM_APPLETS > 8
-/* NB: any char pointer will work as well, not necessarily applet_names */
-static int applet_name_compare(const void *name, const void *v)
+static int applet_name_compare(const void *name, const void *idx)
{
- int i = (const char *)v - applet_names;
+ int i = (int)(ptrdiff_t)idx - 1;
return strcmp(name, APPLET_NAME(i));
}
#endif
@@ -152,10 +151,12 @@
#if NUM_APPLETS > 8
/* Do a binary search to find the applet entry given the name. */
const char *p;
- p = bsearch(name, applet_names, ARRAY_SIZE(applet_main), 1, applet_name_compare);
- if (!p)
- return -1;
- return p - applet_names;
+ p = bsearch(name, (void*)(ptrdiff_t)1, ARRAY_SIZE(applet_main), 1, applet_name_compare);
+ /*
+ * if (!p) return -1;
+ * ^^^^^^^^^^^^^^^^^^ the code below will do this if p == NULL :)
+ */
+ return (int)(ptrdiff_t)p - 1;
#else
/* A version which does not pull in bsearch */
int i = 0;
@@ -627,11 +628,11 @@
full_write2_str(bb_banner); /* reuse const string */
full_write2_str(" multi-call binary.\n"); /* reuse */
full_write2_str(
- "Copyright (C) 1998-2011 Erik Andersen, Rob Landley, Denys Vlasenko\n"
- "and others. Licensed under GPLv2.\n"
- "See source distribution for full notice.\n"
+ "BusyBox is copyrighted by many authors between 1998-2012.\n"
+ "Licensed under GPLv2. See source distribution for detailed\n"
+ "copyright notices.\n"
"\n"
- "Usage: busybox [function] [arguments]...\n"
+ "Usage: busybox [function [arguments]...]\n"
" or: busybox --list"IF_FEATURE_INSTALLER("[-full]")"\n"
IF_FEATURE_INSTALLER(
" or: busybox --install [-s] [DIR]\n"
@@ -747,8 +748,11 @@
/* Special case. POSIX says "test --help"
* should be no different from e.g. "test --foo". */
//TODO: just compare applet_no with APPLET_NO_test
- if (!ENABLE_TEST || strcmp(applet_name, "test") != 0)
+ if (!ENABLE_TEST || strcmp(applet_name, "test") != 0) {
+ /* If you want "foo --help" to return 0: */
+ /*xfunc_error_retval = 0;*/
bb_show_usage();
+ }
}
if (ENABLE_FEATURE_SUID)
check_suid(applet_no);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/correct_password.c
^
|
@@ -41,12 +41,6 @@
char *unencrypted, *encrypted;
const char *correct;
int r;
-#if ENABLE_FEATURE_SHADOWPASSWDS
- /* Using _r function to avoid pulling in static buffers */
- struct spwd spw;
- char buffer[256];
-#endif
-
/* fake salt. crypt() can choke otherwise. */
correct = "aa";
if (!pw) {
@@ -55,7 +49,10 @@
}
correct = pw->pw_passwd;
#if ENABLE_FEATURE_SHADOWPASSWDS
+ /* Using _r function to avoid pulling in static buffers */
if ((correct[0] == 'x' || correct[0] == '*') && !correct[1]) {
+ struct spwd spw;
+ char buffer[256];
/* getspnam_r may return 0 yet set result to NULL.
* At least glibc 2.4 does this. Be extra paranoid here. */
struct spwd *result = NULL;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/get_shell_name.c
^
|
@@ -8,7 +8,7 @@
#include "libbb.h"
-const char *get_shell_name(void)
+const char* FAST_FUNC get_shell_name(void)
{
struct passwd *pw;
char *shell;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/hash_md5_sha.c
^
|
@@ -31,6 +31,11 @@
return (x >> n) | (x << (64 - n));
}
+/* rotl64 only used for sha3 currently */
+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
@@ -51,7 +56,7 @@
len -= remaining;
buffer = (const char *)buffer + remaining;
bufpos += remaining;
- /* clever way to do "if (bufpos != 64) break; ... ; bufpos = 0;" */
+ /* Clever way to do "if (bufpos != N) break; ... ; bufpos = 0;" */
bufpos -= 64;
if (bufpos != 0)
break;
@@ -185,10 +190,9 @@
int i;
uint32_t temp;
-# if BB_BIG_ENDIAN
- for (i = 0; i < 16; i++)
- words[i] = SWAP_LE32(words[i]);
-# endif
+ if (BB_BIG_ENDIAN)
+ for (i = 0; i < 16; i++)
+ words[i] = SWAP_LE32(words[i]);
# if MD5_SMALL == 3
pc = C_array;
@@ -462,12 +466,13 @@
common64_end(ctx, /*swap_needed:*/ BB_BIG_ENDIAN);
/* The MD5 result is in little endian byte order */
-#if BB_BIG_ENDIAN
- ctx->hash[0] = SWAP_LE32(ctx->hash[0]);
- ctx->hash[1] = SWAP_LE32(ctx->hash[1]);
- ctx->hash[2] = SWAP_LE32(ctx->hash[2]);
- ctx->hash[3] = SWAP_LE32(ctx->hash[3]);
-#endif
+ if (BB_BIG_ENDIAN) {
+ ctx->hash[0] = SWAP_LE32(ctx->hash[0]);
+ ctx->hash[1] = SWAP_LE32(ctx->hash[1]);
+ ctx->hash[2] = SWAP_LE32(ctx->hash[2]);
+ ctx->hash[3] = SWAP_LE32(ctx->hash[3]);
+ }
+
memcpy(resbuf, ctx->hash, sizeof(ctx->hash[0]) * 4);
}
@@ -834,7 +839,7 @@
len -= remaining;
buffer = (const char *)buffer + remaining;
bufpos += remaining;
- /* clever way to do "if (bufpos != 128) break; ... ; bufpos = 0;" */
+ /* Clever way to do "if (bufpos != N) break; ... ; bufpos = 0;" */
bufpos -= 128;
if (bufpos != 0)
break;
@@ -896,3 +901,268 @@
}
memcpy(resbuf, ctx->hash, sizeof(ctx->hash));
}
+
+
+/*
+ * The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
+ * Michael Peeters and Gilles Van Assche. For more information, feedback or
+ * questions, please refer to our website: http://keccak.noekeon.org/
+ *
+ * Implementation by Ronny Van Keer,
+ * hereby denoted as "the implementer".
+ *
+ * To the extent possible under law, the implementer has waived all copyright
+ * and related or neighboring rights to the source code in this file.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ *
+ * Busybox modifications (C) Lauri Kasanen, under the GPLv2.
+ */
+
+#if CONFIG_SHA3_SMALL < 0
+# define SHA3_SMALL 0
+#elif CONFIG_SHA3_SMALL > 1
+# define SHA3_SMALL 1
+#else
+# define SHA3_SMALL CONFIG_SHA3_SMALL
+#endif
+
+enum {
+ SHA3_IBLK_BYTES = 72, /* 576 bits / 8 */
+};
+
+/*
+ * In the crypto literature this function is usually called Keccak-f().
+ */
+static void sha3_process_block72(uint64_t *state)
+{
+ enum { NROUNDS = 24 };
+
+ /* 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 instead of 64-bit.
+ * The speed penalty is lost in the noise.
+ */
+ static const uint16_t IOTA_CONST[NROUNDS] = {
+ 0x0001,
+ 0x8082,
+ 0x808a,
+ 0x8000,
+ 0x808b,
+ 0x0001,
+ 0x8081,
+ 0x8009,
+ 0x008a,
+ 0x0088,
+ 0x8009,
+ 0x000a,
+ 0x808b,
+ 0x008b,
+ 0x8089,
+ 0x8003,
+ 0x8002,
+ 0x0080,
+ 0x800a,
+ 0x000a,
+ 0x8081,
+ 0x8080,
+ 0x0001,
+ 0x8008,
+ };
+ /* bit for CONST[0] is in msb: 0011 0011 0000 0111 1101 1101 */
+ const uint32_t IOTA_CONST_bit63 = (uint32_t)(0x3307dd00);
+ /* 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] = {
+ 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] = {
+ 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, };*/
+
+ unsigned x, y;
+ unsigned round;
+
+ if (BB_BIG_ENDIAN) {
+ for (x = 0; x < 25; x++) {
+ state[x] = SWAP_LE64(state[x]);
+ }
+ }
+
+ for (round = 0; round < NROUNDS; ++round) {
+ /* Theta */
+ {
+ uint64_t BC[10];
+ for (x = 0; x < 5; ++x) {
+ BC[x + 5] = BC[x] = state[x]
+ ^ state[x + 5] ^ state[x + 10]
+ ^ state[x + 15] ^ state[x + 20];
+ }
+ /* Using 2x5 vector above eliminates the need to use
+ * BC[MOD5[x+N]] trick below to fetch BC[(x+N) % 5],
+ * and the code is a bit _smaller_.
+ */
+ for (x = 0; x < 5; ++x) {
+ uint64_t temp = BC[x + 4] ^ rotl64(BC[x + 1], 1);
+ state[x] ^= temp;
+ state[x + 5] ^= temp;
+ state[x + 10] ^= temp;
+ state[x + 15] ^= temp;
+ state[x + 20] ^= temp;
+ }
+ }
+
+ /* Rho Pi */
+ if (SHA3_SMALL) {
+ uint64_t t1 = state[1];
+ for (x = 0; x < 24; ++x) {
+ uint64_t t0 = state[PI_LANE[x]];
+ state[PI_LANE[x]] = rotl64(t1, ROT_CONST[x]);
+ t1 = t0;
+ }
+ } else {
+ /* Especially large benefit for 32-bit arch (75% faster):
+ * 64-bit rotations by non-constant usually are SLOW on those.
+ * We resort to unrolling here.
+ * This optimizes out PI_LANE[] and ROT_CONST[],
+ * but generates 300-500 more bytes of code.
+ */
+ uint64_t t0;
+ uint64_t t1 = state[1];
+#define RhoPi_twice(x) \
+ t0 = state[PI_LANE[x ]]; \
+ state[PI_LANE[x ]] = rotl64(t1, ROT_CONST[x ]); \
+ t1 = state[PI_LANE[x+1]]; \
+ state[PI_LANE[x+1]] = rotl64(t0, ROT_CONST[x+1]);
+ RhoPi_twice(0); RhoPi_twice(2);
+ RhoPi_twice(4); RhoPi_twice(6);
+ RhoPi_twice(8); RhoPi_twice(10);
+ RhoPi_twice(12); RhoPi_twice(14);
+ RhoPi_twice(16); RhoPi_twice(18);
+ RhoPi_twice(20); RhoPi_twice(22);
+#undef RhoPi_twice
+ }
+
+ /* Chi */
+ for (y = 0; y <= 20; y += 5) {
+ uint64_t BC0, BC1, BC2, BC3, BC4;
+ BC0 = state[y + 0];
+ BC1 = state[y + 1];
+ BC2 = state[y + 2];
+ state[y + 0] = BC0 ^ ((~BC1) & BC2);
+ BC3 = state[y + 3];
+ state[y + 1] = BC1 ^ ((~BC2) & BC3);
+ BC4 = state[y + 4];
+ state[y + 2] = BC2 ^ ((~BC3) & BC4);
+ state[y + 3] = BC3 ^ ((~BC4) & BC0);
+ state[y + 4] = BC4 ^ ((~BC0) & BC1);
+ }
+
+ /* Iota */
+ state[0] ^= IOTA_CONST[round]
+ | (uint32_t)((IOTA_CONST_bit31 << round) & 0x80000000)
+ | (uint64_t)((IOTA_CONST_bit63 << round) & 0x80000000) << 32;
+ }
+
+ if (BB_BIG_ENDIAN) {
+ for (x = 0; x < 25; x++) {
+ state[x] = SWAP_LE64(state[x]);
+ }
+ }
+}
+
+void FAST_FUNC sha3_begin(sha3_ctx_t *ctx)
+{
+ memset(ctx, 0, sizeof(*ctx));
+}
+
+void FAST_FUNC sha3_hash(sha3_ctx_t *ctx, const void *buffer, size_t len)
+{
+#if SHA3_SMALL
+ const uint8_t *data = buffer;
+ unsigned bufpos = ctx->bytes_queued;
+
+ while (1) {
+ unsigned remaining = SHA3_IBLK_BYTES - bufpos;
+ if (remaining > len)
+ remaining = len;
+ len -= remaining;
+ /* XOR data into buffer */
+ while (remaining != 0) {
+ uint8_t *buf = (uint8_t*)ctx->state;
+ buf[bufpos] ^= *data++;
+ bufpos++;
+ remaining--;
+ }
+ /* Clever way to do "if (bufpos != N) break; ... ; bufpos = 0;" */
+ bufpos -= SHA3_IBLK_BYTES;
+ if (bufpos != 0)
+ break;
+ /* Buffer is filled up, process it */
+ sha3_process_block72(ctx->state);
+ /*bufpos = 0; - already is */
+ }
+ ctx->bytes_queued = bufpos + SHA3_IBLK_BYTES;
+#else
+ /* +50 bytes code size, but a bit faster because of long-sized XORs */
+ const uint8_t *data = buffer;
+ unsigned bufpos = ctx->bytes_queued;
+
+ /* If already data in queue, continue queuing first */
+ while (len != 0 && bufpos != 0) {
+ uint8_t *buf = (uint8_t*)ctx->state;
+ buf[bufpos] ^= *data++;
+ len--;
+ bufpos++;
+ if (bufpos == SHA3_IBLK_BYTES) {
+ bufpos = 0;
+ goto do_block;
+ }
+ }
+
+ /* Absorb complete blocks */
+ while (len >= SHA3_IBLK_BYTES) {
+ /* XOR data onto beginning of state[].
+ * We try to be efficient - operate one word at a time, not byte.
+ * Careful wrt unaligned access: can't just use "*(long*)data"!
+ */
+ unsigned count = SHA3_IBLK_BYTES / sizeof(long);
+ long *buf = (long*)ctx->state;
+ do {
+ long v;
+ move_from_unaligned_long(v, (long*)data);
+ *buf++ ^= v;
+ data += sizeof(long);
+ } while (--count);
+ len -= SHA3_IBLK_BYTES;
+ do_block:
+ sha3_process_block72(ctx->state);
+ }
+
+ /* Queue remaining data bytes */
+ while (len != 0) {
+ uint8_t *buf = (uint8_t*)ctx->state;
+ buf[bufpos] ^= *data++;
+ bufpos++;
+ len--;
+ }
+
+ ctx->bytes_queued = bufpos;
+#endif
+}
+
+void FAST_FUNC sha3_end(sha3_ctx_t *ctx, void *resbuf)
+{
+ /* Padding */
+ uint8_t *buf = (uint8_t*)ctx->state;
+ buf[ctx->bytes_queued] ^= 1;
+ buf[SHA3_IBLK_BYTES - 1] ^= 0x80;
+
+ sha3_process_block72(ctx->state);
+
+ /* Output */
+ memcpy(resbuf, ctx->state, 64);
+}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/inet_common.c
^
|
@@ -97,7 +97,7 @@
if (s_in->sin_family != AF_INET) {
#ifdef DEBUG
bb_error_msg("rresolve: unsupported address family %d!",
- s_in->sin_family);
+ s_in->sin_family);
#endif
errno = EAFNOSUPPORT;
return NULL;
@@ -195,7 +195,7 @@
if (sin6->sin6_family != AF_INET6) {
#ifdef DEBUG
bb_error_msg("rresolve: unsupported address family %d!",
- sin6->sin6_family);
+ sin6->sin6_family);
#endif
errno = EAFNOSUPPORT;
return NULL;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/kernel_version.c
^
|
@@ -20,18 +20,15 @@
int FAST_FUNC get_linux_version_code(void)
{
struct utsname name;
- char *s;
+ char *s, *t;
int i, r;
- if (uname(&name) == -1) {
- bb_perror_msg("can't get system information");
- return 0;
- }
-
+ uname(&name); /* never fails */
s = name.release;
r = 0;
for (i = 0; i < 3; i++) {
- r = r * 256 + atoi(strtok(s, "."));
+ t = strtok(s, ".");
+ r = r * 256 + (t ? atoi(t) : 0);
s = NULL;
}
return r;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/lineedit.c
^
|
@@ -2527,9 +2527,9 @@
/* Delete word forward */
int nc, sc = cursor;
ctrl_right();
- nc = cursor;
- input_backward(cursor - sc);
- while (--nc >= cursor)
+ nc = cursor - sc;
+ input_backward(nc);
+ while (--nc >= 0)
input_delete(1);
break;
}
@@ -2729,7 +2729,8 @@
{
fputs(prompt, stdout);
fflush_all();
- fgets(command, maxsize, stdin);
+ if (!fgets(command, maxsize, stdin))
+ return -1;
return strlen(command);
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/loop.c
^
|
@@ -150,9 +150,9 @@
}
/* If this block device already set up right, re-use it.
- (Yes this is racy, but associating two loop devices with the same
- file isn't pretty either. In general, mounting the same file twice
- without using losetup manually is problematic.)
+ * (Yes this is racy, but associating two loop devices with the same
+ * file isn't pretty either. In general, mounting the same file twice
+ * without using losetup manually is problematic.)
*/
} else
if (strcmp(file, (char *)loopinfo.lo_file_name) != 0
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/make_directory.c
^
|
@@ -107,6 +107,10 @@
* an error. */
if ((mode != -1) && (chmod(path, mode) < 0)) {
fail_msg = "set permissions of";
+ if (flags & FILEUTILS_IGNORE_CHMOD_ERR) {
+ flags = 0;
+ goto print_err;
+ }
break;
}
goto ret0;
@@ -116,8 +120,9 @@
*s = c;
} /* while (1) */
- bb_perror_msg("can't %s directory '%s'", fail_msg, path);
flags = -1;
+ print_err:
+ bb_perror_msg("can't %s directory '%s'", fail_msg, path);
goto ret;
ret0:
flags = 0;
|
[-]
[+]
|
Added |
busybox-1.21.0.tar.bz2/libbb/missing_syscalls.c
^
|
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2012, Denys Vlasenko
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+
+//kbuild:lib-y += missing_syscalls.o
+
+/*#include <linux/timex.h> - for struct timex, but may collide with <time.h> */
+#include <sys/syscall.h>
+#include "libbb.h"
+
+#if defined(ANDROID) || defined(__ANDROID__)
+pid_t getsid(pid_t pid)
+{
+ return syscall(__NR_getsid, pid);
+}
+
+int stime(const time_t *t)
+{
+ struct timeval tv;
+ tv.tv_sec = *t;
+ tv.tv_usec = 0;
+ return settimeofday(&tv, NULL);
+}
+
+int sethostname(const char *name, size_t len)
+{
+ return syscall(__NR_sethostname, name, len);
+}
+
+struct timex;
+int adjtimex(struct timex *buf)
+{
+ return syscall(__NR_adjtimex, buf);
+}
+
+int pivot_root(const char *new_root, const char *put_old)
+{
+ return syscall(__NR_pivot_root, new_root, put_old);
+}
+#endif
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/procps.c
^
|
@@ -180,7 +180,7 @@
#if ENABLE_FEATURE_TOPMEM || ENABLE_PMAP
int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total,
- void (*cb)(struct smaprec *, void *), void *data)
+ void (*cb)(struct smaprec *, void *), void *data)
{
FILE *file;
struct smaprec currec;
@@ -425,7 +425,7 @@
if (n < 11)
continue; /* bogus data, get next /proc/XXX */
# if ENABLE_FEATURE_TOP_SMP_PROCESS
- if (n < 11+15)
+ if (n == 11)
sp->last_seen_on_cpu = 0;
# endif
@@ -583,6 +583,8 @@
buf[sz] = '\0';
while (--sz >= 0 && buf[sz] == '\0')
continue;
+ /* Prevent basename("process foo/bar") = "bar" */
+ strchrnul(buf, ' ')[0] = '\0';
base = bb_basename(buf); /* before we replace argv0's NUL with space */
while (sz >= 0) {
if ((unsigned char)(buf[sz]) < ' ')
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/read_key.c
^
|
@@ -15,7 +15,10 @@
const char *seq;
int n;
- /* Known escape sequences for cursor and function keys */
+ /* Known escape sequences for cursor and function keys.
+ * See "Xterm Control Sequences"
+ * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+ */
static const char esccmds[] ALIGN1 = {
'O','A' |0x80,KEYCODE_UP ,
'O','B' |0x80,KEYCODE_DOWN ,
@@ -44,6 +47,8 @@
/* ESC [ 1 ; 4 x, where x = A/B/C/D: Alt-Shift-<arrow> */
/* ESC [ 1 ; 5 x, where x = A/B/C/D: Ctrl-<arrow> - implemented below */
/* ESC [ 1 ; 6 x, where x = A/B/C/D: Ctrl-Shift-<arrow> */
+ /* ESC [ 1 ; 7 x, where x = A/B/C/D: Ctrl-Alt-<arrow> */
+ /* ESC [ 1 ; 8 x, where x = A/B/C/D: Ctrl-Alt-Shift-<arrow> */
'[','H' |0x80,KEYCODE_HOME , /* xterm */
'[','F' |0x80,KEYCODE_END , /* xterm */
/* [ESC] ESC [ [2] H - [Alt-][Shift-]Home (End similarly?) */
@@ -64,10 +69,10 @@
'[','7','~' |0x80,KEYCODE_HOME , /* vt100? linux vt? or what? */
'[','8','~' |0x80,KEYCODE_END , /* vt100? linux vt? or what? */
#if 0
- '[','1','1','~'|0x80,KEYCODE_FUN1 ,
- '[','1','2','~'|0x80,KEYCODE_FUN2 ,
- '[','1','3','~'|0x80,KEYCODE_FUN3 ,
- '[','1','4','~'|0x80,KEYCODE_FUN4 ,
+ '[','1','1','~'|0x80,KEYCODE_FUN1 , /* old xterm, deprecated by ESC O P */
+ '[','1','2','~'|0x80,KEYCODE_FUN2 , /* old xterm... */
+ '[','1','3','~'|0x80,KEYCODE_FUN3 , /* old xterm... */
+ '[','1','4','~'|0x80,KEYCODE_FUN4 , /* old xterm... */
'[','1','5','~'|0x80,KEYCODE_FUN5 ,
/* [ESC] ESC [ 1 5 [;2] ~ - [Alt-][Shift-]F5 */
'[','1','7','~'|0x80,KEYCODE_FUN6 ,
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/remove_file.c
^
|
@@ -33,7 +33,7 @@
int status = 0;
if (!(flags & FILEUTILS_RECUR)) {
- bb_error_msg("%s: is a directory", path);
+ bb_error_msg("'%s' is a directory", path);
return -1;
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/safe_gethostname.c
^
|
@@ -50,25 +50,3 @@
uname(&uts);
return xstrndup(!uts.nodename[0] ? "?" : uts.nodename, sizeof(uts.nodename));
}
-
-/*
- * On success return the current malloced and NUL terminated domainname.
- * On error return malloced and NUL terminated string "?".
- * This is an illegal first character for a domainname.
- * The returned malloced string must be freed by the caller.
- */
-char* FAST_FUNC safe_getdomainname(void)
-{
-#if defined(__linux__)
-/* The field domainname of struct utsname is Linux specific. */
- struct utsname uts;
- uname(&uts);
- return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname));
-#else
- /* We really don't care about people with domain names wider than most screens */
- char buf[256];
- int r = getdomainname(buf, sizeof(buf));
- buf[sizeof(buf)-1] = '\0';
- return xstrdup(r < 0 ? "?" : buf);
-#endif
-}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/selinux_common.c
^
|
@@ -10,7 +10,7 @@
#include <selinux/context.h>
context_t FAST_FUNC set_security_context_component(security_context_t cur_context,
- char *user, char *role, char *type, char *range)
+ char *user, char *role, char *type, char *range)
{
context_t con = context_new(cur_context);
if (!con)
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/setup_environment.c
^
|
@@ -37,9 +37,11 @@
/* Change the current working directory to be the home directory
* of the user */
- if (chdir(pw->pw_dir)) {
- xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/");
- bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
+ if (!(flags & SETUP_ENV_NO_CHDIR)) {
+ if (chdir(pw->pw_dir) != 0) {
+ bb_error_msg("can't change directory to '%s'", pw->pw_dir);
+ xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/");
+ }
}
if (flags & SETUP_ENV_CLEARENV) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/signals.c
^
|
@@ -39,7 +39,7 @@
while (sigs) {
if (sigs & bit) {
- sigs &= ~bit;
+ sigs -= bit;
signal(sig_no, f);
}
sig_no++;
@@ -60,7 +60,7 @@
while (sigs) {
if (sigs & bit) {
- sigs &= ~bit;
+ sigs -= bit;
sigaction_set(sig_no, &sa);
}
sig_no++;
@@ -97,7 +97,7 @@
signal(sig, SIG_DFL);
sig_unblock(sig);
raise(sig);
- _exit(EXIT_FAILURE); /* Should not reach it */
+ _exit(sig | 128); /* Should not reach it */
}
void FAST_FUNC signal_SA_RESTART_empty_mask(int sig, void (*handler)(int))
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/xatonum_template.c
^
|
@@ -59,7 +59,7 @@
}
/* Note: trailing space is an error.
- It would be easy enough to allow though if desired. */
+ * It would be easy enough to allow though if desired. */
if (*e)
goto inval;
chk_range:
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libbb/xfuncs_printf.c
^
|
@@ -355,13 +355,13 @@
void FAST_FUNC xchdir(const char *path)
{
if (chdir(path))
- bb_perror_msg_and_die("chdir(%s)", path);
+ bb_perror_msg_and_die("can't change directory to '%s'", path);
}
void FAST_FUNC xchroot(const char *path)
{
if (chroot(path))
- bb_perror_msg_and_die("can't change root directory to %s", path);
+ bb_perror_msg_and_die("can't change root directory to '%s'", path);
xchdir("/");
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/libpwdgrp/pwd_grp.c
^
|
@@ -300,8 +300,8 @@
* to have been created as a reentrant version of the non-standard
* functions getspuid. Why getspuid was added, I do not know. */
int getspuid_r(uid_t uid, struct spwd *__restrict resultbuf,
- char *__restrict buffer, size_t buflen,
- struct spwd **__restrict result)
+ char *__restrict buffer, size_t buflen,
+ struct spwd **__restrict result)
{
int rv;
struct passwd *pp;
@@ -403,8 +403,8 @@
int getpwent_r(struct passwd *__restrict resultbuf,
- char *__restrict buffer, size_t buflen,
- struct passwd **__restrict result)
+ char *__restrict buffer, size_t buflen,
+ struct passwd **__restrict result)
{
int rv;
@@ -451,8 +451,8 @@
}
int getgrent_r(struct group *__restrict resultbuf,
- char *__restrict buffer, size_t buflen,
- struct group **__restrict result)
+ char *__restrict buffer, size_t buflen,
+ struct group **__restrict result)
{
int rv;
@@ -501,7 +501,7 @@
}
int getspent_r(struct spwd *resultbuf, char *buffer,
- size_t buflen, struct spwd **result)
+ size_t buflen, struct spwd **result)
{
int rv;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/loginutils/add-remove-shell.c
^
|
@@ -8,8 +8,8 @@
* for details.
*/
-//applet:IF_ADD_SHELL( APPLET_ODDNAME(add-shell , add_remove_shell, BB_DIR_USR_BIN, BB_SUID_DROP, add_shell ))
-//applet:IF_REMOVE_SHELL(APPLET_ODDNAME(remove-shell, add_remove_shell, BB_DIR_USR_BIN, BB_SUID_DROP, remove_shell))
+//applet:IF_ADD_SHELL( APPLET_ODDNAME(add-shell , add_remove_shell, BB_DIR_USR_SBIN, BB_SUID_DROP, add_shell ))
+//applet:IF_REMOVE_SHELL(APPLET_ODDNAME(remove-shell, add_remove_shell, BB_DIR_USR_SBIN, BB_SUID_DROP, remove_shell))
//kbuild:lib-$(CONFIG_ADD_SHELL) += add-remove-shell.o
//kbuild:lib-$(CONFIG_REMOVE_SHELL) += add-remove-shell.o
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/loginutils/adduser.c
^
|
@@ -9,9 +9,9 @@
*/
//usage:#define adduser_trivial_usage
-//usage: "[OPTIONS] USER"
+//usage: "[OPTIONS] USER [GROUP]"
//usage:#define adduser_full_usage "\n\n"
-//usage: "Add a user\n"
+//usage: "Create new user, or add USER to GROUP\n"
//usage: "\n -h DIR Home directory"
//usage: "\n -g GECOS GECOS field"
//usage: "\n -s SHELL Login shell"
@@ -80,7 +80,7 @@
}
}
-static void addgroup_wrapper(struct passwd *p, const char *group_name)
+static int addgroup_wrapper(struct passwd *p, const char *group_name)
{
char *argv[6];
@@ -110,7 +110,7 @@
argv[5] = NULL;
}
- spawn_and_wait(argv);
+ return spawn_and_wait(argv);
}
static void passwd_wrapper(const char *login_name) NORETURN;
@@ -162,9 +162,9 @@
pw.pw_shell = (char *)get_shell_name();
pw.pw_dir = NULL;
- /* exactly one non-option arg */
+ /* at most two non-option args */
/* disable interactive passwd for system accounts */
- opt_complementary = "=1:SD:u+";
+ opt_complementary = "?2:SD:u+";
if (sizeof(pw.pw_uid) == sizeof(int)) {
opts = getopt32(argv, "h:g:s:G:DSHu:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &pw.pw_uid);
} else {
@@ -175,9 +175,16 @@
}
}
argv += optind;
+ pw.pw_name = argv[0];
+
+ if (!opts && argv[1]) {
+ /* if called with two non-option arguments, adduser
+ * will add an existing user to an existing group.
+ */
+ return addgroup_wrapper(&pw, argv[1]);
+ }
/* fill in the passwd struct */
- pw.pw_name = argv[0];
die_if_bad_username(pw.pw_name);
if (!pw.pw_dir) {
/* create string for $HOME if not specified already */
@@ -205,7 +212,6 @@
}
if (ENABLE_FEATURE_CLEAN_UP)
free(p);
-
#if ENABLE_FEATURE_SHADOWPASSWDS
/* /etc/shadow fields:
* 1. username
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/loginutils/getty.c
^
|
@@ -548,8 +548,15 @@
* a session leader - which is quite possible for getty!
*/
pid = getpid();
- if (getsid(0) != pid)
+ if (getsid(0) != pid) {
+ //for debugging:
+ //bb_perror_msg_and_die("setsid failed:"
+ // " pid %d ppid %d"
+ // " sid %d pgid %d",
+ // pid, getppid(),
+ // getsid(0), getpgid(0));
bb_perror_msg_and_die("setsid");
+ }
/* Looks like we are already a session leader.
* In this case (setsid failed) we may still have ctty,
* and it may be different from tty we need to control!
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/loginutils/login.c
^
|
@@ -37,7 +37,8 @@
enum {
TIMEOUT = 60,
EMPTY_USERNAME_COUNT = 10,
- USERNAME_SIZE = 32,
+ /* Some users found 32 chars limit to be too low: */
+ USERNAME_SIZE = 64,
TTYNAME_SIZE = 32,
};
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/loginutils/passwd.c
^
|
@@ -15,6 +15,7 @@
#include "libbb.h"
#include <syslog.h>
+#include <sys/resource.h> /* setrlimit */
static void nuke_str(char *str)
{
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/loginutils/su.c
^
|
@@ -131,7 +131,8 @@
change_identity(pw);
setup_environment(opt_shell,
((flags & SU_OPT_l) / SU_OPT_l * SETUP_ENV_CLEARENV)
- + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV),
+ + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV)
+ + (!(flags & SU_OPT_l) * SETUP_ENV_NO_CHDIR),
pw);
IF_SELINUX(set_current_security_context(NULL);)
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/mailutils/sendmail.c
^
|
@@ -118,7 +118,7 @@
char *opt_from;
char *s;
llist_t *list = NULL;
- char *domain = sane_address(safe_getdomainname());
+ char *host = sane_address(safe_gethostname());
unsigned nheaders = 0;
int code;
@@ -222,8 +222,9 @@
}
// we should start with modern EHLO
- if (250 != smtp_checkp("EHLO %s", domain, -1))
- smtp_checkp("HELO %s", domain, 250);
+ if (250 != smtp_checkp("EHLO %s", host, -1))
+ smtp_checkp("HELO %s", host, 250);
+ free(host);
// perform authentication
if (opts & OPT_a) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/miscutils/crond.c
^
|
@@ -885,7 +885,7 @@
xsetenv("SHELL", DEFAULT_SHELL); /* once, for all future children */
crondlog(LVL8 "crond (busybox "BB_VER") started, log level %d", G.log_level);
rescan_crontab_dir();
- write_pidfile("/var/run/crond.pid");
+ write_pidfile(CONFIG_PID_FILE_PATH "/crond.pid");
/* Main loop */
t2 = time(NULL);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/miscutils/dc.c
^
|
@@ -11,11 +11,11 @@
//usage:
//usage:#define dc_full_usage "\n\n"
//usage: "Tiny RPN calculator. Operations:\n"
-//usage: "+, add, -, sub, *, mul, /, div, %, mod, "IF_FEATURE_DC_LIBM("**, exp, ")"and, or, not, eor,\n"
+//usage: "+, add, -, sub, *, mul, /, div, %, mod, "IF_FEATURE_DC_LIBM("**, exp, ")"and, or, not, xor,\n"
//usage: "p - print top of the stack (without popping),\n"
//usage: "f - print entire stack,\n"
//usage: "o - pop the value and set output radix (must be 10, 16, 8 or 2).\n"
-//usage: "Examples: 'dc 2 2 add p' -> 4, 'dc 8 8 * 2 2 + / p' -> 16"
+//usage: "Examples: 'dc 2 2 add p' -> 4, 'dc 8 8 mul 2 2 + / p' -> 16"
//usage:
//usage:#define dc_example_usage
//usage: "$ dc 2 2 + p\n"
@@ -219,29 +219,29 @@
{"p", print_no_pop},
{"f", print_stack_no_pop},
{"o", set_output_base},
- { "", NULL }
};
static void stack_machine(const char *argument)
{
- char *endPointer;
+ char *end;
double d;
- const struct op *o = operators;
+ const struct op *o;
- d = strtod(argument, &endPointer);
-
- if (endPointer != argument && *endPointer == '\0') {
+ d = strtod(argument, &end);
+ if (end != argument && *end == '\0') {
push(d);
return;
}
- while (o->function) {
+ o = operators;
+ do {
if (strcmp(o->name, argument) == 0) {
o->function();
return;
}
o++;
- }
+ } while (o != operators + ARRAY_SIZE(operators));
+
bb_error_msg_and_die("syntax error at '%s'", argument);
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/miscutils/devfsd.c
^
|
@@ -219,7 +219,7 @@
const regmatch_t *, unsigned);
static void action_modload(const struct devfsd_notify_struct *info, const struct config_entry_struct *entry);
static void action_copy(const struct devfsd_notify_struct *, const struct config_entry_struct *,
- const regmatch_t *, unsigned);
+ const regmatch_t *, unsigned);
static void action_compat(const struct devfsd_notify_struct *, unsigned);
static void free_config(void);
static void restore(char *spath, struct stat source_stat, int rootlen);
@@ -229,12 +229,12 @@
static const char *get_variable(const char *, void *);
static int make_dir_tree(const char *);
static int expand_expression(char *, unsigned, const char *, const char *(*)(const char *, void *), void *,
- const char *, const regmatch_t *, unsigned);
+ const char *, const regmatch_t *, unsigned);
static void expand_regexp(char *, size_t, const char *, const char *, const regmatch_t *, unsigned);
static const char *expand_variable( char *, unsigned, unsigned *, const char *,
const char *(*)(const char *, void *), void *);
static const char *get_variable_v2(const char *, const char *(*)(const char *, void *), void *);
-static char get_old_ide_name(unsigned , unsigned);
+static char get_old_ide_name(unsigned, unsigned);
static char *write_old_sd_name(char *, unsigned, unsigned, const char *);
/* busybox functions */
@@ -580,9 +580,9 @@
/*This action will pass "/dev/$devname"(i.e. "/dev/" prefixed to
the device name) to the module loading facility. In addition,
the /etc/modules.devfs configuration file is used.*/
- if (ENABLE_DEVFSD_MODLOAD)
+ if (ENABLE_DEVFSD_MODLOAD)
new->action.what = AC_MODLOAD;
- break;
+ break;
case 6: /* EXECUTE */
new->action.what = AC_EXECUTE;
num_args -= 3;
@@ -750,7 +750,7 @@
} /* End Function action_permissions */
static void action_modload(const struct devfsd_notify_struct *info,
- const struct config_entry_struct *entry UNUSED_PARAM)
+ const struct config_entry_struct *entry UNUSED_PARAM)
/* [SUMMARY] Load a module.
<info> The devfs change.
<entry> The config file entry.
@@ -771,8 +771,8 @@
} /* End Function action_modload */
static void action_execute(const struct devfsd_notify_struct *info,
- const struct config_entry_struct *entry,
- const regmatch_t *regexpr, unsigned int numexpr)
+ const struct config_entry_struct *entry,
+ const regmatch_t *regexpr, unsigned int numexpr)
/* [SUMMARY] Execute a programme.
<info> The devfs change.
<entry> The config file entry.
@@ -803,8 +803,8 @@
static void action_copy(const struct devfsd_notify_struct *info,
- const struct config_entry_struct *entry,
- const regmatch_t *regexpr, unsigned int numexpr)
+ const struct config_entry_struct *entry,
+ const regmatch_t *regexpr, unsigned int numexpr)
/* [SUMMARY] Copy permissions.
<info> The devfs change.
<entry> The config file entry.
@@ -1259,11 +1259,11 @@
} /* End Function make_dir_tree */
static int expand_expression(char *output, unsigned int outsize,
- const char *input,
- const char *(*get_variable_func)(const char *variable, void *info),
- void *info,
- const char *devname,
- const regmatch_t *ex, unsigned int numexp)
+ const char *input,
+ const char *(*get_variable_func)(const char *variable, void *info),
+ void *info,
+ const char *devname,
+ const regmatch_t *ex, unsigned int numexp)
/* [SUMMARY] Expand environment variables and regular subexpressions in string.
<output> The output expanded expression is written here.
<length> The size of the output buffer.
@@ -1288,8 +1288,8 @@
} /* End Function expand_expression */
static void expand_regexp(char *output, size_t outsize, const char *input,
- const char *devname,
- const regmatch_t *ex, unsigned int numex)
+ const char *devname,
+ const regmatch_t *ex, unsigned int numex)
/* [SUMMARY] Expand all occurrences of the regular subexpressions \0 to \9.
<output> The output expanded expression is written here.
<outsize> The size of the output buffer.
@@ -1385,7 +1385,7 @@
};
const char *get_old_name(const char *devname, unsigned int namelen,
- char *buffer, unsigned int major, unsigned int minor)
+ char *buffer, unsigned int major, unsigned int minor)
/* [SUMMARY] Translate a kernel-supplied name into an old name.
<devname> The device name provided by the kernel.
<namelen> The length of the name.
@@ -1423,7 +1423,7 @@
};
for (trans = translate_table; trans->match != NULL; ++trans) {
- len = strlen(trans->match);
+ len = strlen(trans->match);
if (strncmp(devname, trans->match, len) == 0) {
if (trans->format == NULL)
@@ -1549,9 +1549,9 @@
/*EXPERIMENTAL_FUNCTION*/
int st_expr_expand(char *output, unsigned int length, const char *input,
- const char *(*get_variable_func)(const char *variable,
- void *info),
- void *info)
+ const char *(*get_variable_func)(const char *variable,
+ void *info),
+ void *info)
/* [SUMMARY] Expand an expression using Borne Shell-like unquoted rules.
<output> The output expanded expression is written here.
<length> The size of the output buffer.
@@ -1641,10 +1641,10 @@
/* Private functions follow */
static const char *expand_variable(char *buffer, unsigned int length,
- unsigned int *out_pos, const char *input,
- const char *(*func)(const char *variable,
- void *info),
- void *info)
+ unsigned int *out_pos, const char *input,
+ const char *(*func)(const char *variable,
+ void *info),
+ void *info)
/* [SUMMARY] Expand a variable.
<buffer> The buffer to write to.
<length> The length of the output buffer.
@@ -1786,8 +1786,8 @@
static const char *get_variable_v2(const char *variable,
- const char *(*func)(const char *variable, void *info),
- void *info)
+ const char *(*func)(const char *variable, void *info),
+ void *info)
/* [SUMMARY] Get a variable from the environment or .
<variable> The variable name.
<func> A function which will be used to get the variable. If this returns
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/miscutils/fbsplash.c
^
|
@@ -50,6 +50,10 @@
struct fb_var_screeninfo scr_var;
struct fb_fix_screeninfo scr_fix;
unsigned bytes_per_pixel;
+ // cached (8 - scr_var.COLOR.length):
+ unsigned red_shift;
+ unsigned green_shift;
+ unsigned blue_shift;
};
#define G (*ptr_to_globals)
#define INIT_G() do { \
@@ -139,11 +143,14 @@
break;
}
+ G.red_shift = 8 - G.scr_var.red.length;
+ G.green_shift = 8 - G.scr_var.green.length;
+ G.blue_shift = 8 - G.scr_var.blue.length;
G.bytes_per_pixel = (G.scr_var.bits_per_pixel + 7) >> 3;
// map the device in memory
G.addr = mmap(NULL,
- G.scr_var.yres * G.scr_fix.line_length,
+ G.scr_var.yres * G.scr_fix.line_length,
PROT_WRITE, MAP_SHARED, fbfd, 0);
if (G.addr == MAP_FAILED)
bb_perror_msg_and_die("mmap");
@@ -155,10 +162,13 @@
/**
- * Return pixel value of the passed RGB color
+ * Return pixel value of the passed RGB color.
+ * This is performance critical fn.
*/
static unsigned fb_pixel_value(unsigned r, unsigned g, unsigned b)
{
+ /* We assume that the r,g,b values are <= 255 */
+
if (G.bytes_per_pixel == 1) {
r = r & 0xe0; // 3-bit red
g = (g >> 3) & 0x1c; // 3-bit green
@@ -166,10 +176,17 @@
return r + g + b;
}
if (G.bytes_per_pixel == 2) {
- r = (r & 0xf8) << 8; // 5-bit red
- g = (g & 0xfc) << 3; // 6-bit green
- b = b >> 3; // 5-bit blue
- return r + g + b;
+ // ARM PL110 on Integrator/CP has RGBA5551 bit arrangement.
+ // We want to support bit locations like that.
+ //
+ // First shift out unused bits
+ r = r >> G.red_shift;
+ g = g >> G.green_shift;
+ b = b >> G.blue_shift;
+ // Then shift the remaining bits to their offset
+ return (r << G.scr_var.red.offset) +
+ (g << G.scr_var.green.offset) +
+ (b << G.scr_var.blue.offset);
}
// RGB 888
return b + (g << 8) + (r << 16);
@@ -295,8 +312,7 @@
pos_x = left_x;
if (percent > 0) {
- int y;
- unsigned i;
+ int i, y;
// actual progress bar
pos_x += (unsigned)(width * percent) / 100;
@@ -308,7 +324,7 @@
while (i >= 0) {
// draw one-line thick "rectangle"
// top line will have gray lvl 200, bottom one 100
- unsigned gray_level = 100 + i*100 / height;
+ unsigned gray_level = 100 + (unsigned)i*100 / height;
fb_drawfullrectangle(
left_x, y, pos_x, y,
gray_level, gray_level, gray_level);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/miscutils/flashcp.c
^
|
@@ -50,7 +50,6 @@
int fd_f, fd_d; /* input file and mtd device file descriptors */
int i;
uoff_t erase_count;
- unsigned opts;
struct mtd_info_user mtd;
struct erase_info_user e;
struct stat statb;
@@ -59,7 +58,7 @@
RESERVE_CONFIG_UBUFFER(buf2, BUFSIZE);
opt_complementary = "=2"; /* exactly 2 non-option args: file, dev */
- opts = getopt32(argv, "v");
+ /*opts =*/ getopt32(argv, "v");
argv += optind;
// filename = *argv++;
// devicename = *argv;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/miscutils/hdparm.c
^
|
@@ -1022,8 +1022,8 @@
}
if ((like_std > 3) && (val[CMDS_SUPP_1] & 0x0008)) {
/* We print out elsewhere whether the APM feature is enabled or
- not. If it's not enabled, let's not repeat the info; just print
- nothing here. */
+ * not. If it's not enabled, let's not repeat the info; just print
+ * nothing here. */
printf("\tAdvancedPM level: ");
if ((val[ADV_PWR] & 0xFF00) == 0x4000) {
uint8_t apm_level = val[ADV_PWR] & 0x00FF;
@@ -1038,7 +1038,7 @@
val[ACOUSTIC] & 0x00ff);
}
} else {
- /* ATAPI */
+ /* ATAPI */
if (eqpt != CDROM && (val[CAPAB_0] & SWRST_REQ))
printf("\tATA sw reset required\n");
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/miscutils/last.c
^
|
@@ -71,7 +71,7 @@
file = xopen(bb_path_wtmp_file, O_RDONLY);
printf("%-10s %-14s %-18s %-12.12s %s\n",
- "USER", "TTY", "HOST", "LOGIN", "TIME");
+ "USER", "TTY", "HOST", "LOGIN", "TIME");
/* yikes. We reverse over the file and that is a not too elegant way */
pos = xlseek(file, 0, SEEK_END);
pos = lseek(file, pos - sizeof(ut), SEEK_SET);
@@ -131,7 +131,7 @@
* but some systems have it wrong */
t_tmp = (time_t)ut.ut_tv.tv_sec;
printf("%-10s %-14s %-18s %-12.12s\n",
- ut.ut_user, ut.ut_line, ut.ut_host, ctime(&t_tmp) + 4);
+ ut.ut_user, ut.ut_line, ut.ut_host, ctime(&t_tmp) + 4);
next:
pos -= sizeof(ut);
if (pos <= 0)
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/miscutils/last_fancy.c
^
|
@@ -93,14 +93,14 @@
}
printf(HEADER_FORMAT,
- ut->ut_user,
- ut->ut_line,
- show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN,
- show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN,
- ut->ut_host,
- login_time,
- logout_str,
- duration_str);
+ ut->ut_user,
+ ut->ut_line,
+ show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN,
+ show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN,
+ ut->ut_host,
+ login_time,
+ logout_str,
+ duration_str);
}
static int get_ut_type(struct utmp *ut)
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/miscutils/less.c
^
|
@@ -709,9 +709,9 @@
/* buf[] holds quarantined version of str */
/* Each part of the line that matches has the HIGHLIGHT
- and NORMAL escape sequences placed around it.
- NB: we regex against line, but insert text
- from quarantined copy (buf[]) */
+ * and NORMAL escape sequences placed around it.
+ * NB: we regex against line, but insert text
+ * from quarantined copy (buf[]) */
str = buf;
growline = NULL;
eflags = 0;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/miscutils/nandwrite.c
^
|
@@ -39,7 +39,7 @@
//usage: "[-o] [-b] [-s ADDR] [-f FILE] MTD_DEVICE"
//usage:#define nanddump_full_usage "\n\n"
//usage: "Dump the specified MTD device\n"
-//usage: "\n -o Omit oob data"
+//usage: "\n -o Dump oob data"
//usage: "\n -b Omit bad block from the dump"
//usage: "\n -s ADDR Start address"
//usage: "\n -l LEN Length"
@@ -129,7 +129,7 @@
xmove_fd(tmp_fd, IS_NANDDUMP ? STDOUT_FILENO : STDIN_FILENO);
}
- fd = xopen(argv[0], O_RDWR);
+ fd = xopen(argv[0], IS_NANDWRITE ? O_RDWR : O_RDONLY);
xioctl(fd, MEMGETINFO, &meminfo);
mtdoffset = xstrtou(opt_s, 0);
@@ -162,9 +162,9 @@
tmp = next_good_eraseblock(fd, &meminfo, blockstart);
if (tmp != blockstart) {
/* bad block(s), advance mtdoffset */
- if (IS_NANDDUMP & !(opts & OPT_b)) {
+ if (IS_NANDDUMP && !(opts & OPT_b)) {
int bad_len = MIN(tmp, end_addr) - mtdoffset;
- dump_bad(&meminfo, bad_len, !(opts & OPT_o));
+ dump_bad(&meminfo, bad_len, opts & OPT_o);
}
mtdoffset = tmp;
}
@@ -182,9 +182,9 @@
mtdoffset = next_good_eraseblock(fd, &meminfo, blockstart);
if (IS_NANDWRITE)
printf("Writing at 0x%08x\n", mtdoffset);
- else if (mtdoffset > blockstart) {
+ else if (mtdoffset > blockstart && !(opts & OPT_b)) {
int bad_len = MIN(mtdoffset, limit) - blockstart;
- dump_bad(&meminfo, bad_len, !(opts & OPT_o));
+ dump_bad(&meminfo, bad_len, opts & OPT_o);
}
if (mtdoffset >= limit)
break;
@@ -210,7 +210,7 @@
}
xwrite(output_fd, filebuf, meminfo_writesize);
- if (IS_NANDDUMP && !(opts & OPT_o)) {
+ if (IS_NANDDUMP && (opts & OPT_o)) {
/* Dump OOB data */
oob.start = mtdoffset;
xioctl(fd, MEMREADOOB, &oob);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/miscutils/rx.c
^
|
@@ -193,8 +193,8 @@
}
if (cksum_or_crc != expected) {
bb_error_msg(do_crc ? "crc error, expected 0x%04x, got 0x%04x"
- : "checksum error, expected 0x%02x, got 0x%02x",
- expected, cksum_or_crc);
+ : "checksum error, expected 0x%02x, got 0x%02x",
+ expected, cksum_or_crc);
goto error;
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/miscutils/time.c
^
|
@@ -16,6 +16,7 @@
//usage: "\n -v Verbose"
#include "libbb.h"
+#include <sys/resource.h> /* getrusage */
/* Information on the resources used by a child process. */
typedef struct {
@@ -69,7 +70,7 @@
pid_t caught;
/* Ignore signals, but don't ignore the children. When wait3
- returns the child process, set the time the command finished. */
+ * returns the child process, set the time the command finished. */
while ((caught = wait3(&resp->waitstatus, 0, &resp->ru)) != pid) {
if (caught == -1 && errno != EINTR) {
bb_perror_msg("wait");
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/miscutils/watchdog.c
^
|
@@ -31,6 +31,7 @@
{
static const char V = 'V';
+ remove_pidfile(CONFIG_PID_FILE_PATH "/watchdog.pid");
write(3, &V, 1); /* Magic, see watchdog-api.txt in kernel */
if (ENABLE_FEATURE_CLEAN_UP)
close(3);
@@ -95,6 +96,8 @@
stimer_duration, htimer_duration * 1000);
#endif
+ write_pidfile(CONFIG_PID_FILE_PATH "/watchdog.pid");
+
while (1) {
/*
* Make sure we clear the counter before sleeping,
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/modutils/depmod.c
^
|
@@ -31,7 +31,7 @@
} module_info;
static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARAM,
- void *data, int depth UNUSED_PARAM)
+ void *data, int depth UNUSED_PARAM)
{
char modname[MODULE_NAME_LEN];
module_info **first = (module_info **) data;
@@ -95,7 +95,7 @@
}
static void order_dep_list(module_info *modules, module_info *start,
- llist_t *add)
+ llist_t *add)
{
module_info *m;
llist_t *n;
@@ -216,7 +216,7 @@
} while (*++argv);
} else {
recursive_action(".", ACTION_RECURSE,
- parse_module, NULL, &modules, 0);
+ parse_module, NULL, &modules, 0);
}
/* Generate dependency and alias files */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/modutils/modinfo.c
^
|
@@ -24,9 +24,9 @@
enum {
- OPT_TAGS = (1 << 8) - 1,
- OPT_F = (1 << 8), /* field name */
- OPT_0 = (1 << 9), /* \0 as separator */
+ OPT_TAGS = (1 << 12) - 1, /* shortcut count */
+ OPT_F = (1 << 12), /* field name */
+ OPT_0 = (1 << 13), /* \0 as separator */
};
struct modinfo_env {
@@ -49,13 +49,17 @@
{
static const char *const shortcuts[] = {
"filename",
- "description",
- "author",
"license",
+ "author",
+ "description",
+ "version",
+ "alias",
+ "srcversion",
+ "depends",
+ "uts_release",
"vermagic",
"parm",
"firmware",
- "depends",
};
size_t len;
int j, length;
@@ -97,8 +101,11 @@
if (ptr == NULL) /* no occurance left, done */
break;
if (strncmp(ptr, pattern, length) == 0 && ptr[length] == '=') {
- ptr += length + 1;
- ptr += display(ptr, pattern, (1<<j) != tags);
+ /* field prefixes are 0x80 or 0x00 */
+ if ((ptr[-1] & 0x7F) == '\0') {
+ ptr += length + 1;
+ ptr += display(ptr, pattern, (1<<j) != tags);
+ }
}
++ptr;
}
@@ -131,7 +138,7 @@
env.field = NULL;
opt_complementary = "-1"; /* minimum one param */
- opts = getopt32(argv, "fdalvpF:0", &env.field);
+ opts = getopt32(argv, "nladvAsDumpF:0", &env.field);
env.tags = opts & OPT_TAGS ? opts & OPT_TAGS : OPT_TAGS;
argv += optind;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/modutils/modprobe-small.c
^
|
@@ -594,11 +594,18 @@
bb_perror_msg("remove '%s'", name);
goto ret;
}
- /* N.B. we do not stop here -
+
+ if (applet_name[0] == 'r') {
+ /* rmmod: do not remove dependencies, exit */
+ goto ret;
+ }
+
+ /* modprobe -r: we do not stop here -
* continue to unload modules on which the module depends:
* "-r --remove: option causes modprobe to remove a module.
* If the modules it depends on are also unused, modprobe
- * will try to remove them, too." */
+ * will try to remove them, too."
+ */
}
if (!info) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/modutils/rmmod.c
^
|
@@ -60,7 +60,7 @@
filename2modname(bname, modname);
if (bb_delete_module(modname, flags))
bb_error_msg_and_die("can't unload '%s': %s",
- modname, moderror(errno));
+ modname, moderror(errno));
}
return EXIT_SUCCESS;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/Config.src
^
|
@@ -82,12 +82,12 @@
This adds about 600 bytes.
config FEATURE_BRCTL_SHOW
- bool "Support show, showmac and showstp"
+ bool "Support show"
default y
depends on BRCTL && FEATURE_BRCTL_FANCY
help
Add support for option which prints the current config:
- showmacs, showstp, show
+ show
config DNSD
bool "dnsd"
@@ -945,8 +945,8 @@
bool "wget"
default y
help
- wget is a utility for non-interactive download of files from HTTP,
- HTTPS, and FTP servers.
+ wget is a utility for non-interactive download of files from HTTP
+ and FTP servers.
config FEATURE_WGET_STATUSBAR
bool "Enable a nifty process meter (+2k)"
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/arp.c
^
|
@@ -214,7 +214,7 @@
/* Get the hardware address to a specified interface name */
static void arp_getdevhw(char *ifname, struct sockaddr *sa,
- const struct hwtype *hwt)
+ const struct hwtype *hwt)
{
struct ifreq ifr;
const struct hwtype *xhw;
@@ -233,8 +233,8 @@
xhw = get_hwntype(-1);
}
bb_error_msg("device '%s' has HW address %s '%s'",
- ifname, xhw->name,
- xhw->print((unsigned char *) &ifr.ifr_hwaddr.sa_data));
+ ifname, xhw->name,
+ xhw->print((unsigned char *) &ifr.ifr_hwaddr.sa_data));
}
}
@@ -345,7 +345,7 @@
/* Print the contents of an ARP request block. */
static void
arp_disp(const char *name, char *ip, int type, int arp_flags,
- char *hwa, char *mask, char *dev)
+ char *hwa, char *mask, char *dev)
{
static const int arp_masks[] = {
ATF_PERM, ATF_PUBL,
@@ -428,7 +428,7 @@
/* All these strings can't overflow
* because fgets above reads limited amount of data */
num = sscanf(line, "%s 0x%x 0x%x %s %s %s\n",
- ip, &type, &flags, hwa, mask, dev);
+ ip, &type, &flags, hwa, mask, dev);
if (num < 4)
break;
@@ -461,7 +461,7 @@
}
if (option_mask32 & ARP_OPT_v)
printf("Entries: %d\tSkipped: %d\tFound: %d\n",
- entries, entries - shown, shown);
+ entries, entries - shown, shown);
if (!shown) {
if (hw_set || host || device[0])
@@ -517,7 +517,7 @@
if (hw->alen <= 0) {
bb_error_msg_and_die("%s: %s without ARP support",
- hw->name, "hardware type");
+ hw->name, "hardware type");
}
/* Now see what we have to do here... */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/brctl.c
^
|
@@ -67,7 +67,7 @@
# include <linux/if_bridge.h>
/* FIXME: These 4 funcs are not really clean and could be improved */
-static ALWAYS_INLINE void strtotimeval(struct timeval *tv,
+static ALWAYS_INLINE void bb_strtotimeval(struct timeval *tv,
const char *time_str)
{
double secs;
@@ -104,7 +104,7 @@
static unsigned long str_to_jiffies(const char *time_str)
{
struct timeval tv;
- strtotimeval(&tv, time_str);
+ bb_strtotimeval(&tv, time_str);
return tv_to_jiffies(&tv);
}
@@ -129,15 +129,15 @@
"setageing\0" "setfd\0" "sethello\0" "setmaxage\0"
"setpathcost\0" "setportprio\0" "setbridgeprio\0"
)
- IF_FEATURE_BRCTL_SHOW("showmacs\0" "show\0");
+ IF_FEATURE_BRCTL_SHOW("show\0");
enum { ARG_addbr = 0, ARG_delbr, ARG_addif, ARG_delif
IF_FEATURE_BRCTL_FANCY(,
- ARG_stp,
- ARG_setageing, ARG_setfd, ARG_sethello, ARG_setmaxage,
- ARG_setpathcost, ARG_setportprio, ARG_setbridgeprio
+ ARG_stp,
+ ARG_setageing, ARG_setfd, ARG_sethello, ARG_setmaxage,
+ ARG_setpathcost, ARG_setportprio, ARG_setbridgeprio
)
- IF_FEATURE_BRCTL_SHOW(, ARG_showmacs, ARG_show)
+ IF_FEATURE_BRCTL_SHOW(, ARG_show)
};
int fd;
@@ -285,7 +285,7 @@
bb_error_msg_and_die(bb_msg_invalid_arg, *argv, "port");
memset(ifidx, 0, sizeof ifidx);
arm_ioctl(args, BRCTL_GET_PORT_LIST, (unsigned long)ifidx,
- MAX_PORTS);
+ MAX_PORTS);
xioctl(fd, SIOCDEVPRIVATE, &ifr);
for (i = 0; i < MAX_PORTS; i++) {
if (ifidx[i] == port) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/ether-wake.c
^
|
@@ -49,9 +49,9 @@
* Copyright 1999-2003 Donald Becker and Scyld Computing Corporation.
*
* The author may be reached as becker@scyld, or C/O
- * Scyld Computing Corporation
- * 914 Bay Ridge Road, Suite 220
- * Annapolis MD 21403
+ * Scyld Computing Corporation
+ * 914 Bay Ridge Road, Suite 220
+ * Annapolis MD 21403
*
* Notes:
* On some systems dropping root capability allows the process to be
@@ -113,7 +113,7 @@
* Host name
* IP address string
* MAC address string
-*/
+ */
static void get_dest_addr(const char *hostid, struct ether_addr *eaddr)
{
struct ether_addr *eap;
@@ -238,9 +238,9 @@
{
unsigned char *hwaddr = if_hwaddr.ifr_hwaddr.sa_data;
printf("The hardware address (SIOCGIFHWADDR) of %s is type %d "
- "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n\n", ifname,
- if_hwaddr.ifr_hwaddr.sa_family, hwaddr[0], hwaddr[1],
- hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]);
+ "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n\n", ifname,
+ if_hwaddr.ifr_hwaddr.sa_family, hwaddr[0], hwaddr[1],
+ hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]);
}
# endif
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/ftpd.c
^
|
@@ -821,7 +821,7 @@
gmtime_r(&statbuf.st_mtime, &broken_out);
sprintf(buf, STR(FTP_STATFILE_OK)" %04u%02u%02u%02u%02u%02u\r\n",
broken_out.tm_year + 1900,
- broken_out.tm_mon,
+ broken_out.tm_mon + 1,
broken_out.tm_mday,
broken_out.tm_hour,
broken_out.tm_min,
@@ -927,6 +927,7 @@
|| fstat(local_file_fd, &statbuf) != 0
|| !S_ISREG(statbuf.st_mode)
) {
+ free(tempname);
WRITE_ERR(FTP_UPLOADFAIL);
if (local_file_fd >= 0)
goto close_local_and_bail;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/httpd.c
^
|
@@ -796,9 +796,9 @@
/* the line is not recognized */
config_error:
bb_error_msg("config error '%s' in '%s'", buf, filename);
- } /* while (fgets) */
+ } /* while (fgets) */
- fclose(f);
+ fclose(f);
}
#if ENABLE_FEATURE_HTTPD_ENCODE_URL_STR
@@ -1414,7 +1414,7 @@
if (script != url) { /* paranoia */
*script = '\0';
if (chdir(url + 1) != 0) {
- bb_perror_msg("chdir(%s)", url + 1);
+ bb_perror_msg("can't change directory to '%s'", url + 1);
goto error_execing_cgi;
}
// not needed: *script = '/';
@@ -1708,7 +1708,7 @@
case PAM_PROMPT_ECHO_OFF:
s = userinfo->pw;
break;
- case PAM_ERROR_MSG:
+ case PAM_ERROR_MSG:
case PAM_TEXT_INFO:
s = "";
break;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/httpd_indexcgi.c
^
|
@@ -35,6 +35,7 @@
* 2576 4 2048 4628 1214 index.cgi.o
*/
+#define _GNU_SOURCE 1 /* for strchrnul */
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/httpd_ssi.c
^
|
@@ -133,7 +133,7 @@
process_includes(include_directive);
/* Print everything after directive */
- if (end) {
+ if (end) {
fputs(end, stdout);
free(end);
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/ifconfig.c
^
|
@@ -174,10 +174,6 @@
#define ARG_ADD_DEL (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER)
-/*
- * Set up the tables. Warning! They must have corresponding order!
- */
-
struct arg1opt {
const char *name;
unsigned short selector;
@@ -198,6 +194,10 @@
#define ifreq_offsetof(x) offsetof(struct ifreq, x)
+/*
+ * Set up the tables. Warning! They must have corresponding order!
+ */
+
static const struct arg1opt Arg1Opt[] = {
{ "SIFMETRIC", SIOCSIFMETRIC, ifreq_offsetof(ifr_metric) },
{ "SIFMTU", SIOCSIFMTU, ifreq_offsetof(ifr_mtu) },
@@ -220,11 +220,11 @@
{ "SIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.base_addr) },
{ "SIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.irq) },
#endif
- /* Last entry if for unmatched (possibly hostname) arg. */
#if ENABLE_FEATURE_IPV6
{ "SIFADDR", SIOCSIFADDR, ifreq_offsetof(ifr_addr) }, /* IPv6 version ignores the offset */
{ "DIFADDR", SIOCDIFADDR, ifreq_offsetof(ifr_addr) }, /* IPv6 version ignores the offset */
#endif
+ /* Last entry is for unmatched (assumed to be hostname/address) arg. */
{ "SIFADDR", SIOCSIFADDR, ifreq_offsetof(ifr_addr) },
};
@@ -265,16 +265,49 @@
{ NULL, 0, ARG_HOSTNAME, (IFF_UP | IFF_RUNNING) }
};
-/*
- * A couple of prototypes.
- */
#if ENABLE_FEATURE_IFCONFIG_HW
-static int in_ether(const char *bufp, struct sockaddr *sap);
+/* Input an Ethernet address and convert to binary. */
+static int in_ether(const char *bufp, struct sockaddr *sap)
+{
+ char *ptr;
+ int i, j;
+ unsigned char val;
+ unsigned char c;
+
+ sap->sa_family = ARPHRD_ETHER;
+ ptr = (char *) sap->sa_data;
+
+ i = 0;
+ do {
+ j = val = 0;
+
+ /* We might get a semicolon here - not required. */
+ if (i && (*bufp == ':')) {
+ bufp++;
+ }
+
+ do {
+ c = *bufp;
+ if (((unsigned char)(c - '0')) <= 9) {
+ c -= '0';
+ } else if ((unsigned char)((c|0x20) - 'a') <= 5) {
+ c = (unsigned char)((c|0x20) - 'a') + 10;
+ } else if (j && (c == ':' || c == 0)) {
+ break;
+ } else {
+ return -1;
+ }
+ ++bufp;
+ val <<= 4;
+ val += c;
+ } while (++j < 2);
+ *ptr++ = val;
+ } while (++i < ETH_ALEN);
+
+ return *bufp; /* Error if we don't end at end of string. */
+}
#endif
-/*
- * Our main function.
- */
int ifconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ifconfig_main(int argc UNUSED_PARAM, char **argv)
{
@@ -330,7 +363,7 @@
strncpy_IFNAMSIZ(ifr.ifr_name, *argv);
/* Process the remaining arguments. */
- while (*++argv != (char *) NULL) {
+ while (*++argv != NULL) {
p = *argv;
mask = N_MASK;
if (*p == '-') { /* If the arg starts with '-'... */
@@ -356,9 +389,9 @@
FOUND_ARG:
if (mask & ARG_MASK) {
mask = op->arg_flags;
- a1op = Arg1Opt + (op - OptArray);
if (mask & A_NETMASK & did_flags)
bb_show_usage();
+ a1op = Arg1Opt + (op - OptArray);
if (*++argv == NULL) {
if (mask & A_ARG_REQ)
bb_show_usage();
@@ -371,19 +404,9 @@
#if ENABLE_FEATURE_IFCONFIG_HW
if (mask & A_CAST_RESOLVE) {
#endif
-#if ENABLE_FEATURE_IPV6
- char *prefix;
- int prefix_len = 0;
-#endif
- /*safe_strncpy(host, *argv, (sizeof host));*/
host = *argv;
-#if ENABLE_FEATURE_IPV6
- prefix = strchr(host, '/');
- if (prefix) {
- prefix_len = xatou_range(prefix + 1, 0, 128);
- *prefix = '\0';
- }
-#endif
+ if (strcmp(host, "inet") == 0)
+ continue; /* compat stuff */
sai.sin_family = AF_INET;
sai.sin_port = 0;
if (strcmp(host, "default") == 0) {
@@ -391,7 +414,8 @@
sai.sin_addr.s_addr = INADDR_ANY;
}
#if ENABLE_FEATURE_IFCONFIG_BROADCAST_PLUS
- else if ((host[0] == '+' && !host[1]) && (mask & A_BROADCAST)
+ else if ((host[0] == '+' && !host[1])
+ && (mask & A_BROADCAST)
&& (did_flags & (A_NETMASK|A_HOSTNAME)) == (A_NETMASK|A_HOSTNAME)
) {
/* + is special, meaning broadcast is derived. */
@@ -400,23 +424,36 @@
#endif
else {
len_and_sockaddr *lsa;
- if (strcmp(host, "inet") == 0)
- continue; /* compat stuff */
+#if ENABLE_FEATURE_IPV6
+ char *prefix;
+ int prefix_len = 0;
+ prefix = strchr(host, '/');
+ if (prefix) {
+ prefix_len = xatou_range(prefix + 1, 0, 128);
+ *prefix = '\0';
+ }
+ resolve:
+#endif
lsa = xhost2sockaddr(host, 0);
#if ENABLE_FEATURE_IPV6
+ if (lsa->u.sa.sa_family != AF_INET6 && prefix) {
+/* TODO: we do not support "ifconfig eth0 up 1.2.3.4/17".
+ * For now, just make it fail instead of silently ignoring "/17" part:
+ */
+ *prefix = '/';
+ goto resolve;
+ }
if (lsa->u.sa.sa_family == AF_INET6) {
int sockfd6;
struct in6_ifreq ifr6;
- memcpy((char *) &ifr6.ifr6_addr,
- (char *) &(lsa->u.sin6.sin6_addr),
- sizeof(struct in6_addr));
-
- /* Create a channel to the NET kernel. */
sockfd6 = xsocket(AF_INET6, SOCK_DGRAM, 0);
- xioctl(sockfd6, SIOGIFINDEX, &ifr);
+ xioctl(sockfd6, SIOCGIFINDEX, &ifr);
ifr6.ifr6_ifindex = ifr.ifr_ifindex;
ifr6.ifr6_prefixlen = prefix_len;
+ memcpy(&ifr6.ifr6_addr,
+ &lsa->u.sin6.sin6_addr,
+ sizeof(struct in6_addr));
ioctl_or_perror_and_die(sockfd6, a1op->selector, &ifr6, "SIOC%s", a1op->name);
if (ENABLE_FEATURE_CLEAN_UP)
free(lsa);
@@ -437,19 +474,18 @@
#if ENABLE_FEATURE_IFCONFIG_HW
} else { /* A_CAST_HOST_COPY_IN_ETHER */
/* This is the "hw" arg case. */
- smalluint hw_class= index_in_substrings("ether\0"
+ smalluint hw_class = index_in_substrings("ether\0"
IF_FEATURE_HWIB("infiniband\0"), *argv) + 1;
if (!hw_class || !*++argv)
bb_show_usage();
- /*safe_strncpy(host, *argv, sizeof(host));*/
host = *argv;
if (hw_class == 1 ? in_ether(host, &sa) : in_ib(host, &sa))
bb_error_msg_and_die("invalid hw-addr %s", host);
p = (char *) &sa;
}
#endif
- memcpy( (((char *)&ifr) + a1op->ifr_offset),
- p, sizeof(struct sockaddr));
+ memcpy( ((char *)&ifr) + a1op->ifr_offset,
+ p, sizeof(struct sockaddr));
} else {
/* FIXME: error check?? */
unsigned long i = strtoul(*argv, NULL, 0);
@@ -458,17 +494,17 @@
if (mask & A_MAP_TYPE) {
xioctl(sockfd, SIOCGIFMAP, &ifr);
if ((mask & A_MAP_UCHAR) == A_MAP_UCHAR)
- *((unsigned char *) p) = i;
+ *(unsigned char *) p = i;
else if (mask & A_MAP_USHORT)
- *((unsigned short *) p) = i;
+ *(unsigned short *) p = i;
else
- *((unsigned long *) p) = i;
+ *(unsigned long *) p = i;
} else
#endif
if (mask & A_CAST_CHAR_PTR)
- *((caddr_t *) p) = (caddr_t) i;
+ *(caddr_t *) p = (caddr_t) i;
else /* A_CAST_INT */
- *((int *) p) = i;
+ *(int *) p = i;
}
ioctl_or_perror_and_die(sockfd, a1op->selector, &ifr, "SIOC%s", a1op->name);
@@ -494,7 +530,7 @@
if (!(mask & A_SET_AFTER))
continue;
mask = N_SET;
- }
+ } /* if (mask & ARG_MASK) */
xioctl(sockfd, SIOCGIFFLAGS, &ifr);
selector = op->selector;
@@ -509,46 +545,3 @@
close(sockfd);
return 0;
}
-
-#if ENABLE_FEATURE_IFCONFIG_HW
-/* Input an Ethernet address and convert to binary. */
-static int in_ether(const char *bufp, struct sockaddr *sap)
-{
- char *ptr;
- int i, j;
- unsigned char val;
- unsigned char c;
-
- sap->sa_family = ARPHRD_ETHER;
- ptr = (char *) sap->sa_data;
-
- i = 0;
- do {
- j = val = 0;
-
- /* We might get a semicolon here - not required. */
- if (i && (*bufp == ':')) {
- bufp++;
- }
-
- do {
- c = *bufp;
- if (((unsigned char)(c - '0')) <= 9) {
- c -= '0';
- } else if (((unsigned char)((c|0x20) - 'a')) <= 5) {
- c = (c|0x20) - ('a'-10);
- } else if (j && (c == ':' || c == 0)) {
- break;
- } else {
- return -1;
- }
- ++bufp;
- val <<= 4;
- val += c;
- } while (++j < 2);
- *ptr++ = val;
- } while (++i < ETH_ALEN);
-
- return *bufp; /* Error if we don't end at end of string. */
-}
-#endif
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/ifenslave.c
^
|
@@ -270,7 +270,7 @@
if (res < 0) {
ifr.ifr_addr.sa_family = AF_INET;
memset(ifr.ifr_addr.sa_data, 0,
- sizeof(ifr.ifr_addr.sa_data));
+ sizeof(ifr.ifr_addr.sa_data));
}
res = set_ifrname_and_do_ioctl(ifra[i].s_ioctl, &ifr, slave_ifname);
@@ -546,7 +546,7 @@
#ifdef WHY_BOTHER
/* Neither -c[hange] nor -d[etach] -> it's "enslave" then;
* and -f[orce] is not there too. Check that it's ethernet. */
- if (!(opt & (OPT_d|OPT_c|OPT_f)) {
+ if (!(opt & (OPT_d|OPT_c|OPT_f))) {
/* The family '1' is ARPHRD_ETHER for ethernet. */
if (master.hwaddr.ifr_hwaddr.sa_family != 1) {
bb_error_msg_and_die(
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/ifplugd.c
^
|
@@ -22,9 +22,9 @@
//usage: "\n -r PROG Script to run"
//usage: "\n -x ARG Extra argument for script"
//usage: "\n -I Don't exit on nonzero exit code from script"
-//usage: "\n -p Don't run script on daemon startup"
-//usage: "\n -q Don't run script on daemon quit"
-//usage: "\n -l Run script on startup even if no cable is detected"
+//usage: "\n -p Don't run \"up\" script on startup"
+//usage: "\n -q Don't run \"down\" script on exit"
+//usage: "\n -l Always run script on startup"
//usage: "\n -t SECS Poll time in seconds"
//usage: "\n -u SECS Delay before running script after link up"
//usage: "\n -d SECS Delay after link down"
@@ -551,7 +551,7 @@
applet_name = xasprintf("ifplugd(%s)", G.iface);
#if ENABLE_FEATURE_PIDFILE
- pidfile_name = xasprintf(_PATH_VARRUN"ifplugd.%s.pid", G.iface);
+ pidfile_name = xasprintf(CONFIG_PID_FILE_PATH "/ifplugd.%s.pid", G.iface);
pid_from_pidfile = read_pid(pidfile_name);
if (opts & FLAG_KILL) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/ifupdown.c
^
|
@@ -49,9 +49,6 @@
#include <fnmatch.h>
#define MAX_OPT_DEPTH 10
-#define EUNBALBRACK 10001
-#define EUNDEFVAR 10002
-#define EUNBALPER 10000
#if ENABLE_FEATURE_IFUPDOWN_MAPPING
#define MAX_INTERFACE_LENGTH 10
@@ -233,7 +230,7 @@
static char *parse(const char *command, struct interface_defn_t *ifd)
{
size_t old_pos[MAX_OPT_DEPTH] = { 0 };
- int okay[MAX_OPT_DEPTH] = { 1 };
+ smallint okay[MAX_OPT_DEPTH] = { 1 };
int opt_depth = 1;
char *result = NULL;
@@ -244,13 +241,10 @@
command++;
break;
case '\\':
- if (command[1]) {
- addstr(&result, command + 1, 1);
- command += 2;
- } else {
- addstr(&result, command, 1);
+ if (command[1])
command++;
- }
+ addstr(&result, command, 1);
+ command++;
break;
case '[':
if (command[1] == '[' && opt_depth < MAX_OPT_DEPTH) {
@@ -259,7 +253,7 @@
opt_depth++;
command += 2;
} else {
- addstr(&result, "[", 1);
+ addstr(&result, command, 1);
command++;
}
break;
@@ -271,7 +265,7 @@
}
command += 2;
} else {
- addstr(&result, "]", 1);
+ addstr(&result, command, 1);
command++;
}
break;
@@ -283,7 +277,7 @@
command++;
nextpercent = strchr(command, '%');
if (!nextpercent) {
- errno = EUNBALPER;
+ /* Unterminated %var% */
free(result);
return NULL;
}
@@ -328,13 +322,13 @@
}
if (opt_depth > 1) {
- errno = EUNBALBRACK;
+ /* Unbalanced bracket */
free(result);
return NULL;
}
if (!okay[0]) {
- errno = EUNDEFVAR;
+ /* Undefined variable and we aren't in a bracket */
free(result);
return NULL;
}
@@ -1058,7 +1052,7 @@
static int iface_down(struct interface_defn_t *iface)
{
- if (!iface->method->down(iface,check)) return -1;
+ if (!iface->method->down(iface, check)) return -1;
set_environ(iface, "stop", "pre-down");
if (!execute_all(iface, "down")) return 0;
if (!iface->method->down(iface, doit)) return 0;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/inetd.c
^
|
@@ -165,6 +165,8 @@
//usage: "\n (default: 0 - disabled)"
#include <syslog.h>
+#include <sys/resource.h> /* setrlimit */
+#include <sys/socket.h> /* un.h may need this */
#include <sys/un.h>
#include "libbb.h"
@@ -184,8 +186,6 @@
#define ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN 0
#endif
-#define _PATH_INETDPID "/var/run/inetd.pid"
-
#define CNT_INTERVAL 60 /* servers in CNT_INTERVAL sec. */
#define RETRYTIME 60 /* retry after bind or server fail */
@@ -1130,7 +1130,7 @@
if (ENABLE_FEATURE_CLEAN_UP)
close(sep->se_fd);
}
- remove_pidfile(_PATH_INETDPID);
+ remove_pidfile(CONFIG_PID_FILE_PATH "/inetd.pid");
exit(EXIT_SUCCESS);
}
@@ -1179,7 +1179,7 @@
setgroups(1, &gid);
}
- write_pidfile(_PATH_INETDPID);
+ write_pidfile(CONFIG_PID_FILE_PATH "/inetd.pid");
/* never fails under Linux (except if you pass it bad arguments) */
getrlimit(RLIMIT_NOFILE, &rlim_ofile);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/interface.c
^
|
@@ -27,7 +27,7 @@
* {1.34} - 19980630 - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* - gettext instead of catgets for i18n
* 10/1998 - Andi Kleen. Use interface list primitives.
- * 20001008 - Bernd Eckenfels, Patch from RH for setting mtu
+ * 20001008 - Bernd Eckenfels, Patch from RH for setting mtu
* (default AF was wrong)
*/
@@ -950,8 +950,8 @@
(struct sockaddr *) &sap.sin6_addr);
sap.sin6_family = AF_INET6;
printf(" inet6 addr: %s/%d",
- INET6_sprint((struct sockaddr *) &sap, 1),
- plen);
+ INET6_sprint((struct sockaddr *) &sap, 1),
+ plen);
printf(" Scope:");
switch (scope & IPV6_ADDR_SCOPE_MASK) {
case 0:
@@ -1019,7 +1019,7 @@
if (ptr->has_ip) {
printf(" %s addr:%s ", ap->name,
- ap->sprint(&ptr->addr, 1));
+ ap->sprint(&ptr->addr, 1));
if (ptr->flags & IFF_POINTOPOINT) {
printf(" P-t-P:%s ", ap->sprint(&ptr->dstaddr, 1));
}
@@ -1102,17 +1102,17 @@
printf(" ");
printf("RX packets:%llu errors:%lu dropped:%lu overruns:%lu frame:%lu\n",
- ptr->stats.rx_packets, ptr->stats.rx_errors,
- ptr->stats.rx_dropped, ptr->stats.rx_fifo_errors,
- ptr->stats.rx_frame_errors);
+ ptr->stats.rx_packets, ptr->stats.rx_errors,
+ ptr->stats.rx_dropped, ptr->stats.rx_fifo_errors,
+ ptr->stats.rx_frame_errors);
if (can_compress)
printf(" compressed:%lu\n",
- ptr->stats.rx_compressed);
+ ptr->stats.rx_compressed);
printf(" ");
printf("TX packets:%llu errors:%lu dropped:%lu overruns:%lu carrier:%lu\n",
- ptr->stats.tx_packets, ptr->stats.tx_errors,
- ptr->stats.tx_dropped, ptr->stats.tx_fifo_errors,
- ptr->stats.tx_carrier_errors);
+ ptr->stats.tx_packets, ptr->stats.tx_errors,
+ ptr->stats.tx_dropped, ptr->stats.tx_fifo_errors,
+ ptr->stats.tx_carrier_errors);
printf(" collisions:%lu ", ptr->stats.collisions);
if (can_compress)
printf("compressed:%lu ", ptr->stats.tx_compressed);
@@ -1129,13 +1129,12 @@
printf(" ");
if (ptr->map.irq)
printf("Interrupt:%d ", ptr->map.irq);
- if (ptr->map.base_addr >= 0x100) /* Only print devices using it for
- I/O maps */
+ if (ptr->map.base_addr >= 0x100) /* Only print devices using it for I/O maps */
printf("Base address:0x%lx ",
- (unsigned long) ptr->map.base_addr);
+ (unsigned long) ptr->map.base_addr);
if (ptr->map.mem_start) {
printf("Memory:%lx-%lx ", ptr->map.mem_start,
- ptr->map.mem_end);
+ ptr->map.mem_end);
}
if (ptr->map.dma)
printf("DMA chan:%x ", ptr->map.dma);
@@ -1168,7 +1167,7 @@
#ifdef UNUSED
static int for_all_interfaces(int (*doit) (struct interface *, void *),
- void *cookie)
+ void *cookie)
{
struct interface *ife;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/libiproute/ipaddress.c
^
|
@@ -314,14 +314,16 @@
if (rta_tb[IFA_BROADCAST]) {
printf("brd %s ",
rt_addr_n2a(ifa->ifa_family,
- RTA_DATA(rta_tb[IFA_BROADCAST]),
- abuf, sizeof(abuf)));
+ RTA_DATA(rta_tb[IFA_BROADCAST]),
+ abuf, sizeof(abuf))
+ );
}
if (rta_tb[IFA_ANYCAST]) {
printf("any %s ",
rt_addr_n2a(ifa->ifa_family,
- RTA_DATA(rta_tb[IFA_ANYCAST]),
- abuf, sizeof(abuf)));
+ RTA_DATA(rta_tb[IFA_ANYCAST]),
+ abuf, sizeof(abuf))
+ );
}
printf("scope %s ", rtnl_rtscope_n2a(ifa->ifa_scope, b1));
if (ifa->ifa_flags & IFA_F_SECONDARY) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/libiproute/iprule.c
^
|
@@ -73,15 +73,17 @@
if (tb[RTA_SRC]) {
if (r->rtm_src_len != host_len) {
printf("%s/%u", rt_addr_n2a(r->rtm_family,
- RTA_DATA(tb[RTA_SRC]),
- abuf, sizeof(abuf)),
+ RTA_DATA(tb[RTA_SRC]),
+ abuf, sizeof(abuf)),
r->rtm_src_len
- );
+ );
} else {
fputs(format_host(r->rtm_family,
- RTA_PAYLOAD(tb[RTA_SRC]),
- RTA_DATA(tb[RTA_SRC]),
- abuf, sizeof(abuf)), stdout);
+ RTA_PAYLOAD(tb[RTA_SRC]),
+ RTA_DATA(tb[RTA_SRC]),
+ abuf, sizeof(abuf)),
+ stdout
+ );
}
} else if (r->rtm_src_len) {
printf("0/%d", r->rtm_src_len);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/libiproute/iptunnel.c
^
|
@@ -438,7 +438,7 @@
printf(" inherit");
if (p->iph.tos & ~1)
printf("%c%s ", p->iph.tos & 1 ? '/' : ' ',
- rtnl_dsfield_n2a(p->iph.tos & ~1, b1));
+ rtnl_dsfield_n2a(p->iph.tos & ~1, b1));
}
if (!(p->iph.frag_off & htons(IP_DF)))
printf(" nopmtudisc");
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/libiproute/ll_proto.c
^
|
@@ -14,19 +14,10 @@
#include <netinet/if_ether.h>
-#if !ENABLE_WERROR
-#warning de-bloat
-#endif
-/* Before re-enabling this, please (1) conditionalize exotic protocols
- * on CONFIG_something, and (2) decouple strings and numbers
- * (use llproto_ids[] = n,n,n..; and llproto_names[] = "loop\0" "pup\0" ...;)
- */
-
-#define __PF(f,n) { ETH_P_##f, #n },
-static struct {
- int id;
- const char *name;
-} llproto_names[] = {
+/* Please conditionalize exotic protocols on CONFIG_something */
+
+static const uint16_t llproto_ids[] = {
+#define __PF(f,n) ETH_P_##f,
__PF(LOOP,loop)
__PF(PUP,pup)
#ifdef ETH_P_PUPAT
@@ -86,33 +77,104 @@
__PF(ECONET,econet)
#endif
-{ 0x8100, "802.1Q" },
-{ ETH_P_IP, "ipv4" },
+0x8100,
+ETH_P_IP
};
#undef __PF
+/* Keep declarations above and below in sync! */
+
+static const char llproto_names[] =
+#define __PF(f,n) #n "\0"
+__PF(LOOP,loop)
+__PF(PUP,pup)
+#ifdef ETH_P_PUPAT
+__PF(PUPAT,pupat)
+#endif
+__PF(IP,ip)
+__PF(X25,x25)
+__PF(ARP,arp)
+__PF(BPQ,bpq)
+#ifdef ETH_P_IEEEPUP
+__PF(IEEEPUP,ieeepup)
+#endif
+#ifdef ETH_P_IEEEPUPAT
+__PF(IEEEPUPAT,ieeepupat)
+#endif
+__PF(DEC,dec)
+__PF(DNA_DL,dna_dl)
+__PF(DNA_RC,dna_rc)
+__PF(DNA_RT,dna_rt)
+__PF(LAT,lat)
+__PF(DIAG,diag)
+__PF(CUST,cust)
+__PF(SCA,sca)
+__PF(RARP,rarp)
+__PF(ATALK,atalk)
+__PF(AARP,aarp)
+__PF(IPX,ipx)
+__PF(IPV6,ipv6)
+#ifdef ETH_P_PPP_DISC
+__PF(PPP_DISC,ppp_disc)
+#endif
+#ifdef ETH_P_PPP_SES
+__PF(PPP_SES,ppp_ses)
+#endif
+#ifdef ETH_P_ATMMPOA
+__PF(ATMMPOA,atmmpoa)
+#endif
+#ifdef ETH_P_ATMFATE
+__PF(ATMFATE,atmfate)
+#endif
+
+__PF(802_3,802_3)
+__PF(AX25,ax25)
+__PF(ALL,all)
+__PF(802_2,802_2)
+__PF(SNAP,snap)
+__PF(DDCMP,ddcmp)
+__PF(WAN_PPP,wan_ppp)
+__PF(PPP_MP,ppp_mp)
+__PF(LOCALTALK,localtalk)
+__PF(PPPTALK,ppptalk)
+__PF(TR_802_2,tr_802_2)
+__PF(MOBITEX,mobitex)
+__PF(CONTROL,control)
+__PF(IRDA,irda)
+#ifdef ETH_P_ECONET
+__PF(ECONET,econet)
+#endif
+
+"802.1Q" "\0"
+"ipv4" "\0"
+;
+#undef __PF
+
const char* FAST_FUNC ll_proto_n2a(unsigned short id, char *buf, int len)
{
unsigned i;
id = ntohs(id);
- for (i = 0; i < ARRAY_SIZE(llproto_names); i++) {
- if (llproto_names[i].id == id)
- return llproto_names[i].name;
+ for (i = 0; i < ARRAY_SIZE(llproto_ids); i++) {
+ if (llproto_ids[i] == id)
+ return nth_string(llproto_names, i);
}
- snprintf(buf, len, "[%d]", id);
+ snprintf(buf, len, "[%u]", id);
return buf;
}
int FAST_FUNC ll_proto_a2n(unsigned short *id, char *buf)
{
unsigned i;
- for (i = 0; i < ARRAY_SIZE(llproto_names); i++) {
- if (strcasecmp(llproto_names[i].name, buf) == 0) {
- i = llproto_names[i].id;
- goto good;
- }
+ const char *name = llproto_names;
+ for (i = 0; i < ARRAY_SIZE(llproto_ids); i++) {
+ if (strcasecmp(name, buf) == 0) {
+ i = llproto_ids[i];
+ goto good;
+ }
+ name += strlen(name) + 1;
}
+ errno = 0;
i = bb_strtou(buf, NULL, 0);
if (errno || i > 0xffff)
return -1;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/nc.c
^
|
@@ -120,7 +120,7 @@
/* getopt32 is _almost_ usable:
** it cannot handle "... -e PROG -prog-opt" */
while ((opt = getopt(argc, argv,
- "" IF_NC_SERVER("lp:") IF_NC_EXTRA("w:i:f:e:") )) > 0
+ "" IF_NC_SERVER("lp:") IF_NC_EXTRA("w:i:f:e:") )) > 0
) {
if (ENABLE_NC_SERVER && opt == 'l')
IF_NC_SERVER(do_listen++);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/netstat.c
^
|
@@ -187,7 +187,7 @@
for (pnp = prg_hash + hi; (pn = *pnp) != NULL; pnp = &pn->next) {
if (pn->inode == inode) {
/* Some warning should be appropriate here
- as we got multiple processes for one i-node */
+ * as we got multiple processes for one i-node */
return;
}
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/ntpd.c
^
|
@@ -46,6 +46,7 @@
#include "libbb.h"
#include <math.h>
#include <netinet/ip.h> /* For IPTOS_LOWDELAY definition */
+#include <sys/resource.h> /* setpriority */
#include <sys/timex.h>
#ifndef IPTOS_LOWDELAY
# define IPTOS_LOWDELAY 0x10
@@ -220,14 +221,14 @@
typedef struct {
len_and_sockaddr *p_lsa;
char *p_dotted;
- /* when to send new query (if p_fd == -1)
- * or when receive times out (if p_fd >= 0): */
int p_fd;
int datapoint_idx;
uint32_t lastpkt_refid;
uint8_t lastpkt_status;
uint8_t lastpkt_stratum;
uint8_t reachable_bits;
+ /* when to send new query (if p_fd == -1)
+ * or when receive times out (if p_fd >= 0): */
double next_action_time;
double p_xmttime;
double lastpkt_recv_time;
@@ -895,6 +896,11 @@
/* Correct various fields which contain time-relative values: */
+ /* Globals: */
+ G.cur_time += offset;
+ G.last_update_recv_time += offset;
+ G.last_script_run += offset;
+
/* p->lastpkt_recv_time, p->next_action_time and such: */
for (item = G.ntp_peers; item != NULL; item = item->link) {
peer_t *pp = (peer_t *) item->data;
@@ -902,11 +908,16 @@
//bb_error_msg("offset:%+f pp->next_action_time:%f -> %f",
// offset, pp->next_action_time, pp->next_action_time + offset);
pp->next_action_time += offset;
+ if (pp->p_fd >= 0) {
+ /* We wait for reply from this peer too.
+ * But due to step we are doing, reply's data is no longer
+ * useful (in fact, it'll be bogus). Stop waiting for it.
+ */
+ close(pp->p_fd);
+ pp->p_fd = -1;
+ set_next(pp, RETRY_INTERVAL);
+ }
}
- /* Globals: */
- G.cur_time += offset;
- G.last_update_recv_time += offset;
- G.last_script_run += offset;
}
@@ -1623,22 +1634,30 @@
) {
//TODO: always do this?
interval = retry_interval();
- goto set_next_and_close_sock;
+ goto set_next_and_ret;
}
xfunc_die();
}
if (size != NTP_MSGSIZE_NOAUTH && size != NTP_MSGSIZE) {
bb_error_msg("malformed packet received from %s", p->p_dotted);
- goto bail;
+ return;
}
if (msg.m_orgtime.int_partl != p->p_xmt_msg.m_xmttime.int_partl
|| msg.m_orgtime.fractionl != p->p_xmt_msg.m_xmttime.fractionl
) {
- goto bail;
+ /* Somebody else's packet */
+ return;
}
+ /* We do not expect any more packets from this peer for now.
+ * Closing the socket informs kernel about it.
+ * We open a new socket when we send a new query.
+ */
+ close(p->p_fd);
+ p->p_fd = -1;
+
if ((msg.m_status & LI_ALARM) == LI_ALARM
|| msg.m_stratum == 0
|| msg.m_stratum > NTP_MAXSTRATUM
@@ -1647,8 +1666,8 @@
// "DENY", "RSTR" - peer does not like us at all
// "RATE" - peer is overloaded, reduce polling freq
interval = poll_interval(0);
- bb_error_msg("reply from %s: not synced, next query in %us", p->p_dotted, interval);
- goto set_next_and_close_sock;
+ bb_error_msg("reply from %s: peer is unsynced, next query in %us", p->p_dotted, interval);
+ goto set_next_and_ret;
}
// /* Verify valid root distance */
@@ -1794,16 +1813,8 @@
/* Decide when to send new query for this peer */
interval = poll_interval(0);
- set_next_and_close_sock:
+ set_next_and_ret:
set_next(p, interval);
- /* We do not expect any more packets from this peer for now.
- * Closing the socket informs kernel about it.
- * We open a new socket when we send a new query.
- */
- close(p->p_fd);
- p->p_fd = -1;
- bail:
- return;
}
#if ENABLE_FEATURE_NTPD_SERVER
@@ -1840,10 +1851,10 @@
/* Build a reply packet */
memset(&msg, 0, sizeof(msg));
- msg.m_status = G.stratum < MAXSTRAT ? G.ntp_status : LI_ALARM;
+ msg.m_status = G.stratum < MAXSTRAT ? (G.ntp_status & LI_MASK) : LI_ALARM;
msg.m_status |= (query_status & VERSION_MASK);
msg.m_status |= ((query_status & MODE_MASK) == MODE_CLIENT) ?
- MODE_SERVER : MODE_SYM_PAS;
+ MODE_SERVER : MODE_SYM_PAS;
msg.m_stratum = G.stratum;
msg.m_ppoll = G.poll_exp;
msg.m_precision_exp = G_precision_exp;
@@ -2069,6 +2080,8 @@
*/
cnt = G.peer_cnt * (INITIAL_SAMPLES + 1);
+ write_pidfile(CONFIG_PID_FILE_PATH "/ntpd.pid");
+
while (!bb_got_signal) {
llist_t *item;
unsigned i, j;
@@ -2184,6 +2197,7 @@
}
} /* while (!bb_got_signal) */
+ remove_pidfile(CONFIG_PID_FILE_PATH "/ntpd.pid");
kill_myself_with_sig(bb_got_signal);
}
@@ -2314,14 +2328,13 @@
if (pps_enable) {
if (!(pll_status & STA_PPSTIME))
report_event(EVNT_KERN,
- NULL, "PPS enabled");
+ NULL, "PPS enabled");
ntv.status |= STA_PPSTIME | STA_PPSFREQ;
} else {
if (pll_status & STA_PPSTIME)
report_event(EVNT_KERN,
- NULL, "PPS disabled");
- ntv.status &= ~(STA_PPSTIME |
- STA_PPSFREQ);
+ NULL, "PPS disabled");
+ ntv.status &= ~(STA_PPSTIME | STA_PPSFREQ);
}
if (sys_leap == LEAP_ADDSECOND)
ntv.status |= STA_INS;
@@ -2337,7 +2350,7 @@
if (ntp_adjtime(&ntv) == TIME_ERROR) {
if (!(ntv.status & STA_PPSSIGNAL))
report_event(EVNT_KERN, NULL,
- "PPS no signal");
+ "PPS no signal");
}
pll_status = ntv.status;
#ifdef STA_NANO
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/ntpd_simple.c
^
|
@@ -7,6 +7,7 @@
*/
#include "libbb.h"
#include <netinet/ip.h> /* For IPTOS_LOWDELAY definition */
+#include <sys/resource.h> /* setpriority */
#ifndef IPTOS_LOWDELAY
# define IPTOS_LOWDELAY 0x10
#endif
@@ -709,7 +710,7 @@
msg.m_status = G.synced ? G.leap : LI_ALARM;
msg.m_status |= (query_status & VERSION_MASK);
msg.m_status |= ((query_status & MODE_MASK) == MODE_CLIENT) ?
- MODE_SERVER : MODE_SYM_PAS;
+ MODE_SERVER : MODE_SYM_PAS;
msg.m_stratum = G.stratum;
msg.m_ppoll = query_ppoll;
msg.m_precision_exp = G_precision_exp;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/ping.c
^
|
@@ -724,7 +724,7 @@
ICMP6_FILTER_SETPASSALL(&filt);
}
if (setsockopt(pingsock, IPPROTO_ICMPV6, ICMP6_FILTER, &filt,
- sizeof(filt)) < 0)
+ sizeof(filt)) < 0)
bb_error_msg_and_die("setsockopt(ICMP6_FILTER)");
}
#endif /*ICMP6_FILTER*/
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/route.c
^
|
@@ -409,7 +409,7 @@
bb_error_msg_and_die("resolving %s", args_m1);
}
memcpy(&rt.rtmsg_gateway, sa6.sin6_addr.s6_addr,
- sizeof(struct in6_addr));
+ sizeof(struct in6_addr));
rt.rtmsg_flags |= RTF_GATEWAY;
continue;
}
@@ -435,7 +435,7 @@
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
strncpy_IFNAMSIZ(ifr.ifr_name, devname);
- xioctl(skfd, SIOGIFINDEX, &ifr);
+ xioctl(skfd, SIOCGIFINDEX, &ifr);
rt.rtmsg_ifindex = ifr.ifr_ifindex;
}
@@ -498,17 +498,17 @@
FILE *fp = xfopen_for_read("/proc/net/route");
printf("Kernel IP routing table\n"
- "Destination Gateway Genmask Flags %s Iface\n",
+ "Destination Gateway Genmask Flags %s Iface\n",
netstatfmt ? " MSS Window irtt" : "Metric Ref Use");
if (fscanf(fp, "%*[^\n]\n") < 0) { /* Skip the first line. */
- goto ERROR; /* Empty or missing line, or read error. */
+ goto ERROR; /* Empty or missing line, or read error. */
}
while (1) {
int r;
r = fscanf(fp, "%63s%lx%lx%X%d%d%d%lx%d%d%d\n",
- devname, &d, &g, &flgs, &ref, &use, &metric, &m,
- &mtu, &win, &ir);
+ devname, &d, &g, &flgs, &ref, &use, &metric, &m,
+ &mtu, &win, &ir);
if (r != 11) {
if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */
break;
@@ -567,8 +567,8 @@
FILE *fp = xfopen_for_read("/proc/net/ipv6_route");
printf("Kernel IPv6 routing table\n%-44s%-40s"
- "Flags Metric Ref Use Iface\n",
- "Destination", "Next Hop");
+ "Flags Metric Ref Use Iface\n",
+ "Destination", "Next Hop");
while (1) {
int r;
@@ -618,8 +618,8 @@
(struct sockaddr *) &snaddr6.sin6_addr);
snaddr6.sin6_family = AF_INET6;
naddr6 = INET6_rresolve((struct sockaddr_in6 *) &snaddr6,
- 0x0fff /* Apparently, upstream never resolves. */
- );
+ 0x0fff /* Apparently, upstream never resolves. */
+ );
if (!r) { /* 1st pass */
snprintf(addr6, sizeof(addr6), "%s/%d", naddr6, prefix_len);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/tc.c
^
|
@@ -391,7 +391,7 @@
printf("root ");
else if (msg->tcm_parent) {
classid = print_tc_classid(filter_qdisc ?
- TC_H_MIN(msg->tcm_parent) : msg->tcm_parent);
+ TC_H_MIN(msg->tcm_parent) : msg->tcm_parent);
printf("parent %s ", classid);
if (ENABLE_FEATURE_CLEAN_UP)
free(classid);
@@ -526,7 +526,8 @@
duparg(*argv, "handle");
/* reject LONG_MIN || LONG_MAX */
/* TODO: for fw
- if ((slash = strchr(handle, '/')) != NULL)
+ slash = strchr(handle, '/');
+ if (slash != NULL)
*slash = '\0';
*/
msg.tcm_handle = get_u32(*argv, "handle");
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/telnet.c
^
|
@@ -186,40 +186,35 @@
static void handle_net_output(int len)
{
- /* here we could do smart tricks how to handle 0xFF:s in output
- * stream like writing twice every sequence of FF:s (thus doing
- * many write()s. But I think interactive telnet application does
- * not need to be 100% 8-bit clean, so changing every 0xff:s to
- * 0x7f:s
- *
- * 2002-mar-21, Przemyslaw Czerpak (druzus@polbox.com)
- * I don't agree.
- * first - I cannot use programs like sz/rz
- * second - the 0x0D is sent as one character and if the next
- * char is 0x0A then it's eaten by a server side.
- * third - why do you have to make 'many write()s'?
- * I don't understand.
- * So I implemented it. It's really useful for me. I hope that
- * other people will find it interesting too.
- */
byte outbuf[2 * DATABUFSIZE];
- byte *p = (byte*)G.buf;
- int j = 0;
+ byte *dst = outbuf;
+ byte *src = (byte*)G.buf;
+ byte *end = src + len;
- for (; len > 0; len--, p++) {
- byte c = *p;
+ while (src < end) {
+ byte c = *src++;
if (c == 0x1d) {
con_escape();
return;
}
- outbuf[j++] = c;
+ *dst = c;
if (c == IAC)
- outbuf[j++] = c; /* IAC -> IAC IAC */
- else if (c == '\r')
- outbuf[j++] = '\0'; /* CR -> CR NUL */
+ *++dst = c; /* IAC -> IAC IAC */
+ else
+ if (c == '\r' || c == '\n') {
+ /* Enter key sends '\r' in raw mode and '\n' in cooked one.
+ *
+ * See RFC 1123 3.3.1 Telnet End-of-Line Convention.
+ * Using CR LF instead of other allowed possibilities
+ * like CR NUL - easier to talk to HTTP/SMTP servers.
+ */
+ *dst = '\r'; /* Enter -> CR LF */
+ *++dst = '\n';
+ }
+ dst++;
}
- if (j > 0)
- full_write(netfd, outbuf, j);
+ if (dst - outbuf != 0)
+ full_write(netfd, outbuf, dst - outbuf);
}
static void handle_net_input(int len)
@@ -398,20 +393,20 @@
}
#endif
-static char const escapecharis[] ALIGN1 = "\r\nEscape character is ";
-
static void setConMode(void)
{
if (G.telflags & UF_ECHO) {
if (G.charmode == CHM_TRY) {
G.charmode = CHM_ON;
- printf("\r\nEntering character mode%s'^]'.\r\n", escapecharis);
+ printf("\r\nEntering %s mode"
+ "\r\nEscape character is '^%c'.\r\n", "character", ']');
rawmode();
}
} else {
if (G.charmode != CHM_OFF) {
G.charmode = CHM_OFF;
- printf("\r\nEntering line mode%s'^C'.\r\n", escapecharis);
+ printf("\r\nEntering %s mode"
+ "\r\nEscape character is '^%c'.\r\n", "line", 'C');
cookmode();
}
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/telnetd.c
^
|
@@ -125,6 +125,7 @@
/* We map \r\n ==> \r for pragmatic reasons.
* Many client implementations send \r\n when
* the user hits the CarriageReturn key.
+ * See RFC 1123 3.3.1 Telnet End-of-Line Convention.
*/
if (c == '\r' && ptr < end && (*ptr == '\n' || *ptr == '\0'))
ptr++;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/tftp.c
^
|
@@ -116,7 +116,7 @@
struct globals {
/* u16 TFTP_ERROR; u16 reason; both network-endian, then error text: */
uint8_t error_pkt[4 + 32];
- char *user_opt;
+ struct passwd *pw;
/* used in tftpd_main(), a bit big for stack: */
char block_buf[TFTP_BLKSIZE_DEFAULT];
#if ENABLE_FEATURE_TFTP_PROGRESS_BAR
@@ -130,13 +130,10 @@
struct BUG_G_too_big {
char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1];
};
-#define block_buf (G.block_buf )
-#define user_opt (G.user_opt )
-#define error_pkt (G.error_pkt )
#define INIT_G() do { } while (0)
-#define error_pkt_reason (error_pkt[3])
-#define error_pkt_str (error_pkt + 4)
+#define G_error_pkt_reason (G.error_pkt[3])
+#define G_error_pkt_str ((char*)(G.error_pkt + 4))
#if ENABLE_FEATURE_TFTP_PROGRESS_BAR
static void tftp_progress_update(void)
@@ -272,12 +269,11 @@
xconnect(socket_fd, &peer_lsa->u.sa, peer_lsa->len);
/* Is there an error already? Send pkt and bail out */
- if (error_pkt_reason || error_pkt_str[0])
+ if (G_error_pkt_reason || G_error_pkt_str[0])
goto send_err_pkt;
- if (user_opt) {
- struct passwd *pw = xgetpwnam(user_opt);
- change_identity(pw); /* initgroups, setgid, setuid */
+ if (G.pw) {
+ change_identity(G.pw); /* initgroups, setgid, setuid */
}
}
@@ -329,8 +325,8 @@
/* Open file (must be after changing user) */
local_fd = open(local_file, open_mode, 0666);
if (local_fd < 0) {
- error_pkt_reason = ERR_NOFILE;
- strcpy((char*)error_pkt_str, "can't open file");
+ G_error_pkt_reason = ERR_NOFILE;
+ strcpy(G_error_pkt_str, "can't open file");
goto send_err_pkt;
}
/* gcc 4.3.1 would NOT optimize it out as it should! */
@@ -575,7 +571,7 @@
if (res) {
blksize = tftp_blksize_check(res, blksize);
if (blksize < 0) {
- error_pkt_reason = ERR_BAD_OPT;
+ G_error_pkt_reason = ERR_BAD_OPT;
goto send_err_pkt;
}
io_bufsize = blksize + 4;
@@ -614,8 +610,8 @@
if (recv_blk == block_nr) {
int sz = full_write(local_fd, &rbuf[4], len - 4);
if (sz != len - 4) {
- strcpy((char*)error_pkt_str, bb_msg_write_error);
- error_pkt_reason = ERR_WRITE;
+ strcpy(G_error_pkt_str, bb_msg_write_error);
+ G_error_pkt_reason = ERR_WRITE;
goto send_err_pkt;
}
if (sz != blksize) {
@@ -664,12 +660,12 @@
return finished == 0; /* returns 1 on failure */
send_read_err_pkt:
- strcpy((char*)error_pkt_str, bb_msg_read_error);
+ strcpy(G_error_pkt_str, bb_msg_read_error);
send_err_pkt:
- if (error_pkt_str[0])
- bb_error_msg("%s", (char*)error_pkt_str);
- error_pkt[1] = TFTP_ERROR;
- xsendto(socket_fd, error_pkt, 4 + 1 + strlen((char*)error_pkt_str),
+ if (G_error_pkt_str[0])
+ bb_error_msg("%s", G_error_pkt_str);
+ G.error_pkt[1] = TFTP_ERROR;
+ xsendto(socket_fd, G.error_pkt, 4 + 1 + strlen(G_error_pkt_str),
&peer_lsa->u.sa, peer_lsa->len);
return EXIT_FAILURE;
#undef remote_file
@@ -761,7 +757,7 @@
{
len_and_sockaddr *our_lsa;
len_and_sockaddr *peer_lsa;
- char *local_file, *mode;
+ char *local_file, *mode, *user_opt;
const char *error_msg;
int opt, result, opcode;
IF_FEATURE_TFTP_BLOCKSIZE(int blksize = TFTP_BLKSIZE_DEFAULT;)
@@ -789,18 +785,22 @@
openlog(applet_name, LOG_PID, LOG_DAEMON);
logmode = LOGMODE_SYSLOG;
}
+ if (opt & TFTPD_OPT_u) {
+ /* Must be before xchroot */
+ G.pw = xgetpwnam(user_opt);
+ }
if (argv[0]) {
xchroot(argv[0]);
}
- result = recv_from_to(STDIN_FILENO, block_buf, sizeof(block_buf),
+ result = recv_from_to(STDIN_FILENO, G.block_buf, sizeof(G.block_buf),
0 /* flags */,
&peer_lsa->u.sa, &our_lsa->u.sa, our_lsa->len);
error_msg = "malformed packet";
- opcode = ntohs(*(uint16_t*)block_buf);
- if (result < 4 || result >= sizeof(block_buf)
- || block_buf[result-1] != '\0'
+ opcode = ntohs(*(uint16_t*)G.block_buf);
+ if (result < 4 || result >= sizeof(G.block_buf)
+ || G.block_buf[result-1] != '\0'
|| (IF_FEATURE_TFTP_PUT(opcode != TFTP_RRQ) /* not download */
IF_GETPUT(&&)
IF_FEATURE_TFTP_GET(opcode != TFTP_WRQ) /* not upload */
@@ -808,27 +808,27 @@
) {
goto err;
}
- local_file = block_buf + 2;
+ local_file = G.block_buf + 2;
if (local_file[0] == '.' || strstr(local_file, "/.")) {
error_msg = "dot in file name";
goto err;
}
mode = local_file + strlen(local_file) + 1;
/* RFC 1350 says mode string is case independent */
- if (mode >= block_buf + result || strcasecmp(mode, "octet") != 0) {
+ if (mode >= G.block_buf + result || strcasecmp(mode, "octet") != 0) {
goto err;
}
# if ENABLE_FEATURE_TFTP_BLOCKSIZE
{
char *res;
char *opt_str = mode + sizeof("octet");
- int opt_len = block_buf + result - opt_str;
+ int opt_len = G.block_buf + result - opt_str;
if (opt_len > 0) {
res = tftp_get_option("blksize", opt_str, opt_len);
if (res) {
blksize = tftp_blksize_check(res, 65564);
if (blksize < 0) {
- error_pkt_reason = ERR_BAD_OPT;
+ G_error_pkt_reason = ERR_BAD_OPT;
/* will just send error pkt */
goto do_proto;
}
@@ -846,7 +846,7 @@
if (!ENABLE_FEATURE_TFTP_PUT || opcode == TFTP_WRQ) {
if (opt & TFTPD_OPT_r) {
/* This would mean "disk full" - not true */
- /*error_pkt_reason = ERR_WRITE;*/
+ /*G_error_pkt_reason = ERR_WRITE;*/
error_msg = bb_msg_write_error;
goto err;
}
@@ -855,7 +855,7 @@
IF_GETPUT(option_mask32 |= TFTP_OPT_PUT;) /* will send file's data */
}
- /* NB: if error_pkt_str or error_pkt_reason is set up,
+ /* NB: if G_error_pkt_str or G_error_pkt_reason is set up,
* tftp_protocol() just sends one error pkt and returns */
do_proto:
@@ -870,7 +870,7 @@
return result;
err:
- strcpy((char*)error_pkt_str, error_msg);
+ strcpy(G_error_pkt_str, error_msg);
goto do_proto;
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/traceroute.c
^
|
@@ -290,9 +290,10 @@
#endif
-#define OPT_STRING "FIlnrdvxt:i:m:p:q:s:w:z:f:" \
- IF_FEATURE_TRACEROUTE_SOURCE_ROUTE("g:") \
- "4" IF_TRACEROUTE6("6")
+#define OPT_STRING \
+ "FIlnrdvxt:i:m:p:q:s:w:z:f:" \
+ IF_FEATURE_TRACEROUTE_SOURCE_ROUTE("g:") \
+ "4" IF_TRACEROUTE6("6")
enum {
OPT_DONT_FRAGMNT = (1 << 0), /* F */
OPT_USE_ICMP = (1 << 1) * ENABLE_FEATURE_TRACEROUTE_USE_ICMP, /* I */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/udhcp/common.h
^
|
@@ -14,7 +14,7 @@
PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
-extern const uint8_t MAC_BCAST_ADDR[6]; /* six all-ones */
+extern const uint8_t MAC_BCAST_ADDR[6] ALIGN2; /* six all-ones */
/*** DHCP packet ***/
@@ -187,8 +187,8 @@
};
extern const struct dhcp_optflag dhcp_optflags[];
-extern const char dhcp_option_strings[];
-extern const uint8_t dhcp_option_lengths[];
+extern const char dhcp_option_strings[] ALIGN1;
+extern const uint8_t dhcp_option_lengths[] ALIGN1;
unsigned FAST_FUNC udhcp_option_idx(const char *name);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/udhcp/d6_dhcpc.c
^
|
@@ -12,10 +12,11 @@
*/
//config:config UDHCPC6
-//config: bool "udhcp client for DHCPv6 (udhcpc6)"
-//config: default n # not yet ready
-//config: help
-//config: udhcpc6 is a DHCPv6 client
+//config: bool "udhcp client for DHCPv6 (udhcpc6)"
+//config: default n # not yet ready
+//config: depends on FEATURE_IPV6
+//config: help
+//config: udhcpc6 is a DHCPv6 client
//applet:IF_UDHCPC6(APPLET(udhcpc6, BB_DIR_USR_BIN, BB_SUID_DROP))
@@ -964,8 +965,6 @@
SERVER_PORT = CLIENT_PORT - 1;
}
#endif
- if (opt & OPT_o)
- client_config.no_default_options = 1;
while (list_O) {
char *optstr = llist_pop(&list_O);
unsigned n = bb_strtou(optstr, NULL, 0);
@@ -975,6 +974,16 @@
}
client_config.opt_mask[n >> 3] |= 1 << (n & 7);
}
+ if (!(opt & OPT_o)) {
+ /*
+ unsigned i, n;
+ for (i = 0; (n = dhcp_optflags[i].code) != 0; i++) {
+ if (dhcp_optflags[i].flags & OPTION_REQ) {
+ client_config.opt_mask[n >> 3] |= 1 << (n & 7);
+ }
+ }
+ */
+ }
while (list_x) {
char *optstr = llist_pop(&list_x);
char *colon = strchr(optstr, ':');
@@ -1065,8 +1074,8 @@
retval = 0;
/* If we already timed out, fall through with retval = 0, else... */
if ((int)tv.tv_sec > 0) {
+ log1("Waiting on select %u seconds", (int)tv.tv_sec);
timestamp_before_wait = (unsigned)monotonic_sec();
- log1("Waiting on select...");
retval = select(max_fd + 1, &rfds, NULL, NULL, &tv);
if (retval < 0) {
/* EINTR? A signal was caught, don't panic */
@@ -1102,7 +1111,7 @@
switch (state) {
case INIT_SELECTING:
- if (packet_num < discover_retries) {
+ if (!discover_retries || packet_num < discover_retries) {
if (packet_num == 0)
xid = random_xid();
/* multicast */
@@ -1131,7 +1140,7 @@
packet_num = 0;
continue;
case REQUESTING:
- if (packet_num < discover_retries) {
+ if (!discover_retries || packet_num < discover_retries) {
/* send multicast select packet */
send_d6_select(xid);
timeout = discover_timeout;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/udhcp/dhcpc.c
^
|
@@ -26,8 +26,8 @@
#include "dhcpc.h"
#include <netinet/if_ether.h>
-#include <netpacket/packet.h>
#include <linux/filter.h>
+#include <linux/if_packet.h>
/* "struct client_config_t client_config" is in bb_common_bufsiz1 */
@@ -589,7 +589,6 @@
static void add_client_options(struct dhcp_packet *packet)
{
- uint8_t c;
int i, end, len;
udhcp_add_simple_option(packet, DHCP_MAX_SIZE, htons(IP_UDP_DHCP_SIZE));
@@ -599,13 +598,9 @@
* No bounds checking because it goes towards the head of the packet. */
end = udhcp_end_option(packet->options);
len = 0;
- for (i = 0; (c = dhcp_optflags[i].code) != 0; i++) {
- if (( (dhcp_optflags[i].flags & OPTION_REQ)
- && !client_config.no_default_options
- )
- || (client_config.opt_mask[c >> 3] & (1 << (c & 7)))
- ) {
- packet->options[end + OPT_DATA + len] = c;
+ for (i = 1; i < DHCP_END; i++) {
+ if (client_config.opt_mask[i >> 3] & (1 << (i & 7))) {
+ packet->options[end + OPT_DATA + len] = i;
len++;
}
}
@@ -841,12 +836,31 @@
int bytes;
struct ip_udp_dhcp_packet packet;
uint16_t check;
+ unsigned char cmsgbuf[CMSG_LEN(sizeof(struct tpacket_auxdata))];
+ struct iovec iov;
+ struct msghdr msg;
+ struct cmsghdr *cmsg;
- bytes = safe_read(fd, &packet, sizeof(packet));
- if (bytes < 0) {
- log1("Packet read error, ignoring");
- /* NB: possible down interface, etc. Caller should pause. */
- return bytes; /* returns -1 */
+ /* used to use just safe_read(fd, &packet, sizeof(packet))
+ * but we need to check for TP_STATUS_CSUMNOTREADY :(
+ */
+ iov.iov_base = &packet;
+ iov.iov_len = sizeof(packet);
+ memset(&msg, 0, sizeof(msg));
+ msg.msg_iov = &iov;
+ msg.msg_iovlen = 1;
+ msg.msg_control = cmsgbuf;
+ msg.msg_controllen = sizeof(cmsgbuf);
+ for (;;) {
+ bytes = recvmsg(fd, &msg, 0);
+ if (bytes < 0) {
+ if (errno == EINTR)
+ continue;
+ log1("Packet read error, ignoring");
+ /* NB: possible down interface, etc. Caller should pause. */
+ return bytes; /* returns -1 */
+ }
+ break;
}
if (bytes < (int) (sizeof(packet.ip) + sizeof(packet.udp))) {
@@ -883,6 +897,20 @@
return -2;
}
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ if (cmsg->cmsg_level == SOL_PACKET
+ && cmsg->cmsg_type == PACKET_AUXDATA
+ ) {
+ /* some VMs don't checksum UDP and TCP data
+ * they send to the same physical machine,
+ * here we detect this case:
+ */
+ struct tpacket_auxdata *aux = (void *)CMSG_DATA(cmsg);
+ if (aux->tp_status & TP_STATUS_CSUMNOTREADY)
+ goto skip_udp_sum_check;
+ }
+ }
+
/* verify UDP checksum. IP header has to be modified for this */
memset(&packet.ip, 0, offsetof(struct iphdr, protocol));
/* ip.xx fields which are not memset: protocol, check, saddr, daddr */
@@ -893,6 +921,7 @@
log1("Packet with bad UDP checksum received, ignoring");
return -2;
}
+ skip_udp_sum_check:
if (packet.data.cookie != htonl(DHCP_MAGIC)) {
bb_info_msg("Packet with bad magic, ignoring");
@@ -988,7 +1017,7 @@
log1("Opening raw socket on ifindex %d", ifindex); //log2?
fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
- log1("Got raw socket fd %d", fd); //log2?
+ log1("Got raw socket fd"); //log2?
sock.sll_family = AF_PACKET;
sock.sll_protocol = htons(ETH_P_IP);
@@ -1000,7 +1029,14 @@
/* Ignoring error (kernel may lack support for this) */
if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog,
sizeof(filter_prog)) >= 0)
- log1("Attached filter to raw socket fd %d", fd); // log?
+ log1("Attached filter to raw socket fd"); // log?
+ }
+
+ if (setsockopt(fd, SOL_PACKET, PACKET_AUXDATA,
+ &const_int_1, sizeof(int)) < 0
+ ) {
+ if (errno != ENOPROTOOPT)
+ log1("Can't set PACKET_AUXDATA on raw socket");
}
log1("Created raw socket");
@@ -1257,8 +1293,6 @@
SERVER_PORT = CLIENT_PORT - 1;
}
#endif
- if (opt & OPT_o)
- client_config.no_default_options = 1;
while (list_O) {
char *optstr = llist_pop(&list_O);
unsigned n = bb_strtou(optstr, NULL, 0);
@@ -1268,6 +1302,14 @@
}
client_config.opt_mask[n >> 3] |= 1 << (n & 7);
}
+ if (!(opt & OPT_o)) {
+ unsigned i, n;
+ for (i = 0; (n = dhcp_optflags[i].code) != 0; i++) {
+ if (dhcp_optflags[i].flags & OPTION_REQ) {
+ client_config.opt_mask[n >> 3] |= 1 << (n & 7);
+ }
+ }
+ }
while (list_x) {
char *optstr = llist_pop(&list_x);
char *colon = strchr(optstr, ':');
@@ -1362,8 +1404,8 @@
retval = 0;
/* If we already timed out, fall through with retval = 0, else... */
if ((int)tv.tv_sec > 0) {
+ log1("Waiting on select %u seconds", (int)tv.tv_sec);
timestamp_before_wait = (unsigned)monotonic_sec();
- log1("Waiting on select...");
retval = select(max_fd + 1, &rfds, NULL, NULL, &tv);
if (retval < 0) {
/* EINTR? A signal was caught, don't panic */
@@ -1400,7 +1442,7 @@
switch (state) {
case INIT_SELECTING:
- if (packet_num < discover_retries) {
+ if (!discover_retries || packet_num < discover_retries) {
if (packet_num == 0)
xid = random_xid();
/* broadcast */
@@ -1429,7 +1471,7 @@
packet_num = 0;
continue;
case REQUESTING:
- if (packet_num < discover_retries) {
+ if (!discover_retries || packet_num < discover_retries) {
/* send broadcast select packet */
send_select(xid, server_addr, requested_ip);
timeout = discover_timeout;
@@ -1681,7 +1723,7 @@
#endif
/* enter bound state */
timeout = lease_seconds / 2;
- temp_addr.s_addr = packet.yiaddr;
+ temp_addr.s_addr = packet.yiaddr;
bb_info_msg("Lease of %s obtained, lease time %u",
inet_ntoa(temp_addr), (unsigned)lease_seconds);
requested_ip = packet.yiaddr;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/udhcp/dhcpc.h
^
|
@@ -9,7 +9,6 @@
struct client_config_t {
uint8_t client_mac[6]; /* Our mac address */
- char no_default_options; /* Do not include default options in request */
IF_FEATURE_UDHCP_PORT(uint16_t port;)
int ifindex; /* Index number of the interface to use */
uint8_t opt_mask[256 / 8]; /* Bitmask of options to send (-O option) */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/udhcp/dhcpd.c
^
|
@@ -377,6 +377,7 @@
/* Setup the signal pipe */
udhcp_sp_setup();
+ continue_with_autotime:
timeout_end = monotonic_sec() + server_config.auto_time;
while (1) { /* loop until universe collapses */
fd_set rfds;
@@ -406,8 +407,7 @@
}
if (retval == 0) {
write_leases();
- timeout_end = monotonic_sec() + server_config.auto_time;
- continue;
+ goto continue_with_autotime;
}
if (retval < 0 && errno != EINTR) {
log1("Error on select");
@@ -419,10 +419,10 @@
bb_info_msg("Received SIGUSR1");
write_leases();
/* why not just reset the timeout, eh */
- timeout_end = monotonic_sec() + server_config.auto_time;
- continue;
+ goto continue_with_autotime;
case SIGTERM:
bb_info_msg("Received SIGTERM");
+ write_leases();
goto ret0;
case 0: /* no signal: read a packet */
break;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/udhcp/socket.c
^
|
@@ -80,6 +80,7 @@
{
int fd;
struct sockaddr_in addr;
+ char *colon;
log1("Opening listen socket on *:%d %s", port, inf);
fd = xsocket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
@@ -88,10 +89,17 @@
if (setsockopt_broadcast(fd) == -1)
bb_perror_msg_and_die("SO_BROADCAST");
- /* NB: bug 1032 says this doesn't work on ethernet aliases (ethN:M) */
+ /* SO_BINDTODEVICE doesn't work on ethernet aliases (ethN:M) */
+ colon = strrchr(inf, ':');
+ if (colon)
+ *colon = '\0';
+
if (setsockopt_bindtodevice(fd, inf))
xfunc_die(); /* warning is already printed */
+ if (colon)
+ *colon = ':';
+
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/networking/wget.c
^
|
@@ -13,8 +13,9 @@
//usage: IF_FEATURE_WGET_LONG_OPTIONS(
//usage: "[-c|--continue] [-s|--spider] [-q|--quiet] [-O|--output-document FILE]\n"
//usage: " [--header 'header: value'] [-Y|--proxy on/off] [-P DIR]\n"
-//usage: " [--no-check-certificate] [-U|--user-agent AGENT]"
-//usage: IF_FEATURE_WGET_TIMEOUT(" [-T SEC]") " URL..."
+/* Since we ignore these opts, we don't show them in --help */
+/* //usage: " [--no-check-certificate] [--no-cache]" */
+//usage: " [-U|--user-agent AGENT]" IF_FEATURE_WGET_TIMEOUT(" [-T SEC]") " URL..."
//usage: )
//usage: IF_NOT_FEATURE_WGET_LONG_OPTIONS(
//usage: "[-csq] [-O FILE] [-Y on/off] [-P DIR] [-U AGENT]"
@@ -35,8 +36,11 @@
#include "libbb.h"
-//#define log_io(...) bb_error_msg(__VA_ARGS__)
-#define log_io(...) ((void)0)
+#if 0
+# define log_io(...) bb_error_msg(__VA_ARGS__)
+#else
+# define log_io(...) ((void)0)
+#endif
struct host_info {
@@ -316,8 +320,6 @@
char *s, *hdrval;
int c;
- /* *istrunc = 0; */
-
/* retrieve header line */
c = fgets_and_trim(fp);
@@ -348,6 +350,15 @@
return hdrval;
}
+static void reset_beg_range_to_zero(void)
+{
+ bb_error_msg("restart failed");
+ G.beg_range = 0;
+ xlseek(G.output_fd, 0, SEEK_SET);
+ /* Done at the end instead: */
+ /* ftruncate(G.output_fd, 0); */
+}
+
static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_sockaddr *lsa)
{
FILE *sfp;
@@ -415,10 +426,12 @@
*dfpp = open_socket(lsa);
- if (G.beg_range) {
+ if (G.beg_range != 0) {
sprintf(G.wget_buf, "REST %"OFF_FMT"u", G.beg_range);
if (ftpcmd(G.wget_buf, NULL, sfp) == 350)
G.content_len -= G.beg_range;
+ else
+ reset_beg_range_to_zero();
}
if (ftpcmd("RETR ", target->path, sfp) > 150)
@@ -431,7 +444,7 @@
{
#if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT
# if ENABLE_FEATURE_WGET_TIMEOUT
- unsigned second_cnt;
+ unsigned second_cnt = G.timeout_seconds;
# endif
struct pollfd polldata;
@@ -452,7 +465,7 @@
* which messes up progress bar and/or timeout logic.
* Because of nonblocking I/O, we need to dance
* very carefully around EAGAIN. See explanation at
- * clearerr() call.
+ * clearerr() calls.
*/
ndelay_on(polldata.fd);
#endif
@@ -460,32 +473,7 @@
int n;
unsigned rdsz;
- rdsz = sizeof(G.wget_buf);
- if (G.got_clen) {
- if (G.content_len < (off_t)sizeof(G.wget_buf)) {
- if ((int)G.content_len <= 0)
- break;
- rdsz = (unsigned)G.content_len;
- }
- }
-
#if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT
-# if ENABLE_FEATURE_WGET_TIMEOUT
- second_cnt = G.timeout_seconds;
-# endif
- while (1) {
- if (safe_poll(&polldata, 1, 1000) != 0)
- break; /* error, EOF, or data is available */
-# if ENABLE_FEATURE_WGET_TIMEOUT
- if (second_cnt != 0 && --second_cnt == 0) {
- progress_meter(PROGRESS_END);
- bb_error_msg_and_die("download timed out");
- }
-# endif
- /* Needed for "stalled" indicator */
- progress_meter(PROGRESS_BUMP);
- }
-
/* fread internally uses read loop, which in our case
* is usually exited when we get EAGAIN.
* In this case, libc sets error marker on the stream.
@@ -495,36 +483,71 @@
* into if (n <= 0) ...
*/
clearerr(dfp);
- errno = 0;
#endif
+ errno = 0;
+ rdsz = sizeof(G.wget_buf);
+ if (G.got_clen) {
+ if (G.content_len < (off_t)sizeof(G.wget_buf)) {
+ if ((int)G.content_len <= 0)
+ break;
+ rdsz = (unsigned)G.content_len;
+ }
+ }
n = fread(G.wget_buf, 1, rdsz, dfp);
- /* man fread:
+
+ if (n > 0) {
+ xwrite(G.output_fd, G.wget_buf, n);
+#if ENABLE_FEATURE_WGET_STATUSBAR
+ G.transferred += n;
+#endif
+ if (G.got_clen) {
+ G.content_len -= n;
+ if (G.content_len == 0)
+ break;
+ }
+#if ENABLE_FEATURE_WGET_TIMEOUT
+ second_cnt = G.timeout_seconds;
+#endif
+ continue;
+ }
+
+ /* n <= 0.
+ * man fread:
* If error occurs, or EOF is reached, the return value
* is a short item count (or zero).
* fread does not distinguish between EOF and error.
*/
- if (n <= 0) {
-#if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT
- if (errno == EAGAIN) /* poll lied, there is no data? */
- continue; /* yes */
-#endif
- if (ferror(dfp))
+ if (errno != EAGAIN) {
+ if (ferror(dfp)) {
+ progress_meter(PROGRESS_END);
bb_perror_msg_and_die(bb_msg_read_error);
+ }
break; /* EOF, not error */
}
- xwrite(G.output_fd, G.wget_buf, n);
-
-#if ENABLE_FEATURE_WGET_STATUSBAR
- G.transferred += n;
+#if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT
+ /* It was EAGAIN. There is no data. Wait up to one second
+ * then abort if timed out, or update the bar and try reading again.
+ */
+ if (safe_poll(&polldata, 1, 1000) == 0) {
+# if ENABLE_FEATURE_WGET_TIMEOUT
+ if (second_cnt != 0 && --second_cnt == 0) {
+ progress_meter(PROGRESS_END);
+ bb_error_msg_and_die("download timed out");
+ }
+# endif
+ /* We used to loop back to poll here,
+ * but there is no great harm in letting fread
+ * to try reading anyway.
+ */
+ }
+ /* Need to do it _every_ second for "stalled" indicator
+ * to be shown properly.
+ */
progress_meter(PROGRESS_BUMP);
#endif
- if (G.got_clen) {
- G.content_len -= n;
- if (G.content_len == 0)
- break;
- }
- }
+ } /* while (reading data) */
+
#if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT
clearerr(dfp);
ndelay_off(polldata.fd); /* else fgets can get very unhappy */
@@ -540,6 +563,24 @@
if (G.content_len == 0)
break; /* all done! */
G.got_clen = 1;
+ /*
+ * Note that fgets may result in some data being buffered in dfp.
+ * We loop back to fread, which will retrieve this data.
+ * Also note that code has to be arranged so that fread
+ * is done _before_ one-second poll wait - poll doesn't know
+ * about stdio buffering and can result in spurious one second waits!
+ */
+ }
+
+ /* If -c failed, we restart from the beginning,
+ * but we do not truncate file then, we do it only now, at the end.
+ * This lets user to ^C if his 99% complete 10 GB file download
+ * failed to restart *without* losing the almost complete file.
+ */
+ {
+ off_t pos = lseek(G.output_fd, 0, SEEK_CUR);
+ if (pos != (off_t)-1)
+ ftruncate(G.output_fd, pos);
}
/* Draw full bar and free its resources */
@@ -597,13 +638,11 @@
if (G.fname_out[0] == '/' || !G.fname_out[0])
G.fname_out = (char*)"index.html";
/* -P DIR is considered only if there was no -O FILE */
+ if (G.dir_prefix)
+ G.fname_out = fname_out_alloc = concat_path_file(G.dir_prefix, G.fname_out);
else {
- if (G.dir_prefix)
- G.fname_out = fname_out_alloc = concat_path_file(G.dir_prefix, G.fname_out);
- else {
- /* redirects may free target.path later, need to make a copy */
- G.fname_out = fname_out_alloc = xstrdup(G.fname_out);
- }
+ /* redirects may free target.path later, need to make a copy */
+ G.fname_out = fname_out_alloc = xstrdup(G.fname_out);
}
}
#if ENABLE_FEATURE_WGET_STATUSBAR
@@ -675,7 +714,7 @@
}
#endif
- if (G.beg_range)
+ if (G.beg_range != 0)
fprintf(sfp, "Range: bytes=%"OFF_FMT"u-\r\n", G.beg_range);
#if ENABLE_FEATURE_WGET_LONG_OPTIONS
@@ -742,15 +781,23 @@
(e.g. Boa/0.94.14rc21) simply use code 204 when file size is zero.
*/
case 204:
+ if (G.beg_range != 0) {
+ /* "Range:..." was not honored by the server.
+ * Restart download from the beginning.
+ */
+ reset_beg_range_to_zero();
+ }
break;
case 300: /* redirection */
case 301:
case 302:
case 303:
break;
- case 206:
- if (G.beg_range)
+ case 206: /* Partial Content */
+ if (G.beg_range != 0)
+ /* "Range:..." worked. Good. */
break;
+ /* Partial Content even though we did not ask for it??? */
/* fall through */
default:
bb_error_msg_and_die("server returned error: %s", sanitize_string(G.wget_buf));
@@ -878,6 +925,8 @@
"post-data\0" Required_argument "\xfd"
/* Ignored (we don't do ssl) */
"no-check-certificate\0" No_argument "\xfc"
+ /* Ignored (we don't support caching) */
+ "no-cache\0" No_argument "\xfb"
;
#endif
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/printutils/lpr.c
^
|
@@ -89,6 +89,10 @@
unsigned opts;
int fd;
+ queue = getenv("PRINTER");
+ if (!queue)
+ queue = "lp";
+
// parse options
// TODO: set opt_complementary: s,d,f are mutually exclusive
opts = getopt32(argv,
@@ -98,16 +102,7 @@
);
argv += optind;
- // if queue is not specified -> use $PRINTER
- if (!(opts & OPT_P))
- queue = getenv("PRINTER");
- // if queue is still not specified ->
- if (!queue) {
- // ... queue defaults to "lp"
- // server defaults to "localhost"
- queue = "lp";
- // if queue is specified ->
- } else {
+ {
// queue name is to the left of '@'
char *s = strchr(queue, '@');
if (s) {
@@ -186,6 +181,17 @@
dfd = xopen(*argv, O_RDONLY);
}
+ st.st_size = 0; /* paranoia: fstat may theoretically fail */
+ fstat(dfd, &st);
+
+ /* Apparently, some servers are buggy and won't accept 0-sized jobs.
+ * Standard lpr works around it by refusing to send such jobs:
+ */
+ if (st.st_size == 0) {
+ bb_error_msg("nothing to print");
+ continue;
+ }
+
/* "The name ... should start with ASCII "cfA",
* followed by a three digit job number, followed
* by the host name which has constructed the file."
@@ -210,14 +216,11 @@
, (opts & LPR_m) ? user : ""
, remote_filename
);
- // delete possible "\nX\n" patterns
+ // delete possible "\nX\n" (that is, one-char) patterns
c = controlfile;
- cflen = (unsigned)strlen(controlfile);
while ((c = strchr(c, '\n')) != NULL) {
if (c[1] && c[2] == '\n') {
- /* can't use strcpy, results are undefined */
- memmove(c, c+2, cflen - (c-controlfile) - 1);
- cflen -= 2;
+ overlapping_strcpy(c, c+2);
} else {
c++;
}
@@ -228,6 +231,7 @@
bb_error_msg("sending control file");
/* "Acknowledgement processing must occur as usual
* after the command is sent." */
+ cflen = (unsigned)strlen(controlfile);
fdprintf(fd, "\x2" "%u c%s\n", cflen, remote_filename);
get_response_or_say_and_die(fd, "sending control file");
/* "Once all of the contents have
@@ -241,8 +245,6 @@
// send data file, with name "dfaXXX"
if (opts & LPR_V)
bb_error_msg("sending data file");
- st.st_size = 0; /* paranoia: fstat may theoretically fail */
- fstat(dfd, &st);
fdprintf(fd, "\x3" "%"OFF_FMT"u d%s\n", st.st_size, remote_filename);
get_response_or_say_and_die(fd, "sending data file");
if (bb_copyfd_size(dfd, fd, st.st_size) != st.st_size) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/procps/Config.src
^
|
@@ -140,60 +140,6 @@
help
Configure kernel parameters at runtime.
-config TOP
- bool "top"
- default y
- help
- The top program provides a dynamic real-time view of a running
- system.
-
-config FEATURE_TOP_CPU_USAGE_PERCENTAGE
- bool "Show CPU per-process usage percentage"
- default y
- depends on TOP
- help
- Make top display CPU usage for each process.
- This adds about 2k.
-
-config FEATURE_TOP_CPU_GLOBAL_PERCENTS
- bool "Show CPU global usage percentage"
- default y
- depends on FEATURE_TOP_CPU_USAGE_PERCENTAGE
- help
- Makes top display "CPU: NN% usr NN% sys..." line.
- This adds about 0.5k.
-
-config FEATURE_TOP_SMP_CPU
- bool "SMP CPU usage display ('c' key)"
- default y
- depends on FEATURE_TOP_CPU_GLOBAL_PERCENTS
- help
- Allow 'c' key to switch between individual/cumulative CPU stats
- This adds about 0.5k.
-
-config FEATURE_TOP_DECIMALS
- bool "Show 1/10th of a percent in CPU/mem statistics"
- default y
- depends on FEATURE_TOP_CPU_USAGE_PERCENTAGE
- help
- Show 1/10th of a percent in CPU/mem statistics.
- This adds about 0.3k.
-
-config FEATURE_TOP_SMP_PROCESS
- bool "Show CPU process runs on ('j' field)"
- default y
- depends on TOP
- help
- Show CPU where process was last found running on.
- This is the 'j' field.
-
-config FEATURE_TOPMEM
- bool "Topmem command ('s' key)"
- default y
- depends on TOP
- help
- Enable 's' in top (gives lots of memory info).
-
config FEATURE_SHOW_THREADS
bool "Support for showing threads in ps/pstree/top"
default y
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/procps/nmeter.c
^
|
@@ -271,7 +271,7 @@
}
// Parses /proc/diskstats
-// 1 2 3 4 5 6(rd) 7 8 9 10(wr) 11 12 13 14
+// 1 2 3 4 5 6(rd) 7 8 9 10(wr) 11 12 13 14
// 3 0 hda 51292 14441 841783 926052 25717 79650 843256 3029804 0 148459 3956933
// 3 1 hda1 0 0 0 0 <- ignore if only 4 fields
// Linux 3.0 (maybe earlier) started printing full stats for hda1 too.
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/procps/powertop.c
^
|
@@ -9,7 +9,7 @@
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
-//applet:IF_POWERTOP(APPLET(powertop, BB_DIR_BIN, BB_SUID_DROP))
+//applet:IF_POWERTOP(APPLET(powertop, BB_DIR_USR_SBIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_POWERTOP) += powertop.o
@@ -493,7 +493,7 @@
* Get information about CPU using CPUID opcode.
*/
static void cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx,
- unsigned int *edx)
+ unsigned int *edx)
{
/* EAX value specifies what information to return */
__asm__(
@@ -650,7 +650,7 @@
} else {
bb_putchar('\n');
bb_error_msg("no stats available; run as root or"
- " enable the cpufreq_stats module");
+ " enable the timer_stats module");
}
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/procps/ps.c
^
|
@@ -655,9 +655,9 @@
time_t now = now;
long uptime;
#endif
- int opts = 0;
/* If we support any options, parse argv */
#if ENABLE_SELINUX || ENABLE_FEATURE_SHOW_THREADS || ENABLE_FEATURE_PS_WIDE || ENABLE_FEATURE_PS_LONG
+ int opts = 0;
# if ENABLE_FEATURE_PS_WIDE
/* -w is a bit complicated */
int w_count = 0;
@@ -711,10 +711,10 @@
* We also show STIME (standard says that -f shows it, -l doesn't).
*/
puts("S UID PID PPID VSZ RSS TTY STIME TIME CMD");
-#if ENABLE_FEATURE_PS_LONG
+# if ENABLE_FEATURE_PS_LONG
now = time(NULL);
uptime = get_uptime();
-#endif
+# endif
}
else {
puts(" PID USER VSZ STAT COMMAND");
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/procps/sysctl.c
^
|
@@ -12,21 +12,23 @@
*/
//usage:#define sysctl_trivial_usage
-//usage: "[OPTIONS] [VALUE]..."
+//usage: "[OPTIONS] [KEY[=VALUE]]..."
//usage:#define sysctl_full_usage "\n\n"
-//usage: "Configure kernel parameters at runtime\n"
-//usage: "\n -n Don't print key names"
+//usage: "Show/set kernel parameters\n"
//usage: "\n -e Don't warn about unknown keys"
-//usage: "\n -w Change sysctl setting"
-//usage: "\n -p FILE Load sysctl settings from FILE (default /etc/sysctl.conf)"
-//usage: "\n -a Display all values"
-//usage: "\n -A Display all values in table form"
+//usage: "\n -n Don't show key names"
+//usage: "\n -a Show all values"
+/* Same as -a, no need to show it */
+/* //usage: "\n -A Show all values in table form" */
+//usage: "\n -w Set values"
+//usage: "\n -p FILE Set values from FILE (default /etc/sysctl.conf)"
+//usage: "\n -q Set values silently"
//usage:
//usage:#define sysctl_example_usage
//usage: "sysctl [-n] [-e] variable...\n"
-//usage: "sysctl [-n] [-e] -w variable=value...\n"
+//usage: "sysctl [-n] [-e] [-q] -w variable=value...\n"
//usage: "sysctl [-n] [-e] -a\n"
-//usage: "sysctl [-n] [-e] -p file (default /etc/sysctl.conf)\n"
+//usage: "sysctl [-n] [-e] [-q] -p file (default /etc/sysctl.conf)\n"
//usage: "sysctl [-n] [-e] -A\n"
#include "libbb.h"
@@ -37,9 +39,11 @@
FLAG_TABLE_FORMAT = 1 << 2, /* not implemented */
FLAG_SHOW_ALL = 1 << 3,
FLAG_PRELOAD_FILE = 1 << 4,
+/* TODO: procps 3.2.8 seems to not require -w for KEY=VAL to work: */
FLAG_WRITE = 1 << 5,
+ FLAG_QUIET = 1 << 6,
};
-#define OPTION_STR "neAapw"
+#define OPTION_STR "neAapwq"
static void sysctl_dots_to_slashes(char *name)
{
@@ -144,9 +148,11 @@
//TODO: procps 3.2.7 writes "value\n", note trailing "\n"
xwrite_str(fd, value);
close(fd);
- if (option_mask32 & FLAG_SHOW_KEYS)
- printf("%s = ", outname);
- puts(value);
+ if (!(option_mask32 & FLAG_QUIET)) {
+ if (option_mask32 & FLAG_SHOW_KEYS)
+ printf("%s = ", outname);
+ puts(value);
+ }
} else {
char c;
@@ -199,7 +205,7 @@
continue; /* d_name is "." or ".." */
/* if path was ".", drop "./" prefix: */
retval |= sysctl_act_recursive((next[0] == '.' && next[1] == '/') ?
- next + 2 : next);
+ next + 2 : next);
free(next);
}
closedir(dirp);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/procps/top.c
^
|
@@ -50,6 +50,60 @@
* chroot . ./top -bn1 >top1.out
*/
+//config:config TOP
+//config: bool "top"
+//config: default y
+//config: help
+//config: The top program provides a dynamic real-time view of a running
+//config: system.
+//config:
+//config:config FEATURE_TOP_CPU_USAGE_PERCENTAGE
+//config: bool "Show CPU per-process usage percentage"
+//config: default y
+//config: depends on TOP
+//config: help
+//config: Make top display CPU usage for each process.
+//config: This adds about 2k.
+//config:
+//config:config FEATURE_TOP_CPU_GLOBAL_PERCENTS
+//config: bool "Show CPU global usage percentage"
+//config: default y
+//config: depends on FEATURE_TOP_CPU_USAGE_PERCENTAGE
+//config: help
+//config: Makes top display "CPU: NN% usr NN% sys..." line.
+//config: This adds about 0.5k.
+//config:
+//config:config FEATURE_TOP_SMP_CPU
+//config: bool "SMP CPU usage display ('c' key)"
+//config: default y
+//config: depends on FEATURE_TOP_CPU_GLOBAL_PERCENTS
+//config: help
+//config: Allow 'c' key to switch between individual/cumulative CPU stats
+//config: This adds about 0.5k.
+//config:
+//config:config FEATURE_TOP_DECIMALS
+//config: bool "Show 1/10th of a percent in CPU/mem statistics"
+//config: default y
+//config: depends on FEATURE_TOP_CPU_USAGE_PERCENTAGE
+//config: help
+//config: Show 1/10th of a percent in CPU/mem statistics.
+//config: This adds about 0.3k.
+//config:
+//config:config FEATURE_TOP_SMP_PROCESS
+//config: bool "Show CPU process runs on ('j' field)"
+//config: default y
+//config: depends on TOP
+//config: help
+//config: Show CPU where process was last found running on.
+//config: This is the 'j' field.
+//config:
+//config:config FEATURE_TOPMEM
+//config: bool "Topmem command ('s' key)"
+//config: default y
+//config: depends on TOP
+//config: help
+//config: Enable 's' in top (gives lots of memory info).
+
#include "libbb.h"
@@ -99,8 +153,13 @@
#if ENABLE_FEATURE_TOP_SMP_CPU
smallint smp_cpu_info; /* one/many cpu info lines? */
#endif
+ unsigned lines; /* screen height */
#if ENABLE_FEATURE_USE_TERMIOS
struct termios initial_settings;
+ int scroll_ofs;
+#define G_scroll_ofs G.scroll_ofs
+#else
+#define G_scroll_ofs 0
#endif
#if !ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
cmp_funcp sort_function[1];
@@ -118,6 +177,9 @@
jiffy_counts_t *cpu_jif, *cpu_prev_jif;
int num_cpus;
#endif
+#if ENABLE_FEATURE_USE_TERMIOS
+ char kbd_input[KEYCODE_BUFFER_SIZE];
+#endif
char line_buf[80];
}; //FIX_ALIASING; - large code growth
enum { LINE_BUF_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line_buf) };
@@ -602,9 +664,9 @@
/* Ok, all preliminary data is ready, go through the list */
scr_width += 2; /* account for leading '\n' and trailing NUL */
- if (lines_rem > ntop)
- lines_rem = ntop;
- s = top;
+ if (lines_rem > ntop - G_scroll_ofs)
+ lines_rem = ntop - G_scroll_ofs;
+ s = top + G_scroll_ofs;
while (--lines_rem >= 0) {
unsigned col;
CALC_STAT(pmem, (s->vsz*pmem_scale + pmem_half) >> pmem_shift);
@@ -649,14 +711,14 @@
clear_username_cache();
free(top);
top = NULL;
- ntop = 0;
}
#if ENABLE_FEATURE_USE_TERMIOS
static void reset_term(void)
{
- tcsetattr_stdin_TCSANOW(&initial_settings);
+ if (!OPT_BATCH_MODE)
+ tcsetattr_stdin_TCSANOW(&initial_settings);
if (ENABLE_FEATURE_CLEAN_UP) {
clearmems();
# if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
@@ -665,10 +727,10 @@
}
}
-static void sig_catcher(int sig UNUSED_PARAM)
+static void sig_catcher(int sig)
{
reset_term();
- _exit(EXIT_FAILURE);
+ kill_myself_with_sig(sig);
}
#endif /* FEATURE_USE_TERMIOS */
@@ -793,7 +855,7 @@
{
#define HDR_STR " PID VSZ VSZRW RSS (SHR) DIRTY (SHR) STACK"
#define MIN_WIDTH sizeof(HDR_STR)
- const topmem_status_t *s = topmem;
+ const topmem_status_t *s = topmem + G_scroll_ofs;
display_topmem_header(scr_width, &lines_rem);
strcpy(line_buf, HDR_STR " COMMAND");
@@ -801,8 +863,8 @@
printf(OPT_BATCH_MODE ? "%.*s" : "\e[7m%.*s\e[0m", scr_width, line_buf);
lines_rem--;
- if (lines_rem > ntop)
- lines_rem = ntop;
+ if (lines_rem > ntop - G_scroll_ofs)
+ lines_rem = ntop - G_scroll_ofs;
while (--lines_rem >= 0) {
/* PID VSZ VSZRW RSS (SHR) DIRTY (SHR) COMMAND */
ulltoa6_and_space(s->pid , &line_buf[0*6]);
@@ -856,26 +918,63 @@
#if ENABLE_FEATURE_USE_TERMIOS
static unsigned handle_input(unsigned scan_mask, unsigned interval)
{
- unsigned char c;
struct pollfd pfd[1];
+ if (option_mask32 & OPT_EOF) {
+ /* EOF on stdin ("top </dev/null") */
+ sleep(interval);
+ return scan_mask;
+ }
+
pfd[0].fd = 0;
pfd[0].events = POLLIN;
while (1) {
- if (safe_poll(pfd, 1, interval * 1000) <= 0)
- return scan_mask;
- interval = 0;
+ int32_t c;
- if (safe_read(STDIN_FILENO, &c, 1) != 1) { /* error/EOF? */
+ c = read_key(STDIN_FILENO, G.kbd_input, interval * 1000);
+ if (c == -1 && errno != EAGAIN) {
+ /* error/EOF */
option_mask32 |= OPT_EOF;
- return scan_mask;
+ break;
}
+ interval = 0;
if (c == initial_settings.c_cc[VINTR])
return EXIT_MASK;
if (c == initial_settings.c_cc[VEOF])
return EXIT_MASK;
+
+ if (c == KEYCODE_UP) {
+ G_scroll_ofs--;
+ goto normalize_ofs;
+ }
+ if (c == KEYCODE_DOWN) {
+ G_scroll_ofs++;
+ goto normalize_ofs;
+ }
+ if (c == KEYCODE_HOME) {
+ G_scroll_ofs = 0;
+ break;
+ }
+ if (c == KEYCODE_END) {
+ G_scroll_ofs = ntop - G.lines / 2;
+ goto normalize_ofs;
+ }
+ if (c == KEYCODE_PAGEUP) {
+ G_scroll_ofs -= G.lines / 2;
+ goto normalize_ofs;
+ }
+ if (c == KEYCODE_PAGEDOWN) {
+ G_scroll_ofs += G.lines / 2;
+ normalize_ofs:
+ if (G_scroll_ofs >= ntop)
+ G_scroll_ofs = ntop - 1;
+ if (G_scroll_ofs < 0)
+ G_scroll_ofs = 0;
+ break;
+ }
+
c |= 0x20; /* lowercase */
if (c == 'q')
return EXIT_MASK;
@@ -896,7 +995,7 @@
}
# if ENABLE_FEATURE_SHOW_THREADS
if (c == 'h'
- IF_FEATURE_TOPMEM(&& scan_mask != TOPMEM_MASK)
+ IF_FEATURE_TOPMEM(&& scan_mask != TOPMEM_MASK)
) {
scan_mask ^= PSSCAN_TASKS;
continue;
@@ -1011,7 +1110,7 @@
int top_main(int argc UNUSED_PARAM, char **argv)
{
int iterations;
- unsigned lines, col;
+ unsigned col;
unsigned interval;
char *str_interval, *str_iterations;
unsigned scan_mask = TOP_MASK;
@@ -1062,10 +1161,13 @@
sort_function[0] = mem_sort;
#endif
+ if (OPT_BATCH_MODE) {
+ option_mask32 |= OPT_EOF;
+ }
#if ENABLE_FEATURE_USE_TERMIOS
- tcgetattr(0, (void *) &initial_settings);
- memcpy(&new_settings, &initial_settings, sizeof(new_settings));
- if (!OPT_BATCH_MODE) {
+ else {
+ tcgetattr(0, (void *) &initial_settings);
+ memcpy(&new_settings, &initial_settings, sizeof(new_settings));
/* unbuffered input, turn off echo */
new_settings.c_lflag &= ~(ISIG | ICANON | ECHO | ECHONL);
tcsetattr_stdin_TCSANOW(&new_settings);
@@ -1081,15 +1183,15 @@
procps_status_t *p = NULL;
if (OPT_BATCH_MODE) {
- lines = INT_MAX;
+ G.lines = INT_MAX;
col = LINE_BUF_SIZE - 2; /* +2 bytes for '\n', NUL */
} else {
- lines = 24; /* default */
+ G.lines = 24; /* default */
col = 79;
#if ENABLE_FEATURE_USE_TERMIOS
/* We output to stdout, we need size of stdout (not stdin)! */
- get_terminal_width_height(STDOUT_FILENO, &col, &lines);
- if (lines < 5 || col < 10) {
+ get_terminal_width_height(STDOUT_FILENO, &col, &G.lines);
+ if (G.lines < 5 || col < 10) {
sleep(interval);
continue;
}
@@ -1099,6 +1201,7 @@
}
/* read process IDs & status for all the processes */
+ ntop = 0;
while ((p = procps_scan(p, scan_mask)) != NULL) {
int n;
#if ENABLE_FEATURE_TOPMEM
@@ -1165,10 +1268,10 @@
}
#endif
if (scan_mask != TOPMEM_MASK)
- display_process_list(lines, col);
+ display_process_list(G.lines, col);
#if ENABLE_FEATURE_TOPMEM
else
- display_topmem_process_list(lines, col);
+ display_topmem_process_list(G.lines, col);
#endif
clearmems();
if (iterations >= 0 && !--iterations)
@@ -1176,11 +1279,7 @@
#if !ENABLE_FEATURE_USE_TERMIOS
sleep(interval);
#else
- if (option_mask32 & OPT_EOF)
- /* EOF on stdin ("top </dev/null") */
- sleep(interval);
- else
- scan_mask = handle_input(scan_mask, interval);
+ scan_mask = handle_input(scan_mask, interval);
#endif /* FEATURE_USE_TERMIOS */
} /* end of "while (not Q)" */
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/runit/chpst.c
^
|
@@ -91,6 +91,7 @@
//usage: "\n a SIGXCPU after N seconds"
#include "libbb.h"
+#include <sys/resource.h> /* getrlimit */
/*
Five applets here: chpst, envdir, envuidgid, setuidgid, softlimit.
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/runit/runsv.c
^
|
@@ -172,7 +172,7 @@
}
close(fd);
if (rename_or_warn("supervise/pid.new",
- s->islog ? "log/supervise/pid" : "log/supervise/pid"+4))
+ s->islog ? "log/supervise/pid" : "log/supervise/pid"+4))
return;
pidchanged = 0;
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/runit/svlogd.c
^
|
@@ -601,12 +601,12 @@
while (fchdir(ld->fddir) == -1)
pause2cannot("change directory, want remove old logfile",
- ld->name);
+ ld->name);
oldest[0] = 'A';
oldest[1] = oldest[27] = '\0';
while (!(d = opendir(".")))
pause2cannot("open directory, want remove old logfile",
- ld->name);
+ ld->name);
errno = 0;
while ((f = readdir(d)))
if ((f->d_name[0] == '@') && (strlen(f->d_name) == 27)) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/scripts/kconfig/mconf.c
^
|
@@ -9,6 +9,8 @@
*/
#define _XOPEN_SOURCE 700
+/* On Darwin, this may be needed to get SIGWINCH: */
+#define _DARWIN_C_SOURCE 1
#include <sys/ioctl.h>
#include <sys/wait.h>
@@ -443,6 +445,7 @@
pid_t pid;
+#ifdef SIGWINCH
static void winch_handler(int sig)
{
if (!do_resize) {
@@ -450,11 +453,11 @@
do_resize = 1;
}
}
+#endif
static int exec_conf(void)
{
int pipefd[2], stat, size;
- struct sigaction sa;
sigset_t sset, osset;
sigemptyset(&sset);
@@ -463,10 +466,15 @@
signal(SIGINT, SIG_DFL);
- sa.sa_handler = winch_handler;
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = SA_RESTART;
- sigaction(SIGWINCH, &sa, NULL);
+#ifdef SIGWINCH
+ {
+ struct sigaction sa;
+ sa.sa_handler = winch_handler;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_RESTART;
+ sigaction(SIGWINCH, &sa, NULL);
+ }
+#endif
*argptr++ = NULL;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/selinux/chcon.c
^
|
@@ -92,7 +92,7 @@
if (specified_context == NULL) {
context = set_security_context_component(file_context,
- user, role, type, range);
+ user, role, type, range);
if (!context) {
bb_error_msg("can't compute security context from %s", file_context);
goto skip;
@@ -121,15 +121,15 @@
}
if ((option_mask32 & OPT_VERBOSE) || ((option_mask32 & OPT_CHANHES) && !fail)) {
printf(!fail
- ? "context of %s changed to %s\n"
- : "can't change context of %s to %s\n",
- fname, context_string);
+ ? "context of %s changed to %s\n"
+ : "can't change context of %s to %s\n",
+ fname, context_string);
}
if (!fail) {
rc = TRUE;
} else if ((option_mask32 & OPT_QUIET) == 0) {
bb_error_msg("can't change context of %s to %s",
- fname, context_string);
+ fname, context_string);
}
} else if (option_mask32 & OPT_VERBOSE) {
printf("context of %s retained as %s\n", fname, context_string);
@@ -181,7 +181,7 @@
#if ENABLE_FEATURE_CHCON_LONG_OPTIONS
if (option_mask32 & OPT_REFERENCE) {
/* FIXME: lgetfilecon() should be used when '-h' is specified.
- But current implementation follows the original one. */
+ * But current implementation follows the original one. */
if (getfilecon(reference_file, &specified_context) < 0)
bb_perror_msg_and_die("getfilecon('%s') failed", reference_file);
} else
@@ -201,10 +201,10 @@
fname[fname_len] = '\0';
if (recursive_action(fname,
- 1<<option_mask32 & OPT_RECURSIVE,
- change_filedir_context,
- change_filedir_context,
- NULL, 0) != TRUE)
+ 1<<option_mask32 & OPT_RECURSIVE,
+ change_filedir_context,
+ change_filedir_context,
+ NULL, 0) != TRUE)
errors = 1;
}
return errors;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/selinux/runcon.c
^
|
@@ -56,7 +56,7 @@
#include "libbb.h"
static context_t runcon_compute_new_context(char *user, char *role, char *type, char *range,
- char *command, int compute_trans)
+ char *command, int compute_trans)
{
context_t con;
security_context_t cur_context;
@@ -69,9 +69,9 @@
if (getfilecon(command, &file_context) < 0)
bb_error_msg_and_die("can't retrieve attributes of '%s'",
- command);
+ command);
if (security_compute_create(cur_context, file_context,
- SECCLASS_PROCESS, &new_context))
+ SECCLASS_PROCESS, &new_context))
bb_error_msg_and_die("unable to compute a new context");
cur_context = new_context;
}
@@ -147,11 +147,11 @@
if (security_check_context(context_str(con)))
bb_error_msg_and_die("'%s' is not a valid context",
- context_str(con));
+ context_str(con));
if (setexeccon(context_str(con)))
bb_error_msg_and_die("can't set up security context '%s'",
- context_str(con));
+ context_str(con));
BB_EXECVP_or_die(argv);
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/selinux/sestatus.c
^
|
@@ -41,7 +41,7 @@
if (pending < 0)
goto skip;
printf(COL_FMT "%s",
- bools[i], active == 0 ? "off" : "on");
+ bools[i], active == 0 ? "off" : "on");
if (active != pending)
printf(" (%sactivate pending)", pending == 0 ? "in" : "");
bb_putchar('\n');
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/selinux/setfiles.c
^
|
@@ -498,10 +498,11 @@
if (S_ISDIR(sb.st_mode) && recurse) {
if (recursive_action(name,
- ACTION_RECURSE,
- apply_spec,
- apply_spec,
- NULL, 0) != TRUE) {
+ ACTION_RECURSE,
+ apply_spec,
+ apply_spec,
+ NULL, 0) != TRUE
+ ) {
bb_error_msg("error while labeling %s", name);
goto err;
}
@@ -584,7 +585,7 @@
flags = getopt32(argv, "de:f:ilnpqr:svo:FW"
IF_FEATURE_SETFILES_CHECK_OPTION("c:"),
&exclude_dir, &input_filename, &rootpath, &out_filename,
- IF_FEATURE_SETFILES_CHECK_OPTION(&policyfile,)
+ IF_FEATURE_SETFILES_CHECK_OPTION(&policyfile,)
&verbose);
}
argv += optind;
@@ -600,8 +601,8 @@
fclose(policystream);
/* Only process the specified file_contexts file, not
- any .homedirs or .local files, and do not perform
- context translations. */
+ * any .homedirs or .local files, and do not perform
+ * context translations. */
set_matchpathcon_flags(MATCHPATHCON_BASEONLY |
MATCHPATHCON_NOTRANS |
MATCHPATHCON_VALIDATE);
@@ -631,8 +632,8 @@
if (applet_name[0] == 's') { /* setfiles */
/* Use our own invalid context checking function so that
- we can support either checking against the active policy or
- checking against a binary policy file. */
+ * we can support either checking against the active policy or
+ * checking against a binary policy file. */
set_matchpathcon_canoncon(&canoncon);
if (!argv[0])
bb_show_usage();
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/shell/ash.c
^
|
@@ -23,8 +23,9 @@
* define DEBUG=1 to compile in debugging ('set -o debug' to turn on)
* define DEBUG=2 to compile in and turn on debugging.
*
- * When debugging is on, debugging info will be written to ./trace and
- * a quit signal will generate a core dump.
+ * When debugging is on (DEBUG is 1 and "set -o debug" was executed),
+ * debugging info will be written to ./trace and a quit signal
+ * will generate a core dump.
*/
#define DEBUG 0
/* Tweak debug output verbosity here */
@@ -1899,6 +1900,10 @@
const char *var_text;
void (*var_func)(const char *) FAST_FUNC;
} varinit_data[] = {
+ /*
+ * Note: VEXPORT would not work correctly here for NOFORK applets:
+ * some environment strings may be constant.
+ */
{ VSTRFIXED|VTEXTFIXED , defifsvar , NULL },
#if ENABLE_ASH_MAIL
{ VSTRFIXED|VTEXTFIXED|VUNSET, "MAIL" , changemail },
@@ -3559,7 +3564,8 @@
break;
case CUR_RUNNING:
/* newly created job or backgrounded job,
- put after all stopped jobs. */
+ * put after all stopped jobs.
+ */
while (1) {
jp1 = *jpp;
#if JOBS
@@ -5105,15 +5111,14 @@
char *fname;
int f;
+ fname = redir->nfile.expfname;
switch (redir->nfile.type) {
case NFROM:
- fname = redir->nfile.expfname;
f = open(fname, O_RDONLY);
if (f < 0)
goto eopen;
break;
case NFROMTO:
- fname = redir->nfile.expfname;
f = open(fname, O_RDWR|O_CREAT, 0666);
if (f < 0)
goto ecreate;
@@ -5124,7 +5129,6 @@
#endif
/* Take care of noclobber mode. */
if (Cflag) {
- fname = redir->nfile.expfname;
f = noclobberopen(fname);
if (f < 0)
goto ecreate;
@@ -5132,13 +5136,11 @@
}
/* FALLTHROUGH */
case NCLOBBER:
- fname = redir->nfile.expfname;
f = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666);
if (f < 0)
goto ecreate;
break;
case NAPPEND:
- fname = redir->nfile.expfname;
f = open(fname, O_WRONLY|O_CREAT|O_APPEND, 0666);
if (f < 0)
goto ecreate;
@@ -6138,7 +6140,9 @@
length++;
goto addquote;
case CTLVAR:
+ TRACE(("argstr: evalvar('%s')\n", p));
p = evalvar(p, flags, var_str_list);
+ TRACE(("argstr: evalvar:'%s'\n", (char *)stackblock()));
goto start;
case CTLBACKQ:
c = '\0';
@@ -6335,7 +6339,8 @@
IF_ASH_BASH_COMPAT(const char *repl = NULL;)
IF_ASH_BASH_COMPAT(int pos, len, orig_len;)
int saveherefd = herefd;
- int amount, workloc, resetloc;
+ int amount, resetloc;
+ IF_ASH_BASH_COMPAT(int workloc;)
int zero;
char *(*scan)(char*, char*, char*, char*, int, int);
@@ -6448,9 +6453,9 @@
rmescend--;
str = (char *)stackblock() + strloc;
preglob(str, varflags & VSQUOTE, 0);
- workloc = expdest - (char *)stackblock();
#if ENABLE_ASH_BASH_COMPAT
+ workloc = expdest - (char *)stackblock();
if (subtype == VSREPLACE || subtype == VSREPLACEALL) {
char *idx, *end;
@@ -7248,6 +7253,7 @@
STARTSTACKSTR(expdest);
ifsfirst.next = NULL;
ifslastp = NULL;
+ TRACE(("expandarg: argstr('%s',flags:%x)\n", arg->narg.text, flag));
argstr(arg->narg.text, flag,
/* var_str_list: */ arglist ? arglist->list : NULL);
p = _STPUTC('\0', expdest);
@@ -7256,6 +7262,7 @@
return; /* here document expanded */
}
p = grabstackstr(p);
+ TRACE(("expandarg: p:'%s'\n", p));
exparg.lastp = &exparg.list;
/*
* TODO - EXP_REDIR
@@ -7266,8 +7273,10 @@
exparg.lastp = &exparg.list;
expandmeta(exparg.list /*, flag*/);
} else {
- if (flag & EXP_REDIR) /*XXX - for now, just remove escapes */
+ if (flag & EXP_REDIR) { /*XXX - for now, just remove escapes */
rmescapes(p, 0);
+ TRACE(("expandarg: rmescapes:'%s'\n", p));
+ }
sp = stzalloc(sizeof(*sp));
sp->text = p;
*exparg.lastp = sp;
@@ -8664,9 +8673,21 @@
case NCLOBBER:
case NAPPEND:
expandarg(redir->nfile.fname, &fn, EXP_TILDE | EXP_REDIR);
+ TRACE(("expredir expanded to '%s'\n", fn.list->text));
#if ENABLE_ASH_BASH_COMPAT
store_expfname:
#endif
+#if 0
+// By the design of stack allocator, the loop of this kind:
+// while true; do while true; do break; done </dev/null; done
+// will look like a memory leak: ash plans to free expfname's
+// of "/dev/null" as soon as it finishes running the loop
+// (in this case, never).
+// This "fix" is wrong:
+ if (redir->nfile.expfname)
+ stunalloc(redir->nfile.expfname);
+// It results in corrupted state of stacked allocations.
+#endif
redir->nfile.expfname = fn.list->text;
break;
case NFROMFD:
@@ -9302,11 +9323,11 @@
/* Now locate the command. */
if (argc) {
- const char *oldpath;
int cmd_flag = DO_ERR;
-
+#if ENABLE_ASH_CMDCMD
+ const char *oldpath = path + 5;
+#endif
path += 5;
- oldpath = path;
for (;;) {
find_command(argv[0], &cmdentry, cmd_flag, path);
if (cmdentry.cmdtype == CMDUNKNOWN) {
@@ -11629,8 +11650,9 @@
INT_ON;
if (oldstyle) {
/* We must read until the closing backquote, giving special
- treatment to some slashes, and then push the string and
- reread it as input, interpreting it normally. */
+ * treatment to some slashes, and then push the string and
+ * reread it as input, interpreting it normally.
+ */
char *pout;
size_t psavelen;
char *pstr;
@@ -12621,9 +12643,27 @@
char *name;
const char *p;
char **aptr;
- int flag = argv[0][0] == 'r' ? VREADONLY : VEXPORT;
+ char opt;
+ int flag;
+ int flag_off;
+
+ /* "readonly" in bash accepts, but ignores -n.
+ * We do the same: it saves a conditional in nextopt's param.
+ */
+ flag_off = 0;
+ while ((opt = nextopt("np")) != '\0') {
+ if (opt == 'n')
+ flag_off = VEXPORT;
+ }
+ flag = VEXPORT;
+ if (argv[0][0] == 'r') {
+ flag = VREADONLY;
+ flag_off = 0; /* readonly ignores -n */
+ }
+ flag_off = ~flag_off;
- if (nextopt("p") != 'p') {
+ /*if (opt_p_not_specified) - bash doesnt check this. Try "export -p NAME" */
+ {
aptr = argptr;
name = *aptr;
if (name) {
@@ -12634,15 +12674,19 @@
} else {
vp = *findvar(hashvar(name), name);
if (vp) {
- vp->flags |= flag;
+ vp->flags = ((vp->flags | flag) & flag_off);
continue;
}
}
- setvar(name, p, flag);
+ setvar(name, p, (flag & flag_off));
} while ((name = *++aptr) != NULL);
return 0;
}
}
+
+ /* No arguments. Show the list of exported or readonly vars.
+ * -n is ignored.
+ */
showvars(argv[0], flag, 0);
return 0;
}
@@ -12795,6 +12839,10 @@
}
}
+ /* "read -s" needs to save/restore termios, can't allow ^C
+ * to jump out of it.
+ */
+ INT_OFF;
r = shell_builtin_read(setvar2,
argptr,
bltinlookup("IFS"), /* can be NULL */
@@ -12804,6 +12852,7 @@
opt_t,
opt_u
);
+ INT_ON;
if ((uintptr_t)r > 1)
ash_msg_and_raise_error(r);
|
[-]
[+]
|
Added |
busybox-1.21.0.tar.bz2/shell/ash_test/ash-redir/redirA.right
^
|
@@ -0,0 +1,2 @@
+tmp11
+tmp11
|
[-]
[+]
|
Added |
busybox-1.21.0.tar.bz2/shell/ash_test/ash-redir/redirA.tests
^
|
@@ -0,0 +1,11 @@
+x="tmp11:tmp22"
+
+# Bug was incorrectly expanding variables in >redir
+echo "${x%:*}" >"${x%:*}"
+echo tmp1*
+rm tmp1*
+
+# Also try unquoted
+echo "${x%:*}" >${x%:*}
+echo tmp1*
+rm tmp1*
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/shell/hush.c
^
|
@@ -106,10 +106,6 @@
# define PIPE_BUF 4096 /* amount of buffering in a pipe */
#endif
-/* Not every libc has sighandler_t. Fix it */
-typedef void (*hush_sighandler_t)(int);
-#define sighandler_t hush_sighandler_t
-
//config:config HUSH
//config: bool "hush"
//config: default y
@@ -4223,7 +4219,7 @@
/* (this makes bare "&" cmd a no-op.
* bash says: "syntax error near unexpected token '&'") */
if (pi->num_cmds == 0
- IF_HAS_KEYWORDS( && pi->res_word == RES_NONE)
+ IF_HAS_KEYWORDS(&& pi->res_word == RES_NONE)
) {
free_pipe_list(pi);
pi = NULL;
@@ -4376,7 +4372,7 @@
debug_printf_parse("dest.o_assignment='%s'\n", assignment_flag[dest.o_assignment]);
/* Do we sit outside of any if's, loops or case's? */
if (!HAS_KEYWORDS
- IF_HAS_KEYWORDS(|| (ctx.ctx_res_w == RES_NONE && ctx.old_flag == 0))
+ IF_HAS_KEYWORDS(|| (ctx.ctx_res_w == RES_NONE && ctx.old_flag == 0))
) {
o_free(&dest);
#if !BB_MMU
@@ -8285,7 +8281,7 @@
* (if there are _stopped_ jobs, running ones don't count)
* # exit
* exit
- # EEE (then bash exits)
+ * EEE (then bash exits)
*
* TODO: we can use G.exiting = -1 as indicator "last cmd was exit"
*/
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/shell/math.c
^
|
@@ -410,7 +410,7 @@
return "exponent less than 0";
c = 1;
while (--right_side_val >= 0)
- c *= rez;
+ c *= rez;
rez = c;
}
else if (right_side_val == 0)
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/shell/shell_common.c
^
|
@@ -18,6 +18,7 @@
*/
#include "libbb.h"
#include "shell_common.h"
+#include <sys/resource.h> /* getrlimit */
const char defifsvar[] ALIGN1 = "IFS= \t\n";
@@ -169,7 +170,7 @@
int timeout;
if ((bufpos & 0xff) == 0)
- buffer = xrealloc(buffer, bufpos + 0x100);
+ buffer = xrealloc(buffer, bufpos + 0x101);
timeout = -1;
if (end_ms) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/shell/shell_common.h
^
|
@@ -21,7 +21,7 @@
PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
-extern const char defifsvar[]; /* "IFS= \t\n" */
+extern const char defifsvar[] ALIGN1; /* "IFS= \t\n" */
#define defifs (defifsvar + 4)
int FAST_FUNC is_well_formed_var_name(const char *s, char terminator);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/sysklogd/Config.src
^
|
@@ -113,6 +113,19 @@
from circular buffer, minimizing semaphore
contention at some minor memory expense.
+config FEATURE_KMSG_SYSLOG
+ bool "Linux kernel printk buffer support"
+ default y
+ depends on SYSLOGD
+ select PLATFORM_LINUX
+ help
+ When you enable this feature, the syslogd utility will
+ write system log message to the Linux kernel's printk buffer.
+ This can be used as a smaller alternative to the syslogd IPC
+ support, as klogd and logread aren't needed.
+
+ NOTICE: Syslog facilities in log entries needs kernel 3.5+.
+
config KLOGD
bool "klogd"
default y
@@ -123,6 +136,9 @@
you wish to record the messages produced by the kernel,
you should enable this option.
+comment "klogd should not be used together with syslog to kernel printk buffer"
+ depends on KLOGD && FEATURE_KMSG_SYSLOG
+
config FEATURE_KLOGD_KLOGCTL
bool "Use the klogctl() interface"
default y
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/sysklogd/klogd.c
^
|
@@ -195,6 +195,8 @@
syslog(LOG_NOTICE, "klogd started: %s", bb_banner);
+ write_pidfile(CONFIG_PID_FILE_PATH "/klogd.pid");
+
used = 0;
while (!bb_got_signal) {
int n;
@@ -238,11 +240,8 @@
priority = LOG_INFO;
if (*start == '<') {
start++;
- if (*start) {
- /* kernel never generates multi-digit prios */
- priority = (*start - '0');
- start++;
- }
+ if (*start)
+ priority = strtoul(start, &start, 10);
if (*start == '>')
start++;
}
@@ -258,6 +257,7 @@
klogd_close();
syslog(LOG_NOTICE, "klogd: exiting");
+ remove_pidfile(CONFIG_PID_FILE_PATH "/klogd.pid");
if (bb_got_signal)
kill_myself_with_sig(bb_got_signal);
return EXIT_FAILURE;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/sysklogd/syslogd.c
^
|
@@ -43,6 +43,9 @@
//usage: "\n -f FILE Use FILE as config (default:/etc/syslog.conf)"
//usage: )
/* //usage: "\n -m MIN Minutes between MARK lines (default:20, 0=off)" */
+//usage: IF_FEATURE_KMSG_SYSLOG(
+//usage: "\n -K Log to kernel printk buffer (use dmesg to read it)"
+//usage: )
//usage:
//usage:#define syslogd_example_usage
//usage: "$ syslogd -R masterlog:514\n"
@@ -140,6 +143,10 @@
) \
IF_FEATURE_SYSLOGD_CFG( \
logRule_t *log_rules; \
+) \
+IF_FEATURE_KMSG_SYSLOG( \
+ int kmsgfd; \
+ int primask; \
)
struct init_globals {
@@ -212,6 +219,7 @@
IF_FEATURE_IPC_SYSLOG( OPTBIT_circularlog,) // -C
IF_FEATURE_SYSLOGD_DUP( OPTBIT_dup ,) // -D
IF_FEATURE_SYSLOGD_CFG( OPTBIT_cfg ,) // -f
+ IF_FEATURE_KMSG_SYSLOG( OPTBIT_kmsg ,) // -K
OPT_mark = 1 << OPTBIT_mark ,
OPT_nofork = 1 << OPTBIT_nofork ,
@@ -225,6 +233,8 @@
OPT_circularlog = IF_FEATURE_IPC_SYSLOG( (1 << OPTBIT_circularlog)) + 0,
OPT_dup = IF_FEATURE_SYSLOGD_DUP( (1 << OPTBIT_dup )) + 0,
OPT_cfg = IF_FEATURE_SYSLOGD_CFG( (1 << OPTBIT_cfg )) + 0,
+ OPT_kmsg = IF_FEATURE_KMSG_SYSLOG( (1 << OPTBIT_kmsg )) + 0,
+
};
#define OPTION_STR "m:nO:l:S" \
IF_FEATURE_ROTATE_LOGFILE("s:" ) \
@@ -233,7 +243,8 @@
IF_FEATURE_REMOTE_LOG( "L" ) \
IF_FEATURE_IPC_SYSLOG( "C::") \
IF_FEATURE_SYSLOGD_DUP( "D" ) \
- IF_FEATURE_SYSLOGD_CFG( "f:" )
+ IF_FEATURE_SYSLOGD_CFG( "f:" ) \
+ IF_FEATURE_KMSG_SYSLOG( "K" )
#define OPTION_DECL *opt_m, *opt_l \
IF_FEATURE_ROTATE_LOGFILE(,*opt_s) \
IF_FEATURE_ROTATE_LOGFILE(,*opt_b) \
@@ -242,7 +253,7 @@
#define OPTION_PARAM &opt_m, &(G.logFile.path), &opt_l \
IF_FEATURE_ROTATE_LOGFILE(,&opt_s) \
IF_FEATURE_ROTATE_LOGFILE(,&opt_b) \
- IF_FEATURE_REMOTE_LOG( ,&remoteAddrList) \
+ IF_FEATURE_REMOTE_LOG( ,&remoteAddrList) \
IF_FEATURE_IPC_SYSLOG( ,&opt_C) \
IF_FEATURE_SYSLOGD_CFG( ,&opt_f)
@@ -418,7 +429,9 @@
return;
cfgerr:
- bb_error_msg_and_die("error in '%s' at line %d", file, parser->lineno);
+ bb_error_msg_and_die("error in '%s' at line %d",
+ file ? file : "/etc/syslog.conf",
+ parser->lineno);
}
#endif
@@ -518,11 +531,49 @@
printf("tail:%d\n", G.shbuf->tail);
}
#else
-void ipcsyslog_cleanup(void);
-void ipcsyslog_init(void);
+static void ipcsyslog_cleanup(void) {}
+static void ipcsyslog_init(void) {}
void log_to_shmem(const char *msg);
#endif /* FEATURE_IPC_SYSLOG */
+#if ENABLE_FEATURE_KMSG_SYSLOG
+static void kmsg_init(void)
+{
+ G.kmsgfd = xopen("/dev/kmsg", O_WRONLY);
+
+ /*
+ * kernel < 3.5 expects single char printk KERN_* priority prefix,
+ * from 3.5 onwards the full syslog facility/priority format is supported
+ */
+ if (get_linux_version_code() < KERNEL_VERSION(3,5,0))
+ G.primask = LOG_PRIMASK;
+ else
+ G.primask = -1;
+}
+
+static void kmsg_cleanup(void)
+{
+ if (ENABLE_FEATURE_CLEAN_UP)
+ close(G.kmsgfd);
+}
+
+/* Write message to /dev/kmsg */
+static void log_to_kmsg(int pri, const char *msg)
+{
+ /*
+ * kernel < 3.5 expects single char printk KERN_* priority prefix,
+ * from 3.5 onwards the full syslog facility/priority format is supported
+ */
+ pri &= G.primask;
+
+ write(G.kmsgfd, G.printbuf, sprintf(G.printbuf, "<%d>%s\n", pri, msg));
+}
+#else
+static void kmsg_init(void) {}
+static void kmsg_cleanup(void) {}
+static void log_to_kmsg(int pri UNUSED_PARAM, const char *msg UNUSED_PARAM) {}
+#endif /* FEATURE_KMSG_SYSLOG */
+
/* Print a message to the log file. */
static void log_locally(time_t now, char *msg, logFile_t *log_file)
{
@@ -657,6 +708,11 @@
}
timestamp[15] = '\0';
+ if (option_mask32 & OPT_kmsg) {
+ log_to_kmsg(pri, msg);
+ return;
+ }
+
if (option_mask32 & OPT_small)
sprintf(G.printbuf, "%s %s\n", timestamp, msg);
else {
@@ -827,9 +883,11 @@
#endif
sock_fd = create_socket();
- if (ENABLE_FEATURE_IPC_SYSLOG && (option_mask32 & OPT_circularlog)) {
+ if (option_mask32 & OPT_circularlog)
ipcsyslog_init();
- }
+
+ if (option_mask32 & OPT_kmsg)
+ kmsg_init();
timestamp_and_log_internal("syslogd started: BusyBox v" BB_VER);
@@ -916,8 +974,10 @@
timestamp_and_log_internal("syslogd exiting");
puts("syslogd exiting");
- if (ENABLE_FEATURE_IPC_SYSLOG)
- ipcsyslog_cleanup();
+ remove_pidfile(CONFIG_PID_FILE_PATH "/syslogd.pid");
+ ipcsyslog_cleanup();
+ if (option_mask32 & OPT_kmsg)
+ kmsg_cleanup();
kill_myself_with_sig(bb_got_signal);
#undef recvbuf
}
@@ -979,8 +1039,10 @@
if (!(opts & OPT_nofork)) {
bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv);
}
+
//umask(0); - why??
- write_pidfile("/var/run/syslogd.pid");
+ write_pidfile(CONFIG_PID_FILE_PATH "/syslogd.pid");
+
do_syslogd();
/* return EXIT_SUCCESS; */
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/testsuite/awk.tests
^
|
@@ -16,6 +16,13 @@
testing "awk -F case 6" "awk -F '[#]' '{ print NF }'" "4\n" "" "z#abc##zz\n"
testing "awk -F case 7" "awk -F '[#]' '{ print NF }'" "5\n" "" "z##abc##zz\n"
+# conditions and operators
+testing "awk if operator == " "awk 'BEGIN{if(23==23) print \"foo\"}'" "foo\n" "" ""
+testing "awk if operator != " "awk 'BEGIN{if(23!=23) print \"bar\"}'" "" "" ""
+testing "awk if operator >= " "awk 'BEGIN{if(23>=23) print \"foo\"}'" "foo\n" "" ""
+testing "awk if operator < " "awk 'BEGIN{if(2 < 13) print \"foo\"}'" "foo\n" "" ""
+testing "awk if string == " "awk 'BEGIN{if(\"a\"==\"ab\") print \"bar\"}'" "" "" ""
+
# 4294967295 = 0xffffffff
testing "awk bitwise op" "awk '{ print or(4294967295,1) }'" "4.29497e+09\n" "" "\n"
optional DESKTOP
@@ -36,6 +43,11 @@
"" \
"a--\na--b--\na--b--c--\na--b--c--d--"
+testing "awk -F handles escapes" "awk -F'\\x21' '{print \$1}'" \
+ "a\n" \
+ "" \
+ "a!b\n"
+
# '@(samp|code|file)\{' is an invalid extended regex (unmatched '{'),
# but gawk 3.1.5 does not bail out on it.
testing "awk gsub falls back to non-extended-regex" \
@@ -205,4 +217,11 @@
testing "awk handles empty ()" \
"awk 'BEGIN {print()}' 2>&1" "awk: cmd. line:1: Empty sequence\n" "" ""
+testing "awk FS assignment" "awk '{FS=\":\"; print \$1}'" \
+ "a:b\ne\n" \
+ "" \
+ "a:b c:d\ne:f g:h"
+
+# testing "description" "command" "result" "infile" "stdin"
+
exit $FAILCOUNT
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/testsuite/du/du-k-works
^
|
@@ -3,4 +3,5 @@
dd if=/dev/zero of=file1 bs=1k count=64 2>/dev/null
dd if=/dev/zero of=file2 bs=1k count=16 2>/dev/null
test x"`busybox du -k .`" = x"80 ." \
+ -o x"`busybox du -k .`" = x"84 ." \
-o x"`busybox du -k .`" = x"88 ."
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/testsuite/grep.tests
^
|
@@ -115,6 +115,18 @@
"" \
"test\n"
+testing "grep -Fw matches only words" \
+ "grep -Fw foo input" \
+ "" \
+ "foop\n" \
+ ""
+
+testing "grep -Fw doesn't stop on 1st mismatch" \
+ "grep -Fw foo input" \
+ "foop foo\n" \
+ "foop foo\n" \
+ ""
+
# testing "test name" "commands" "expected result" "file input" "stdin"
# file input will be file called "input"
# test can create a file "actual" instead of writing to stdout
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/testsuite/mdev.tests
^
|
@@ -11,7 +11,7 @@
# cut: remove size+date
FILTER_LS2="grep -v '^total ' | sed -e 's/, */,/g' -e 's/ */ /g' | cut -d' ' -f 1-4,9-"
-# testing "test name" "options" "expected result" "file input" "stdin"
+# testing "test name" "commands" "expected result" "file input" "stdin"
rm -rf mdev.testdir
mkdir mdev.testdir
@@ -125,6 +125,26 @@
" \
"" ""
SKIP=
+
+# continuing to use directory structure from prev test
+rm -rf mdev.testdir/dev/*
+echo "sda 0:0 444 =disk/sd/a" >mdev.testdir/etc/mdev.conf
+optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
+testing "mdev move rule '=bar/baz/fname'" \
+ "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
+ ls -lnR mdev.testdir/dev | $FILTER_LS2" \
+"\
+mdev.testdir/dev:
+drwxr-xr-x 3 0 0 disk
+
+mdev.testdir/dev/disk:
+drwxr-xr-x 2 0 0 sd
+
+mdev.testdir/dev/disk/sd:
+br--r--r-- 1 0 0 a
+" \
+ "" ""
+SKIP=
# continuing to use directory structure from prev test
rm -rf mdev.testdir/dev/*
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/testsuite/mkfs.minix.tests
^
|
@@ -8,6 +8,14 @@
# testing "test name" "options" "expected result" "file input" "stdin"
+# '\n' produces 10 on little endian, but not on big endian
+cr=`echo | od -i | sed 's/ *$//g;s/.* //g;2d'`
+if [ x"$cr" = x"10" ]; then
+ hash=4f35f7afeba07d56055bed1f29ae20b7
+else
+ hash=5adbc1b3ccd20ca5d0ab5bc1e13ac3fc
+fi
+
testing "mkfs.minix" \
"dd if=/dev/zero of=input bs=1k count=1024 2>/dev/null; mkfs.minix input; md5sum <input" \
"352 inodes\n"\
@@ -15,7 +23,7 @@
"Firstdatazone=15 (15)\n"\
"Zonesize=1024\n"\
"Maxsize=268966912\n"\
-"4f35f7afeba07d56055bed1f29ae20b7 -\n" \
+"$hash -\n" \
"" \
""
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/testsuite/mount.tests
^
|
@@ -36,7 +36,8 @@
"mount -o loop mount.image1m $testdir "\
"&& grep -Fc $testdir </proc/mounts "\
"&& mount -o remount,mand $testdir "\
-"&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'" \
+"&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'"\
+"|| grep -F $testdir </proc/mounts" \
"1\n""1\n" \
"" ""
@@ -83,4 +84,28 @@
"" ""
SKIP=
+
+testing "mount RO loop" "\
+exec 2>&1
+umount -d mount.dir 2>/dev/null
+rmdir mount.dir 2>/dev/null
+mkdir -p mount.dir
+(
+cd mount.dir || { echo 'cd error'; exit 1; }
+mkdir z1 z2 || { echo 'mkdir error'; exit 1; }
+mount -t tmpfs tmpfs z1 || { echo 'mount tmpfs error'; exit 1; }
+dd if=/dev/zero of=z1/e2img count=10 bs=1M 2>/dev/null || { echo 'dd error'; exit 1; }
+mke2fs -F z1/e2img 2>/dev/null >&2 || { echo 'mke2fs error'; exit 1; }
+mount -r -o loop -t ext2 z1/e2img z2 || { echo 'mount -r -o loop error'; exit 1; }
+mount -o remount,ro z1 || { echo 'mount -o remount,ro error'; exit 1; }
+)
+umount -d mount.dir/z2
+##losetup -d /dev/loop*
+umount -d mount.dir/z1
+rm -rf mount.dir
+echo DONE
+" \
+"DONE\n" "" ""
+
+
exit $FAILCOUNT
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/testsuite/sed.tests
^
|
@@ -48,13 +48,12 @@
# substitutions
testing "sed -n" "sed -n -e s/foo/bar/ -e s/bar/baz/" "" "" "foo\n"
+testing "sed with empty match" "sed 's/z*//g'" "string\n" "" "string\n"
testing "sed s//p" "sed -e s/foo/bar/p -e s/bar/baz/p" "bar\nbaz\nbaz\n" \
"" "foo\n"
testing "sed -n s//p" "sed -ne s/abc/def/p" "def\n" "" "abc\n"
-test x"$SKIP_KNOWN_BUGS" = x"" && {
testing "sed s//g (exhaustive)" "sed -e 's/[[:space:]]*/,/g'" ",1,2,3,4,5,\n" \
"" "12345\n"
-}
testing "sed s arbitrary delimiter" "sed -e 's woo boing '" "boing\n" "" "woo\n"
testing "sed s chains" "sed -e s/foo/bar/ -e s/bar/baz/" "baz\n" "" "foo\n"
testing "sed s chains2" "sed -e s/foo/bar/ -e s/baz/nee/" "bar\n" "" "foo\n"
@@ -295,6 +294,22 @@
"sed '1,2d' -i input; echo \$?; cat input" \
"0\n3\n4\n" "1\n2\n3\n4\n" ""
+testing "sed zero chars match/replace advances correctly 1" \
+ "sed 's/l*/@/g'" \
+ "@h@e@o@\n" "" "helllo\n"
+
+testing "sed zero chars match/replace advances correctly 2" \
+ "sed 's [^ .]* x g'" \
+ "x x.x\n" "" " a.b\n"
+
+testing "sed zero chars match/replace logic must not falsely trigger here 1" \
+ "sed 's/a/A/g'" \
+ "_AAA1AA\n" "" "_aaa1aa\n"
+
+testing "sed zero chars match/replace logic must not falsely trigger here 2" \
+ "sed 's/ *$/_/g'" \
+ "qwerty_\n" "" "qwerty\n"
+
# testing "description" "commands" "result" "infile" "stdin"
exit $FAILCOUNT
|
[-]
[+]
|
Added |
busybox-1.21.0.tar.bz2/testsuite/sha3sum.tests
^
|
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+. ./md5sum.tests sha3sum c29d77bc548fa2b20a04c861400a5360879c52156e2a54a3415b99a9a3123e1d5f36714a24eca8c1f05a8e2d8ba859c930d41141f64a255c6794436fc99c486a
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/Config.src
^
|
@@ -734,6 +734,15 @@
help
TODO
+config FEATURE_VOLUMEID_EXFAT
+ bool "exFAT filesystem"
+ default y
+ depends on VOLUMEID
+ help
+ exFAT (extended FAT) is a proprietary file system designed especially
+ for flash drives. It has many features from NTFS, but with less
+ overhead. exFAT is used on most SDXC cards for consumer electronics.
+
config FEATURE_VOLUMEID_HFS
bool "hfs filesystem"
default y
@@ -762,6 +771,13 @@
help
TODO
+config FEATURE_VOLUMEID_NILFS
+ bool "nilfs filesystem"
+ default y
+ depends on VOLUMEID
+ help
+ TODO
+
config FEATURE_VOLUMEID_NTFS
bool "ntfs filesystem"
default y
@@ -825,6 +841,16 @@
help
TODO
+config FEATURE_VOLUMEID_SQUASHFS
+ bool "SquashFS filesystem"
+ default y
+ depends on VOLUMEID && FEATURE_BLKID_TYPE
+ help
+ Squashfs is a compressed read-only filesystem for Linux. Squashfs is
+ intended for general read-only filesystem use and in constrained block
+ device/memory systems (e.g. embedded systems) where low overhead is
+ needed.
+
config FEATURE_VOLUMEID_SYSV
bool "sysv filesystem"
default y
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/acpid.c
^
|
@@ -75,6 +75,7 @@
static const struct acpi_event f_evt_tab[] = {
{ "EV_KEY", 0x01, "KEY_POWER", 116, 1, "button/power PWRF 00000080" },
{ "EV_KEY", 0x01, "KEY_POWER", 116, 1, "button/power PWRB 00000080" },
+ { "EV_SW", 0x05, "SW_LID", 0x00, 1, "button/lid LID0 00000080" },
};
struct acpi_action {
@@ -234,7 +235,7 @@
const char *opt_action = "/etc/acpid.conf";
const char *opt_map = "/etc/acpi.map";
#if ENABLE_FEATURE_PIDFILE
- const char *opt_pidfile = "/var/run/acpid.pid";
+ const char *opt_pidfile = CONFIG_PID_FILE_PATH "/acpid.pid";
#endif
INIT_G();
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/dmesg.c
^
|
@@ -59,16 +59,15 @@
int last = '\n';
int in = 0;
- /* Skip <#> at the start of lines */
+ /* Skip <[0-9]+> at the start of lines */
while (1) {
if (last == '\n' && buf[in] == '<') {
- in += 3;
- if (in >= len)
- break;
+ while (buf[in++] != '>' && in < len)
+ ;
+ } else {
+ last = buf[in++];
+ putchar(last);
}
- last = buf[in];
- putchar(last);
- in++;
if (in >= len)
break;
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/fbset.c
^
|
@@ -271,7 +271,7 @@
}
p = token[1];
i = index_in_strings(
- "geometry\0timings\0interlaced\0double\0vsync\0hsync\0csync\0extsync\0",
+ "geometry\0timings\0interlaced\0double\0vsync\0hsync\0csync\0extsync\0rgba\0",
token[0]);
switch (i) {
case 0:
@@ -342,6 +342,30 @@
ss(&base->sync, FB_SYNC_EXT, p, "false");
//bb_info_msg("EXTSYNC[%s]", p);
break;
+ case 8: {
+ int red_offset, red_length;
+ int green_offset, green_length;
+ int blue_offset, blue_length;
+ int transp_offset, transp_length;
+
+ sscanf(p, "%d/%d,%d/%d,%d/%d,%d/%d",
+ &red_offset, &red_length,
+ &green_offset, &green_length,
+ &blue_offset, &blue_length,
+ &transp_offset, &transp_length);
+ base->red.offset = red_offset;
+ base->red.length = red_length;
+ base->red.msb_right = 0;
+ base->green.offset = green_offset;
+ base->green.length = green_length;
+ base->green.msb_right = 0;
+ base->blue.offset = blue_offset;
+ base->blue.length = blue_length;
+ base->blue.msb_right = 0;
+ base->transp.offset = transp_offset;
+ base->transp.length = transp_length;
+ base->transp.msb_right = 0;
+ }
}
}
return 0;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/fdformat.c
^
|
@@ -116,7 +116,7 @@
/* Check backwards so we don't need a counter */
while (--read_bytes >= 0) {
if (data[read_bytes] != FD_FILL_BYTE) {
- printf("bad data in cyl %d\nContinuing... ", cyl);
+ printf("bad data in cyl %d\nContinuing... ", cyl);
}
}
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/fdisk.c
^
|
@@ -3023,7 +3023,7 @@
printf("\nThe current boot file is: %s\n",
sgi_get_bootfile());
if (read_maybe_empty("Please enter the name of the "
- "new boot file: ") == '\n')
+ "new boot file: ") == '\n')
printf("Boot file unchanged\n");
else
sgi_set_bootfile(line_ptr);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/fdisk_osf.c
^
|
@@ -898,8 +898,7 @@
pp->p_fstype = BSD_FS_UNUSED;
#else
d->d_npartitions = 3;
- pp = &d->d_partitions[2]; /* Partition C should be
- the whole disk */
+ pp = &d->d_partitions[2]; /* Partition C should be the whole disk */
pp->p_offset = 0;
pp->p_size = d->d_secperunit;
pp->p_fstype = BSD_FS_UNUSED;
@@ -935,7 +934,7 @@
fdisk_fatal(unable_to_read);
memmove(d, &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
- sizeof(struct xbsd_disklabel));
+ sizeof(struct xbsd_disklabel));
if (d->d_magic != BSD_DISKMAGIC || d->d_magic2 != BSD_DISKMAGIC)
return 0;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/flock.c
^
|
@@ -45,7 +45,7 @@
if (argv[1]) {
fd = open(argv[0], O_RDONLY|O_NOCTTY|O_CREAT, 0666);
if (fd < 0 && errno == EISDIR)
- fd = open(argv[0], O_RDONLY|O_NOCTTY);
+ fd = open(argv[0], O_RDONLY|O_NOCTTY);
if (fd < 0)
bb_perror_msg_and_die("can't open '%s'", argv[0]);
//TODO? close_on_exec_on(fd);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/fsck_minix.c
^
|
@@ -13,7 +13,7 @@
* 10.11.91 - updated, does checking, no repairs yet.
* Sent out to the mailing-list for testing.
*
- * 14.11.91 - Testing seems to have gone well. Added some
+ * 14.11.91 - Testing seems to have gone well. Added some
* correction-code, and changed some functions.
*
* 15.11.91 - More correction code. Hopefully it notices most
@@ -22,11 +22,10 @@
* 16.11.91 - More corrections (thanks to Mika Jalava). Most
* things seem to work now. Yeah, sure.
*
- *
- * 19.04.92 - Had to start over again from this old version, as a
+ * 19.04.92 - Had to start over again from this old version, as a
* kernel bug ate my enhanced fsck in february.
*
- * 28.02.93 - added support for different directory entry sizes..
+ * 28.02.93 - added support for different directory entry sizes..
*
* Sat Mar 6 18:59:42 1993, faith@cs.unc.edu: Output namelen with
* superblock information
@@ -35,31 +34,31 @@
* to that required by fsutil
*
* Mon Jan 3 11:06:52 1994 - Dr. Wettstein (greg%wind.uucp@plains.nodak.edu)
- * Added support for file system valid flag. Also
- * added program_version variable and output of
- * program name and version number when program
- * is executed.
+ * Added support for file system valid flag. Also
+ * added program_version variable and output of
+ * program name and version number when program
+ * is executed.
*
- * 30.10.94 - added support for v2 filesystem
- * (Andreas Schwab, schwab@issan.informatik.uni-dortmund.de)
+ * 30.10.94 - added support for v2 filesystem
+ * (Andreas Schwab, schwab@issan.informatik.uni-dortmund.de)
*
- * 10.12.94 - added test to prevent checking of mounted fs adapted
- * from Theodore Ts'o's (tytso@athena.mit.edu) e2fsck
- * program. (Daniel Quinlan, quinlan@yggdrasil.com)
+ * 10.12.94 - added test to prevent checking of mounted fs adapted
+ * from Theodore Ts'o's (tytso@athena.mit.edu) e2fsck
+ * program. (Daniel Quinlan, quinlan@yggdrasil.com)
*
* 01.07.96 - Fixed the v2 fs stuff to use the right #defines and such
- * for modern libcs (janl@math.uio.no, Nicolai Langfeldt)
+ * for modern libcs (janl@math.uio.no, Nicolai Langfeldt)
*
* 02.07.96 - Added C bit fiddling routines from rmk@ecs.soton.ac.uk
* (Russell King). He made them for ARM. It would seem
- * that the ARM is powerful enough to do this in C whereas
+ * that the ARM is powerful enough to do this in C whereas
* i386 and m64k must use assembly to get it fast >:-)
- * This should make minix fsck system-independent.
- * (janl@math.uio.no, Nicolai Langfeldt)
+ * This should make minix fsck system-independent.
+ * (janl@math.uio.no, Nicolai Langfeldt)
*
* 04.11.96 - Added minor fixes from Andreas Schwab to avoid compiler
* warnings. Added mc68k bitops from
- * Joerg Dorchain <dorchain@mpi-sb.mpg.de>.
+ * Joerg Dorchain <dorchain@mpi-sb.mpg.de>.
*
* 06.11.96 - Added v2 code submitted by Joerg Dorchain, but written by
* Andreas Schwab.
@@ -1131,7 +1130,7 @@
continue;
}
printf("Zone %d: %sin use, counted=%d\n",
- i, zone_in_use(i) ? "" : "not ", zone_count[i]);
+ i, zone_in_use(i) ? "" : "not ", zone_count[i]);
}
}
@@ -1183,7 +1182,7 @@
continue;
}
printf("Zone %d: %sin use, counted=%d\n",
- i, zone_in_use(i) ? "" : "not ", zone_count[i]);
+ i, zone_in_use(i) ? "" : "not ", zone_count[i]);
}
}
#endif
@@ -1253,7 +1252,7 @@
printf("Forcing filesystem check on %s\n", device_name);
else if (OPT_repair)
printf("Filesystem on %s is dirty, needs checking\n",
- device_name);
+ device_name);
read_tables();
@@ -1280,23 +1279,23 @@
if (!inode_in_use(i))
free_cnt++;
printf("\n%6u inodes used (%u%%)\n", (INODES - free_cnt),
- 100 * (INODES - free_cnt) / INODES);
+ 100 * (INODES - free_cnt) / INODES);
for (i = FIRSTZONE, free_cnt = 0; i < ZONES; i++)
if (!zone_in_use(i))
free_cnt++;
printf("%6u zones used (%u%%)\n\n"
- "%6u regular files\n"
- "%6u directories\n"
- "%6u character device files\n"
- "%6u block device files\n"
- "%6u links\n"
- "%6u symbolic links\n"
- "------\n"
- "%6u files\n",
- (ZONES - free_cnt), 100 * (ZONES - free_cnt) / ZONES,
- regular, directory, chardev, blockdev,
- links - 2 * directory + 1, symlinks,
- total - 2 * directory + 1);
+ "%6u regular files\n"
+ "%6u directories\n"
+ "%6u character device files\n"
+ "%6u block device files\n"
+ "%6u links\n"
+ "%6u symbolic links\n"
+ "------\n"
+ "%6u files\n",
+ (ZONES - free_cnt), 100 * (ZONES - free_cnt) / ZONES,
+ regular, directory, chardev, blockdev,
+ links - 2 * directory + 1, symlinks,
+ total - 2 * directory + 1);
}
if (changed) {
write_tables();
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/getopt.c
^
|
@@ -372,7 +372,7 @@
if (!argv[1]) {
if (compatible) {
/* For some reason, the original getopt gave no error
- when there were no arguments. */
+ * when there were no arguments. */
printf(" --\n");
return 0;
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/ipcrm.c
^
|
@@ -160,7 +160,7 @@
/* convert key to id */
id = ((c == 'q') ? msgget(key, 0) :
- (c == 'm') ? shmget(key, 0, 0) : semget(key, 0, 0));
+ (c == 'm') ? shmget(key, 0, 0) : semget(key, 0, 0));
if (id < 0) {
const char *errmsg;
@@ -189,8 +189,8 @@
}
result = ((c == 'q') ? msgctl(id, IPC_RMID, NULL) :
- (c == 'm') ? shmctl(id, IPC_RMID, NULL) :
- semctl(id, 0, IPC_RMID, arg));
+ (c == 'm') ? shmctl(id, IPC_RMID, NULL) :
+ semctl(id, 0, IPC_RMID, arg));
if (result) {
const char *errmsg;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/ipcs.c
^
|
@@ -152,54 +152,54 @@
if ((shmctl(0, IPC_INFO, (struct shmid_ds *) (void *) &shminfo)) < 0)
return;
/* glibc 2.1.3 and all earlier libc's have ints as fields
- of struct shminfo; glibc 2.1.91 has unsigned long; ach */
+ * of struct shminfo; glibc 2.1.91 has unsigned long; ach */
printf("max number of segments = %lu\n"
- "max seg size (kbytes) = %lu\n"
- "max total shared memory (pages) = %lu\n"
- "min seg size (bytes) = %lu\n",
- (unsigned long) shminfo.shmmni,
- (unsigned long) (shminfo.shmmax >> 10),
- (unsigned long) shminfo.shmall,
- (unsigned long) shminfo.shmmin);
+ "max seg size (kbytes) = %lu\n"
+ "max total shared memory (pages) = %lu\n"
+ "min seg size (bytes) = %lu\n",
+ (unsigned long) shminfo.shmmni,
+ (unsigned long) (shminfo.shmmax >> 10),
+ (unsigned long) shminfo.shmall,
+ (unsigned long) shminfo.shmmin);
return;
case STATUS:
printf("------ Shared Memory %s --------\n", "Status");
- printf( "segments allocated %d\n"
- "pages allocated %ld\n"
- "pages resident %ld\n"
- "pages swapped %ld\n"
- "Swap performance: %ld attempts\t%ld successes\n",
- shm_info.used_ids,
- shm_info.shm_tot,
- shm_info.shm_rss,
- shm_info.shm_swp,
- shm_info.swap_attempts, shm_info.swap_successes);
+ printf("segments allocated %d\n"
+ "pages allocated %ld\n"
+ "pages resident %ld\n"
+ "pages swapped %ld\n"
+ "Swap performance: %ld attempts\t%ld successes\n",
+ shm_info.used_ids,
+ shm_info.shm_tot,
+ shm_info.shm_rss,
+ shm_info.shm_swp,
+ shm_info.swap_attempts, shm_info.swap_successes);
return;
case CREATOR:
printf("------ Shared Memory %s --------\n", "Segment Creators/Owners");
- printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n",
- "shmid", "perms", "cuid", "cgid", "uid", "gid");
+ printf("%-10s %-10s %-10s %-10s %-10s %-10s\n",
+ "shmid", "perms", "cuid", "cgid", "uid", "gid");
break;
case TIME:
printf("------ Shared Memory %s --------\n", "Attach/Detach/Change Times");
- printf( "%-10s %-10s %-20s %-20s %-20s\n",
- "shmid", "owner", "attached", "detached", "changed");
+ printf("%-10s %-10s %-20s %-20s %-20s\n",
+ "shmid", "owner", "attached", "detached", "changed");
break;
case PID:
printf("------ Shared Memory %s --------\n", "Creator/Last-op");
- printf( "%-10s %-10s %-10s %-10s\n",
- "shmid", "owner", "cpid", "lpid");
+ printf("%-10s %-10s %-10s %-10s\n",
+ "shmid", "owner", "cpid", "lpid");
break;
default:
printf("------ Shared Memory %s --------\n", "Segments");
- printf( "%-10s %-10s %-10s %-10s %-10s %-10s %-12s\n",
- "key", "shmid", "owner", "perms", "bytes", "nattch",
- "status");
+ printf("%-10s %-10s %-10s %-10s %-10s %-10s %-12s\n",
+ "key", "shmid", "owner", "perms", "bytes", "nattch",
+ "status");
break;
}
@@ -220,11 +220,11 @@
printf("%-10d %-10d", shmid, ipcp->uid);
/* ctime uses static buffer: use separate calls */
printf(" %-20.16s", shmseg.shm_atime
- ? ctime(&shmseg.shm_atime) + 4 : "Not set");
+ ? ctime(&shmseg.shm_atime) + 4 : "Not set");
printf(" %-20.16s", shmseg.shm_dtime
- ? ctime(&shmseg.shm_dtime) + 4 : "Not set");
+ ? ctime(&shmseg.shm_dtime) + 4 : "Not set");
printf(" %-20.16s\n", shmseg.shm_ctime
- ? ctime(&shmseg.shm_ctime) + 4 : "Not set");
+ ? ctime(&shmseg.shm_ctime) + 4 : "Not set");
break;
case PID:
if (pw)
@@ -241,17 +241,17 @@
else
printf("%-10d %-10d", shmid, ipcp->uid);
printf(" %-10o %-10lu %-10ld %-6s %-6s\n", ipcp->mode & 0777,
- /*
- * earlier: int, Austin has size_t
- */
- (unsigned long) shmseg.shm_segsz,
- /*
- * glibc-2.1.3 and earlier has unsigned short;
- * Austin has shmatt_t
- */
- (long) shmseg.shm_nattch,
- ipcp->mode & SHM_DEST ? "dest" : " ",
- ipcp->mode & SHM_LOCKED ? "locked" : " ");
+ /*
+ * earlier: int, Austin has size_t
+ */
+ (unsigned long) shmseg.shm_segsz,
+ /*
+ * glibc-2.1.3 and earlier has unsigned short;
+ * Austin has shmatt_t
+ */
+ (long) shmseg.shm_nattch,
+ ipcp->mode & SHM_DEST ? "dest" : " ",
+ ipcp->mode & SHM_LOCKED ? "locked" : " ");
break;
}
}
@@ -281,32 +281,32 @@
if ((semctl(0, 0, IPC_INFO, arg)) < 0)
return;
printf("max number of arrays = %d\n"
- "max semaphores per array = %d\n"
- "max semaphores system wide = %d\n"
- "max ops per semop call = %d\n"
- "semaphore max value = %d\n",
- seminfo.semmni,
- seminfo.semmsl,
- seminfo.semmns, seminfo.semopm, seminfo.semvmx);
+ "max semaphores per array = %d\n"
+ "max semaphores system wide = %d\n"
+ "max ops per semop call = %d\n"
+ "semaphore max value = %d\n",
+ seminfo.semmni,
+ seminfo.semmsl,
+ seminfo.semmns, seminfo.semopm, seminfo.semvmx);
return;
case STATUS:
printf("------ Semaphore %s --------\n", "Status");
- printf( "used arrays = %d\n"
- "allocated semaphores = %d\n",
- seminfo.semusz, seminfo.semaem);
+ printf("used arrays = %d\n"
+ "allocated semaphores = %d\n",
+ seminfo.semusz, seminfo.semaem);
return;
case CREATOR:
printf("------ Semaphore %s --------\n", "Arrays Creators/Owners");
- printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n",
- "semid", "perms", "cuid", "cgid", "uid", "gid");
+ printf("%-10s %-10s %-10s %-10s %-10s %-10s\n",
+ "semid", "perms", "cuid", "cgid", "uid", "gid");
break;
case TIME:
printf("------ Shared Memory %s --------\n", "Operation/Change Times");
- printf( "%-8s %-10s %-26.24s %-26.24s\n",
- "shmid", "owner", "last-op", "last-changed");
+ printf("%-8s %-10s %-26.24s %-26.24s\n",
+ "shmid", "owner", "last-op", "last-changed");
break;
case PID:
@@ -314,8 +314,8 @@
default:
printf("------ Semaphore %s --------\n", "Arrays");
- printf( "%-10s %-10s %-10s %-10s %-10s\n",
- "key", "semid", "owner", "perms", "nsems");
+ printf("%-10s %-10s %-10s %-10s %-10s\n",
+ "key", "semid", "owner", "perms", "nsems");
break;
}
@@ -337,9 +337,9 @@
printf("%-8d %-10d", semid, ipcp->uid);
/* ctime uses static buffer: use separate calls */
printf(" %-26.24s", semary.sem_otime
- ? ctime(&semary.sem_otime) : "Not set");
+ ? ctime(&semary.sem_otime) : "Not set");
printf(" %-26.24s\n", semary.sem_ctime
- ? ctime(&semary.sem_ctime) : "Not set");
+ ? ctime(&semary.sem_ctime) : "Not set");
break;
case PID:
break;
@@ -351,13 +351,13 @@
else
printf("%-10d %-9d", semid, ipcp->uid);
printf(" %-10o %-10ld\n", ipcp->mode & 0777,
- /*
- * glibc-2.1.3 and earlier has unsigned short;
- * glibc-2.1.91 has variation between
- * unsigned short and unsigned long
- * Austin prescribes unsigned short.
- */
- (long) semary.sem_nsems);
+ /*
+ * glibc-2.1.3 and earlier has unsigned short;
+ * glibc-2.1.91 has variation between
+ * unsigned short and unsigned long
+ * Austin prescribes unsigned short.
+ */
+ (long) semary.sem_nsems);
break;
}
}
@@ -383,42 +383,42 @@
if ((msgctl(0, IPC_INFO, (struct msqid_ds *) (void *) &msginfo)) < 0)
return;
printf("------ Message%s --------\n", "s: Limits");
- printf( "max queues system wide = %d\n"
- "max size of message (bytes) = %d\n"
- "default max size of queue (bytes) = %d\n",
- msginfo.msgmni, msginfo.msgmax, msginfo.msgmnb);
+ printf("max queues system wide = %d\n"
+ "max size of message (bytes) = %d\n"
+ "default max size of queue (bytes) = %d\n",
+ msginfo.msgmni, msginfo.msgmax, msginfo.msgmnb);
return;
case STATUS:
printf("------ Message%s --------\n", "s: Status");
- printf( "allocated queues = %d\n"
- "used headers = %d\n"
- "used space = %d bytes\n",
- msginfo.msgpool, msginfo.msgmap, msginfo.msgtql);
+ printf("allocated queues = %d\n"
+ "used headers = %d\n"
+ "used space = %d bytes\n",
+ msginfo.msgpool, msginfo.msgmap, msginfo.msgtql);
return;
case CREATOR:
printf("------ Message%s --------\n", " Queues: Creators/Owners");
- printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n",
- "msqid", "perms", "cuid", "cgid", "uid", "gid");
+ printf("%-10s %-10s %-10s %-10s %-10s %-10s\n",
+ "msqid", "perms", "cuid", "cgid", "uid", "gid");
break;
case TIME:
printf("------ Message%s --------\n", " Queues Send/Recv/Change Times");
- printf( "%-8s %-10s %-20s %-20s %-20s\n",
- "msqid", "owner", "send", "recv", "change");
+ printf("%-8s %-10s %-20s %-20s %-20s\n",
+ "msqid", "owner", "send", "recv", "change");
break;
case PID:
printf("------ Message%s --------\n", " Queues PIDs");
- printf( "%-10s %-10s %-10s %-10s\n",
- "msqid", "owner", "lspid", "lrpid");
+ printf("%-10s %-10s %-10s %-10s\n",
+ "msqid", "owner", "lspid", "lrpid");
break;
default:
printf("------ Message%s --------\n", " Queues");
- printf( "%-10s %-10s %-10s %-10s %-12s %-12s\n",
- "key", "msqid", "owner", "perms", "used-bytes", "messages");
+ printf("%-10s %-10s %-10s %-10s %-12s %-12s\n",
+ "key", "msqid", "owner", "perms", "used-bytes", "messages");
break;
}
@@ -438,11 +438,11 @@
else
printf("%-8d %-10d", msqid, ipcp->uid);
printf(" %-20.16s", msgque.msg_stime
- ? ctime(&msgque.msg_stime) + 4 : "Not set");
+ ? ctime(&msgque.msg_stime) + 4 : "Not set");
printf(" %-20.16s", msgque.msg_rtime
- ? ctime(&msgque.msg_rtime) + 4 : "Not set");
+ ? ctime(&msgque.msg_rtime) + 4 : "Not set");
printf(" %-20.16s\n", msgque.msg_ctime
- ? ctime(&msgque.msg_ctime) + 4 : "Not set");
+ ? ctime(&msgque.msg_ctime) + 4 : "Not set");
break;
case PID:
if (pw)
@@ -459,13 +459,13 @@
else
printf("%-10d %-10d", msqid, ipcp->uid);
printf(" %-10o %-12ld %-12ld\n", ipcp->mode & 0777,
- /*
- * glibc-2.1.3 and earlier has unsigned short;
- * glibc-2.1.91 has variation between
- * unsigned short, unsigned long
- * Austin has msgqnum_t
- */
- (long) msgque.msg_cbytes, (long) msgque.msg_qnum);
+ /*
+ * glibc-2.1.3 and earlier has unsigned short;
+ * glibc-2.1.91 has variation between
+ * unsigned short, unsigned long
+ * Austin has msgqnum_t
+ */
+ (long) msgque.msg_cbytes, (long) msgque.msg_qnum);
break;
}
}
@@ -483,18 +483,18 @@
}
printf("\nShared memory Segment shmid=%d\n"
- "uid=%d\tgid=%d\tcuid=%d\tcgid=%d\n"
- "mode=%#o\taccess_perms=%#o\n"
- "bytes=%ld\tlpid=%d\tcpid=%d\tnattch=%ld\n",
- shmid,
- ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid,
- ipcp->mode, ipcp->mode & 0777,
- (long) shmds.shm_segsz, shmds.shm_lpid, shmds.shm_cpid,
- (long) shmds.shm_nattch);
+ "uid=%d\tgid=%d\tcuid=%d\tcgid=%d\n"
+ "mode=%#o\taccess_perms=%#o\n"
+ "bytes=%ld\tlpid=%d\tcpid=%d\tnattch=%ld\n",
+ shmid,
+ ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid,
+ ipcp->mode, ipcp->mode & 0777,
+ (long) shmds.shm_segsz, shmds.shm_lpid, shmds.shm_cpid,
+ (long) shmds.shm_nattch);
printf("att_time=%-26.24s\n",
- shmds.shm_atime ? ctime(&shmds.shm_atime) : "Not set");
+ shmds.shm_atime ? ctime(&shmds.shm_atime) : "Not set");
printf("det_time=%-26.24s\n",
- shmds.shm_dtime ? ctime(&shmds.shm_dtime) : "Not set");
+ shmds.shm_dtime ? ctime(&shmds.shm_dtime) : "Not set");
printf("change_time=%-26.24s\n\n", ctime(&shmds.shm_ctime));
}
@@ -510,24 +510,24 @@
}
printf("\nMessage Queue msqid=%d\n"
- "uid=%d\tgid=%d\tcuid=%d\tcgid=%d\tmode=%#o\n"
- "cbytes=%ld\tqbytes=%ld\tqnum=%ld\tlspid=%d\tlrpid=%d\n",
- msqid, ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid, ipcp->mode,
- /*
- * glibc-2.1.3 and earlier has unsigned short;
- * glibc-2.1.91 has variation between
- * unsigned short, unsigned long
- * Austin has msgqnum_t (for msg_qbytes)
- */
- (long) buf.msg_cbytes, (long) buf.msg_qbytes,
- (long) buf.msg_qnum, buf.msg_lspid, buf.msg_lrpid);
+ "uid=%d\tgid=%d\tcuid=%d\tcgid=%d\tmode=%#o\n"
+ "cbytes=%ld\tqbytes=%ld\tqnum=%ld\tlspid=%d\tlrpid=%d\n",
+ msqid, ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid, ipcp->mode,
+ /*
+ * glibc-2.1.3 and earlier has unsigned short;
+ * glibc-2.1.91 has variation between
+ * unsigned short, unsigned long
+ * Austin has msgqnum_t (for msg_qbytes)
+ */
+ (long) buf.msg_cbytes, (long) buf.msg_qbytes,
+ (long) buf.msg_qnum, buf.msg_lspid, buf.msg_lrpid);
printf("send_time=%-26.24s\n",
- buf.msg_stime ? ctime(&buf.msg_stime) : "Not set");
+ buf.msg_stime ? ctime(&buf.msg_stime) : "Not set");
printf("rcv_time=%-26.24s\n",
- buf.msg_rtime ? ctime(&buf.msg_rtime) : "Not set");
+ buf.msg_rtime ? ctime(&buf.msg_rtime) : "Not set");
printf("change_time=%-26.24s\n\n",
- buf.msg_ctime ? ctime(&buf.msg_ctime) : "Not set");
+ buf.msg_ctime ? ctime(&buf.msg_ctime) : "Not set");
}
static void print_sem(int semid)
@@ -544,19 +544,19 @@
}
printf("\nSemaphore Array semid=%d\n"
- "uid=%d\t gid=%d\t cuid=%d\t cgid=%d\n"
- "mode=%#o, access_perms=%#o\n"
- "nsems = %ld\n"
- "otime = %-26.24s\n",
- semid,
- ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid,
- ipcp->mode, ipcp->mode & 0777,
- (long) semds.sem_nsems,
- semds.sem_otime ? ctime(&semds.sem_otime) : "Not set");
+ "uid=%d\t gid=%d\t cuid=%d\t cgid=%d\n"
+ "mode=%#o, access_perms=%#o\n"
+ "nsems = %ld\n"
+ "otime = %-26.24s\n",
+ semid,
+ ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid,
+ ipcp->mode, ipcp->mode & 0777,
+ (long) semds.sem_nsems,
+ semds.sem_otime ? ctime(&semds.sem_otime) : "Not set");
printf("ctime = %-26.24s\n"
- "%-10s %-10s %-10s %-10s %-10s\n",
- ctime(&semds.sem_ctime),
- "semnum", "value", "ncount", "zcount", "pid");
+ "%-10s %-10s %-10s %-10s %-10s\n",
+ ctime(&semds.sem_ctime),
+ "semnum", "value", "ncount", "zcount", "pid");
arg.val = 0;
for (i = 0; i < semds.sem_nsems; i++) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/lspci.c
^
|
@@ -74,11 +74,11 @@
if (option_mask32 & OPT_m) {
printf("%s \"Class %04x\" \"%04x\" \"%04x\" \"%04x\" \"%04x\"",
- pci_slot_name, pci_class, pci_vid, pci_did,
- pci_subsys_vid, pci_subsys_did);
+ pci_slot_name, pci_class, pci_vid, pci_did,
+ pci_subsys_vid, pci_subsys_did);
} else {
printf("%s Class %04x: %04x:%04x",
- pci_slot_name, pci_class, pci_vid, pci_did);
+ pci_slot_name, pci_class, pci_vid, pci_did);
}
if ((option_mask32 & OPT_k) && driver) {
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/mdev.c
^
|
@@ -92,7 +92,9 @@
//usage: "\n"
//usage: "If /dev/mdev.seq file exists, mdev will wait for its value\n"
//usage: "to match $SEQNUM variable. This prevents plug/unplug races.\n"
-//usage: "To activate this feature, create empty /dev/mdev.seq at boot."
+//usage: "To activate this feature, create empty /dev/mdev.seq at boot.\n"
+//usage: "\n"
+//usage: "If /dev/mdev.log file exists, debug log will be appended to it."
#include "libbb.h"
#include "xregex.h"
@@ -139,10 +141,101 @@
* This happens regardless of /sys/class/.../dev existence.
*/
+/* Kernel's hotplug environment constantly changes.
+ * Here are new cases I observed on 3.1.0:
+ *
+ * Case with $DEVNAME and $DEVICE, not just $DEVPATH:
+ * ACTION=add
+ * BUSNUM=001
+ * DEVICE=/proc/bus/usb/001/003
+ * DEVNAME=bus/usb/001/003
+ * DEVNUM=003
+ * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5
+ * DEVTYPE=usb_device
+ * MAJOR=189
+ * MINOR=2
+ * PRODUCT=18d1/4e12/227
+ * SUBSYSTEM=usb
+ * TYPE=0/0/0
+ *
+ * Case with $DEVICE, but no $DEVNAME - apparenty, usb iface notification?
+ * "Please load me a module" thing?
+ * ACTION=add
+ * DEVICE=/proc/bus/usb/001/003
+ * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0
+ * DEVTYPE=usb_interface
+ * INTERFACE=8/6/80
+ * MODALIAS=usb:v18D1p4E12d0227dc00dsc00dp00ic08isc06ip50
+ * PRODUCT=18d1/4e12/227
+ * SUBSYSTEM=usb
+ * TYPE=0/0/0
+ *
+ * ACTION=add
+ * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/host5
+ * DEVTYPE=scsi_host
+ * SUBSYSTEM=scsi
+ *
+ * ACTION=add
+ * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/host5/scsi_host/host5
+ * SUBSYSTEM=scsi_host
+ *
+ * ACTION=add
+ * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/host5/target5:0:0
+ * DEVTYPE=scsi_target
+ * SUBSYSTEM=scsi
+ *
+ * Case with strange $MODALIAS:
+ * ACTION=add
+ * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/host5/target5:0:0/5:0:0:0
+ * DEVTYPE=scsi_device
+ * MODALIAS=scsi:t-0x00
+ * SUBSYSTEM=scsi
+ *
+ * ACTION=add
+ * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/host5/target5:0:0/5:0:0:0/scsi_disk/5:0:0:0
+ * SUBSYSTEM=scsi_disk
+ *
+ * ACTION=add
+ * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/host5/target5:0:0/5:0:0:0/scsi_device/5:0:0:0
+ * SUBSYSTEM=scsi_device
+ *
+ * Case with explicit $MAJOR/$MINOR (no need to read /sys/$DEVPATH/dev?):
+ * ACTION=add
+ * DEVNAME=bsg/5:0:0:0
+ * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/host5/target5:0:0/5:0:0:0/bsg/5:0:0:0
+ * MAJOR=253
+ * MINOR=1
+ * SUBSYSTEM=bsg
+ *
+ * ACTION=add
+ * DEVPATH=/devices/virtual/bdi/8:16
+ * SUBSYSTEM=bdi
+ *
+ * ACTION=add
+ * DEVNAME=sdb
+ * DEVPATH=/block/sdb
+ * DEVTYPE=disk
+ * MAJOR=8
+ * MINOR=16
+ * SUBSYSTEM=block
+ *
+ * Case with ACTION=change:
+ * ACTION=change
+ * DEVNAME=sdb
+ * DEVPATH=/block/sdb
+ * DEVTYPE=disk
+ * DISK_MEDIA_CHANGE=1
+ * MAJOR=8
+ * MINOR=16
+ * SUBSYSTEM=block
+ */
+
+static const char keywords[] ALIGN1 = "add\0remove\0change\0";
+enum { OP_add, OP_remove };
+
struct rule {
bool keep_matching;
bool regex_compiled;
- bool regex_has_slash;
mode_t mode;
int maj, min0, min1;
struct bb_uidgid_t ugid;
@@ -154,6 +247,7 @@
struct globals {
int root_major, root_minor;
+ smallint verbose;
char *subsystem;
#if ENABLE_FEATURE_MDEV_CONF
const char *filename;
@@ -245,7 +339,6 @@
}
xregcomp(&G.cur_rule.match, val, REG_EXTENDED);
G.cur_rule.regex_compiled = 1;
- G.cur_rule.regex_has_slash = (strchr(val, '/') != NULL);
}
/* 2nd field: uid:gid - device ownership */
@@ -336,6 +429,18 @@
#endif
+static void mkdir_recursive(char *name)
+{
+ /* if name has many levels ("dir1/dir2"),
+ * bb_make_directory() will create dir1 according to umask,
+ * not according to its "mode" parameter.
+ * Since we run with umask=0, need to temporarily switch it.
+ */
+ umask(022); /* "dir1" (if any) will be 0755 too */
+ bb_make_directory(name, 0755, FILEUTILS_RECUR);
+ umask(0);
+}
+
/* Builds an alias path.
* This function potentionally reallocates the alias parameter.
* Only used for ENABLE_FEATURE_MDEV_RENAME
@@ -349,7 +454,7 @@
dest = strrchr(alias, '/');
if (dest) { /* ">bar/[baz]" ? */
*dest = '\0'; /* mkdir bar */
- bb_make_directory(alias, 0755, FILEUTILS_RECUR);
+ mkdir_recursive(alias);
*dest = '/';
if (dest[1] == '\0') { /* ">bar/" => ">bar/device_name" */
dest = alias;
@@ -366,13 +471,16 @@
* after NUL, but we promise to not mangle (IOW: to restore if needed)
* path string.
* NB2: "mdev -s" may call us many times, do not leak memory/fds!
+ *
+ * device_name = $DEVNAME (may be NULL)
+ * path = /sys/$DEVPATH
*/
-static void make_device(char *path, int delete)
+static void make_device(char *device_name, char *path, int operation)
{
- char *device_name, *subsystem_slash_devname;
int major, minor, type, len;
- dbg("%s('%s', delete:%d)", __func__, path, delete);
+ if (G.verbose)
+ bb_error_msg("device: %s, %s", device_name, path);
/* Try to read major/minor string. Note that the kernel puts \n after
* the data, so we don't need to worry about null terminating the string
@@ -380,7 +488,7 @@
* We also depend on path having writeable space after it.
*/
major = -1;
- if (!delete) {
+ if (operation == OP_add) {
char *dev_maj_min = path + strlen(path);
strcpy(dev_maj_min, "/dev");
@@ -391,40 +499,27 @@
return;
/* no "dev" file, but we can still run scripts
* based on device name */
- } else if (sscanf(++dev_maj_min, "%u:%u", &major, &minor) != 2) {
+ } else if (sscanf(++dev_maj_min, "%u:%u", &major, &minor) == 2) {
+ if (G.verbose)
+ bb_error_msg("maj,min: %u,%u", major, minor);
+ } else {
major = -1;
}
}
/* else: for delete, -1 still deletes the node, but < -1 suppresses that */
/* Determine device name, type, major and minor */
- device_name = (char*) bb_basename(path);
+ if (!device_name)
+ device_name = (char*) bb_basename(path);
/* http://kernel.org/doc/pending/hotplug.txt says that only
* "/sys/block/..." is for block devices. "/sys/bus" etc is not.
* But since 2.6.25 block devices are also in /sys/class/block.
- * We use strstr("/block/") to forestall future surprises. */
+ * We use strstr("/block/") to forestall future surprises.
+ */
type = S_IFCHR;
if (strstr(path, "/block/") || (G.subsystem && strncmp(G.subsystem, "block", 5) == 0))
type = S_IFBLK;
- /* Make path point to "subsystem/device_name" */
- subsystem_slash_devname = NULL;
- /* Check for coldplug invocations first */
- if (strncmp(path, "/sys/block/", 11) == 0) /* legacy case */
- path += sizeof("/sys/") - 1;
- else if (strncmp(path, "/sys/class/", 11) == 0)
- path += sizeof("/sys/class/") - 1;
- else {
- /* Example of a hotplug invocation:
- * SUBSYSTEM="block"
- * DEVPATH="/sys" + "/devices/virtual/mtd/mtd3/mtdblock3"
- * ("/sys" is added by mdev_main)
- * - path does not contain subsystem
- */
- subsystem_slash_devname = concat_path_file(G.subsystem, device_name);
- path = subsystem_slash_devname;
- }
-
#if ENABLE_FEATURE_MDEV_CONF
G.rule_idx = 0; /* restart from the beginning (think mdev -s) */
#endif
@@ -434,10 +529,10 @@
char *command;
char *alias;
char aliaslink = aliaslink; /* for compiler */
- const char *node_name;
+ char *node_name;
const struct rule *rule;
- str_to_match = "";
+ str_to_match = device_name;
rule = next_rule();
@@ -455,10 +550,8 @@
dbg("getenv('%s'):'%s'", rule->envvar, str_to_match);
if (!str_to_match)
continue;
- } else {
- /* regex to match [subsystem/]device_name */
- str_to_match = (rule->regex_has_slash ? path : device_name);
}
+ /* else: str_to_match = device_name */
if (rule->regex_compiled) {
int regex_match = regexec(&rule->match, str_to_match, ARRAY_SIZE(off), off, 0);
@@ -537,7 +630,7 @@
/* Are we running this command now?
* Run $cmd on delete, @cmd on create, *cmd on both
*/
- if (s2 - s != delete) {
+ if (s2 - s != (operation == OP_remove) || *s2 == '*') {
/* We are here if: '*',
* or: '@' and delete = 0,
* or: '$' and delete = 1
@@ -556,21 +649,30 @@
dbg("alias2:'%s'", alias);
}
- if (!delete && major >= 0) {
- dbg("mknod('%s',%o,(%d,%d))", node_name, rule->mode | type, major, minor);
+ if (operation == OP_add && major >= 0) {
+ char *slash = strrchr(node_name, '/');
+ if (slash) {
+ *slash = '\0';
+ mkdir_recursive(node_name);
+ *slash = '/';
+ }
+ if (G.verbose)
+ bb_error_msg("mknod: %s (%d,%d) %o", node_name, major, minor, rule->mode | type);
if (mknod(node_name, rule->mode | type, makedev(major, minor)) && errno != EEXIST)
bb_perror_msg("can't create '%s'", node_name);
- if (major == G.root_major && minor == G.root_minor)
- symlink(node_name, "root");
if (ENABLE_FEATURE_MDEV_CONF) {
chmod(node_name, rule->mode);
chown(node_name, rule->ugid.uid, rule->ugid.gid);
}
+ if (major == G.root_major && minor == G.root_minor)
+ symlink(node_name, "root");
if (ENABLE_FEATURE_MDEV_RENAME && alias) {
if (aliaslink == '>') {
//TODO: on devtmpfs, device_name already exists and symlink() fails.
//End result is that instead of symlink, we have two nodes.
//What should be done?
+ if (G.verbose)
+ bb_error_msg("symlink: %s", device_name);
symlink(node_name, device_name);
}
}
@@ -582,17 +684,24 @@
char *s1 = xasprintf("%s=%s", "SUBSYSTEM", G.subsystem);
putenv(s);
putenv(s1);
+ if (G.verbose)
+ bb_error_msg("running: %s", command);
if (system(command) == -1)
bb_perror_msg("can't run '%s'", command);
bb_unsetenv_and_free(s1);
bb_unsetenv_and_free(s);
}
- if (delete && major >= -1) {
+ if (operation == OP_remove && major >= -1) {
if (ENABLE_FEATURE_MDEV_RENAME && alias) {
- if (aliaslink == '>')
+ if (aliaslink == '>') {
+ if (G.verbose)
+ bb_error_msg("unlink: %s", device_name);
unlink(device_name);
+ }
}
+ if (G.verbose)
+ bb_error_msg("unlink: %s", node_name);
unlink(node_name);
}
@@ -605,8 +714,6 @@
if (!ENABLE_FEATURE_MDEV_CONF || !rule->keep_matching)
break;
} /* for (;;) */
-
- free(subsystem_slash_devname);
}
/* File callback for /sys/ traversal */
@@ -624,7 +731,7 @@
strcpy(scratch, fileName);
scratch[len] = '\0';
- make_device(scratch, /*delete:*/ 0);
+ make_device(/*DEVNAME:*/ NULL, scratch, OP_add);
return TRUE;
}
@@ -696,7 +803,7 @@
}
/* Tell kernel result by "echo [0|-1] > /sys/$DEVPATH/loading"
- * Note: we emit -1 if firmware file wasn't found.
+ * Note: we emit -1 also if firmware file wasn't found.
* There are cases when otherwise kernel would wait for minutes
* before timing out.
*/
@@ -769,9 +876,8 @@
char *fw;
char *seq;
char *action;
- char *env_path;
- static const char keywords[] ALIGN1 = "remove\0add\0";
- enum { OP_remove = 0, OP_add };
+ char *env_devname;
+ char *env_devpath;
smalluint op;
/* Hotplug:
@@ -780,12 +886,13 @@
* DEVPATH is like "/block/sda" or "/class/input/mice"
*/
action = getenv("ACTION");
- env_path = getenv("DEVPATH");
+ op = index_in_strings(keywords, action);
+ env_devname = getenv("DEVNAME"); /* can be NULL */
+ env_devpath = getenv("DEVPATH");
G.subsystem = getenv("SUBSYSTEM");
- if (!action || !env_path /*|| !G.subsystem*/)
+ if (!action || !env_devpath /*|| !G.subsystem*/)
bb_show_usage();
fw = getenv("FIRMWARE");
- op = index_in_strings(keywords, action);
/* If it exists, does /dev/mdev.seq match $SEQNUM?
* If it does not match, earlier mdev is running
* in parallel, and we need to wait */
@@ -811,16 +918,25 @@
} while (--timeout);
}
- snprintf(temp, PATH_MAX, "/sys%s", env_path);
+ {
+ int logfd = open("/dev/mdev.log", O_WRONLY | O_APPEND);
+ if (logfd >= 0) {
+ xmove_fd(logfd, STDERR_FILENO);
+ G.verbose = 1;
+ bb_error_msg("seq: %s action: %s", seq, action);
+ }
+ }
+
+ snprintf(temp, PATH_MAX, "/sys%s", env_devpath);
if (op == OP_remove) {
/* Ignoring "remove firmware". It was reported
* to happen and to cause erroneous deletion
* of device nodes. */
if (!fw)
- make_device(temp, /*delete:*/ 1);
+ make_device(env_devname, temp, op);
}
else if (op == OP_add) {
- make_device(temp, /*delete:*/ 0);
+ make_device(env_devname, temp, op);
if (ENABLE_FEATURE_MDEV_LOAD_FIRMWARE) {
if (fw)
load_firmware(fw, temp);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/mount.c
^
|
@@ -36,6 +36,10 @@
//usage: IF_FEATURE_MTAB_SUPPORT(
//usage: "\n -n Don't update /etc/mtab"
//usage: )
+//usage: IF_FEATURE_MOUNT_VERBOSE(
+//usage: "\n -v Verbose"
+//usage: )
+////usage: "\n -s Sloppy (ignored)"
//usage: "\n -r Read-only mount"
//usage: "\n -w Read-write mount (default)"
//usage: "\n -t FSTYPE[,...] Filesystem type(s)"
@@ -113,6 +117,12 @@
#ifndef MS_RELATIME
# define MS_RELATIME (1 << 21)
#endif
+#ifndef MS_STRICTATIME
+# define MS_STRICTATIME (1 << 24)
+#endif
+
+/* Any ~MS_FOO value has this bit set: */
+#define BB_MS_INVERTED_VALUE (1u << 31)
#include "libbb.h"
#if ENABLE_FEATURE_MOUNT_LABEL
@@ -218,6 +228,7 @@
IF_DESKTOP(/* "user" */ MOUNT_USERS,)
IF_DESKTOP(/* "users" */ MOUNT_USERS,)
/* "_netdev" */ 0,
+ IF_DESKTOP(/* "comment=" */ 0,) /* systemd uses this in fstab */
)
IF_FEATURE_MOUNT_FLAGS(
@@ -239,6 +250,7 @@
/* "nomand" */ ~MS_MANDLOCK,
/* "relatime" */ MS_RELATIME,
/* "norelatime" */ ~MS_RELATIME,
+ /* "strictatime" */ MS_STRICTATIME,
/* "loud" */ ~MS_SILENT,
/* "rbind" */ MS_BIND|MS_RECURSIVE,
@@ -275,6 +287,7 @@
IF_DESKTOP("user\0")
IF_DESKTOP("users\0")
"_netdev\0"
+ IF_DESKTOP("comment=\0") /* systemd uses this in fstab */
)
IF_FEATURE_MOUNT_FLAGS(
// vfs flags
@@ -295,6 +308,7 @@
"nomand\0"
"relatime\0"
"norelatime\0"
+ "strictatime\0"
"loud\0"
"rbind\0"
@@ -450,9 +464,9 @@
// Use the mount_options list to parse options into flags.
// Also update list of unrecognized options if unrecognized != NULL
-static long parse_mount_options(char *options, char **unrecognized)
+static unsigned long parse_mount_options(char *options, char **unrecognized)
{
- long flags = MS_SILENT;
+ unsigned long flags = MS_SILENT;
// Loop through options
for (;;) {
@@ -465,15 +479,22 @@
// FIXME: use hasmntopt()
// Find this option in mount_options
for (i = 0; i < ARRAY_SIZE(mount_options); i++) {
- if (strcasecmp(option_str, options) == 0) {
- long fl = mount_options[i];
- if (fl < 0)
+ unsigned opt_len = strlen(option_str);
+
+ if (strncasecmp(option_str, options, opt_len) == 0
+ && (options[opt_len] == '\0'
+ /* or is it "comment=" thingy in fstab? */
+ IF_FEATURE_MOUNT_FSTAB(IF_DESKTOP( || option_str[opt_len-1] == '=' ))
+ )
+ ) {
+ unsigned long fl = mount_options[i];
+ if (fl & BB_MS_INVERTED_VALUE)
flags &= fl;
else
flags |= fl;
goto found;
}
- option_str += strlen(option_str) + 1;
+ option_str += opt_len + 1;
}
// We did not recognize this option.
// If "unrecognized" is not NULL, append option there.
@@ -548,7 +569,7 @@
// Perform actual mount of specific filesystem at specific location.
// NB: mp->xxx fields may be trashed on exit
-static int mount_it_now(struct mntent *mp, long vfsflags, char *filteropts)
+static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filteropts)
{
int rc = 0;
@@ -913,7 +934,7 @@
static bool_t xdr_fhstatus(XDR *xdrs, fhstatus *objp)
{
if (!xdr_u_int(xdrs, &objp->fhs_status))
- return FALSE;
+ return FALSE;
if (objp->fhs_status == 0)
return xdr_fhandle(xdrs, objp->fhstatus_u.fhs_fhandle);
return TRUE;
@@ -927,8 +948,8 @@
static bool_t xdr_fhandle3(XDR *xdrs, fhandle3 *objp)
{
return xdr_bytes(xdrs, (char **)&objp->fhandle3_val,
- (unsigned int *) &objp->fhandle3_len,
- FHSIZE3);
+ (unsigned int *) &objp->fhandle3_len,
+ FHSIZE3);
}
static bool_t xdr_mountres3_ok(XDR *xdrs, mountres3_ok *objp)
@@ -936,10 +957,10 @@
if (!xdr_fhandle3(xdrs, &objp->fhandle))
return FALSE;
return xdr_array(xdrs, &(objp->auth_flavours.auth_flavours_val),
- &(objp->auth_flavours.auth_flavours_len),
- ~0,
- sizeof(int),
- (xdrproc_t) xdr_int);
+ &(objp->auth_flavours.auth_flavours_len),
+ ~0,
+ sizeof(int),
+ (xdrproc_t) xdr_int);
}
static bool_t xdr_mountstat3(XDR *xdrs, mountstat3 *objp)
@@ -1080,7 +1101,7 @@
}
/* NB: mp->xxx fields may be trashed on exit */
-static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
+static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *filteropts)
{
CLIENT *mclient;
char *hostname;
@@ -1508,19 +1529,19 @@
switch (pm_mnt.pm_prot) {
case IPPROTO_UDP:
mclient = clntudp_create(&mount_server_addr,
- pm_mnt.pm_prog,
- pm_mnt.pm_vers,
- retry_timeout,
- &msock);
+ pm_mnt.pm_prog,
+ pm_mnt.pm_vers,
+ retry_timeout,
+ &msock);
if (mclient)
break;
mount_server_addr.sin_port = htons(pm_mnt.pm_port);
msock = RPC_ANYSOCK;
case IPPROTO_TCP:
mclient = clnttcp_create(&mount_server_addr,
- pm_mnt.pm_prog,
- pm_mnt.pm_vers,
- &msock, 0, 0);
+ pm_mnt.pm_prog,
+ pm_mnt.pm_vers,
+ &msock, 0, 0);
break;
default:
mclient = NULL;
@@ -1541,18 +1562,18 @@
if (pm_mnt.pm_vers == 3)
clnt_stat = clnt_call(mclient, MOUNTPROC3_MNT,
- (xdrproc_t) xdr_dirpath,
- (caddr_t) &pathname,
- (xdrproc_t) xdr_mountres3,
- (caddr_t) &status,
- total_timeout);
+ (xdrproc_t) xdr_dirpath,
+ (caddr_t) &pathname,
+ (xdrproc_t) xdr_mountres3,
+ (caddr_t) &status,
+ total_timeout);
else
clnt_stat = clnt_call(mclient, MOUNTPROC_MNT,
- (xdrproc_t) xdr_dirpath,
- (caddr_t) &pathname,
- (xdrproc_t) xdr_fhstatus,
- (caddr_t) &status,
- total_timeout);
+ (xdrproc_t) xdr_dirpath,
+ (caddr_t) &pathname,
+ (xdrproc_t) xdr_fhstatus,
+ (caddr_t) &status,
+ total_timeout);
if (clnt_stat == RPC_SUCCESS)
goto prepare_kernel_data; /* we're done */
@@ -1711,7 +1732,7 @@
* For older kernels, you must build busybox with ENABLE_FEATURE_MOUNT_NFS.
* (However, note that then you lose any chances that NFS over IPv6 would work).
*/
-static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
+static int nfsmount(struct mntent *mp, unsigned long vfsflags, char *filteropts)
{
len_and_sockaddr *lsa;
char *opts;
@@ -1753,7 +1774,7 @@
static int singlemount(struct mntent *mp, int ignore_busy)
{
int rc = -1;
- long vfsflags;
+ unsigned long vfsflags;
char *loopFile = NULL, *filteropts = NULL;
llist_t *fl = NULL;
struct stat st;
@@ -1803,17 +1824,44 @@
) {
int len;
char c;
+ char *hostname, *share;
+ char *dotted, *ip;
len_and_sockaddr *lsa;
- char *hostname, *dotted, *ip;
+
+ // Parse mp->mnt_fsname of the form "//hostname/share[/dir1/dir2]"
hostname = mp->mnt_fsname + 2;
len = strcspn(hostname, "/\\");
- if (len == 0 || hostname[len] == '\0')
+ share = hostname + len + 1;
+ if (len == 0 // 3rd char is a [back]slash (IOW: empty hostname)
+ || share[-1] == '\0' // no [back]slash after hostname
+ || share[0] == '\0' // empty share name
+ ) {
goto report_error;
- c = hostname[len];
- hostname[len] = '\0';
+ }
+ c = share[-1];
+ share[-1] = '\0';
+ len = strcspn(share, "/\\");
+
+ // "unc=\\hostname\share" option is mandatory
+ // after CIFS option parsing was rewritten in Linux 3.4.
+ // Must use backslashes.
+ // If /dir1/dir2 is present, also add "prefixpath=dir1/dir2"
+ {
+ char *unc = xasprintf(
+ share[len] != '\0' /* "/dir1/dir2" exists? */
+ ? "unc=\\\\%s\\%.*s,prefixpath=%s"
+ : "unc=\\\\%s\\%.*s",
+ hostname,
+ len, share,
+ share + len + 1 /* "dir1/dir2" */
+ );
+ parse_mount_options(unc, &filteropts);
+ if (ENABLE_FEATURE_CLEAN_UP) free(unc);
+ }
+
lsa = host2sockaddr(hostname, 0);
- hostname[len] = c;
+ share[-1] = c;
if (!lsa)
goto report_error;
@@ -1825,8 +1873,6 @@
parse_mount_options(ip, &filteropts);
if (ENABLE_FEATURE_CLEAN_UP) free(ip);
- // "-o mand" is required [why?]
- vfsflags |= MS_MANDLOCK;
mp->mnt_type = (char*)"cifs";
rc = mount_it_now(mp, vfsflags, filteropts);
@@ -1854,7 +1900,7 @@
if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) {
loopFile = bb_simplify_path(mp->mnt_fsname);
mp->mnt_fsname = NULL; // will receive malloced loop dev name
- if (set_loop(&mp->mnt_fsname, loopFile, 0, /*ro:*/ 0) < 0) {
+ if (set_loop(&mp->mnt_fsname, loopFile, 0, /*ro:*/ (vfsflags & MS_RDONLY)) < 0) {
if (errno == EPERM || errno == EACCES)
bb_error_msg(bb_msg_perm_denied_are_you_root);
else
@@ -1992,6 +2038,7 @@
FILE *fstab;
int i, j;
int rc = EXIT_SUCCESS;
+ unsigned long cmdopt_flags;
unsigned opt;
struct mntent mtpair[2], *mtcur = mtpair;
IF_NOT_DESKTOP(const int nonroot = 0;)
@@ -2066,16 +2113,16 @@
// Past this point, we are handling either "mount -a [opts]"
// or "mount [opts] single_param"
- i = parse_mount_options(cmdopts, NULL); // FIXME: should be "long", not "int"
- if (nonroot && (i & ~MS_SILENT)) // Non-root users cannot specify flags
+ cmdopt_flags = parse_mount_options(cmdopts, NULL);
+ if (nonroot && (cmdopt_flags & ~MS_SILENT)) // Non-root users cannot specify flags
bb_error_msg_and_die(bb_msg_you_must_be_root);
// If we have a shared subtree flag, don't worry about fstab or mtab.
if (ENABLE_FEATURE_MOUNT_FLAGS
- && (i & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
+ && (cmdopt_flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
) {
// verbose_mount(source, target, type, flags, data)
- rc = verbose_mount("", argv[0], "", i, "");
+ rc = verbose_mount("", argv[0], "", cmdopt_flags, "");
if (rc)
bb_simple_perror_msg_and_die(argv[0]);
return rc;
@@ -2083,7 +2130,7 @@
// Open either fstab or mtab
fstabname = "/etc/fstab";
- if (i & MS_REMOUNT) {
+ if (cmdopt_flags & MS_REMOUNT) {
// WARNING. I am not sure this matches util-linux's
// behavior. It's possible util-linux does not
// take -o opts from mtab (takes only mount source).
@@ -2182,7 +2229,7 @@
// End of fstab/mtab is reached.
// Were we looking for something specific?
if (argv[0]) { // yes
- long l;
+ unsigned long l;
// If we didn't find anything, complain
if (!mtcur->mnt_fsname)
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/rdate.c
^
|
@@ -1,7 +1,7 @@
/* vi: set sw=4 ts=4: */
/*
* The Rdate command will ask a time server for the RFC 868 time
- * and optionally set the system time.
+ * and optionally set the system time.
*
* by Sterling Huxley <sterling@europa.com>
*
@@ -11,9 +11,9 @@
//usage:#define rdate_trivial_usage
//usage: "[-sp] HOST"
//usage:#define rdate_full_usage "\n\n"
-//usage: "Get and possibly set the system date and time from a remote HOST\n"
-//usage: "\n -s Set the system date and time (default)"
-//usage: "\n -p Print the date and time"
+//usage: "Get and possibly set the system date/time from a remote HOST\n"
+//usage: "\n -s Set the system date/time (default)"
+//usage: "\n -p Print the date/time"
#include "libbb.h"
@@ -35,15 +35,16 @@
fd = create_and_connect_stream_or_die(host, bb_lookup_port("time", "tcp", 37));
- if (safe_read(fd, (void *)&nett, 4) != 4) /* read time from server */
+ if (safe_read(fd, &nett, 4) != 4) /* read time from server */
bb_error_msg_and_die("%s did not send the complete time", host);
- close(fd);
+ if (ENABLE_FEATURE_CLEAN_UP)
+ close(fd);
- /* convert from network byte order to local byte order.
+ /* Convert from network byte order to local byte order.
* RFC 868 time is the number of seconds
* since 00:00 (midnight) 1 January 1900 GMT
* the RFC 868 time 2,208,988,800 corresponds to 00:00 1 Jan 1970 GMT
- * Subtract the RFC 868 time to get Linux epoch
+ * Subtract the RFC 868 time to get Linux epoch.
*/
return ntohl(nett) - RFC_868_BIAS;
@@ -53,14 +54,14 @@
int rdate_main(int argc UNUSED_PARAM, char **argv)
{
time_t remote_time;
- unsigned long flags;
+ unsigned flags;
opt_complementary = "-1";
flags = getopt32(argv, "sp");
remote_time = askremotedate(argv[optind]);
- if ((flags & 2) == 0) {
+ if (!(flags & 2)) { /* no -p (-s may be present) */
time_t current_time;
time(¤t_time);
@@ -71,7 +72,7 @@
bb_perror_msg_and_die("can't set time of day");
}
- if ((flags & 1) == 0)
+ if (flags != 1) /* not lone -s */
printf("%s", ctime(&remote_time));
return EXIT_SUCCESS;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/readprofile.c
^
|
@@ -163,7 +163,7 @@
while (fgets(mapline, S_LEN, map)) {
if (sscanf(mapline, "%llx %s %s", &fn_add, mode, fn_name) != 3)
bb_error_msg_and_die("%s(%i): wrong map line",
- mapFile, maplineno);
+ mapFile, maplineno);
if (!strcmp(fn_name, "_stext")) /* only elf works like this */ {
add0 = fn_add;
@@ -198,7 +198,7 @@
if (indx >= len / sizeof(*buf))
bb_error_msg_and_die("profile address out of range. "
- "Wrong map file?");
+ "Wrong map file?");
while (indx < (next_add-add0)/step) {
if (optBins && (buf[indx] || optAll)) {
@@ -220,10 +220,10 @@
) {
if (optVerbose)
printf("%016llx %-40s %6i %8.4f\n", fn_add,
- fn_name, this, this/(double)fn_len);
+ fn_name, this, this/(double)fn_len);
else
printf("%6i %-40s %8.4f\n",
- this, fn_name, this/(double)fn_len);
+ this, fn_name, this/(double)fn_len);
if (optSub) {
unsigned long long scan;
@@ -233,8 +233,8 @@
addr = (scan - 1)*step + add0;
printf("\t%#llx\t%s+%#llx\t%u\n",
- addr, fn_name, addr - fn_add,
- buf[scan]);
+ addr, fn_name, addr - fn_add,
+ buf[scan]);
}
}
}
@@ -251,10 +251,10 @@
/* trailer */
if (optVerbose)
printf("%016x %-40s %6i %8.4f\n",
- 0, "total", total, total/(double)(fn_add-add0));
+ 0, "total", total, total/(double)(fn_add-add0));
else
printf("%6i %-40s %8.4f\n",
- total, "total", total/(double)(fn_add-add0));
+ total, "total", total/(double)(fn_add-add0));
fclose(map);
free(buf);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/volume_id/Kbuild.src
^
|
@@ -31,7 +31,9 @@
### lib-$(CONFIG_FEATURE_VOLUMEID_LVM) += lvm.o
### lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o
### lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS) += msdos.o
+lib-$(CONFIG_FEATURE_VOLUMEID_NILFS) += nilfs.o
lib-$(CONFIG_FEATURE_VOLUMEID_NTFS) += ntfs.o
+lib-$(CONFIG_FEATURE_VOLUMEID_EXFAT) += exfat.o
lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS) += reiserfs.o
lib-$(CONFIG_FEATURE_VOLUMEID_UDF) += udf.o
### lib-$(CONFIG_FEATURE_VOLUMEID_UFS) += ufs.o
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/volume_id/btrfs.c
^
|
@@ -102,6 +102,7 @@
// N.B.: btrfs natively supports 256 (>VOLUME_ID_LABEL_SIZE) size labels
volume_id_set_label_string(id, sb->label, VOLUME_ID_LABEL_SIZE);
volume_id_set_uuid(id, sb->fsid, UUID_DCE);
+ IF_FEATURE_BLKID_TYPE(id->type = "btrfs";)
return 0;
}
|
[-]
[+]
|
Added |
busybox-1.21.0.tar.bz2/util-linux/volume_id/exfat.c
^
|
@@ -0,0 +1,130 @@
+/*
+ * volume_id - reads filesystem label and uuid
+ *
+ * Copyright (C) 2012 S-G Bergh <sgb@systemasis.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "volume_id_internal.h"
+
+#define EXFAT_SB_OFFSET 0
+#define EXFAT_DIR_ENTRY_SZ 32
+#define EXFAT_MAX_DIR_ENTRIES 100
+
+struct exfat_super_block {
+/* 0x00 */ uint8_t boot_jump[3];
+/* 0x03 */ uint8_t fs_name[8];
+/* 0x0B */ uint8_t must_be_zero[53];
+/* 0x40 */ uint64_t partition_offset;
+/* 0x48 */ uint64_t volume_length;
+/* 0x50 */ uint32_t fat_offset; // Sector address of 1st FAT
+/* 0x54 */ uint32_t fat_size; // In sectors
+/* 0x58 */ uint32_t cluster_heap_offset; // Sector address of Data Region
+/* 0x5C */ uint32_t cluster_count;
+/* 0x60 */ uint32_t root_dir; // Cluster address of Root Directory
+/* 0x64 */ uint8_t vol_serial_nr[4]; // Volume ID
+/* 0x68 */ uint16_t fs_revision; // VV.MM
+/* 0x6A */ uint16_t vol_flags;
+/* 0x6C */ uint8_t bytes_per_sector; // Power of 2: 9 => 512, 12 => 4096
+/* 0x6D */ uint8_t sectors_per_cluster; // Power of 2
+/* 0x6E */ uint8_t nr_of_fats; // 2 for TexFAT
+/* 0x6F */ // ...
+} PACKED;
+
+struct exfat_dir_entry {
+/* 0x00 */ uint8_t entry_type;
+ union {
+ struct volume_label {
+/* 0x01 */ uint8_t char_count; // Length of label
+/* 0x02 */ uint16_t vol_label[11]; // UTF16 string without null termination
+/* 0x18 */ uint8_t reserved[8];
+/* 0x20 */ } PACKED label;
+ struct volume_guid {
+/* 0x01 */ uint8_t sec_count;
+/* 0x02 */ uint16_t set_checksum;
+/* 0x04 */ uint16_t flags;
+/* 0x06 */ uint8_t vol_guid[16];
+/* 0x16 */ uint8_t reserved[10];
+/* 0x20 */ } PACKED guid;
+ } PACKED type;
+} PACKED;
+
+int FAST_FUNC volume_id_probe_exfat(struct volume_id *id /*,uint64_t off*/)
+{
+ struct exfat_super_block *sb;
+ struct exfat_dir_entry *de;
+ unsigned sector_sz;
+ unsigned cluster_sz;
+ uint64_t root_dir_off;
+ unsigned count;
+ unsigned need_lbl_guid;
+
+ // Primary super block
+ dbg("exFAT: probing at offset 0x%x", EXFAT_SB_OFFSET);
+ sb = volume_id_get_buffer(id, EXFAT_SB_OFFSET, sizeof(*sb));
+
+ if (!sb)
+ return -1;
+
+ if (memcmp(sb->fs_name, "EXFAT ", 8) != 0)
+ return -1;
+
+ sector_sz = 1 << sb->bytes_per_sector;
+ cluster_sz = sector_sz << sb->sectors_per_cluster;
+ // There are no clusters 0 and 1, so the first cluster is 2.
+ root_dir_off = (uint64_t)EXFAT_SB_OFFSET +
+ // Hmm... should we cast sector_sz/cluster_sz to uint64_t?
+ (le32_to_cpu(sb->cluster_heap_offset)) * sector_sz +
+ (le32_to_cpu(sb->root_dir) - 2) * cluster_sz;
+ dbg("exFAT: sector size 0x%x bytes", sector_sz);
+ dbg("exFAT: cluster size 0x%x bytes", cluster_sz);
+ dbg("exFAT: root dir is at 0x%llx", (long long)root_dir_off);
+
+ // Use DOS uuid as fallback, if no GUID set
+ volume_id_set_uuid(id, sb->vol_serial_nr, UUID_DOS);
+
+ // EXFAT_MAX_DIR_ENTRIES is used as a safety belt.
+ // The Root Directory may hold an unlimited number of entries,
+ // so we do not want to check all. Usually label and GUID
+ // are in the beginning, but there are no guarantees.
+ need_lbl_guid = (1 << 0) | (1 << 1);
+ for (count = 0; count < EXFAT_MAX_DIR_ENTRIES; count++) {
+ de = volume_id_get_buffer(id, root_dir_off + (count * EXFAT_DIR_ENTRY_SZ), EXFAT_DIR_ENTRY_SZ);
+ if (de == NULL)
+ break;
+ if (de->entry_type == 0x00) {
+ // End of Directory Marker
+ dbg("exFAT: End of root directory reached after %u entries", count);
+ break;
+ }
+ if (de->entry_type == 0x83) {
+ // Volume Label Directory Entry
+ volume_id_set_label_unicode16(id, (uint8_t *)de->type.label.vol_label,
+ LE, 2 * de->type.label.char_count);
+ need_lbl_guid &= ~(1 << 0);
+ }
+ if (de->entry_type == 0xA0) {
+ // Volume GUID Directory Entry
+ volume_id_set_uuid(id, de->type.guid.vol_guid, UUID_DCE);
+ need_lbl_guid &= ~(1 << 1);
+ }
+ if (!need_lbl_guid)
+ break;
+ }
+
+ IF_FEATURE_BLKID_TYPE(id->type = "exfat";)
+ return 0;
+}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/volume_id/ext.c
^
|
@@ -19,70 +19,10 @@
*/
#include "volume_id_internal.h"
-
-struct ext2_super_block {
- uint32_t inodes_count;
- uint32_t blocks_count;
- uint32_t r_blocks_count;
- uint32_t free_blocks_count;
- uint32_t free_inodes_count;
- uint32_t first_data_block;
- uint32_t log_block_size;
- uint32_t dummy3[7];
- uint8_t magic[2];
- uint16_t state;
- uint32_t dummy5[8];
- uint32_t feature_compat;
- uint32_t feature_incompat;
- uint32_t feature_ro_compat;
- uint8_t uuid[16];
- uint8_t volume_name[16];
-} PACKED;
+#include "bb_e2fs_defs.h"
#define EXT_SUPERBLOCK_OFFSET 0x400
-/* for s_flags */
-#define EXT2_FLAGS_TEST_FILESYS 0x0004
-
-/* for s_feature_compat */
-#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
-
-/* for s_feature_ro_compat */
-#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
-#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
-#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
-#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
-#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
-#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
-#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
-
-/* for s_feature_incompat */
-#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
-#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
-#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
-#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
-#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */
-#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
-#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
-#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
-
-#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
- EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
- EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
-#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
- EXT2_FEATURE_INCOMPAT_META_BG)
-#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED ~EXT2_FEATURE_INCOMPAT_SUPP
-#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED ~EXT2_FEATURE_RO_COMPAT_SUPP
-
-#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
- EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
- EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
-#define EXT3_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
- EXT3_FEATURE_INCOMPAT_RECOVER| \
- EXT2_FEATURE_INCOMPAT_META_BG)
-#define EXT3_FEATURE_INCOMPAT_UNSUPPORTED ~EXT3_FEATURE_INCOMPAT_SUPP
-#define EXT3_FEATURE_RO_COMPAT_UNSUPPORTED ~EXT3_FEATURE_RO_COMPAT_SUPP
-
int FAST_FUNC volume_id_probe_ext(struct volume_id *id /*,uint64_t off*/)
{
#define off ((uint64_t)0)
@@ -94,24 +34,24 @@
if (es == NULL)
return -1;
- if (es->magic[0] != 0123 || es->magic[1] != 0357) {
+ if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
dbg("ext: no magic found");
return -1;
}
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
// volume_id_set_label_raw(id, es->volume_name, 16);
- volume_id_set_label_string(id, es->volume_name, 16);
- volume_id_set_uuid(id, es->uuid, UUID_DCE);
+ volume_id_set_label_string(id, (void*)es->s_volume_name, 16);
+ volume_id_set_uuid(id, es->s_uuid, UUID_DCE);
dbg("ext: label '%s' uuid '%s'", id->label, id->uuid);
#if ENABLE_FEATURE_BLKID_TYPE
- if ((es->feature_ro_compat & cpu_to_le32(EXT4_FEATURE_RO_COMPAT_HUGE_FILE | EXT4_FEATURE_RO_COMPAT_DIR_NLINK))
- || (es->feature_incompat & cpu_to_le32(EXT4_FEATURE_INCOMPAT_EXTENTS | EXT4_FEATURE_INCOMPAT_64BIT))
+ if ((es->s_feature_ro_compat & cpu_to_le32(EXT4_FEATURE_RO_COMPAT_HUGE_FILE | EXT4_FEATURE_RO_COMPAT_DIR_NLINK))
+ || (es->s_feature_incompat & cpu_to_le32(EXT4_FEATURE_INCOMPAT_EXTENTS | EXT4_FEATURE_INCOMPAT_64BIT))
) {
id->type = "ext4";
}
- else if (es->feature_compat & cpu_to_le32(EXT3_FEATURE_COMPAT_HAS_JOURNAL))
+ else if (es->s_feature_compat & cpu_to_le32(EXT3_FEATURE_COMPAT_HAS_JOURNAL))
id->type = "ext3";
else
id->type = "ext2";
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/volume_id/get_devname.c
^
|
@@ -49,7 +49,11 @@
if (volume_id_probe_all(vid, /*0,*/ size) != 0)
goto ret;
- if (vid->label[0] != '\0' || vid->uuid[0] != '\0') {
+ if (vid->label[0] != '\0' || vid->uuid[0] != '\0'
+#if ENABLE_FEATURE_BLKID_TYPE
+ || vid->type != NULL
+#endif
+ ) {
*label = xstrndup(vid->label, sizeof(vid->label));
*uuid = xstrndup(vid->uuid, sizeof(vid->uuid));
#if ENABLE_FEATURE_BLKID_TYPE
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/volume_id/hfs.c
^
|
@@ -131,6 +131,27 @@
#define HFS_NODE_LEAF 0xff
#define HFSPLUS_POR_CNID 1
+static void FAST_FUNC hfs_set_uuid(struct volume_id *id, const uint8_t *hfs_id)
+{
+#define hfs_id_len 8
+ md5_ctx_t md5c;
+ uint8_t uuid[16];
+ unsigned i;
+
+ for (i = 0; i < hfs_id_len; i++)
+ if (hfs_id[i] != 0)
+ goto do_md5;
+ return;
+ do_md5:
+ md5_begin(&md5c);
+ md5_hash(&md5c, "\263\342\17\71\362\222\21\326\227\244\0\60\145\103\354\254", 16);
+ md5_hash(&md5c, hfs_id, hfs_id_len);
+ md5_end(&md5c, uuid);
+ uuid[6] = 0x30 | (uuid[6] & 0x0f);
+ uuid[8] = 0x80 | (uuid[8] & 0x3f);
+ volume_id_set_uuid(id, uuid, UUID_DCE);
+}
+
int FAST_FUNC volume_id_probe_hfs_hfsplus(struct volume_id *id /*,uint64_t off*/)
{
uint64_t off = 0;
@@ -193,7 +214,7 @@
volume_id_set_label_string(id, hfs->label, hfs->label_len) ;
}
- volume_id_set_uuid(id, hfs->finder_info.id, UUID_HFS);
+ hfs_set_uuid(id, hfs->finder_info.id);
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
IF_FEATURE_BLKID_TYPE(id->type = "hfs";)
@@ -207,7 +228,7 @@
return -1;
hfsplus:
- volume_id_set_uuid(id, hfsplus->finder_info.id, UUID_HFS);
+ hfs_set_uuid(id, hfsplus->finder_info.id);
blocksize = be32_to_cpu(hfsplus->blocksize);
dbg("blocksize %u", blocksize);
@@ -286,7 +307,7 @@
found:
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
-// id->type = "hfsplus";
+ IF_FEATURE_BLKID_TYPE(id->type = "hfsplus";)
return 0;
}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/volume_id/linux_raid.c
^
|
@@ -69,9 +69,9 @@
volume_id_set_uuid(id, uuid, UUID_DCE);
// snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u.%u",
-// le32_to_cpu(mdp->major_version),
-// le32_to_cpu(mdp->minor_version),
-// le32_to_cpu(mdp->patch_version));
+// le32_to_cpu(mdp->major_version),
+// le32_to_cpu(mdp->minor_version),
+// le32_to_cpu(mdp->patch_version));
dbg("found raid signature");
// volume_id_set_usage(id, VOLUME_ID_RAID);
|
[-]
[+]
|
Added |
busybox-1.21.0.tar.bz2/util-linux/volume_id/nilfs.c
^
|
@@ -0,0 +1,96 @@
+/*
+ * volume_id - reads filesystem label and uuid
+ *
+ * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (C) 2012 S-G Bergh <sgb@systemasis.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "volume_id_internal.h"
+
+#define NILFS_UUID_SIZE 16
+#define NILFS_LABEL_SIZE 80
+#define NILFS_SB1_OFFSET 0x400
+#define NILFS_SB2_OFFSET 0x1000
+#define NILFS_MAGIC 0x3434
+
+struct nilfs2_super_block {
+/* 0x00 */ uint32_t s_rev_level; // Major revision level.
+/* 0x04 */ uint16_t s_minor_rev_level; // Minor revision level.
+/* 0x06 */ uint16_t s_magic; // Magic signature.
+/* 0x08 */ uint16_t s_bytes;
+/* 0x0A */ uint16_t s_flags;
+/* 0x0C */ uint32_t s_crc_seed;
+/* 0x10 */ uint32_t s_sum;
+/* 0x14 */ uint32_t s_log_block_size;
+/* 0x18 */ uint64_t s_nsegments;
+/* 0x20 */ uint64_t s_dev_size; // Block device size in bytes.
+/* 0x28 */ uint64_t s_first_data_block;
+/* 0x30 */ uint32_t s_blocks_per_segment;
+/* 0x34 */ uint32_t s_r_segments_percentage;
+/* 0x38 */ uint64_t s_last_cno;
+/* 0x40 */ uint64_t s_last_pseg;
+/* 0x48 */ uint64_t s_last_seq;
+/* 0x50 */ uint64_t s_free_blocks_count;
+/* 0x58 */ uint64_t s_ctime;
+/* 0x60 */ uint64_t s_mtime;
+/* 0x68 */ uint64_t s_wtime;
+/* 0x70 */ uint16_t s_mnt_count;
+/* 0x72 */ uint16_t s_max_mnt_count;
+/* 0x74 */ uint16_t s_state;
+/* 0x76 */ uint16_t s_errors;
+/* 0x78 */ uint64_t s_lastcheck;
+/* 0x80 */ uint32_t s_checkinterval;
+/* 0x84 */ uint32_t s_creator_os;
+/* 0x88 */ uint16_t s_def_resuid;
+/* 0x8A */ uint16_t s_def_resgid;
+/* 0x8C */ uint32_t s_first_ino;
+/* 0x90 */ uint16_t s_inode_size;
+/* 0x92 */ uint16_t s_dat_entry_size;
+/* 0x94 */ uint16_t s_checkpoint_size;
+/* 0x96 */ uint16_t s_segment_usage_size;
+/* 0x98 */ uint8_t s_uuid[NILFS_UUID_SIZE]; // 128-bit UUID for volume.
+/* 0xA8 */ uint8_t s_volume_name[NILFS_LABEL_SIZE]; // Volume label.
+/* 0xF8 */ // ...
+} PACKED;
+
+int FAST_FUNC volume_id_probe_nilfs(struct volume_id *id /*,uint64_t off*/)
+{
+ struct nilfs2_super_block *sb;
+
+ // Primary super block
+ dbg("nilfs: probing at offset 0x%x", NILFS_SB1_OFFSET);
+
+ sb = volume_id_get_buffer(id, NILFS_SB1_OFFSET, sizeof(*sb));
+
+ if (sb == NULL)
+ return -1;
+
+ if (sb->s_magic != NILFS_MAGIC)
+ return -1;
+
+ // The secondary superblock is not always used, so ignore it for now.
+ // When used it is at 4K from the end of the partition (sb->s_dev_size - NILFS_SB2_OFFSET).
+
+ volume_id_set_label_string(id, sb->s_volume_name, NILFS_LABEL_SIZE < VOLUME_ID_LABEL_SIZE ?
+ NILFS_LABEL_SIZE : VOLUME_ID_LABEL_SIZE);
+ volume_id_set_uuid(id, sb->s_uuid, UUID_DCE);
+
+ if (sb->s_rev_level == 2)
+ IF_FEATURE_BLKID_TYPE(id->type = "nilfs2");
+
+ return 0;
+}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/volume_id/ntfs.c
^
|
@@ -132,7 +132,7 @@
dbg("mft record size %i", mft_record_size);
buf = volume_id_get_buffer(id, off + mft_off + (MFT_RECORD_VOLUME * mft_record_size),
- mft_record_size);
+ mft_record_size);
if (buf == NULL)
goto found;
@@ -165,7 +165,7 @@
break;
dbg("found attribute type 0x%x, len %i, at offset %i",
- attr_type, attr_len, attr_off);
+ attr_type, attr_len, attr_off);
// if (attr_type == MFT_RECORD_ATTR_VOLUME_INFO) {
// struct volume_info *info;
|
[-]
[+]
|
Added |
busybox-1.21.0.tar.bz2/util-linux/volume_id/squashfs.c
^
|
@@ -0,0 +1,49 @@
+/*
+ * volume_id - reads filesystem label and uuid
+ *
+ * Copyright (C) 2012 S-G Bergh <sgb@systemasis.org>
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+
+//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_SQUASHFS) += squashfs.o
+
+#include "volume_id_internal.h"
+
+struct squashfs_superblock {
+ uint32_t magic;
+/*
+ uint32_t dummy[6];
+ uint16_t major;
+ uint16_t minor;
+*/
+} PACKED;
+
+int FAST_FUNC volume_id_probe_squashfs(struct volume_id *id /*,uint64_t off*/)
+{
+#define off ((uint64_t)0)
+ struct squashfs_superblock *sb;
+
+ dbg("SquashFS: probing at offset 0x%llx", (unsigned long long) off);
+ sb = volume_id_get_buffer(id, off, 0x200);
+ if (!sb)
+ return -1;
+
+ // Old SquashFS (pre 4.0) can be both big and little endian, so test for both.
+ // Likewise, it is commonly used in firwmare with some non-standard signatures.
+#define pack(a,b,c,d) ( (uint32_t)((a * 256 + b) * 256 + c) * 256 + d )
+#define SIG1 pack('s','q','s','h')
+#define SIG2 pack('h','s','q','s')
+#define SIG3 pack('s','h','s','q')
+#define SIG4 pack('q','s','h','s')
+ if (sb->magic == SIG1
+ || sb->magic == SIG2
+ || sb->magic == SIG3
+ || sb->magic == SIG4
+ ) {
+ IF_FEATURE_BLKID_TYPE(id->type = "squashfs";)
+ return 0;
+ }
+
+ return -1;
+}
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/volume_id/udf.c
^
|
@@ -109,7 +109,7 @@
return -1;
dbg("vsd: %c%c%c%c%c",
- vsd->id[0], vsd->id[1], vsd->id[2], vsd->id[3], vsd->id[4]);
+ vsd->id[0], vsd->id[1], vsd->id[2], vsd->id[3], vsd->id[4]);
if (vsd->id[0] == '\0')
return -1;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/volume_id/unused_msdos.c
^
|
@@ -109,7 +109,7 @@
extended = off + poff;
} else {
dbg("found 0x%x data partition at 0x%llx, len 0x%llx",
- part[i].sys_ind, (unsigned long long) poff, (unsigned long long) plen);
+ part[i].sys_ind, (unsigned long long) poff, (unsigned long long) plen);
// if (is_raid(part[i].sys_ind))
// volume_id_set_usage_part(p, VOLUME_ID_RAID);
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/volume_id/unused_silicon_raid.c
^
|
@@ -62,7 +62,7 @@
// volume_id_set_usage(id, VOLUME_ID_RAID);
// snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u",
-// le16_to_cpu(sil->major_ver), le16_to_cpu(sil->minor_ver));
+// le16_to_cpu(sil->major_ver), le16_to_cpu(sil->minor_ver));
// id->type = "silicon_medley_raid_member";
return 0;
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/volume_id/util.c
^
|
@@ -31,25 +31,29 @@
c = (buf[i+1] << 8) | buf[i];
else
c = (buf[i] << 8) | buf[i+1];
- if (c == 0) {
- str[j] = '\0';
+ if (c == 0)
break;
- } else if (c < 0x80) {
- if (j+1 >= len)
- break;
- str[j++] = (uint8_t) c;
- } else if (c < 0x800) {
- if (j+2 >= len)
- break;
- str[j++] = (uint8_t) (0xc0 | (c >> 6));
- str[j++] = (uint8_t) (0x80 | (c & 0x3f));
+ if (j+1 >= len)
+ break;
+ if (c < 0x80) {
+ /* 0xxxxxxx */
} else {
- if (j+3 >= len)
+ uint8_t topbits = 0xc0;
+ if (j+2 >= len)
break;
- str[j++] = (uint8_t) (0xe0 | (c >> 12));
- str[j++] = (uint8_t) (0x80 | ((c >> 6) & 0x3f));
- str[j++] = (uint8_t) (0x80 | (c & 0x3f));
+ if (c < 0x800) {
+ /* 110yyyxx 10xxxxxx */
+ } else {
+ if (j+3 >= len)
+ break;
+ /* 1110yyyy 10yyyyxx 10xxxxxx */
+ str[j++] = (uint8_t) (0xe0 | (c >> 12));
+ topbits = 0x80;
+ }
+ str[j++] = (uint8_t) (topbits | ((c >> 6) & 0x3f));
+ c = 0x80 | (c & 0x3f);
}
+ str[j++] = (uint8_t) c;
}
str[j] = '\0';
}
@@ -125,30 +129,14 @@
void volume_id_set_label_unicode16(struct volume_id *id, const uint8_t *buf, enum endian endianess, size_t count)
{
- volume_id_set_unicode16(id->label, sizeof(id->label), buf, endianess, count);
+ volume_id_set_unicode16(id->label, sizeof(id->label), buf, endianess, count);
}
void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, enum uuid_format format)
{
unsigned i;
- unsigned count = 0;
+ unsigned count = (format == UUID_DCE_STRING ? VOLUME_ID_UUID_SIZE : 4 << format);
- switch (format) {
- case UUID_DOS:
- count = 4;
- break;
- case UUID_NTFS:
- case UUID_HFS:
- count = 8;
- break;
- case UUID_DCE:
- count = 16;
- break;
- case UUID_DCE_STRING:
- /* 36 is ok, id->uuid has one extra byte for NUL */
- count = VOLUME_ID_UUID_SIZE;
- break;
- }
// memcpy(id->uuid_raw, buf, count);
// id->uuid_raw_len = count;
@@ -169,11 +157,6 @@
buf[7], buf[6], buf[5], buf[4],
buf[3], buf[2], buf[1], buf[0]);
break;
- case UUID_HFS:
- sprintf(id->uuid, "%02X%02X%02X%02X%02X%02X%02X%02X",
- buf[0], buf[1], buf[2], buf[3],
- buf[4], buf[5], buf[6], buf[7]);
- break;
case UUID_DCE:
sprintf(id->uuid,
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/volume_id/volume_id.c
^
|
@@ -93,9 +93,15 @@
#if ENABLE_FEATURE_VOLUMEID_FAT
volume_id_probe_vfat,
#endif
+#if ENABLE_FEATURE_VOLUMEID_EXFAT
+ volume_id_probe_exfat,
+#endif
#if ENABLE_FEATURE_VOLUMEID_MAC
volume_id_probe_mac_partition_map,
#endif
+#if ENABLE_FEATURE_VOLUMEID_SQUASHFS
+ volume_id_probe_squashfs,
+#endif
#if ENABLE_FEATURE_VOLUMEID_XFS
volume_id_probe_xfs,
#endif
@@ -130,6 +136,9 @@
#if ENABLE_FEATURE_VOLUMEID_UFS
volume_id_probe_ufs,
#endif
+#if ENABLE_FEATURE_VOLUMEID_NILFS
+ volume_id_probe_nilfs,
+#endif
#if ENABLE_FEATURE_VOLUMEID_NTFS
volume_id_probe_ntfs,
#endif
|
[-]
[+]
|
Changed |
busybox-1.21.0.tar.bz2/util-linux/volume_id/volume_id_internal.h
^
|
@@ -136,12 +136,15 @@
#define cpu_to_be32(x) (x)
#endif
+/* volume_id_set_uuid(id,buf,fmt) assumes size of uuid buf
+ * by shifting: 4 << fmt, except for fmt == UUID_DCE_STRING.
+ * The constants below should match sizes.
+ */
enum uuid_format {
- UUID_DCE_STRING,
- UUID_DCE,
- UUID_DOS,
- UUID_NTFS,
- UUID_HFS,
+ UUID_DOS = 0, /* 4 bytes */
+ UUID_NTFS = 1, /* 8 bytes */
+ UUID_DCE = 2, /* 16 bytes */
+ UUID_DCE_STRING = 3, /* 36 bytes (VOLUME_ID_UUID_SIZE) */
};
enum endian {
@@ -212,14 +215,20 @@
//int FAST_FUNC volume_id_probe_msdos_part_table(struct volume_id *id /*,uint64_t off*/);
+int FAST_FUNC volume_id_probe_nilfs(struct volume_id *id /*,uint64_t off*/);
+
int FAST_FUNC volume_id_probe_ntfs(struct volume_id *id /*,uint64_t off*/);
+int FAST_FUNC volume_id_probe_exfat(struct volume_id *id /*,uint64_t off*/);
+
int FAST_FUNC volume_id_probe_ocfs2(struct volume_id *id /*,uint64_t off*/);
int FAST_FUNC volume_id_probe_reiserfs(struct volume_id *id /*,uint64_t off*/);
int FAST_FUNC volume_id_probe_romfs(struct volume_id *id /*,uint64_t off*/);
+int FAST_FUNC volume_id_probe_squashfs(struct volume_id *id /*,uint64_t off*/);
+
int FAST_FUNC volume_id_probe_sysv(struct volume_id *id /*,uint64_t off*/);
int FAST_FUNC volume_id_probe_udf(struct volume_id *id /*,uint64_t off*/);
|