From 707a7ef4c72d1d00ff61221511a70eada19185ca Mon Sep 17 00:00:00 2001 From: Louis Sautier Date: Thu, 4 Nov 2021 13:55:16 +0100 Subject: pkill: add -e to display the name and PID of the process being killed This mimics the behaviour of pkill -e / --echo from procps. function old new delta .rodata 105179 105200 +21 packed_usage 34523 34516 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 21/-7) Total: 14 bytes Signed-off-by: Louis Sautier Signed-off-by: Denys Vlasenko --- procps/pgrep.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/procps/pgrep.c b/procps/pgrep.c index 6d25c247e..82e00322f 100644 --- a/procps/pgrep.c +++ b/procps/pgrep.c @@ -44,7 +44,7 @@ //usage: "\n -P Match parent process ID" //usage: //usage:#define pkill_trivial_usage -//usage: "[-l|-SIGNAL] [-xfvno] [-s SID|-P PPID|PATTERN]" +//usage: "[-l|-SIGNAL] [-xfvnoe] [-s SID|-P PPID|PATTERN]" //usage:#define pkill_full_usage "\n\n" //usage: "Send signal to processes selected by regex PATTERN\n" //usage: "\n -l List all signals" @@ -55,6 +55,7 @@ //usage: "\n -v Negate the match" //usage: "\n -n Signal the newest process only" //usage: "\n -o Signal the oldest process only" +//usage: "\n -e Display name and PID of the process being killed" #include "libbb.h" #include "xregex.h" @@ -64,7 +65,7 @@ #define pkill (ENABLE_PKILL && (!ENABLE_PGREP || applet_name[1] == 'k')) enum { - /* "vlafxons:+P:+" */ + /* "vlafxones:+P:+" */ OPTBIT_V = 0, /* must be first, we need OPT_INVERT = 0/1 */ OPTBIT_L, OPTBIT_A, @@ -72,6 +73,7 @@ enum { OPTBIT_X, OPTBIT_O, OPTBIT_N, + OPTBIT_E, /* should be pkill-only, do we care? */ OPTBIT_S, OPTBIT_P, }; @@ -83,6 +85,7 @@ enum { #define OPT_ANCHOR (opt & (1 << OPTBIT_X)) #define OPT_FIRST (opt & (1 << OPTBIT_O)) #define OPT_LAST (opt & (1 << OPTBIT_N)) +#define OPT_ECHO (opt & (1 << OPTBIT_E)) #define OPT_SID (opt & (1 << OPTBIT_S)) #define OPT_PPID (opt & (1 << OPTBIT_P)) @@ -93,8 +96,12 @@ static void act(unsigned pid, char *cmd, int signo) printf("%u %s\n", pid, cmd); else printf("%u\n", pid); - } else + } else { kill(pid, signo); + if (option_mask32 & (1 << OPTBIT_E)) { + printf("%s killed (pid %u)\n", cmd, pid); + } + } } int pgrep_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; @@ -131,7 +138,7 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv) /* Parse remaining options */ ppid2match = -1; sid2match = -1; - opt = getopt32(argv, "vlafxons:+P:+", &sid2match, &ppid2match); + opt = getopt32(argv, "vlafxones:+P:+", &sid2match, &ppid2match); argv += optind; if (pkill && OPT_LIST) { /* -l: print the whole signal list */ -- cgit v1.2.3-55-g6feb From cb8d2ea8c91b5671b05e06ab2282496104453378 Mon Sep 17 00:00:00 2001 From: Xiaoming Ni Date: Tue, 15 Nov 2022 14:54:05 +0100 Subject: loop: fix a race when a free loop device is snatched When /dev/loop-control exists and *device is empty, the mount may fail if a concurrent mount is running. function old new delta set_loop 809 807 -2 Signed-off-by: Xiaoming Ni Signed-off-by: Denys Vlasenko --- libbb/loop.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libbb/loop.c b/libbb/loop.c index cb8fa2442..750642ade 100644 --- a/libbb/loop.c +++ b/libbb/loop.c @@ -218,8 +218,17 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse } /* failure, undo LOOP_SET_FD */ ioctl(lfd, LOOP_CLR_FD, 0); // actually, 0 param is unnecessary + } else { + /* device is not free (rc == 0), or error other than ENXIO */ + if (rc == 0 /* device is not free? */ + && !*device /* racing with other mount? */ + && try != dev /* tried a _kernel-offered_ loopN? */ + ) { + free(try); + close(lfd); + goto get_free_loopN; + } } - /* else: device is not free (rc == 0) or error other than ENXIO */ close_and_try_next_loopN: close(lfd); try_next_loopN: -- cgit v1.2.3-55-g6feb From e8dfa0c1bedf69783e54b5a7798fb14dcaeb0434 Mon Sep 17 00:00:00 2001 From: Dario Binacchi Date: Fri, 9 Sep 2022 09:05:51 +0200 Subject: fbset: abort on not handled options Not all options are actually implemented. In this case, return a message and an error code to make it clear that the requested command has not been executed. function old new delta .rodata 105200 105224 +24 fbset_main 747 733 -14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 24/-14) Total: 10 bytes Signed-off-by: Dario Binacchi Signed-off-by: Denys Vlasenko --- util-linux/fbset.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util-linux/fbset.c b/util-linux/fbset.c index 41cc29f37..0eaa7c0a6 100644 --- a/util-linux/fbset.c +++ b/util-linux/fbset.c @@ -519,6 +519,9 @@ int fbset_main(int argc, char **argv) var_set.bits_per_pixel = xatou32(argv[1]); break; #endif + default: + bb_perror_msg_and_die("option '%s' not handled", + g_cmdoptions[i].name); } switch (g_cmdoptions[i].code) { case CMD_FB: -- cgit v1.2.3-55-g6feb From 75fbff1326674b768cee66f32e3799d5bff5e194 Mon Sep 17 00:00:00 2001 From: Dario Binacchi Date: Fri, 9 Sep 2022 09:05:52 +0200 Subject: fbset: support setting pixel clock rate Only in case the FEATURE_FBSET_FANCY configuration is enabled. function old new delta fbset_main 733 766 +33 Signed-off-by: Dario Binacchi Signed-off-by: Denys Vlasenko --- util-linux/fbset.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util-linux/fbset.c b/util-linux/fbset.c index 0eaa7c0a6..768ab80eb 100644 --- a/util-linux/fbset.c +++ b/util-linux/fbset.c @@ -518,6 +518,9 @@ int fbset_main(int argc, char **argv) case CMD_DEPTH: var_set.bits_per_pixel = xatou32(argv[1]); break; + case CMD_PIXCLOCK: + var_set.pixclock = xatou32(argv[1]); + break; #endif default: bb_perror_msg_and_die("option '%s' not handled", -- cgit v1.2.3-55-g6feb From 77216c368f3ae65c3a9fc504d28d3fadd46d6d8d Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 16 Oct 2022 02:04:59 +0200 Subject: Fix non-Linux builds Various tools are Linuxish and should thus only attempted to build on Linux only. Some features are also Linux-only. Also, libresolv is used on all GNU platforms, notably GNU/Hurd and GNU/kfreeBSD. Signed-off-by: Samuel Thibault Signed-off-by: Denys Vlasenko --- Makefile.flags | 2 +- console-tools/loadfont.c | 1 + console-tools/openvt.c | 1 + coreutils/dd.c | 20 ++++++++++++++++++-- klibc-utils/run-init.c | 1 + miscutils/adjtimex.c | 1 + miscutils/i2c_tools.c | 5 +++++ miscutils/partprobe.c | 1 + miscutils/ubirename.c | 1 + miscutils/watchdog.c | 1 + modutils/Config.src | 1 + modutils/depmod.c | 1 + modutils/insmod.c | 1 + modutils/lsmod.c | 1 + modutils/modinfo.c | 1 + modutils/modprobe.c | 1 + modutils/rmmod.c | 1 + networking/arp.c | 1 + networking/arping.c | 1 + networking/brctl.c | 1 + networking/ifconfig.c | 1 + networking/ifplugd.c | 1 + networking/ip.c | 6 ++++++ networking/nameif.c | 1 + networking/route.c | 1 + networking/tc.c | 1 + networking/traceroute.c | 2 ++ networking/tunctl.c | 1 + networking/udhcp/Config.src | 3 +++ procps/free.c | 1 + procps/uptime.c | 1 + sysklogd/klogd.c | 1 + util-linux/acpid.c | 1 + util-linux/blkdiscard.c | 1 + util-linux/blkid.c | 1 + util-linux/dmesg.c | 1 + util-linux/fdisk.c | 1 + util-linux/findfs.c | 1 + util-linux/freeramdisk.c | 2 ++ util-linux/fsfreeze.c | 1 + util-linux/fstrim.c | 1 + util-linux/hwclock.c | 1 + util-linux/ionice.c | 1 + util-linux/losetup.c | 1 + util-linux/mdev.c | 1 + util-linux/mkfs_ext2.c | 1 + util-linux/mkfs_vfat.c | 1 + util-linux/mount.c | 1 + util-linux/nsenter.c | 1 + util-linux/pivot_root.c | 1 + util-linux/setarch.c | 3 +++ util-linux/setpriv.c | 1 + util-linux/swaponoff.c | 2 ++ util-linux/switch_root.c | 1 + util-linux/uevent.c | 1 + util-linux/unshare.c | 1 + 56 files changed, 89 insertions(+), 3 deletions(-) diff --git a/Makefile.flags b/Makefile.flags index 84cb00a75..50137a78e 100644 --- a/Makefile.flags +++ b/Makefile.flags @@ -184,7 +184,7 @@ LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=% endif ifeq ($(CONFIG_FEATURE_NSLOOKUP_BIG),y) -ifneq (,$(findstring linux,$(shell $(CC) $(CFLAGS) -dumpmachine))) +ifneq (,$(findstring gnu,$(shell $(CC) $(CFLAGS) -dumpmachine))) LDLIBS += resolv endif endif diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c index 81a0e6aa8..3f36cabe0 100644 --- a/console-tools/loadfont.c +++ b/console-tools/loadfont.c @@ -12,6 +12,7 @@ //config:config LOADFONT //config: bool "loadfont (5.2 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: This program loads a console font from standard input. //config: diff --git a/console-tools/openvt.c b/console-tools/openvt.c index db2f073b2..9e6cffecc 100644 --- a/console-tools/openvt.c +++ b/console-tools/openvt.c @@ -10,6 +10,7 @@ //config:config OPENVT //config: bool "openvt (7.2 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: This program is used to start a command on an unused //config: virtual terminal. diff --git a/coreutils/dd.c b/coreutils/dd.c index 06c1b7b9c..3e034eb1e 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c @@ -200,6 +200,7 @@ static void dd_output_status(int UNUSED_PARAM cur_signal) } #if ENABLE_FEATURE_DD_IBS_OBS +# ifdef O_DIRECT static int clear_O_DIRECT(int fd) { if (errno == EINVAL) { @@ -211,6 +212,7 @@ static int clear_O_DIRECT(int fd) } return 0; } +# endif #endif static ssize_t dd_read(void *ibuf, size_t ibs) @@ -225,8 +227,10 @@ static ssize_t dd_read(void *ibuf, size_t ibs) #endif n = safe_read(ifd, ibuf, ibs); #if ENABLE_FEATURE_DD_IBS_OBS +# ifdef O_DIRECT if (n < 0 && (G.flags & FLAG_IDIRECT) && clear_O_DIRECT(ifd)) goto read_again; +# endif #endif return n; } @@ -239,8 +243,10 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs, IF_FEATURE_DD_IBS_OBS(write_again:) n = full_write(ofd, buf, len); #if ENABLE_FEATURE_DD_IBS_OBS +# ifdef O_DIRECT if (n < 0 && (G.flags & FLAG_ODIRECT) && clear_O_DIRECT(ofd)) goto write_again; +# endif #endif #if ENABLE_FEATURE_DD_THIRD_STATUS_LINE @@ -501,8 +507,13 @@ int dd_main(int argc UNUSED_PARAM, char **argv) if (infile) { int iflag = O_RDONLY; #if ENABLE_FEATURE_DD_IBS_OBS - if (G.flags & FLAG_IDIRECT) + if (G.flags & FLAG_IDIRECT) { +# ifdef O_DIRECT iflag |= O_DIRECT; +# else + bb_error_msg_and_die("O_DIRECT not supported on this platform"); +# endif + } #endif xmove_fd(xopen(infile, iflag), ifd); } else { @@ -516,8 +527,13 @@ int dd_main(int argc UNUSED_PARAM, char **argv) if (G.flags & FLAG_APPEND) oflag |= O_APPEND; #if ENABLE_FEATURE_DD_IBS_OBS - if (G.flags & FLAG_ODIRECT) + if (G.flags & FLAG_ODIRECT) { +# ifdef O_DIRECT oflag |= O_DIRECT; +# else + bb_error_msg_and_die("O_DIRECT not supported on this platform"); +# endif + } #endif xmove_fd(xopen(outfile, oflag), ofd); diff --git a/klibc-utils/run-init.c b/klibc-utils/run-init.c index 73c677bab..77fc0e60c 100644 --- a/klibc-utils/run-init.c +++ b/klibc-utils/run-init.c @@ -8,6 +8,7 @@ //config:config RUN_INIT //config: bool "run-init (7.7 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: The run-init utility is used from initramfs to select a new //config: root device. Under initramfs, you have to use this instead of diff --git a/miscutils/adjtimex.c b/miscutils/adjtimex.c index 209d1d560..c289245c0 100644 --- a/miscutils/adjtimex.c +++ b/miscutils/adjtimex.c @@ -13,6 +13,7 @@ //config:config ADJTIMEX //config: bool "adjtimex (4.7 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Adjtimex reads and optionally sets adjustment parameters for //config: the Linux clock adjustment algorithm. diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index da26f5e19..46749fb9c 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c @@ -11,30 +11,35 @@ //config:config I2CGET //config: bool "i2cget (5.5 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Read from I2C/SMBus chip registers. //config: //config:config I2CSET //config: bool "i2cset (6.7 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Set I2C registers. //config: //config:config I2CDUMP //config: bool "i2cdump (7.1 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Examine I2C registers. //config: //config:config I2CDETECT //config: bool "i2cdetect (7.1 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Detect I2C chips. //config: //config:config I2CTRANSFER //config: bool "i2ctransfer (4.0 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Send user-defined I2C messages in one transfer. //config: diff --git a/miscutils/partprobe.c b/miscutils/partprobe.c index 0fb1927b7..0abed6ff1 100644 --- a/miscutils/partprobe.c +++ b/miscutils/partprobe.c @@ -7,6 +7,7 @@ //config:config PARTPROBE //config: bool "partprobe (3.5 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Ask kernel to rescan partition table. diff --git a/miscutils/ubirename.c b/miscutils/ubirename.c index 06a0adacf..e7c56640c 100644 --- a/miscutils/ubirename.c +++ b/miscutils/ubirename.c @@ -9,6 +9,7 @@ //config:config UBIRENAME //config: bool "ubirename (2.4 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Utility to rename UBI volumes diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c index 9f5a4b849..91a20239d 100644 --- a/miscutils/watchdog.c +++ b/miscutils/watchdog.c @@ -11,6 +11,7 @@ //config:config WATCHDOG //config: bool "watchdog (5.3 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: The watchdog utility is used with hardware or software watchdog //config: device drivers. It opens the specified watchdog device special file diff --git a/modutils/Config.src b/modutils/Config.src index 188296814..b8ba3b7b6 100644 --- a/modutils/Config.src +++ b/modutils/Config.src @@ -8,6 +8,7 @@ menu "Linux Module Utilities" config MODPROBE_SMALL bool "Simplified modutils" default y + select PLATFORM_LINUX help Build smaller (~1.5 kbytes), simplified module tools. diff --git a/modutils/depmod.c b/modutils/depmod.c index bb42bbefe..9e39481c5 100644 --- a/modutils/depmod.c +++ b/modutils/depmod.c @@ -10,6 +10,7 @@ //config:config DEPMOD //config: bool "depmod (27 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: depmod generates modules.dep (and potentially modules.alias //config: and modules.symbols) that contain dependency information diff --git a/modutils/insmod.c b/modutils/insmod.c index 8f7163e25..85b46cdd6 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c @@ -9,6 +9,7 @@ //config:config INSMOD //config: bool "insmod (22 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: insmod is used to load specified modules in the running kernel. diff --git a/modutils/lsmod.c b/modutils/lsmod.c index 2beb12362..39dc8e6b7 100644 --- a/modutils/lsmod.c +++ b/modutils/lsmod.c @@ -10,6 +10,7 @@ //config:config LSMOD //config: bool "lsmod (1.9 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: lsmod is used to display a list of loaded modules. //config: diff --git a/modutils/modinfo.c b/modutils/modinfo.c index 0a86c3296..5d01179a0 100644 --- a/modutils/modinfo.c +++ b/modutils/modinfo.c @@ -8,6 +8,7 @@ //config:config MODINFO //config: bool "modinfo (24 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Show information about a Linux Kernel module diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 235706fd5..77c4bb74d 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c @@ -10,6 +10,7 @@ //config:config MODPROBE //config: bool "modprobe (28 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Handle the loading of modules, and their dependencies on a high //config: level. diff --git a/modutils/rmmod.c b/modutils/rmmod.c index 2b3c39153..8d4639f50 100644 --- a/modutils/rmmod.c +++ b/modutils/rmmod.c @@ -10,6 +10,7 @@ //config:config RMMOD //config: bool "rmmod (3.3 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: rmmod is used to unload specified modules from the kernel. diff --git a/networking/arp.c b/networking/arp.c index 16783ab95..6519f8156 100644 --- a/networking/arp.c +++ b/networking/arp.c @@ -15,6 +15,7 @@ //config:config ARP //config: bool "arp (10 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Manipulate the system ARP cache. diff --git a/networking/arping.c b/networking/arping.c index 86f0221ed..fd0e1b276 100644 --- a/networking/arping.c +++ b/networking/arping.c @@ -8,6 +8,7 @@ //config:config ARPING //config: bool "arping (9 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Ping hosts by ARP packets. diff --git a/networking/brctl.c b/networking/brctl.c index 956bd91f3..b353210d7 100644 --- a/networking/brctl.c +++ b/networking/brctl.c @@ -12,6 +12,7 @@ //config:config BRCTL //config: bool "brctl (4.7 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Manage ethernet bridges. //config: Supports addbr/delbr and addif/delif. diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 9ee232a66..4090959b8 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c @@ -27,6 +27,7 @@ //config:config IFCONFIG //config: bool "ifconfig (12 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Ifconfig is used to configure the kernel-resident network interfaces. //config: diff --git a/networking/ifplugd.c b/networking/ifplugd.c index 0b55bf4e5..bc4303ef0 100644 --- a/networking/ifplugd.c +++ b/networking/ifplugd.c @@ -9,6 +9,7 @@ //config:config IFPLUGD //config: bool "ifplugd (10 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Network interface plug detection daemon. diff --git a/networking/ip.c b/networking/ip.c index 7c3208699..23ee7d24b 100644 --- a/networking/ip.c +++ b/networking/ip.c @@ -11,6 +11,7 @@ //config:config IP //config: bool "ip (35 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: The "ip" applet is a TCP/IP interface configuration and routing //config: utility. @@ -21,6 +22,7 @@ //config:config IPADDR //config: bool "ipaddr (14 kb)" //config: default y +//config: select PLATFORM_LINUX //config: select FEATURE_IP_ADDRESS //config: help //config: Short form of "ip addr" @@ -28,6 +30,7 @@ //config:config IPLINK //config: bool "iplink (17 kb)" //config: default y +//config: select PLATFORM_LINUX //config: select FEATURE_IP_LINK //config: help //config: Short form of "ip link" @@ -35,6 +38,7 @@ //config:config IPROUTE //config: bool "iproute (15 kb)" //config: default y +//config: select PLATFORM_LINUX //config: select FEATURE_IP_ROUTE //config: help //config: Short form of "ip route" @@ -49,6 +53,7 @@ //config:config IPRULE //config: bool "iprule (10 kb)" //config: default y +//config: select PLATFORM_LINUX //config: select FEATURE_IP_RULE //config: help //config: Short form of "ip rule" @@ -56,6 +61,7 @@ //config:config IPNEIGH //config: bool "ipneigh (8.3 kb)" //config: default y +//config: select PLATFORM_LINUX //config: select FEATURE_IP_NEIGH //config: help //config: Short form of "ip neigh" diff --git a/networking/nameif.c b/networking/nameif.c index 66e042688..3ccd935b8 100644 --- a/networking/nameif.c +++ b/networking/nameif.c @@ -12,6 +12,7 @@ //config:config NAMEIF //config: bool "nameif (6.6 kb)" //config: default y +//config: select PLATFORM_LINUX //config: select FEATURE_SYSLOG //config: help //config: nameif is used to rename network interface by its MAC address. diff --git a/networking/route.c b/networking/route.c index 26146f8e9..616572814 100644 --- a/networking/route.c +++ b/networking/route.c @@ -27,6 +27,7 @@ //config:config ROUTE //config: bool "route (8.7 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Route displays or manipulates the kernel's IP routing tables. diff --git a/networking/tc.c b/networking/tc.c index 43187f7ee..1f4bcce2b 100644 --- a/networking/tc.c +++ b/networking/tc.c @@ -9,6 +9,7 @@ //config:config TC //config: bool "tc (8.3 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Show / manipulate traffic control settings //config: diff --git a/networking/traceroute.c b/networking/traceroute.c index 4bbe1ab8e..2ba990fd0 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -963,8 +963,10 @@ traceroute_init(int op, char **argv) if (af == AF_INET) { xmove_fd(xsocket(AF_INET, SOCK_RAW, IPPROTO_ICMP), rcvsock); #if ENABLE_FEATURE_TRACEROUTE_VERBOSE +# ifdef IP_PKTINFO /* want recvmsg to report target local address (for -v) */ setsockopt_1(rcvsock, IPPROTO_IP, IP_PKTINFO); +# endif #endif } #if ENABLE_TRACEROUTE6 diff --git a/networking/tunctl.c b/networking/tunctl.c index 97e6917aa..59cae331c 100644 --- a/networking/tunctl.c +++ b/networking/tunctl.c @@ -12,6 +12,7 @@ //config:config TUNCTL //config: bool "tunctl (6.2 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: tunctl creates or deletes tun devices. //config: diff --git a/networking/udhcp/Config.src b/networking/udhcp/Config.src index 8c8c11c26..23e2b40d8 100644 --- a/networking/udhcp/Config.src +++ b/networking/udhcp/Config.src @@ -6,6 +6,7 @@ config UDHCPD bool "udhcpd (21 kb)" default y + select PLATFORM_LINUX help udhcpd is a DHCP server geared primarily toward embedded systems, while striving to be fully functional and RFC compliant. @@ -53,6 +54,7 @@ config DUMPLEASES config DHCPRELAY bool "dhcprelay (5.2 kb)" default y + select PLATFORM_LINUX help dhcprelay listens for DHCP requests on one or more interfaces and forwards these requests to a different interface or DHCP @@ -61,6 +63,7 @@ config DHCPRELAY config UDHCPC bool "udhcpc (24 kb)" default y + select PLATFORM_LINUX help udhcpc is a DHCP client geared primarily toward embedded systems, while striving to be fully functional and RFC compliant. diff --git a/procps/free.c b/procps/free.c index 0b68e1b88..c734f757d 100644 --- a/procps/free.c +++ b/procps/free.c @@ -9,6 +9,7 @@ //config:config FREE //config: bool "free (3.1 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: free displays the total amount of free and used physical and swap //config: memory in the system, as well as the buffers used by the kernel. diff --git a/procps/uptime.c b/procps/uptime.c index 4fd0c9d2d..4992c263e 100644 --- a/procps/uptime.c +++ b/procps/uptime.c @@ -14,6 +14,7 @@ //config:config UPTIME //config: bool "uptime (3.7 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: uptime gives a one line display of the current time, how long //config: the system has been running, how many users are currently logged diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c index df0edee0a..ddf50071d 100644 --- a/sysklogd/klogd.c +++ b/sysklogd/klogd.c @@ -19,6 +19,7 @@ //config:config KLOGD //config: bool "klogd (5.7 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: klogd is a utility which intercepts and logs all //config: messages from the Linux kernel and sends the messages diff --git a/util-linux/acpid.c b/util-linux/acpid.c index 00613f8e3..7bce8abea 100644 --- a/util-linux/acpid.c +++ b/util-linux/acpid.c @@ -9,6 +9,7 @@ //config:config ACPID //config: bool "acpid (9 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: acpid listens to ACPI events coming either in textual form from //config: /proc/acpi/event (though it is marked deprecated it is still widely diff --git a/util-linux/blkdiscard.c b/util-linux/blkdiscard.c index 7ac8045f9..2291eec21 100644 --- a/util-linux/blkdiscard.c +++ b/util-linux/blkdiscard.c @@ -8,6 +8,7 @@ //config:config BLKDISCARD //config: bool "blkdiscard (4.3 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: blkdiscard discards sectors on a given device. diff --git a/util-linux/blkid.c b/util-linux/blkid.c index 4a820771f..008ae5d9e 100644 --- a/util-linux/blkid.c +++ b/util-linux/blkid.c @@ -9,6 +9,7 @@ //config:config BLKID //config: bool "blkid (12 kb)" //config: default y +//config: select PLATFORM_LINUX //config: select VOLUMEID //config: help //config: Lists labels and UUIDs of all filesystems. diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c index 6670b84de..5da887f0e 100644 --- a/util-linux/dmesg.c +++ b/util-linux/dmesg.c @@ -11,6 +11,7 @@ //config:config DMESG //config: bool "dmesg (3.7 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: dmesg is used to examine or control the kernel ring buffer. When the //config: Linux kernel prints messages to the system log, they are stored in diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 20e7d56fa..e9ebbd5d4 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c @@ -10,6 +10,7 @@ //config:config FDISK //config: bool "fdisk (37 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: The fdisk utility is used to divide hard disks into one or more //config: logical disks, which are generally called partitions. This utility diff --git a/util-linux/findfs.c b/util-linux/findfs.c index f5621a1fa..7ca9dc96b 100644 --- a/util-linux/findfs.c +++ b/util-linux/findfs.c @@ -10,6 +10,7 @@ //config:config FINDFS //config: bool "findfs (12 kb)" //config: default y +//config: select PLATFORM_LINUX //config: select VOLUMEID //config: help //config: Prints the name of a filesystem with given label or UUID. diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c index 309169d25..d27113d97 100644 --- a/util-linux/freeramdisk.c +++ b/util-linux/freeramdisk.c @@ -11,6 +11,7 @@ //config:config FDFLUSH //config: bool "fdflush (1.3 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: fdflush is only needed when changing media on slightly-broken //config: removable media drives. It is used to make Linux believe that a @@ -23,6 +24,7 @@ //config:config FREERAMDISK //config: bool "freeramdisk (1.3 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Linux allows you to create ramdisks. This utility allows you to //config: delete them and completely free all memory that was used for the diff --git a/util-linux/fsfreeze.c b/util-linux/fsfreeze.c index 6e2ff0a54..fb0b3c4bd 100644 --- a/util-linux/fsfreeze.c +++ b/util-linux/fsfreeze.c @@ -7,6 +7,7 @@ //config:config FSFREEZE //config: bool "fsfreeze (3.5 kb)" //config: default y +//config: select PLATFORM_LINUX //config: select LONG_OPTS //config: help //config: Halt new accesses and flush writes on a mounted filesystem. diff --git a/util-linux/fstrim.c b/util-linux/fstrim.c index 6d673002f..12bab40d1 100644 --- a/util-linux/fstrim.c +++ b/util-linux/fstrim.c @@ -10,6 +10,7 @@ //config:config FSTRIM //config: bool "fstrim (4.4 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Discard unused blocks on a mounted filesystem. diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index 723b09589..2edadfa4d 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c @@ -9,6 +9,7 @@ //config:config HWCLOCK //config: bool "hwclock (5.8 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: The hwclock utility is used to read and set the hardware clock //config: on a system. This is primarily used to set the current time on diff --git a/util-linux/ionice.c b/util-linux/ionice.c index 82bd309d1..b30d5f78d 100644 --- a/util-linux/ionice.c +++ b/util-linux/ionice.c @@ -9,6 +9,7 @@ //config:config IONICE //config: bool "ionice (3.8 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Set/set program io scheduling class and priority //config: Requires kernel >= 2.6.13 diff --git a/util-linux/losetup.c b/util-linux/losetup.c index 24f7a2349..ec0cf04e4 100644 --- a/util-linux/losetup.c +++ b/util-linux/losetup.c @@ -9,6 +9,7 @@ //config:config LOSETUP //config: bool "losetup (5.5 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: losetup is used to associate or detach a loop device with a regular //config: file or block device, and to query the status of a loop device. This diff --git a/util-linux/mdev.c b/util-linux/mdev.c index ebdc0c254..f6de7ad2a 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c @@ -10,6 +10,7 @@ //config:config MDEV //config: bool "mdev (17 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: mdev is a mini-udev implementation for dynamically creating device //config: nodes in the /dev directory. diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index fcf374b2d..892b0867a 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c @@ -10,6 +10,7 @@ //config:config MKE2FS //config: bool "mke2fs (10 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Utility to create EXT2 filesystems. //config: diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c index 821371953..5136446eb 100644 --- a/util-linux/mkfs_vfat.c +++ b/util-linux/mkfs_vfat.c @@ -10,6 +10,7 @@ //config:config MKDOSFS //config: bool "mkdosfs (7.2 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Utility to create FAT32 filesystems. //config: diff --git a/util-linux/mount.c b/util-linux/mount.c index 4e65b6b46..e3aeda666 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -20,6 +20,7 @@ //config:config MOUNT //config: bool "mount (23 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: All files and filesystems in Unix are arranged into one big directory //config: tree. The 'mount' utility is used to graft a filesystem onto a diff --git a/util-linux/nsenter.c b/util-linux/nsenter.c index 1aa045b35..8652e803a 100644 --- a/util-linux/nsenter.c +++ b/util-linux/nsenter.c @@ -9,6 +9,7 @@ //config:config NSENTER //config: bool "nsenter (6.5 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Run program with namespaces of other processes. diff --git a/util-linux/pivot_root.c b/util-linux/pivot_root.c index ecc891100..41f29da32 100644 --- a/util-linux/pivot_root.c +++ b/util-linux/pivot_root.c @@ -11,6 +11,7 @@ //config:config PIVOT_ROOT //config: bool "pivot_root (1.1 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: The pivot_root utility swaps the mount points for the root filesystem //config: with some other mounted filesystem. This allows you to do all sorts diff --git a/util-linux/setarch.c b/util-linux/setarch.c index cf8ef0064..57051a683 100644 --- a/util-linux/setarch.c +++ b/util-linux/setarch.c @@ -9,6 +9,7 @@ //config:config SETARCH //config: bool "setarch (3.6 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: The linux32 utility is used to create a 32bit environment for the //config: specified program (usually a shell). It only makes sense to have @@ -18,12 +19,14 @@ //config:config LINUX32 //config: bool "linux32 (3.3 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Alias to "setarch linux32". //config: //config:config LINUX64 //config: bool "linux64 (3.3 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Alias to "setarch linux64". diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c index 6904cf019..bfe2c7a7a 100644 --- a/util-linux/setpriv.c +++ b/util-linux/setpriv.c @@ -9,6 +9,7 @@ //config:config SETPRIV //config: bool "setpriv (6.6 kb)" //config: default y +//config: select PLATFORM_LINUX //config: select LONG_OPTS //config: help //config: Run a program with different Linux privilege settings. diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c index e2ff4b5cc..567869cc7 100644 --- a/util-linux/swaponoff.c +++ b/util-linux/swaponoff.c @@ -9,6 +9,7 @@ //config:config SWAPON //config: bool "swapon (15 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: Once you have created some swap space using 'mkswap', you also need //config: to enable your swap space with the 'swapon' utility. The 'swapoff' @@ -35,6 +36,7 @@ //config:config SWAPOFF //config: bool "swapoff (14 kb)" //config: default y +//config: select PLATFORM_LINUX //config: //config:config FEATURE_SWAPONOFF_LABEL //config: bool "Support specifying devices by label or UUID" diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c index 901c0b8db..f61002236 100644 --- a/util-linux/switch_root.c +++ b/util-linux/switch_root.c @@ -9,6 +9,7 @@ //config:config SWITCH_ROOT //config: bool "switch_root (5.5 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: The switch_root utility is used from initramfs to select a new //config: root device. Under initramfs, you have to use this instead of diff --git a/util-linux/uevent.c b/util-linux/uevent.c index db11746d0..bd39c3acd 100644 --- a/util-linux/uevent.c +++ b/util-linux/uevent.c @@ -6,6 +6,7 @@ //config:config UEVENT //config: bool "uevent (3.1 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: uevent is a netlink listener for kernel uevent notifications //config: sent via netlink. It is usually used for dynamic device creation. diff --git a/util-linux/unshare.c b/util-linux/unshare.c index 06b938074..156a96d94 100644 --- a/util-linux/unshare.c +++ b/util-linux/unshare.c @@ -9,6 +9,7 @@ //config:config UNSHARE //config: bool "unshare (7.2 kb)" //config: default y +//config: select PLATFORM_LINUX //config: depends on !NOMMU //config: select LONG_OPTS //config: help -- cgit v1.2.3-55-g6feb From 99476502f926fb6e5d61126c3b672f3f6f357d5d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 29 Nov 2022 14:14:06 +0100 Subject: Remove "select PLATFORM_LINUX" Signed-off-by: Denys Vlasenko --- console-tools/loadfont.c | 1 - console-tools/openvt.c | 1 - klibc-utils/run-init.c | 1 - miscutils/adjtimex.c | 1 - miscutils/i2c_tools.c | 5 ----- miscutils/partprobe.c | 1 - miscutils/ubirename.c | 1 - miscutils/watchdog.c | 1 - modutils/Config.src | 1 - modutils/depmod.c | 1 - modutils/insmod.c | 1 - modutils/lsmod.c | 1 - modutils/modinfo.c | 1 - modutils/modprobe.c | 1 - modutils/rmmod.c | 1 - networking/arp.c | 1 - networking/arping.c | 1 - networking/brctl.c | 1 - networking/ifconfig.c | 1 - networking/ifplugd.c | 1 - networking/ip.c | 6 ------ networking/nameif.c | 1 - networking/route.c | 1 - networking/tc.c | 1 - networking/traceroute.c | 2 -- networking/tunctl.c | 1 - networking/udhcp/Config.src | 3 --- procps/free.c | 1 - procps/uptime.c | 1 - sysklogd/klogd.c | 1 - util-linux/acpid.c | 1 - util-linux/blkdiscard.c | 1 - util-linux/blkid.c | 1 - util-linux/dmesg.c | 1 - util-linux/fdisk.c | 1 - util-linux/findfs.c | 1 - util-linux/freeramdisk.c | 2 -- util-linux/fsfreeze.c | 1 - util-linux/fstrim.c | 1 - util-linux/hwclock.c | 1 - util-linux/ionice.c | 1 - util-linux/losetup.c | 1 - util-linux/mdev.c | 1 - util-linux/mkfs_ext2.c | 1 - util-linux/mkfs_vfat.c | 1 - util-linux/mount.c | 1 - util-linux/nsenter.c | 1 - util-linux/pivot_root.c | 1 - util-linux/setarch.c | 3 --- util-linux/setpriv.c | 1 - util-linux/swaponoff.c | 2 -- util-linux/switch_root.c | 1 - util-linux/uevent.c | 1 - util-linux/unshare.c | 1 - 54 files changed, 70 deletions(-) diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c index 3f36cabe0..81a0e6aa8 100644 --- a/console-tools/loadfont.c +++ b/console-tools/loadfont.c @@ -12,7 +12,6 @@ //config:config LOADFONT //config: bool "loadfont (5.2 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: This program loads a console font from standard input. //config: diff --git a/console-tools/openvt.c b/console-tools/openvt.c index 9e6cffecc..db2f073b2 100644 --- a/console-tools/openvt.c +++ b/console-tools/openvt.c @@ -10,7 +10,6 @@ //config:config OPENVT //config: bool "openvt (7.2 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: This program is used to start a command on an unused //config: virtual terminal. diff --git a/klibc-utils/run-init.c b/klibc-utils/run-init.c index 77fc0e60c..73c677bab 100644 --- a/klibc-utils/run-init.c +++ b/klibc-utils/run-init.c @@ -8,7 +8,6 @@ //config:config RUN_INIT //config: bool "run-init (7.7 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: The run-init utility is used from initramfs to select a new //config: root device. Under initramfs, you have to use this instead of diff --git a/miscutils/adjtimex.c b/miscutils/adjtimex.c index c289245c0..209d1d560 100644 --- a/miscutils/adjtimex.c +++ b/miscutils/adjtimex.c @@ -13,7 +13,6 @@ //config:config ADJTIMEX //config: bool "adjtimex (4.7 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Adjtimex reads and optionally sets adjustment parameters for //config: the Linux clock adjustment algorithm. diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index 46749fb9c..da26f5e19 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c @@ -11,35 +11,30 @@ //config:config I2CGET //config: bool "i2cget (5.5 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Read from I2C/SMBus chip registers. //config: //config:config I2CSET //config: bool "i2cset (6.7 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Set I2C registers. //config: //config:config I2CDUMP //config: bool "i2cdump (7.1 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Examine I2C registers. //config: //config:config I2CDETECT //config: bool "i2cdetect (7.1 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Detect I2C chips. //config: //config:config I2CTRANSFER //config: bool "i2ctransfer (4.0 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Send user-defined I2C messages in one transfer. //config: diff --git a/miscutils/partprobe.c b/miscutils/partprobe.c index 0abed6ff1..0fb1927b7 100644 --- a/miscutils/partprobe.c +++ b/miscutils/partprobe.c @@ -7,7 +7,6 @@ //config:config PARTPROBE //config: bool "partprobe (3.5 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Ask kernel to rescan partition table. diff --git a/miscutils/ubirename.c b/miscutils/ubirename.c index e7c56640c..06a0adacf 100644 --- a/miscutils/ubirename.c +++ b/miscutils/ubirename.c @@ -9,7 +9,6 @@ //config:config UBIRENAME //config: bool "ubirename (2.4 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Utility to rename UBI volumes diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c index 91a20239d..9f5a4b849 100644 --- a/miscutils/watchdog.c +++ b/miscutils/watchdog.c @@ -11,7 +11,6 @@ //config:config WATCHDOG //config: bool "watchdog (5.3 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: The watchdog utility is used with hardware or software watchdog //config: device drivers. It opens the specified watchdog device special file diff --git a/modutils/Config.src b/modutils/Config.src index b8ba3b7b6..188296814 100644 --- a/modutils/Config.src +++ b/modutils/Config.src @@ -8,7 +8,6 @@ menu "Linux Module Utilities" config MODPROBE_SMALL bool "Simplified modutils" default y - select PLATFORM_LINUX help Build smaller (~1.5 kbytes), simplified module tools. diff --git a/modutils/depmod.c b/modutils/depmod.c index 9e39481c5..bb42bbefe 100644 --- a/modutils/depmod.c +++ b/modutils/depmod.c @@ -10,7 +10,6 @@ //config:config DEPMOD //config: bool "depmod (27 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: depmod generates modules.dep (and potentially modules.alias //config: and modules.symbols) that contain dependency information diff --git a/modutils/insmod.c b/modutils/insmod.c index 85b46cdd6..8f7163e25 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c @@ -9,7 +9,6 @@ //config:config INSMOD //config: bool "insmod (22 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: insmod is used to load specified modules in the running kernel. diff --git a/modutils/lsmod.c b/modutils/lsmod.c index 39dc8e6b7..2beb12362 100644 --- a/modutils/lsmod.c +++ b/modutils/lsmod.c @@ -10,7 +10,6 @@ //config:config LSMOD //config: bool "lsmod (1.9 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: lsmod is used to display a list of loaded modules. //config: diff --git a/modutils/modinfo.c b/modutils/modinfo.c index 5d01179a0..0a86c3296 100644 --- a/modutils/modinfo.c +++ b/modutils/modinfo.c @@ -8,7 +8,6 @@ //config:config MODINFO //config: bool "modinfo (24 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Show information about a Linux Kernel module diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 77c4bb74d..235706fd5 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c @@ -10,7 +10,6 @@ //config:config MODPROBE //config: bool "modprobe (28 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Handle the loading of modules, and their dependencies on a high //config: level. diff --git a/modutils/rmmod.c b/modutils/rmmod.c index 8d4639f50..2b3c39153 100644 --- a/modutils/rmmod.c +++ b/modutils/rmmod.c @@ -10,7 +10,6 @@ //config:config RMMOD //config: bool "rmmod (3.3 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: rmmod is used to unload specified modules from the kernel. diff --git a/networking/arp.c b/networking/arp.c index 6519f8156..16783ab95 100644 --- a/networking/arp.c +++ b/networking/arp.c @@ -15,7 +15,6 @@ //config:config ARP //config: bool "arp (10 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Manipulate the system ARP cache. diff --git a/networking/arping.c b/networking/arping.c index fd0e1b276..86f0221ed 100644 --- a/networking/arping.c +++ b/networking/arping.c @@ -8,7 +8,6 @@ //config:config ARPING //config: bool "arping (9 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Ping hosts by ARP packets. diff --git a/networking/brctl.c b/networking/brctl.c index b353210d7..956bd91f3 100644 --- a/networking/brctl.c +++ b/networking/brctl.c @@ -12,7 +12,6 @@ //config:config BRCTL //config: bool "brctl (4.7 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Manage ethernet bridges. //config: Supports addbr/delbr and addif/delif. diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 4090959b8..9ee232a66 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c @@ -27,7 +27,6 @@ //config:config IFCONFIG //config: bool "ifconfig (12 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Ifconfig is used to configure the kernel-resident network interfaces. //config: diff --git a/networking/ifplugd.c b/networking/ifplugd.c index bc4303ef0..0b55bf4e5 100644 --- a/networking/ifplugd.c +++ b/networking/ifplugd.c @@ -9,7 +9,6 @@ //config:config IFPLUGD //config: bool "ifplugd (10 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Network interface plug detection daemon. diff --git a/networking/ip.c b/networking/ip.c index 23ee7d24b..7c3208699 100644 --- a/networking/ip.c +++ b/networking/ip.c @@ -11,7 +11,6 @@ //config:config IP //config: bool "ip (35 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: The "ip" applet is a TCP/IP interface configuration and routing //config: utility. @@ -22,7 +21,6 @@ //config:config IPADDR //config: bool "ipaddr (14 kb)" //config: default y -//config: select PLATFORM_LINUX //config: select FEATURE_IP_ADDRESS //config: help //config: Short form of "ip addr" @@ -30,7 +28,6 @@ //config:config IPLINK //config: bool "iplink (17 kb)" //config: default y -//config: select PLATFORM_LINUX //config: select FEATURE_IP_LINK //config: help //config: Short form of "ip link" @@ -38,7 +35,6 @@ //config:config IPROUTE //config: bool "iproute (15 kb)" //config: default y -//config: select PLATFORM_LINUX //config: select FEATURE_IP_ROUTE //config: help //config: Short form of "ip route" @@ -53,7 +49,6 @@ //config:config IPRULE //config: bool "iprule (10 kb)" //config: default y -//config: select PLATFORM_LINUX //config: select FEATURE_IP_RULE //config: help //config: Short form of "ip rule" @@ -61,7 +56,6 @@ //config:config IPNEIGH //config: bool "ipneigh (8.3 kb)" //config: default y -//config: select PLATFORM_LINUX //config: select FEATURE_IP_NEIGH //config: help //config: Short form of "ip neigh" diff --git a/networking/nameif.c b/networking/nameif.c index 3ccd935b8..66e042688 100644 --- a/networking/nameif.c +++ b/networking/nameif.c @@ -12,7 +12,6 @@ //config:config NAMEIF //config: bool "nameif (6.6 kb)" //config: default y -//config: select PLATFORM_LINUX //config: select FEATURE_SYSLOG //config: help //config: nameif is used to rename network interface by its MAC address. diff --git a/networking/route.c b/networking/route.c index 616572814..26146f8e9 100644 --- a/networking/route.c +++ b/networking/route.c @@ -27,7 +27,6 @@ //config:config ROUTE //config: bool "route (8.7 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Route displays or manipulates the kernel's IP routing tables. diff --git a/networking/tc.c b/networking/tc.c index 1f4bcce2b..43187f7ee 100644 --- a/networking/tc.c +++ b/networking/tc.c @@ -9,7 +9,6 @@ //config:config TC //config: bool "tc (8.3 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Show / manipulate traffic control settings //config: diff --git a/networking/traceroute.c b/networking/traceroute.c index 2ba990fd0..4bbe1ab8e 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -963,10 +963,8 @@ traceroute_init(int op, char **argv) if (af == AF_INET) { xmove_fd(xsocket(AF_INET, SOCK_RAW, IPPROTO_ICMP), rcvsock); #if ENABLE_FEATURE_TRACEROUTE_VERBOSE -# ifdef IP_PKTINFO /* want recvmsg to report target local address (for -v) */ setsockopt_1(rcvsock, IPPROTO_IP, IP_PKTINFO); -# endif #endif } #if ENABLE_TRACEROUTE6 diff --git a/networking/tunctl.c b/networking/tunctl.c index 59cae331c..97e6917aa 100644 --- a/networking/tunctl.c +++ b/networking/tunctl.c @@ -12,7 +12,6 @@ //config:config TUNCTL //config: bool "tunctl (6.2 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: tunctl creates or deletes tun devices. //config: diff --git a/networking/udhcp/Config.src b/networking/udhcp/Config.src index 23e2b40d8..8c8c11c26 100644 --- a/networking/udhcp/Config.src +++ b/networking/udhcp/Config.src @@ -6,7 +6,6 @@ config UDHCPD bool "udhcpd (21 kb)" default y - select PLATFORM_LINUX help udhcpd is a DHCP server geared primarily toward embedded systems, while striving to be fully functional and RFC compliant. @@ -54,7 +53,6 @@ config DUMPLEASES config DHCPRELAY bool "dhcprelay (5.2 kb)" default y - select PLATFORM_LINUX help dhcprelay listens for DHCP requests on one or more interfaces and forwards these requests to a different interface or DHCP @@ -63,7 +61,6 @@ config DHCPRELAY config UDHCPC bool "udhcpc (24 kb)" default y - select PLATFORM_LINUX help udhcpc is a DHCP client geared primarily toward embedded systems, while striving to be fully functional and RFC compliant. diff --git a/procps/free.c b/procps/free.c index c734f757d..0b68e1b88 100644 --- a/procps/free.c +++ b/procps/free.c @@ -9,7 +9,6 @@ //config:config FREE //config: bool "free (3.1 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: free displays the total amount of free and used physical and swap //config: memory in the system, as well as the buffers used by the kernel. diff --git a/procps/uptime.c b/procps/uptime.c index 4992c263e..4fd0c9d2d 100644 --- a/procps/uptime.c +++ b/procps/uptime.c @@ -14,7 +14,6 @@ //config:config UPTIME //config: bool "uptime (3.7 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: uptime gives a one line display of the current time, how long //config: the system has been running, how many users are currently logged diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c index ddf50071d..df0edee0a 100644 --- a/sysklogd/klogd.c +++ b/sysklogd/klogd.c @@ -19,7 +19,6 @@ //config:config KLOGD //config: bool "klogd (5.7 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: klogd is a utility which intercepts and logs all //config: messages from the Linux kernel and sends the messages diff --git a/util-linux/acpid.c b/util-linux/acpid.c index 7bce8abea..00613f8e3 100644 --- a/util-linux/acpid.c +++ b/util-linux/acpid.c @@ -9,7 +9,6 @@ //config:config ACPID //config: bool "acpid (9 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: acpid listens to ACPI events coming either in textual form from //config: /proc/acpi/event (though it is marked deprecated it is still widely diff --git a/util-linux/blkdiscard.c b/util-linux/blkdiscard.c index 2291eec21..7ac8045f9 100644 --- a/util-linux/blkdiscard.c +++ b/util-linux/blkdiscard.c @@ -8,7 +8,6 @@ //config:config BLKDISCARD //config: bool "blkdiscard (4.3 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: blkdiscard discards sectors on a given device. diff --git a/util-linux/blkid.c b/util-linux/blkid.c index 008ae5d9e..4a820771f 100644 --- a/util-linux/blkid.c +++ b/util-linux/blkid.c @@ -9,7 +9,6 @@ //config:config BLKID //config: bool "blkid (12 kb)" //config: default y -//config: select PLATFORM_LINUX //config: select VOLUMEID //config: help //config: Lists labels and UUIDs of all filesystems. diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c index 5da887f0e..6670b84de 100644 --- a/util-linux/dmesg.c +++ b/util-linux/dmesg.c @@ -11,7 +11,6 @@ //config:config DMESG //config: bool "dmesg (3.7 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: dmesg is used to examine or control the kernel ring buffer. When the //config: Linux kernel prints messages to the system log, they are stored in diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index e9ebbd5d4..20e7d56fa 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c @@ -10,7 +10,6 @@ //config:config FDISK //config: bool "fdisk (37 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: The fdisk utility is used to divide hard disks into one or more //config: logical disks, which are generally called partitions. This utility diff --git a/util-linux/findfs.c b/util-linux/findfs.c index 7ca9dc96b..f5621a1fa 100644 --- a/util-linux/findfs.c +++ b/util-linux/findfs.c @@ -10,7 +10,6 @@ //config:config FINDFS //config: bool "findfs (12 kb)" //config: default y -//config: select PLATFORM_LINUX //config: select VOLUMEID //config: help //config: Prints the name of a filesystem with given label or UUID. diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c index d27113d97..309169d25 100644 --- a/util-linux/freeramdisk.c +++ b/util-linux/freeramdisk.c @@ -11,7 +11,6 @@ //config:config FDFLUSH //config: bool "fdflush (1.3 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: fdflush is only needed when changing media on slightly-broken //config: removable media drives. It is used to make Linux believe that a @@ -24,7 +23,6 @@ //config:config FREERAMDISK //config: bool "freeramdisk (1.3 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Linux allows you to create ramdisks. This utility allows you to //config: delete them and completely free all memory that was used for the diff --git a/util-linux/fsfreeze.c b/util-linux/fsfreeze.c index fb0b3c4bd..6e2ff0a54 100644 --- a/util-linux/fsfreeze.c +++ b/util-linux/fsfreeze.c @@ -7,7 +7,6 @@ //config:config FSFREEZE //config: bool "fsfreeze (3.5 kb)" //config: default y -//config: select PLATFORM_LINUX //config: select LONG_OPTS //config: help //config: Halt new accesses and flush writes on a mounted filesystem. diff --git a/util-linux/fstrim.c b/util-linux/fstrim.c index 12bab40d1..6d673002f 100644 --- a/util-linux/fstrim.c +++ b/util-linux/fstrim.c @@ -10,7 +10,6 @@ //config:config FSTRIM //config: bool "fstrim (4.4 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Discard unused blocks on a mounted filesystem. diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index 2edadfa4d..723b09589 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c @@ -9,7 +9,6 @@ //config:config HWCLOCK //config: bool "hwclock (5.8 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: The hwclock utility is used to read and set the hardware clock //config: on a system. This is primarily used to set the current time on diff --git a/util-linux/ionice.c b/util-linux/ionice.c index b30d5f78d..82bd309d1 100644 --- a/util-linux/ionice.c +++ b/util-linux/ionice.c @@ -9,7 +9,6 @@ //config:config IONICE //config: bool "ionice (3.8 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Set/set program io scheduling class and priority //config: Requires kernel >= 2.6.13 diff --git a/util-linux/losetup.c b/util-linux/losetup.c index ec0cf04e4..24f7a2349 100644 --- a/util-linux/losetup.c +++ b/util-linux/losetup.c @@ -9,7 +9,6 @@ //config:config LOSETUP //config: bool "losetup (5.5 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: losetup is used to associate or detach a loop device with a regular //config: file or block device, and to query the status of a loop device. This diff --git a/util-linux/mdev.c b/util-linux/mdev.c index f6de7ad2a..ebdc0c254 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c @@ -10,7 +10,6 @@ //config:config MDEV //config: bool "mdev (17 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: mdev is a mini-udev implementation for dynamically creating device //config: nodes in the /dev directory. diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index 892b0867a..fcf374b2d 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c @@ -10,7 +10,6 @@ //config:config MKE2FS //config: bool "mke2fs (10 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Utility to create EXT2 filesystems. //config: diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c index 5136446eb..821371953 100644 --- a/util-linux/mkfs_vfat.c +++ b/util-linux/mkfs_vfat.c @@ -10,7 +10,6 @@ //config:config MKDOSFS //config: bool "mkdosfs (7.2 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Utility to create FAT32 filesystems. //config: diff --git a/util-linux/mount.c b/util-linux/mount.c index e3aeda666..4e65b6b46 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -20,7 +20,6 @@ //config:config MOUNT //config: bool "mount (23 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: All files and filesystems in Unix are arranged into one big directory //config: tree. The 'mount' utility is used to graft a filesystem onto a diff --git a/util-linux/nsenter.c b/util-linux/nsenter.c index 8652e803a..1aa045b35 100644 --- a/util-linux/nsenter.c +++ b/util-linux/nsenter.c @@ -9,7 +9,6 @@ //config:config NSENTER //config: bool "nsenter (6.5 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Run program with namespaces of other processes. diff --git a/util-linux/pivot_root.c b/util-linux/pivot_root.c index 41f29da32..ecc891100 100644 --- a/util-linux/pivot_root.c +++ b/util-linux/pivot_root.c @@ -11,7 +11,6 @@ //config:config PIVOT_ROOT //config: bool "pivot_root (1.1 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: The pivot_root utility swaps the mount points for the root filesystem //config: with some other mounted filesystem. This allows you to do all sorts diff --git a/util-linux/setarch.c b/util-linux/setarch.c index 57051a683..cf8ef0064 100644 --- a/util-linux/setarch.c +++ b/util-linux/setarch.c @@ -9,7 +9,6 @@ //config:config SETARCH //config: bool "setarch (3.6 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: The linux32 utility is used to create a 32bit environment for the //config: specified program (usually a shell). It only makes sense to have @@ -19,14 +18,12 @@ //config:config LINUX32 //config: bool "linux32 (3.3 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Alias to "setarch linux32". //config: //config:config LINUX64 //config: bool "linux64 (3.3 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Alias to "setarch linux64". diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c index bfe2c7a7a..6904cf019 100644 --- a/util-linux/setpriv.c +++ b/util-linux/setpriv.c @@ -9,7 +9,6 @@ //config:config SETPRIV //config: bool "setpriv (6.6 kb)" //config: default y -//config: select PLATFORM_LINUX //config: select LONG_OPTS //config: help //config: Run a program with different Linux privilege settings. diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c index 567869cc7..e2ff4b5cc 100644 --- a/util-linux/swaponoff.c +++ b/util-linux/swaponoff.c @@ -9,7 +9,6 @@ //config:config SWAPON //config: bool "swapon (15 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: Once you have created some swap space using 'mkswap', you also need //config: to enable your swap space with the 'swapon' utility. The 'swapoff' @@ -36,7 +35,6 @@ //config:config SWAPOFF //config: bool "swapoff (14 kb)" //config: default y -//config: select PLATFORM_LINUX //config: //config:config FEATURE_SWAPONOFF_LABEL //config: bool "Support specifying devices by label or UUID" diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c index f61002236..901c0b8db 100644 --- a/util-linux/switch_root.c +++ b/util-linux/switch_root.c @@ -9,7 +9,6 @@ //config:config SWITCH_ROOT //config: bool "switch_root (5.5 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: The switch_root utility is used from initramfs to select a new //config: root device. Under initramfs, you have to use this instead of diff --git a/util-linux/uevent.c b/util-linux/uevent.c index bd39c3acd..db11746d0 100644 --- a/util-linux/uevent.c +++ b/util-linux/uevent.c @@ -6,7 +6,6 @@ //config:config UEVENT //config: bool "uevent (3.1 kb)" //config: default y -//config: select PLATFORM_LINUX //config: help //config: uevent is a netlink listener for kernel uevent notifications //config: sent via netlink. It is usually used for dynamic device creation. diff --git a/util-linux/unshare.c b/util-linux/unshare.c index 156a96d94..06b938074 100644 --- a/util-linux/unshare.c +++ b/util-linux/unshare.c @@ -9,7 +9,6 @@ //config:config UNSHARE //config: bool "unshare (7.2 kb)" //config: default y -//config: select PLATFORM_LINUX //config: depends on !NOMMU //config: select LONG_OPTS //config: help -- cgit v1.2.3-55-g6feb From 7ade421b1a410f4d2d2314f06d7f5a9d0fd123ec Mon Sep 17 00:00:00 2001 From: Peter Kaestle Date: Tue, 25 Oct 2022 13:56:48 +0200 Subject: unzip -l: add missed big-endian conversions date and time When calling unzip -l the date and time output was missing big-endian conversions. Signed-off-by: Peter Kaestle Signed-off-by: Denys Vlasenko --- archival/unzip.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/archival/unzip.c b/archival/unzip.c index fc92ac661..b27dd2187 100644 --- a/archival/unzip.c +++ b/archival/unzip.c @@ -118,6 +118,8 @@ typedef union { #define FIX_ENDIANNESS_ZIP(zip) \ do { if (BB_BIG_ENDIAN) { \ (zip).fmt.method = SWAP_LE16((zip).fmt.method ); \ + (zip).fmt.modtime = SWAP_LE16((zip).fmt.modtime ); \ + (zip).fmt.moddate = SWAP_LE16((zip).fmt.moddate ); \ (zip).fmt.crc32 = SWAP_LE32((zip).fmt.crc32 ); \ (zip).fmt.cmpsize = SWAP_LE32((zip).fmt.cmpsize ); \ (zip).fmt.ucmpsize = SWAP_LE32((zip).fmt.ucmpsize ); \ -- cgit v1.2.3-55-g6feb From 90456a6aa3a039ac1b16a09e64d13cc9589b55ee Mon Sep 17 00:00:00 2001 From: Brandon Maier Date: Fri, 2 Dec 2022 09:50:29 -0600 Subject: xxd: fix typo in trivial usage Signed-off-by: Brandon Maier Signed-off-by: Denys Vlasenko --- util-linux/hexdump_xxd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util-linux/hexdump_xxd.c b/util-linux/hexdump_xxd.c index 6629407de..45391b565 100644 --- a/util-linux/hexdump_xxd.c +++ b/util-linux/hexdump_xxd.c @@ -41,7 +41,7 @@ // -u use upper case hex letters. //usage:#define xxd_trivial_usage -//usage: "[-pri] [-g N] [-c N] [-n LEN] [-s OFS] [-o OFS] [FILE]" +//usage: "[-pri] [-g N] [-c N] [-l LEN] [-s OFS] [-o OFS] [FILE]" //usage:#define xxd_full_usage "\n\n" //usage: "Hex dump FILE (or stdin)\n" //usage: "\n -g N Bytes per group" -- cgit v1.2.3-55-g6feb From ddccf6cd2f519c46a6286a43ceaf680eb367301c Mon Sep 17 00:00:00 2001 From: Xiaoming Ni Date: Mon, 12 Dec 2022 18:41:02 +0100 Subject: loop: refactor: extract subfunction get_next_free_loop() Extract subfunction get_next_free_loop() from set_loop() Also fix miss free(try) when stat(try) and mknod fail function old new delta set_loop 807 790 -17 Fixes: 3448914e8cc5 ("mount,losetup: use /dev/loop-control is it exists") Signed-off-by: Xiaoming Ni Signed-off-by: Denys Vlasenko --- libbb/loop.c | 56 ++++++++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/libbb/loop.c b/libbb/loop.c index 750642ade..8e5c915fc 100644 --- a/libbb/loop.c +++ b/libbb/loop.c @@ -96,6 +96,20 @@ int FAST_FUNC get_free_loop(void) return loopdevno; /* can be -1 if error */ } +static int get_next_free_loop(char *dev, int id) +{ + int loopdevno; + + loopdevno = get_free_loop(); + if (loopdevno != -1) { + /* loopdevno is -2 (use id) or >= 0 (use id = loopdevno): */ + if (loopdevno >= 0) + id = loopdevno; + sprintf(dev, LOOP_FORMAT, id); + } + return loopdevno; +} + /* Returns opened fd to the loop device, <0 on error. * *device is loop device to use, or if *device==NULL finds a loop device to * mount it on and sets *device to a strdup of that loop device name. @@ -123,30 +137,27 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse try = *device; if (!try) { - get_free_loopN: - i = get_free_loop(); - if (i == -1) { - close(ffd); - return -1; /* no free loop devices */ - } - if (i >= 0) { - try = xasprintf(LOOP_FORMAT, i); - goto open_lfd; - } - /* i == -2: no /dev/loop-control. Do an old-style search for a free device */ try = dev; } /* Find a loop device */ /* 0xfffff is a max possible minor number in Linux circa 2010 */ for (i = 0; i <= 0xfffff; i++) { - sprintf(dev, LOOP_FORMAT, i); + if (!*device) { + rc = get_next_free_loop(dev, i); + if (rc == -1) + break; /* no free loop devices (or other error in LOOP_CTL_GET_FREE) */ + if (rc >= 0) + /* /dev/loop-control gave us the next free /dev/loopN */ + goto open_lfd; + /* else: sequential /dev/loopN, needs to be tested/maybe_created */ + } IF_FEATURE_MOUNT_LOOP_CREATE(errno = 0;) if (stat(try, &statbuf) != 0 || !S_ISBLK(statbuf.st_mode)) { if (ENABLE_FEATURE_MOUNT_LOOP_CREATE && errno == ENOENT - && try == dev + && (!*device) ) { /* Node doesn't exist, try to create it */ if (mknod(dev, S_IFBLK|0644, makedev(7, i)) == 0) @@ -179,13 +190,10 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse /* Associate free loop device with file */ if (ioctl(lfd, LOOP_SET_FD, ffd)) { /* Ouch. Are we racing with other mount? */ - if (!*device /* yes */ - && try != dev /* tried a _kernel-offered_ loopN? */ - ) { - free(try); + if (!*device) { close(lfd); //TODO: add "if (--failcount != 0) ..."? - goto get_free_loopN; + continue; } goto close_and_try_next_loopN; } @@ -209,8 +217,6 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse } if (rc == 0) { /* SUCCESS! */ - if (try != dev) /* tried a kernel-offered free loopN? */ - *device = try; /* malloced */ if (!*device) /* was looping in search of free "/dev/loopN"? */ *device = xstrdup(dev); rc = lfd; /* return this */ @@ -218,16 +224,6 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse } /* failure, undo LOOP_SET_FD */ ioctl(lfd, LOOP_CLR_FD, 0); // actually, 0 param is unnecessary - } else { - /* device is not free (rc == 0), or error other than ENXIO */ - if (rc == 0 /* device is not free? */ - && !*device /* racing with other mount? */ - && try != dev /* tried a _kernel-offered_ loopN? */ - ) { - free(try); - close(lfd); - goto get_free_loopN; - } } close_and_try_next_loopN: close(lfd); -- cgit v1.2.3-55-g6feb From 7dc76c9f210b3c66a9c89e6690af7b49f6c540a8 Mon Sep 17 00:00:00 2001 From: Xiaoming Ni Date: Mon, 12 Dec 2022 18:57:09 +0100 Subject: loop: simplify code of LOOP_SET_FD failure function old new delta set_loop 790 760 -30 Signed-off-by: Xiaoming Ni Signed-off-by: Denys Vlasenko --- libbb/loop.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libbb/loop.c b/libbb/loop.c index 8e5c915fc..256b7ac90 100644 --- a/libbb/loop.c +++ b/libbb/loop.c @@ -188,13 +188,9 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse /* If device is free, try to claim it */ if (rc && errno == ENXIO) { /* Associate free loop device with file */ - if (ioctl(lfd, LOOP_SET_FD, ffd)) { - /* Ouch. Are we racing with other mount? */ - if (!*device) { - close(lfd); -//TODO: add "if (--failcount != 0) ..."? - continue; - } + rc = ioctl(lfd, LOOP_SET_FD, ffd); + if (rc != 0) { + /* Ouch... race: the device already has a fd */ goto close_and_try_next_loopN; } memset(&loopinfo, 0, sizeof(loopinfo)); -- cgit v1.2.3-55-g6feb From a1856934ba795f81546f5dd9a14ba4faa757ce52 Mon Sep 17 00:00:00 2001 From: Xiaoming Ni Date: Tue, 13 Dec 2022 13:13:23 +0100 Subject: loop: refactor: extract subfunction set_loopdev_params() Extract subfunction set_loop_info() from set_loop() function old new delta set_loop 760 784 +24 Signed-off-by: Xiaoming Ni Signed-off-by: Denys Vlasenko --- libbb/loop.c | 90 ++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 39 deletions(-) diff --git a/libbb/loop.c b/libbb/loop.c index 256b7ac90..424c39216 100644 --- a/libbb/loop.c +++ b/libbb/loop.c @@ -110,6 +110,51 @@ static int get_next_free_loop(char *dev, int id) return loopdevno; } +static int set_loopdev_params(int ffd, + int lfd, const char *file, + unsigned long long offset, + unsigned long long sizelimit, + unsigned flags) +{ + int rc; + bb_loop_info loopinfo; + + rc = ioctl(lfd, BB_LOOP_GET_STATUS, &loopinfo); + + /* If device is free, try to claim it */ + if (rc && errno == ENXIO) { + /* Associate free loop device with file */ + rc = ioctl(lfd, LOOP_SET_FD, ffd); + if (rc != 0) { + /* Ouch... race: the device already has a fd */ + return -1; + } + memset(&loopinfo, 0, sizeof(loopinfo)); + safe_strncpy((char *)loopinfo.lo_file_name, file, LO_NAME_SIZE); + loopinfo.lo_offset = offset; + loopinfo.lo_sizelimit = sizelimit; + /* + * Used by mount to set LO_FLAGS_AUTOCLEAR. + * LO_FLAGS_READ_ONLY is not set because RO is controlled by open type of the file. + * Note that closing LO_FLAGS_AUTOCLEARed lfd before mount + * is wrong (would free the loop device!) + */ + loopinfo.lo_flags = (flags & ~BB_LO_FLAGS_READ_ONLY); + rc = ioctl(lfd, BB_LOOP_SET_STATUS, &loopinfo); + if (rc != 0 && (loopinfo.lo_flags & BB_LO_FLAGS_AUTOCLEAR)) { + /* Old kernel, does not support LO_FLAGS_AUTOCLEAR? */ + /* (this code path is not tested) */ + loopinfo.lo_flags -= BB_LO_FLAGS_AUTOCLEAR; + rc = ioctl(lfd, BB_LOOP_SET_STATUS, &loopinfo); + } + if (rc == 0) + return rc; /* SUCCESS! */ + /* failure, undo LOOP_SET_FD */ + ioctl(lfd, LOOP_CLR_FD, 0); // actually, 0 param is unnecessary + } + return -1; +} + /* Returns opened fd to the loop device, <0 on error. * *device is loop device to use, or if *device==NULL finds a loop device to * mount it on and sets *device to a strdup of that loop device name. @@ -119,7 +164,6 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse { char dev[LOOP_NAMESIZE]; char *try; - bb_loop_info loopinfo; struct stat statbuf; int i, lfd, ffd, mode, rc; @@ -183,45 +227,13 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse goto try_next_loopN; } - rc = ioctl(lfd, BB_LOOP_GET_STATUS, &loopinfo); - - /* If device is free, try to claim it */ - if (rc && errno == ENXIO) { - /* Associate free loop device with file */ - rc = ioctl(lfd, LOOP_SET_FD, ffd); - if (rc != 0) { - /* Ouch... race: the device already has a fd */ - goto close_and_try_next_loopN; - } - memset(&loopinfo, 0, sizeof(loopinfo)); - safe_strncpy((char *)loopinfo.lo_file_name, file, LO_NAME_SIZE); - loopinfo.lo_offset = offset; - loopinfo.lo_sizelimit = sizelimit; - /* - * Used by mount to set LO_FLAGS_AUTOCLEAR. - * LO_FLAGS_READ_ONLY is not set because RO is controlled by open type of the file. - * Note that closing LO_FLAGS_AUTOCLEARed lfd before mount - * is wrong (would free the loop device!) - */ - loopinfo.lo_flags = (flags & ~BB_LO_FLAGS_READ_ONLY); - rc = ioctl(lfd, BB_LOOP_SET_STATUS, &loopinfo); - if (rc != 0 && (loopinfo.lo_flags & BB_LO_FLAGS_AUTOCLEAR)) { - /* Old kernel, does not support LO_FLAGS_AUTOCLEAR? */ - /* (this code path is not tested) */ - loopinfo.lo_flags -= BB_LO_FLAGS_AUTOCLEAR; - rc = ioctl(lfd, BB_LOOP_SET_STATUS, &loopinfo); - } - if (rc == 0) { - /* SUCCESS! */ - if (!*device) /* was looping in search of free "/dev/loopN"? */ - *device = xstrdup(dev); - rc = lfd; /* return this */ - break; - } - /* failure, undo LOOP_SET_FD */ - ioctl(lfd, LOOP_CLR_FD, 0); // actually, 0 param is unnecessary + rc = set_loopdev_params(ffd, lfd, file, offset, sizelimit, flags); + if (rc == 0) { + /* SUCCESS! */ + if (!*device) + *device = xstrdup(dev); + break; } - close_and_try_next_loopN: close(lfd); try_next_loopN: rc = -1; -- cgit v1.2.3-55-g6feb From 9df54deead6845fc38509c412736b47a9a5d5187 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 13 Dec 2022 15:12:31 +0100 Subject: testsuite/mount.tests: accomodate umount failure seen on 5.18.0 Signed-off-by: Denys Vlasenko --- testsuite/mount.tests | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/testsuite/mount.tests b/testsuite/mount.tests index b6d5ebe08..7370805cd 100755 --- a/testsuite/mount.tests +++ b/testsuite/mount.tests @@ -104,12 +104,24 @@ mount -r -o loop -t ext2 z1/e2img z2 || { echo 'mount -r -o loop error'; e mount -o remount,ro z1 || { echo 'mount -o remount,ro error'; exit 1; } ) umount -d mount.dir/z2 -##losetup -d /dev/loop* +##sleep 0.1 umount -d mount.dir/z1 rm -rf mount.dir echo DONE " \ "DONE\n" "" "" +# On 5.18.0, "umount -d mount.dir/z1" above fails. +# (It would work with "sleep 0.1" - looks like z1/e2img +# is momentarily keeping z1 mountpoint busy, even though +# the "umount" which freed z1/e2img from being the base +# of z2 mountpoint has returned). +# Fixing the mess if it did fail: +if test -d mount.dir/z1; then + ls -ld mount.dir/z1/* mount.dir/z1 + sleep 1 + umount -d mount.dir/z1 + rmdir mount.dir/z1 mount.dir +fi exit $FAILCOUNT -- cgit v1.2.3-55-g6feb From 45734a23515b3e1f2305ad33dc22d1bc69e3cba6 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 13 Dec 2022 14:27:08 +0100 Subject: loop: optionally use ioctl(LOOP_CONFIGURE) to set up loopdevs LOOP_CONFIGURE is added to Linux 5.8 function old new delta NO_LOOP_CONFIGURE (old code): set_loop 784 782 -2 LOOP_CONFIGURE: set_loop 784 653 -131 TRY_LOOP_CONFIGURE: set_loop 784 811 +27 Based on a patch by Xiaoming Ni Signed-off-by: Denys Vlasenko --- libbb/Config.src | 22 ++++++++++++++++++++++ libbb/loop.c | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 65 insertions(+), 9 deletions(-) diff --git a/libbb/Config.src b/libbb/Config.src index 66a3ffa23..b980f19a9 100644 --- a/libbb/Config.src +++ b/libbb/Config.src @@ -369,3 +369,25 @@ config UNICODE_PRESERVE_BROKEN For example, this means that entering 'l', 's', ' ', 0xff, [Enter] at shell prompt will list file named 0xff (single char name with char value 255), not file named '?'. + +choice + prompt "Use LOOP_CONFIGURE for losetup and loop mounts" + default TRY_LOOP_CONFIGURE + help + LOOP_CONFIGURE is added to Linux 5.8 + https://lwn.net/Articles/820408/ + This allows userspace to completely setup a loop device with a single + ioctl, removing the in-between state where the device can be partially + configured - eg the loop device has a backing file associated with it, + but is reading from the wrong offset. + +config LOOP_CONFIGURE + bool "use LOOP_CONFIGURE, needs kernel >= 5.8" + +config NO_LOOP_CONFIGURE + bool "use LOOP_SET_FD + LOOP_SET_STATUS" + +config TRY_LOOP_CONFIGURE + bool "try LOOP_CONFIGURE, fall back to LOOP_SET_FD + LOOP_SET_STATUS" + +endchoice diff --git a/libbb/loop.c b/libbb/loop.c index 424c39216..e930b1b1f 100644 --- a/libbb/loop.c +++ b/libbb/loop.c @@ -110,26 +110,39 @@ static int get_next_free_loop(char *dev, int id) return loopdevno; } -static int set_loopdev_params(int ffd, - int lfd, const char *file, +#if ENABLE_TRY_LOOP_CONFIGURE || ENABLE_LOOP_CONFIGURE +# define LOOP_CONFIGURE 0x4C0A +struct loop_config { + uint32_t fd; + uint32_t block_size; + struct loop_info64 info; + uint64_t __reserved[8]; +}; +#endif + +static int set_loopdev_params(int lfd, + int ffd, const char *file, unsigned long long offset, unsigned long long sizelimit, unsigned flags) { int rc; +#if ENABLE_TRY_LOOP_CONFIGURE || ENABLE_LOOP_CONFIGURE + struct loop_config lconfig; +# define loopinfo lconfig.info +#else bb_loop_info loopinfo; +#endif rc = ioctl(lfd, BB_LOOP_GET_STATUS, &loopinfo); /* If device is free, try to claim it */ if (rc && errno == ENXIO) { - /* Associate free loop device with file */ - rc = ioctl(lfd, LOOP_SET_FD, ffd); - if (rc != 0) { - /* Ouch... race: the device already has a fd */ - return -1; - } +#if ENABLE_TRY_LOOP_CONFIGURE || ENABLE_LOOP_CONFIGURE + memset(&lconfig, 0, sizeof(lconfig)); +#else memset(&loopinfo, 0, sizeof(loopinfo)); +#endif safe_strncpy((char *)loopinfo.lo_file_name, file, LO_NAME_SIZE); loopinfo.lo_offset = offset; loopinfo.lo_sizelimit = sizelimit; @@ -140,6 +153,25 @@ static int set_loopdev_params(int ffd, * is wrong (would free the loop device!) */ loopinfo.lo_flags = (flags & ~BB_LO_FLAGS_READ_ONLY); + +#if ENABLE_TRY_LOOP_CONFIGURE || ENABLE_LOOP_CONFIGURE + lconfig.fd = ffd; + rc = ioctl(lfd, LOOP_CONFIGURE, &lconfig); + if (rc == 0) + return rc; /* SUCCESS! */ +# if ENABLE_TRY_LOOP_CONFIGURE + if (errno != EINVAL) + return rc; /* error other than old kernel */ + /* Old kernel, fall through into old way to do it: */ +# endif +#endif +#if ENABLE_TRY_LOOP_CONFIGURE || ENABLE_NO_LOOP_CONFIGURE + /* Associate free loop device with file */ + rc = ioctl(lfd, LOOP_SET_FD, ffd); + if (rc != 0) { + /* Ouch... race: the device already has a fd */ + return rc; + } rc = ioctl(lfd, BB_LOOP_SET_STATUS, &loopinfo); if (rc != 0 && (loopinfo.lo_flags & BB_LO_FLAGS_AUTOCLEAR)) { /* Old kernel, does not support LO_FLAGS_AUTOCLEAR? */ @@ -151,8 +183,10 @@ static int set_loopdev_params(int ffd, return rc; /* SUCCESS! */ /* failure, undo LOOP_SET_FD */ ioctl(lfd, LOOP_CLR_FD, 0); // actually, 0 param is unnecessary +#endif } return -1; +#undef loopinfo } /* Returns opened fd to the loop device, <0 on error. @@ -227,7 +261,7 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse goto try_next_loopN; } - rc = set_loopdev_params(ffd, lfd, file, offset, sizelimit, flags); + rc = set_loopdev_params(lfd, ffd, file, offset, sizelimit, flags); if (rc == 0) { /* SUCCESS! */ if (!*device) -- cgit v1.2.3-55-g6feb From a55bd1c4847dda99cf9e65519ed67f3bcc9786d8 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 13 Dec 2022 15:49:09 +0100 Subject: loop: restore the correct return vaule of set_loop() It is only used by mount's error path, though... Signed-off-by: Denys Vlasenko --- libbb/loop.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libbb/loop.c b/libbb/loop.c index e930b1b1f..ffc8acd39 100644 --- a/libbb/loop.c +++ b/libbb/loop.c @@ -147,10 +147,8 @@ static int set_loopdev_params(int lfd, loopinfo.lo_offset = offset; loopinfo.lo_sizelimit = sizelimit; /* - * Used by mount to set LO_FLAGS_AUTOCLEAR. - * LO_FLAGS_READ_ONLY is not set because RO is controlled by open type of the file. - * Note that closing LO_FLAGS_AUTOCLEARed lfd before mount - * is wrong (would free the loop device!) + * LO_FLAGS_READ_ONLY is not set because RO is controlled + * by open type of the lfd. */ loopinfo.lo_flags = (flags & ~BB_LO_FLAGS_READ_ONLY); @@ -266,6 +264,12 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse /* SUCCESS! */ if (!*device) *device = xstrdup(dev); + /* Note: mount asks for LO_FLAGS_AUTOCLEAR loopdev. + * Closing LO_FLAGS_AUTOCLEARed lfd before mount + * is wrong (would free the loop device!), + * this is why we return without closing it. + */ + rc = lfd; /* return this */ break; } close(lfd); -- cgit v1.2.3-55-g6feb From 7710250e4a610ae6a4d8f6feb5500f16f82d19f4 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 13 Dec 2022 16:00:00 +0100 Subject: libbb: shrink del_loop() function old new delta del_loop 52 49 -3 Signed-off-by: Denys Vlasenko --- libbb/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libbb/loop.c b/libbb/loop.c index ffc8acd39..95c4a34e2 100644 --- a/libbb/loop.c +++ b/libbb/loop.c @@ -71,7 +71,7 @@ int FAST_FUNC del_loop(const char *device) fd = open(device, O_RDONLY); if (fd < 0) - return 1; + return fd; /* -1 */ rc = ioctl(fd, LOOP_CLR_FD, 0); close(fd); -- cgit v1.2.3-55-g6feb From 9898db4c948b9610608a4adda0f1389052c656be Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 13 Dec 2022 23:21:59 +0100 Subject: udhcpc6: remove stray comment Signed-off-by: Denys Vlasenko --- networking/udhcp/d6_dhcpc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index c7f130a70..fd196eb67 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c @@ -890,7 +890,6 @@ int send_d6_release(struct in6_addr *server_ipv6, struct in6_addr *our_cur_ipv6) if (client6_data.ia_pd) opt_ptr = mempcpy(opt_ptr, client6_data.ia_pd, client6_data.ia_pd->len + 2+2); /* Client-id */ -///vda ci = udhcp_find_option(client_data.options, D6_OPT_CLIENTID, /*dhcpv6:*/ 1); if (ci) opt_ptr = mempcpy(opt_ptr, ci->data, D6_OPT_DATA + 2+2 + 6); -- cgit v1.2.3-55-g6feb From e977853e70d4a8c346a1ad765fc8353ce0e2ced8 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 14 Dec 2022 00:36:59 +0100 Subject: udhcpc6: add some comments RFCs for DHCPv6 are written rather badly... Signed-off-by: Denys Vlasenko --- networking/udhcp/d6_common.h | 41 +++++++++++++++++++++++++++++------------ networking/udhcp/d6_dhcpc.c | 10 ++++++++++ 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/networking/udhcp/d6_common.h b/networking/udhcp/d6_common.h index 9dfde7709..3cbfbb89e 100644 --- a/networking/udhcp/d6_common.h +++ b/networking/udhcp/d6_common.h @@ -63,28 +63,45 @@ struct d6_option { #define D6_OPT_CLIENTID 1 #define D6_OPT_SERVERID 2 +/* "Identity Association for Non-temporary Addresses", + * also known as a "network interface" in plain English */ #define D6_OPT_IA_NA 3 -#define D6_OPT_IA_TA 4 +/* "Identity Association for the Temporary Addresses". + * Presumably this is a "network interface with only link-local addresses". + * Why would DHCPv6 server assign such addresses, I have no idea. */ +//#define D6_OPT_IA_TA 4 +/* "IA Address", an IPv6 address */ #define D6_OPT_IAADDR 5 +/* Option "Option Request Option". From the owners of a doggy dog named Dog? */ #define D6_OPT_ORO 6 -#define D6_OPT_PREFERENCE 7 +//#define D6_OPT_PREFERENCE 7 #define D6_OPT_ELAPSED_TIME 8 -#define D6_OPT_RELAY_MSG 9 -#define D6_OPT_AUTH 11 -#define D6_OPT_UNICAST 12 +//#define D6_OPT_RELAY_MSG 9 +//#define D6_OPT_AUTH 11 +/* "The server sends this option to a client to indicate to the client + * that it is allowed to unicast messages to the server." + * Contains IPv6 address to send packets to. */ +//#define D6_OPT_UNICAST 12 +/* "A Status Code option may appear in the options field of a DHCP + * message and/or in the options field of another option." */ #define D6_OPT_STATUS_CODE 13 -#define D6_OPT_RAPID_COMMIT 14 -#define D6_OPT_USER_CLASS 15 -#define D6_OPT_VENDOR_CLASS 16 -#define D6_OPT_VENDOR_OPTS 17 -#define D6_OPT_INTERFACE_ID 18 -#define D6_OPT_RECONF_MSG 19 -#define D6_OPT_RECONF_ACCEPT 20 +/* "A client MAY include this option in a Solicit message if the client + * is prepared to perform the Solicit-Reply message exchange..." */ +//#define D6_OPT_RAPID_COMMIT 14 /* zero-length option */ +//#define D6_OPT_USER_CLASS 15 +//#define D6_OPT_VENDOR_CLASS 16 +//#define D6_OPT_VENDOR_OPTS 17 +//#define D6_OPT_INTERFACE_ID 18 +//#define D6_OPT_RECONF_MSG 19 +//#define D6_OPT_RECONF_ACCEPT 20 #define D6_OPT_DNS_SERVERS 23 #define D6_OPT_DOMAIN_LIST 24 +/* RFC 3633 "Identity Association for Prefix Delegation". + * This option says that client wants to get an IPv6 prefix */ #define D6_OPT_IA_PD 25 +/* Response from the server comes in this one */ #define D6_OPT_IAPREFIX 26 /* RFC 4704 "The DHCPv6 Client FQDN Option" diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index fd196eb67..9384e4b9c 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c @@ -1617,6 +1617,16 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) prefix_timeout = 0; option = d6_find_option(packet.d6_options, packet_end, D6_OPT_STATUS_CODE); if (option && (option->data[0] | option->data[1]) != 0) { +///FIXME: +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | OPTION_STATUS_CODE | option-len | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | status-code | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | +// . status-message . +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// so why do we think it's NAK if data[0] is zero but data[1] is not? That's wrong... +// we should also check that option->len is ok (i.e. not 0), right? /* return to init state */ bb_info_msg("received DHCP NAK (%u)", option->data[4]); d6_run_script(packet.d6_options, -- cgit v1.2.3-55-g6feb From 3636d52cbebe81e306b3571183232f6e8be730d1 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Mon, 21 Nov 2022 14:09:57 +0100 Subject: more: accept and ignore -e Accept and ignore -e which is specified in POSIX. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/more.html Signed-off-by: Natanael Copa Signed-off-by: Denys Vlasenko --- util-linux/more.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util-linux/more.c b/util-linux/more.c index eea69da06..a830dcbc1 100644 --- a/util-linux/more.c +++ b/util-linux/more.c @@ -84,11 +84,12 @@ int more_main(int argc UNUSED_PARAM, char **argv) /* Parse options */ /* Accepted but ignored: */ /* -d Display help instead of ringing bell */ + /* -e Exit immediately after writing the last line */ /* -f Count logical lines (IOW: long lines are not folded) */ /* -l Do not pause after any line containing a ^L (form feed) */ /* -s Squeeze blank lines into one */ /* -u Suppress underlining */ - getopt32(argv, "dflsu"); + getopt32(argv, "deflsu"); argv += optind; /* Another popular pager, most, detects when stdout -- cgit v1.2.3-55-g6feb From 301ef96892939498ceb0a70e1f523ba9a7a7b9c1 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 15 Dec 2022 11:49:00 +0100 Subject: udhcpc6: align FF02__1_2[] Signed-off-by: Denys Vlasenko --- networking/udhcp/common.h | 3 ++- networking/udhcp/d6_dhcpc.c | 2 +- networking/udhcp/d6_packet.c | 5 ++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index 5882238e3..49a0b593d 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h @@ -370,7 +370,8 @@ void udhcp_sp_setup(void) FAST_FUNC; void udhcp_sp_fd_set(struct pollfd *pfds, int extra_fd) FAST_FUNC; int udhcp_sp_read(void) FAST_FUNC; -int udhcp_read_interface(const char *interface, int *ifindex, uint32_t *nip, uint8_t *mac) FAST_FUNC; +int udhcp_read_interface(const char *interface, + int *ifindex, uint32_t *nip, uint8_t *mac) FAST_FUNC; int udhcp_listen_socket(/*uint32_t ip,*/ int port, const char *inf) FAST_FUNC; diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index 9384e4b9c..e49d752e6 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c @@ -548,7 +548,7 @@ static uint8_t *add_d6_client_options(uint8_t *ptr) static int d6_mcast_from_client_data_ifindex(struct d6_packet *packet, uint8_t *end) { /* FF02::1:2 is "All_DHCP_Relay_Agents_and_Servers" address */ - static const uint8_t FF02__1_2[16] = { + static const uint8_t FF02__1_2[16] ALIGNED(sizeof(long)) = { 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, }; diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c index c1949f6e3..aab1a9182 100644 --- a/networking/udhcp/d6_packet.c +++ b/networking/udhcp/d6_packet.c @@ -27,9 +27,8 @@ void FAST_FUNC d6_dump_packet(struct d6_packet *packet) } #endif -int FAST_FUNC d6_recv_kernel_packet(struct in6_addr *peer_ipv6 - UNUSED_PARAM - , struct d6_packet *packet, int fd) +int FAST_FUNC d6_recv_kernel_packet(struct in6_addr *peer_ipv6 UNUSED_PARAM, + struct d6_packet *packet, int fd) { int bytes; -- cgit v1.2.3-55-g6feb From 242d0562307549af61b234bff545ca13474a2603 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 15 Dec 2022 11:51:16 +0100 Subject: udhcpc6: use a different default config script Signed-off-by: Denys Vlasenko --- networking/udhcp/Config.src | 7 ++++++- networking/udhcp/d6_dhcpc.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/networking/udhcp/Config.src b/networking/udhcp/Config.src index 8c8c11c26..7ba7f48fc 100644 --- a/networking/udhcp/Config.src +++ b/networking/udhcp/Config.src @@ -92,12 +92,17 @@ config FEATURE_UDHCPC_SANITIZEOPT config UDHCPC_DEFAULT_SCRIPT string "Absolute path to config script" default "/usr/share/udhcpc/default.script" - depends on UDHCPC || UDHCPC6 + depends on UDHCPC help This script is called after udhcpc receives an answer. See examples/udhcp for a working example. Normally it is safe to leave this untouched. +config UDHCPC6_DEFAULT_SCRIPT + string "Absolute path to config script for IPv6" + default "/usr/share/udhcpc/default6.script" + depends on UDHCPC6 + # udhcpc6 config is inserted here: INSERT diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index e49d752e6..cdd06188e 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c @@ -1134,7 +1134,7 @@ static void client_background(void) //usage:#define udhcpc6_full_usage "\n" //usage: "\n -i IFACE Interface to use (default "CONFIG_UDHCPC_DEFAULT_INTERFACE")" //usage: "\n -p FILE Create pidfile" -//usage: "\n -s PROG Run PROG at DHCP events (default "CONFIG_UDHCPC_DEFAULT_SCRIPT")" +//usage: "\n -s PROG Run PROG at DHCP events (default "CONFIG_UDHCPC6_DEFAULT_SCRIPT")" //usage: "\n -B Request broadcast replies" //usage: "\n -t N Send up to N discover packets" //usage: "\n -T SEC Pause between packets (default 3)" @@ -1200,7 +1200,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) IF_FEATURE_UDHCP_PORT(SERVER_PORT6 = 547;) IF_FEATURE_UDHCP_PORT(CLIENT_PORT6 = 546;) client_data.interface = CONFIG_UDHCPC_DEFAULT_INTERFACE; - client_data.script = CONFIG_UDHCPC_DEFAULT_SCRIPT; + client_data.script = CONFIG_UDHCPC6_DEFAULT_SCRIPT; client_data.sockfd = -1; /* Make sure fd 0,1,2 are open */ -- cgit v1.2.3-55-g6feb From 6c2ddf808ed70bf515daf4d073411d86ec043550 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 15 Dec 2022 13:34:52 +0100 Subject: udhcp: add a few comments, no code changes Signed-off-by: Denys Vlasenko --- networking/udhcp/d6_packet.c | 10 ++++++++++ networking/udhcp/packet.c | 1 + 2 files changed, 11 insertions(+) diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c index aab1a9182..142de9b43 100644 --- a/networking/udhcp/d6_packet.c +++ b/networking/udhcp/d6_packet.c @@ -80,12 +80,22 @@ int FAST_FUNC d6_send_raw_packet_from_client_data_ifindex( dest_sll.sll_halen = 6; memcpy(dest_sll.sll_addr, dest_arp, 6); +//TODO: is bind() necessary? we sendto() to this destination, should work anyway if (bind(fd, (struct sockaddr *)&dest_sll, sizeof(dest_sll)) < 0) { msg = "bind(%s)"; goto ret_close; } packet.ip6.ip6_vfc = (6 << 4); /* 4 bits version, top 4 bits of tclass */ +// In case we have no IPv6 on our interface at all, we can try +// to fill "all hosts" mcast address as source: +// /* FF02::1 is Link-local "All_Nodes" address */ +// packet.ip6.ip6_dst.s6_addr[0] = 0xff; +// packet.ip6.ip6_dst.s6_addr[1] = 0x02; +// packet.ip6.ip6_dst.s6_addr[15] = 0x01; +// Maybe some servers will be able to respond to us this way? +// Users report that leaving ::0 address there makes servers try to reply to ::0, +// which doesn't work. if (src_ipv6) packet.ip6.ip6_src = *src_ipv6; /* struct copy */ packet.ip6.ip6_dst = *dst_ipv6; /* struct copy */ diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c index 78f580ce9..529978189 100644 --- a/networking/udhcp/packet.c +++ b/networking/udhcp/packet.c @@ -133,6 +133,7 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt, dest_sll.sll_halen = 6; memcpy(dest_sll.sll_addr, dest_arp, 6); +//TODO: is bind() necessary? we sendto() to this destination, should work anyway if (bind(fd, (struct sockaddr *)&dest_sll, sizeof(dest_sll)) < 0) { msg = "bind(%s)"; goto ret_close; -- cgit v1.2.3-55-g6feb From 02ca56564628de474f7a59dbdf3a1a8711b5bee7 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 15 Dec 2022 23:57:27 +0100 Subject: udhcpc6: fix binding to network aliases Signed-off-by: Denys Vlasenko --- networking/udhcp/d6_socket.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/networking/udhcp/d6_socket.c b/networking/udhcp/d6_socket.c index 21cf61c6e..acf108367 100644 --- a/networking/udhcp/d6_socket.c +++ b/networking/udhcp/d6_socket.c @@ -95,9 +95,6 @@ int FAST_FUNC d6_read_interface( close(fd); } - if (retval == 0) - return retval; - if (retval & (1<<0)) bb_error_msg("can't get %s", "MAC"); if (retval & (1<<1)) @@ -109,6 +106,7 @@ int FAST_FUNC d6_listen_socket(int port, const char *inf) { int fd; struct sockaddr_in6 addr; + char *colon; log2("opening listen socket on *:%d %s", port, inf); fd = xsocket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); @@ -117,10 +115,17 @@ int FAST_FUNC d6_listen_socket(int port, const char *inf) if (setsockopt_broadcast(fd) == -1) bb_simple_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.sin6_family = AF_INET6; addr.sin6_port = htons(port); -- cgit v1.2.3-55-g6feb From c4d296aa7c71d3dd812497c02c976124b66a0ff9 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 22 Dec 2022 10:38:08 +0100 Subject: xargs: implement -o, closes 15146 function old new delta .rodata 105225 105259 +34 d6_listen_socket 150 180 +30 packed_usage 34512 34532 +20 d6_read_interface 595 581 -14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 84/-14) Total: 70 bytes Signed-off-by: Denys Vlasenko --- findutils/xargs.c | 85 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/findutils/xargs.c b/findutils/xargs.c index 90ff05986..067ef41c5 100644 --- a/findutils/xargs.c +++ b/findutils/xargs.c @@ -111,6 +111,8 @@ struct globals { #endif const char *eof_str; int idx; + int fd_tty; + int fd_stdin; #if ENABLE_FEATURE_XARGS_SUPPORT_PARALLEL int running_procs; int max_procs; @@ -140,6 +142,42 @@ struct globals { IF_FEATURE_XARGS_SUPPORT_QUOTES(G.process_stdin__q = '\0';) \ } while (0) +/* Correct regardless of combination of CONFIG_xxx */ +enum { + OPTBIT_VERBOSE = 0, + OPTBIT_NO_EMPTY, + OPTBIT_UPTO_NUMBER, + OPTBIT_UPTO_SIZE, + OPTBIT_EOF_STRING, + OPTBIT_EOF_STRING1, + OPTBIT_STDIN_TTY, + IF_FEATURE_XARGS_SUPPORT_CONFIRMATION(OPTBIT_INTERACTIVE,) + IF_FEATURE_XARGS_SUPPORT_TERMOPT( OPTBIT_TERMINATE ,) + IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( OPTBIT_ZEROTERM ,) + IF_FEATURE_XARGS_SUPPORT_REPL_STR( OPTBIT_REPLSTR ,) + IF_FEATURE_XARGS_SUPPORT_REPL_STR( OPTBIT_REPLSTR1 ,) + + OPT_VERBOSE = 1 << OPTBIT_VERBOSE , + OPT_NO_EMPTY = 1 << OPTBIT_NO_EMPTY , + OPT_UPTO_NUMBER = 1 << OPTBIT_UPTO_NUMBER, + OPT_UPTO_SIZE = 1 << OPTBIT_UPTO_SIZE , + OPT_EOF_STRING = 1 << OPTBIT_EOF_STRING , /* GNU: -e[] */ + OPT_EOF_STRING1 = 1 << OPTBIT_EOF_STRING1, /* SUS: -E */ + OPT_STDIN_TTY = 1 << OPTBIT_STDIN_TTY, + OPT_INTERACTIVE = IF_FEATURE_XARGS_SUPPORT_CONFIRMATION((1 << OPTBIT_INTERACTIVE)) + 0, + OPT_TERMINATE = IF_FEATURE_XARGS_SUPPORT_TERMOPT( (1 << OPTBIT_TERMINATE )) + 0, + OPT_ZEROTERM = IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( (1 << OPTBIT_ZEROTERM )) + 0, + OPT_REPLSTR = IF_FEATURE_XARGS_SUPPORT_REPL_STR( (1 << OPTBIT_REPLSTR )) + 0, + OPT_REPLSTR1 = IF_FEATURE_XARGS_SUPPORT_REPL_STR( (1 << OPTBIT_REPLSTR1 )) + 0, +}; +#define OPTION_STR "+trn:s:e::E:o" \ + IF_FEATURE_XARGS_SUPPORT_CONFIRMATION("p") \ + IF_FEATURE_XARGS_SUPPORT_TERMOPT( "x") \ + IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( "0") \ + IF_FEATURE_XARGS_SUPPORT_REPL_STR( "I:i::") \ + IF_FEATURE_XARGS_SUPPORT_PARALLEL( "P:+") \ + IF_FEATURE_XARGS_SUPPORT_ARGS_FILE( "a:") + /* * Returns 0 if xargs should continue (but may set G.xargs_exitcode to 123). @@ -151,6 +189,9 @@ static int xargs_exec(void) { int status; + if (option_mask32 & OPT_STDIN_TTY) + xdup2(G.fd_tty, STDIN_FILENO); + #if !ENABLE_FEATURE_XARGS_SUPPORT_PARALLEL status = spawn_and_wait(G.args); #else @@ -237,6 +278,8 @@ static int xargs_exec(void) ret: if (status != 0) G.xargs_exitcode = status; + if (option_mask32 & OPT_STDIN_TTY) + xdup2(G.fd_stdin, STDIN_FILENO); return status; } @@ -542,6 +585,7 @@ static int xargs_ask_confirmation(void) //usage: IF_FEATURE_XARGS_SUPPORT_ARGS_FILE( //usage: "\n -a FILE Read from FILE instead of stdin" //usage: ) +//usage: "\n -o Reopen stdin as /dev/tty" //usage: "\n -r Don't run command if input is empty" //usage: "\n -t Print the command on stderr before execution" //usage: IF_FEATURE_XARGS_SUPPORT_CONFIRMATION( @@ -563,40 +607,6 @@ static int xargs_ask_confirmation(void) //usage: "$ ls | xargs gzip\n" //usage: "$ find . -name '*.c' -print | xargs rm\n" -/* Correct regardless of combination of CONFIG_xxx */ -enum { - OPTBIT_VERBOSE = 0, - OPTBIT_NO_EMPTY, - OPTBIT_UPTO_NUMBER, - OPTBIT_UPTO_SIZE, - OPTBIT_EOF_STRING, - OPTBIT_EOF_STRING1, - IF_FEATURE_XARGS_SUPPORT_CONFIRMATION(OPTBIT_INTERACTIVE,) - IF_FEATURE_XARGS_SUPPORT_TERMOPT( OPTBIT_TERMINATE ,) - IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( OPTBIT_ZEROTERM ,) - IF_FEATURE_XARGS_SUPPORT_REPL_STR( OPTBIT_REPLSTR ,) - IF_FEATURE_XARGS_SUPPORT_REPL_STR( OPTBIT_REPLSTR1 ,) - - OPT_VERBOSE = 1 << OPTBIT_VERBOSE , - OPT_NO_EMPTY = 1 << OPTBIT_NO_EMPTY , - OPT_UPTO_NUMBER = 1 << OPTBIT_UPTO_NUMBER, - OPT_UPTO_SIZE = 1 << OPTBIT_UPTO_SIZE , - OPT_EOF_STRING = 1 << OPTBIT_EOF_STRING , /* GNU: -e[] */ - OPT_EOF_STRING1 = 1 << OPTBIT_EOF_STRING1, /* SUS: -E */ - OPT_INTERACTIVE = IF_FEATURE_XARGS_SUPPORT_CONFIRMATION((1 << OPTBIT_INTERACTIVE)) + 0, - OPT_TERMINATE = IF_FEATURE_XARGS_SUPPORT_TERMOPT( (1 << OPTBIT_TERMINATE )) + 0, - OPT_ZEROTERM = IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( (1 << OPTBIT_ZEROTERM )) + 0, - OPT_REPLSTR = IF_FEATURE_XARGS_SUPPORT_REPL_STR( (1 << OPTBIT_REPLSTR )) + 0, - OPT_REPLSTR1 = IF_FEATURE_XARGS_SUPPORT_REPL_STR( (1 << OPTBIT_REPLSTR1 )) + 0, -}; -#define OPTION_STR "+trn:s:e::E:" \ - IF_FEATURE_XARGS_SUPPORT_CONFIRMATION("p") \ - IF_FEATURE_XARGS_SUPPORT_TERMOPT( "x") \ - IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( "0") \ - IF_FEATURE_XARGS_SUPPORT_REPL_STR( "I:i::") \ - IF_FEATURE_XARGS_SUPPORT_PARALLEL( "P:+") \ - IF_FEATURE_XARGS_SUPPORT_ARGS_FILE( "a:") - int xargs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int xargs_main(int argc UNUSED_PARAM, char **argv) { @@ -726,6 +736,13 @@ int xargs_main(int argc UNUSED_PARAM, char **argv) store_param(argv[i]); } + if (opt & OPT_STDIN_TTY) { + G.fd_tty = xopen(CURRENT_TTY, O_RDONLY); + close_on_exec_on(G.fd_tty); + G.fd_stdin = dup(STDIN_FILENO); + close_on_exec_on(G.fd_stdin); + } + initial_idx = G.idx; while (1) { char *rem; -- cgit v1.2.3-55-g6feb From adb1c7dcfe14132f2a5e0947d1af3eb50c751327 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 2 Jan 2023 16:59:40 +0100 Subject: xxd: fix use of non-initialized data Signed-off-by: Denys Vlasenko --- util-linux/hexdump_xxd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util-linux/hexdump_xxd.c b/util-linux/hexdump_xxd.c index 45391b565..b5942899e 100644 --- a/util-linux/hexdump_xxd.c +++ b/util-linux/hexdump_xxd.c @@ -229,7 +229,8 @@ int xxd_main(int argc UNUSED_PARAM, char **argv) { char buf[80]; dumper_t *dumper; - char *opt_l, *opt_s, *opt_o; + char *opt_l, *opt_o; + char *opt_s = NULL; unsigned bytes = 2; unsigned cols = 0; unsigned opt; -- cgit v1.2.3-55-g6feb From dc068abad597cb8ccd08da84180d0bdba7b3af01 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 2 Jan 2023 17:01:14 +0100 Subject: testsuite/tree.tests: fix false positive failure Signed-off-by: Denys Vlasenko --- testsuite/tree.tests | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/testsuite/tree.tests b/testsuite/tree.tests index 4f4a9e30b..1fa66da80 100755 --- a/testsuite/tree.tests +++ b/testsuite/tree.tests @@ -18,6 +18,8 @@ tree.tempdir [error opening dir]\n\ mkdir -p tree2.tempdir touch tree2.tempdir/testfile +optional UNICODE_SUPPORT + testing "tree single file" \ "cd tree2.tempdir && tree" \ "\ @@ -50,17 +52,17 @@ testing "tree nested directories and files" \ .\n\ ├── test1\n\ ├── test2\n\ -│   ├── a\n\ -│   │   ├── testfile1\n\ -│   │   ├── testfile2\n\ -│   │   ├── testfile3\n\ -│   │   └── testfile4 -> ../b/testfile4\n\ -│   └── b\n\ -│   ├── test3 -> ../../test3\n\ -│   └── testfile4\n\ +│ ├── a\n\ +│ │ ├── testfile1\n\ +│ │ ├── testfile2\n\ +│ │ ├── testfile3\n\ +│ │ └── testfile4 -> ../b/testfile4\n\ +│ └── b\n\ +│ ├── test3 -> ../../test3\n\ +│ └── testfile4\n\ └── test3\n\ ├── c\n\ - │   └── testfile5\n\ + │ └── testfile5\n\ └── d\n\ └── testfile6\n\ \n\ @@ -77,17 +79,17 @@ tree2.tempdir\n\ tree3.tempdir\n\ ├── test1\n\ ├── test2\n\ -│   ├── a\n\ -│   │   ├── testfile1\n\ -│   │   ├── testfile2\n\ -│   │   ├── testfile3\n\ -│   │   └── testfile4 -> ../b/testfile4\n\ -│   └── b\n\ -│   ├── test3 -> ../../test3\n\ -│   └── testfile4\n\ +│ ├── a\n\ +│ │ ├── testfile1\n\ +│ │ ├── testfile2\n\ +│ │ ├── testfile3\n\ +│ │ └── testfile4 -> ../b/testfile4\n\ +│ └── b\n\ +│ ├── test3 -> ../../test3\n\ +│ └── testfile4\n\ └── test3\n\ ├── c\n\ - │   └── testfile5\n\ + │ └── testfile5\n\ └── d\n\ └── testfile6\n\ \n\ -- cgit v1.2.3-55-g6feb From fb0c000567634db32a644fef0e82627517a0f2e8 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 2 Jan 2023 17:02:17 +0100 Subject: testsuite/sha1sum.tests: fix false positive failure Signed-off-by: Denys Vlasenko --- testsuite/sha1sum.tests | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testsuite/sha1sum.tests b/testsuite/sha1sum.tests index 7ad1334c3..e6ddb2a86 100755 --- a/testsuite/sha1sum.tests +++ b/testsuite/sha1sum.tests @@ -4,10 +4,12 @@ # testing "test name" "cmd" "expected result" "file input" "stdin" >EMPTY +optional FEATURE_MD5_SHA1_SUM_CHECK testing "sha1sum: one-space separated input for -c" \ 'echo "da39a3ee5e6b4b0d3255bfef95601890afd80709 EMPTY" | sha1sum -c' \ "EMPTY: OK\n" \ "" "" +SKIP= rm EMPTY . ./md5sum.tests sha1sum d41337e834377140ae7f98460d71d908598ef04f -- cgit v1.2.3-55-g6feb From e7977df2cae2ac2c5da38f77488ec9e97d10c33b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 2 Jan 2023 17:03:26 +0100 Subject: libbb/loop: fix compile failure (name collision) Signed-off-by: Denys Vlasenko --- libbb/loop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libbb/loop.c b/libbb/loop.c index 95c4a34e2..a0c5d0259 100644 --- a/libbb/loop.c +++ b/libbb/loop.c @@ -112,7 +112,7 @@ static int get_next_free_loop(char *dev, int id) #if ENABLE_TRY_LOOP_CONFIGURE || ENABLE_LOOP_CONFIGURE # define LOOP_CONFIGURE 0x4C0A -struct loop_config { +struct bb_loop_config { uint32_t fd; uint32_t block_size; struct loop_info64 info; @@ -128,7 +128,7 @@ static int set_loopdev_params(int lfd, { int rc; #if ENABLE_TRY_LOOP_CONFIGURE || ENABLE_LOOP_CONFIGURE - struct loop_config lconfig; + struct bb_loop_config lconfig; # define loopinfo lconfig.info #else bb_loop_info loopinfo; -- cgit v1.2.3-55-g6feb From cadf57b3afac5f77c75516d82aed4bc845b5d704 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 2 Jan 2023 17:04:44 +0100 Subject: mv: fix error in !VERBOSE configs Signed-off-by: Denys Vlasenko --- coreutils/mv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coreutils/mv.c b/coreutils/mv.c index fd2422683..cf6169a1e 100644 --- a/coreutils/mv.c +++ b/coreutils/mv.c @@ -71,9 +71,9 @@ int mv_main(int argc, char **argv) "no-target-directory\0" No_argument "T" "target-directory\0" Required_argument "t" IF_FEATURE_VERBOSE( - "verbose\0" No_argument "v", - &last + "verbose\0" No_argument "v" ) + , &last ); argc -= optind; argv += optind; -- cgit v1.2.3-55-g6feb From 9b2d766e0ecb222d25a43333287835452e43f8a9 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 2 Jan 2023 17:05:55 +0100 Subject: sed: fix double-free in FEATURE_CLEAN_UP=y configs Signed-off-by: Denys Vlasenko --- editors/sed.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/editors/sed.c b/editors/sed.c index 32a4b61f6..00dde60be 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -99,7 +99,7 @@ enum { struct sed_FILE { struct sed_FILE *next; /* Next (linked list, NULL terminated) */ - const char *fname; + char *fname; FILE *fp; }; @@ -188,9 +188,6 @@ static void sed_free_and_close_stuff(void) while (sed_cmd) { sed_cmd_t *sed_cmd_next = sed_cmd->next; - if (sed_cmd->sw_file) - fclose(sed_cmd->sw_file); - /* Used to free regexps, but now there is code * in get_address() which can reuse a regexp * for constructs as /regexp/cmd1;//cmd2 @@ -217,6 +214,18 @@ static void sed_free_and_close_stuff(void) if (G.current_fp) fclose(G.current_fp); + + if (G.FILE_head) { + struct sed_FILE *cur = G.FILE_head; + do { + struct sed_FILE *p; + fclose(cur->fp); + free(cur->fname); + p = cur; + cur = cur->next; + free(p); + } while (cur); + } } #else void sed_free_and_close_stuff(void); -- cgit v1.2.3-55-g6feb From 8ed57db65ba66709d3b4061c4f03766f1fe58780 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 2 Jan 2023 17:10:04 +0100 Subject: Makefile.flags: add resolv to LDLIBS for linux compilers too (not only gnu ones) Signed-off-by: Denys Vlasenko --- Makefile.flags | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.flags b/Makefile.flags index 50137a78e..1cec5ba20 100644 --- a/Makefile.flags +++ b/Makefile.flags @@ -184,6 +184,9 @@ LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=% endif ifeq ($(CONFIG_FEATURE_NSLOOKUP_BIG),y) +ifneq (,$(findstring linux,$(shell $(CC) $(CFLAGS) -dumpmachine))) +LDLIBS += resolv +endif ifneq (,$(findstring gnu,$(shell $(CC) $(CFLAGS) -dumpmachine))) LDLIBS += resolv endif -- cgit v1.2.3-55-g6feb From 27be0e8cfeb6f0f7a66bbfb2a6ca23d5a064e6ab Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 3 Jan 2023 08:28:16 +0100 Subject: shell: fix compile failures in some configs Signed-off-by: Denys Vlasenko --- include/libbb.h | 8 +++++++- libbb/lineedit.c | 24 +++++++++++++----------- shell/ash.c | 8 ++++++-- shell/hush.c | 6 +++++- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index 19ed9ec09..cca33a177 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1939,9 +1939,15 @@ typedef struct line_input_t { # if ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH /* function to fetch additional application-specific names to match */ get_exe_name_t *get_exe_name; +# endif +# endif +# if (ENABLE_FEATURE_USERNAME_COMPLETION || ENABLE_FEATURE_EDITING_FANCY_PROMPT) \ + && (ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH) /* function to fetch value of shell variable */ sh_get_var_t *sh_get_var; -# endif +# define EDITING_HAS_sh_get_var 1 +# else +# define EDITING_HAS_sh_get_var 0 # endif # if MAX_HISTORY int cnt_history; diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 697f2a577..d6b2e76ff 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -249,14 +249,6 @@ static void get_user_strings(void) } } -static const char *get_username_str(void) -{ - if (!got_user_strings) - get_user_strings(); - return user_buf ? user_buf : ""; - /* btw, bash uses "I have no name!" string if uid has no entry */ -} - static NOINLINE const char *get_homedir_or_NULL(void) { const char *home; @@ -275,6 +267,16 @@ static NOINLINE const char *get_homedir_or_NULL(void) } #endif +#if ENABLE_FEATURE_EDITING_FANCY_PROMPT +static const char *get_username_str(void) +{ + if (!got_user_strings) + get_user_strings(); + return user_buf ? user_buf : ""; + /* btw, bash uses "I have no name!" string if uid has no entry */ +} +#endif + #if ENABLE_UNICODE_SUPPORT static size_t load_string(const char *src) { @@ -2035,13 +2037,13 @@ static void parse_and_put_prompt(const char *prmt_ptr) case 'W': /* basename of cur dir */ if (!cwd_buf) { const char *home; -#if ENABLE_SHELL_ASH +# if EDITING_HAS_sh_get_var cwd_buf = state->sh_get_var ? xstrdup(state->sh_get_var("PWD")) : xrealloc_getcwd_or_warn(NULL); -#else +# else cwd_buf = xrealloc_getcwd_or_warn(NULL); -#endif +# endif if (!cwd_buf) cwd_buf = (char *)bb_msg_unknown; else if ((home = get_homedir_or_NULL()) != NULL && home[0]) { diff --git a/shell/ash.c b/shell/ash.c index 326f8b2a9..99fdbce7b 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -9736,7 +9736,7 @@ evalpipe(union node *n, int flags) } /* setinteractive needs this forward reference */ -#if ENABLE_FEATURE_EDITING +#if ENABLE_FEATURE_TAB_COMPLETION static const char *get_builtin_name(int i) FAST_FUNC; #endif @@ -9773,8 +9773,12 @@ setinteractive(int on) #if ENABLE_FEATURE_EDITING if (!line_input_state) { line_input_state = new_line_input_t(FOR_SHELL | WITH_PATH_LOOKUP); +# if ENABLE_FEATURE_TAB_COMPLETION line_input_state->get_exe_name = get_builtin_name; +# endif +# if EDITING_HAS_sh_get_var line_input_state->sh_get_var = lookupvar; +# endif } #endif } @@ -10283,7 +10287,7 @@ find_builtin(const char *name) return bp; } -#if ENABLE_FEATURE_EDITING +#if ENABLE_FEATURE_TAB_COMPLETION static const char * FAST_FUNC get_builtin_name(int i) { diff --git a/shell/hush.c b/shell/hush.c index 051b123e7..693099209 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -8188,7 +8188,7 @@ static const struct built_in_command *find_builtin(const char *name) return find_builtin_helper(name, bltins2, &bltins2[ARRAY_SIZE(bltins2)]); } -#if ENABLE_HUSH_JOB && ENABLE_FEATURE_EDITING +#if ENABLE_HUSH_JOB && ENABLE_FEATURE_TAB_COMPLETION static const char * FAST_FUNC get_builtin_name(int i) { if (/*i >= 0 && */ i < ARRAY_SIZE(bltins1)) { @@ -10668,8 +10668,12 @@ int hush_main(int argc, char **argv) # if ENABLE_FEATURE_EDITING G.line_input_state = new_line_input_t(FOR_SHELL); +# if ENABLE_FEATURE_TAB_COMPLETION G.line_input_state->get_exe_name = get_builtin_name; +# endif +# if EDITING_HAS_sh_get_var G.line_input_state->sh_get_var = get_local_var_value; +# endif # endif # if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0 { -- cgit v1.2.3-55-g6feb From bcb90b9c419c9d616f21d8fc143f9b343c064ed7 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 3 Jan 2023 08:30:12 +0100 Subject: xxd: use bb_simple_perror_msg... where appropriate Signed-off-by: Denys Vlasenko --- util-linux/hexdump_xxd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util-linux/hexdump_xxd.c b/util-linux/hexdump_xxd.c index b5942899e..9738a76ad 100644 --- a/util-linux/hexdump_xxd.c +++ b/util-linux/hexdump_xxd.c @@ -78,7 +78,7 @@ static void write_zeros(off_t count) do { unsigned sz = count < COMMON_BUFSIZE ? (unsigned)count : COMMON_BUFSIZE; if (fwrite(fillbuf, 1, sz, stdout) != sz) - bb_perror_msg_and_die("write error"); + bb_simple_perror_msg_and_die("write error"); count -= sz; } while (count != 0); } @@ -120,7 +120,7 @@ static void reverse(unsigned opt, const char *filename, char *opt_s) if (ofs != cur) { if (fseeko(stdout, ofs, SEEK_SET) != 0) { if (ofs < cur) - bb_perror_msg_and_die("cannot seek"); + bb_simple_perror_msg_and_die("cannot seek"); write_zeros(ofs - cur); } cur = ofs; -- cgit v1.2.3-55-g6feb From d488a5218b378631ab78c3358dab9498426bc777 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 3 Jan 2023 13:39:14 +0100 Subject: ash: trivial code shrink Signed-off-by: Denys Vlasenko --- shell/ash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/ash.c b/shell/ash.c index 99fdbce7b..18ccc1329 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -10018,7 +10018,7 @@ mklocal(char *name, int flags) setvareq(name, flags); else /* "local VAR" unsets VAR: */ - setvar0(name, NULL); + unsetvar(name); } } lvp->vp = vp; -- cgit v1.2.3-55-g6feb From 969e00816835769429fcd98046313f66b1c194fb Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 3 Jan 2023 14:08:18 +0100 Subject: hush: code shrink function old new delta run_list 1032 1012 -20 Signed-off-by: Denys Vlasenko --- shell/hush.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index 693099209..d111f0cc5 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -2460,10 +2460,15 @@ static int set_local_var(char *str, unsigned flags) return retval; } +static int set_local_var0(char *str) +{ + return set_local_var(str, 0); +} + static void FAST_FUNC set_local_var_from_halves(const char *name, const char *val) { char *var = xasprintf("%s=%s", name, val); - set_local_var(var, /*flag:*/ 0); + set_local_var0(var); } /* Used at startup and after each cd */ @@ -6964,7 +6969,7 @@ static NOINLINE int expand_one_var(o_string *output, int n, val = NULL; } else { char *new_var = xasprintf("%s=%s", var, val); - set_local_var(new_var, /*flag:*/ 0); + set_local_var0(new_var); } } } @@ -9373,7 +9378,7 @@ static NOINLINE int run_pipe(struct pipe *pi) } #endif debug_printf_env("set shell var:'%s'->'%s'\n", *argv, p); - if (set_local_var(p, /*flag:*/ 0)) { + if (set_local_var0(p)) { /* assignment to readonly var / putenv error? */ rcode = 1; } @@ -9856,7 +9861,7 @@ static int run_list(struct pipe *pi) } /* Insert next value from for_lcur */ /* note: *for_lcur already has quotes removed, $var expanded, etc */ - set_local_var(xasprintf("%s=%s", pi->cmds[0].argv[0], *for_lcur++), /*flag:*/ 0); + set_local_var_from_halves(pi->cmds[0].argv[0], *for_lcur++); continue; } if (rword == RES_IN) { -- cgit v1.2.3-55-g6feb From 70f77e4617e06077231b8b63c3fb3406d7f8865d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 3 Jan 2023 15:15:41 +0100 Subject: Bump version to 1.36.0 Signed-off-by: Denys Vlasenko --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 503475fe9..503af6941 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION = 1 PATCHLEVEL = 36 SUBLEVEL = 0 -EXTRAVERSION = .git +EXTRAVERSION = NAME = Unnamed # *DOCUMENTATION* -- cgit v1.2.3-55-g6feb From b1884deb514c35289d37e7bfbf23f770b0bd09b3 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 3 Jan 2023 15:32:00 +0100 Subject: Start 1.37.0 development cycle Signed-off-by: Denys Vlasenko --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 503af6941..7b4686fc8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION = 1 -PATCHLEVEL = 36 +PATCHLEVEL = 37 SUBLEVEL = 0 -EXTRAVERSION = +EXTRAVERSION = .git NAME = Unnamed # *DOCUMENTATION* -- cgit v1.2.3-55-g6feb