Re: [PATCH 7/7] libbb.h: Handle missing HOST_NAME_MAX; ensure MAXFOOLEN agrees with FOO_MAX
On Sun, Oct 8, 2017 at 1:53 AM, James Clarke wrote: > Signed-off-by: James Clarke > --- > include/libbb.h | 19 ++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/include/libbb.h b/include/libbb.h > index daccf154a..56f4f4cb3 100644 > --- a/include/libbb.h > +++ b/include/libbb.h > @@ -181,7 +181,24 @@ extern char **environ; > /* klogctl is in libc's klog.h, but we cheat and not #include that */ > int klogctl(int type, char *b, int len); > #ifndef PATH_MAX > -# define PATH_MAX 256 > +# ifdef MAXPATHLEN > +# define PATH_MAX MAXPATHLEN > +# else > +# define PATH_MAX 256 > +# endif > +#endif > +#ifndef MAXPATHLEN > +# define MAXPATHLEN PATH_MAX > +#endif > +#ifndef HOST_NAME_MAX > +# ifdef MAXHOSTNAMELEN > +# define HOST_NAME_MAX MAXHOSTNAMELEN > +# else > +# define HOST_NAME_MAX 256 > +# endif > +#endif > +#ifndef MAXHOSTNAMELEN > +# define MAXHOSTNAMELEN HOST_NAME_MAX > #endif > #ifndef BUFSIZ > # define BUFSIZ 4096 Um, why do we need to define MAXPATHLEN and MAXHOSTNAMELEN where there have been no use in BusyBox, and there have been standard macros available? While we are at it, could you also please change the HOST_NAME_MAX fallback definition to 255? 255 is the POSIX defined minimum. http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html (see _POSIX_HOST_NAME_MAX value)
Re: [PATCH 4/7] xfuncs: Handle missing non-POSIX termios constants
On Sun, Oct 8, 2017 at 1:53 AM, James Clarke wrote: > diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c > index 9cbfb2836..95dac656a 100644 > --- a/libbb/xfuncs.c > +++ b/libbb/xfuncs.c > @@ -22,6 +22,16 @@ > */ > #include "libbb.h" > > +#ifndef IMAXBEL > +# define IMAXBEL 0 > +#endif > +#ifndef IUCLC > +# define IUCLC 0 > +#endif > +#ifndef IXANY > +# define IXANY 0 > +#endif > + I wonder, how do these break, and why does defining them as 0 solve the problem?
Fwd: lists.debian.org: kill debian-ports mailing list
JFYI Hopefully this is latest spam we get through this pseudo mailing list, please follow-up on #877951 if you support the idea. Best regards -- Forwarded message -- From: Héctor Orón Martínez Date: 2017-10-07 23:15 GMT+02:00 Subject: lists.debian.org: kill debian-ports mailing list To: Debian Bug Tracking System Package: lists.debian.org Severity: wishlist Dear Maintainer, debian-ports mailing list, actually not a mailing list but a can of worms as it spams all other debian-$architecture (ports) mailing lists, should be imho killed. Not only because we are getting several copies of the same email, but also because it can be confused with unofficial Debian ports maintenance mailing list (recently created request for debian-ports-devel). Do you think it is time for that to happen? Best Regards, -- System Information: Debian Release: buster/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'stable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 4.12.0-2-amd64 (SMP w/4 CPU cores) Locale: LANG=ca_AD.UTF-8, LC_CTYPE=ca_AD.UTF-8 (charmap=UTF-8), LANGUAGE=ca_AD:ca (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) -- Héctor Orón -.. . -... .. .- -. -.. . ...- . .-.. --- .--. . .-.
[PATCH 7/7] libbb.h: Handle missing HOST_NAME_MAX; ensure MAXFOOLEN agrees with FOO_MAX
Signed-off-by: James Clarke --- include/libbb.h | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/include/libbb.h b/include/libbb.h index daccf154a..56f4f4cb3 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -181,7 +181,24 @@ extern char **environ; /* klogctl is in libc's klog.h, but we cheat and not #include that */ int klogctl(int type, char *b, int len); #ifndef PATH_MAX -# define PATH_MAX 256 +# ifdef MAXPATHLEN +# define PATH_MAX MAXPATHLEN +# else +# define PATH_MAX 256 +# endif +#endif +#ifndef MAXPATHLEN +# define MAXPATHLEN PATH_MAX +#endif +#ifndef HOST_NAME_MAX +# ifdef MAXHOSTNAMELEN +# define HOST_NAME_MAX MAXHOSTNAMELEN +# else +# define HOST_NAME_MAX 256 +# endif +#endif +#ifndef MAXHOSTNAMELEN +# define MAXHOSTNAMELEN HOST_NAME_MAX #endif #ifndef BUFSIZ # define BUFSIZ 4096 -- 2.14.1
[PATCH 0/7] Hurd and GNU/kFreeBSD portability fixes
Hi, With this patch series, busybox once again builds on the Hurd and GNU/kFreeBSD, and it also fixes one bug with "grep -cr" and symlinks to directories found as a result of FreeBSD's handling of reading from directories: $ ls -lR grep.testdir grep.testdir: total 4 drwxr-xr-x 2 jrtc27 jrtc27 4096 Oct 7 18:50 foo lrwxrwxrwx 1 jrtc27 jrtc273 Oct 7 18:49 symfoo -> foo grep.testdir/foo: total 4 -rw-r--r-- 1 jrtc27 jrtc27 4 Oct 7 18:50 file $ grep -cr . grep.testdir grep.testdir/foo/file:1 $ busybox grep -cr . grep.testdir grep.testdir/foo/file:1 grep.testdir/symfoo:0 Regards, James James Clarke (7): blkdiscard: Only build on Linux df: Use statvfs instead of non-standard statfs networking: Fall back on IPPROTO_RAW when SOL_RAW is not defined xfuncs: Handle missing non-POSIX termios constants {udp_io,traceroute}: Standardise IPv6 PKTINFO handling to be portable grep: Skip grepping symlinks to directories libbb.h: Handle missing HOST_NAME_MAX; ensure MAXFOOLEN agrees with FOO_MAX coreutils/df.c | 6 +++--- findutils/grep.c| 22 -- include/libbb.h | 19 ++- libbb/udp_io.c | 8 ++-- libbb/xfuncs.c | 10 ++ networking/ping.c | 8 networking/traceroute.c | 16 +++- util-linux/blkdiscard.c | 1 + 8 files changed, 77 insertions(+), 13 deletions(-) -- 2.14.1
[PATCH 1/7] blkdiscard: Only build on Linux
Signed-off-by: James Clarke --- util-linux/blkdiscard.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util-linux/blkdiscard.c b/util-linux/blkdiscard.c index 5863f0aab..e4902e5b5 100644 --- a/util-linux/blkdiscard.c +++ b/util-linux/blkdiscard.c @@ -8,6 +8,7 @@ //config:config BLKDISCARD //config: bool "blkdiscard (5.3 kb)" //config: default y +//config: select PLATFORM_LINUX //config: help //config: blkdiscard discards sectors on a given device. -- 2.14.1
[PATCH 4/7] xfuncs: Handle missing non-POSIX termios constants
Signed-off-by: James Clarke --- libbb/xfuncs.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 9cbfb2836..95dac656a 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -22,6 +22,16 @@ */ #include "libbb.h" +#ifndef IMAXBEL +# define IMAXBEL 0 +#endif +#ifndef IUCLC +# define IUCLC 0 +#endif +#ifndef IXANY +# define IXANY 0 +#endif + /* Turn on nonblocking I/O on a fd */ int FAST_FUNC ndelay_on(int fd) { -- 2.14.1
[PATCH 6/7] grep: Skip grepping symlinks to directories
When grep is passed -r, recursive_action will treat any symlinks to directories not in the root as normal files, since it lstat's them and is therefore told they are not directories. However, file_action_grep will still try to fopen and read from them to see whether they match, which varies in behaviour across platforms. Linux will give EISDIR and thus grep will not find any matching lines, but FreeBSD will give the raw contents of the directory itself, which may match the given pattern. Also, if grep is passed -c, it will even print a count for these symlinks, even on Linux. Since this recursive_action behaviour is required for the correct functioning of other applets, such as tar, grep should handle this special case and skip any such symlinks. Signed-off-by: James Clarke --- findutils/grep.c | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/findutils/grep.c b/findutils/grep.c index f72175afb..0cb0aac64 100644 --- a/findutils/grep.c +++ b/findutils/grep.c @@ -639,11 +639,29 @@ static void load_regexes_from_file(llist_t *fopt) } static int FAST_FUNC file_action_grep(const char *filename, - struct stat *statbuf UNUSED_PARAM, + struct stat *statbuf, void* matched, int depth UNUSED_PARAM) { - FILE *file = fopen_for_read(filename); + FILE *file; + struct stat statbufFollow; + + /* If we are given a link to a directory, we should bail out now, rather +* than trying to open the "file" and hoping getline gives us nothing, +* since that is not portable across operating systems (FreeBSD for example +* will return the raw directory contents). */ + if (S_ISLNK(statbuf->st_mode)) { + if (stat(filename, &statbufFollow) < 0) { + if (!SUPPRESS_ERR_MSGS) + bb_simple_perror_msg(filename); + return 0; + } + + if (S_ISDIR(statbufFollow.st_mode)) + return 1; + } + + file = fopen_for_read(filename); if (file == NULL) { if (!SUPPRESS_ERR_MSGS) bb_simple_perror_msg(filename); -- 2.14.1
[PATCH 5/7] {udp_io,traceroute}: Standardise IPv6 PKTINFO handling to be portable
The current standard (RFC 3542) is for IPV6_RECVPKTINFO to be given to setsockopt, and IPV6_PKTINFO to be used as the packet type. Previously, RFC 2292 required IPV6_PKTINFO to be used for both, but RFC 3542 re-purposed IPV6_PKTINFO when given to setsockopt. The special Linux-specific IPV6_2292PKTINFO has the same semantics as IPV6_PKTINFO in RFC 2292, but was introduced at the same time as IPV6_RECVPKTINFO. Therefore, if we have IPV6_RECVPKTINFO available, we can use the RFC 3542 style, and if not, we assume that only the RFC 2292 API is available, using IPV6_PKTINFO for both. Signed-off-by: James Clarke --- libbb/udp_io.c | 8 ++-- networking/traceroute.c | 8 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libbb/udp_io.c b/libbb/udp_io.c index 6e3ef484e..68355e6c4 100644 --- a/libbb/udp_io.c +++ b/libbb/udp_io.c @@ -8,6 +8,10 @@ */ #include "libbb.h" +#if defined(IPV6_PKTINFO) && !defined(IPV6_RECVPKTINFO) +# define IPV6_RECVPKTINFO IPV6_PKTINFO +#endif + /* * This asks kernel to let us know dst addr/port of incoming packets * We don't check for errors here. Not supported == won't be used @@ -18,8 +22,8 @@ socket_want_pktinfo(int fd UNUSED_PARAM) #ifdef IP_PKTINFO setsockopt_1(fd, IPPROTO_IP, IP_PKTINFO); #endif -#if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO) - setsockopt_1(fd, IPPROTO_IPV6, IPV6_PKTINFO); +#if ENABLE_FEATURE_IPV6 && defined(IPV6_RECVPKTINFO) + setsockopt_1(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO); #endif } diff --git a/networking/traceroute.c b/networking/traceroute.c index df7122047..6dcbc2faa 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -311,6 +311,9 @@ # ifndef SOL_IPV6 # define SOL_IPV6 IPPROTO_IPV6 # endif +# if defined(IPV6_PKTINFO) && !defined(IPV6_RECVPKTINFO) +# define IPV6_RECVPKTINFO IPV6_PKTINFO +# endif #endif #include "libbb.h" @@ -911,12 +914,7 @@ common_traceroute_main(int op, char **argv) #if ENABLE_TRACEROUTE6 if (af == AF_INET6) { xmove_fd(xsocket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6), rcvsock); -# ifdef IPV6_RECVPKTINFO setsockopt_1(rcvsock, SOL_IPV6, IPV6_RECVPKTINFO); - setsockopt_1(rcvsock, SOL_IPV6, IPV6_2292PKTINFO); -# else - setsockopt_1(rcvsock, SOL_IPV6, IPV6_PKTINFO); -# endif } else #endif { -- 2.14.1
[PATCH 3/7] networking: Fall back on IPPROTO_RAW when SOL_RAW is not defined
Signed-off-by: James Clarke --- networking/ping.c | 8 networking/traceroute.c | 8 2 files changed, 16 insertions(+) diff --git a/networking/ping.c b/networking/ping.c index 774f8f3e0..d1d59d545 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -135,6 +135,14 @@ # define ICMP_ADDRESSREPLY 18 /* Address Mask Reply*/ #endif +/* Some operating systems, like GNU/Hurd, don't define SOL_RAW, but do have + * IPPROTO_RAW. Since the IPPROTO definitions are also valid to use for + * setsockopt (and take the same value as their corresponding SOL definitions, + * if they exist), we can just fall back on IPPROTO_RAW. */ +#ifndef SOL_RAW +# define SOL_RAW IPPROTO_RAW +#endif + #if ENABLE_PING6 # include /* I see RENUMBERED constants in bits/in.h - !!? diff --git a/networking/traceroute.c b/networking/traceroute.c index 8b6247482..df7122047 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -323,6 +323,14 @@ # define IPPROTO_IP 0 #endif +/* Some operating systems, like GNU/Hurd, don't define SOL_RAW, but do have + * IPPROTO_RAW. Since the IPPROTO definitions are also valid to use for + * setsockopt (and take the same value as their corresponding SOL definitions, + * if they exist), we can just fall back on IPPROTO_RAW. */ +#ifndef SOL_RAW +# define SOL_RAW IPPROTO_RAW +#endif + #define OPT_STRING \ "FIlnrdvxt:i:m:p:q:s:w:z:f:" \ -- 2.14.1
[PATCH 2/7] df: Use statvfs instead of non-standard statfs
Platforms differ on what their implementations of statfs include. Importantly, FreeBSD's does not include a f_frsize member inside struct statfs. However, statvfs is specified by POSIX and includes everything we need, so we can just use that instead. Signed-off-by: James Clarke --- coreutils/df.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coreutils/df.c b/coreutils/df.c index 121da970b..4076b5fec 100644 --- a/coreutils/df.c +++ b/coreutils/df.c @@ -77,7 +77,7 @@ //usage: "/dev/sda3 17381728 17107080274648 98% /\n" #include -#include +#include #include "libbb.h" #include "unicode.h" @@ -98,7 +98,7 @@ int df_main(int argc UNUSED_PARAM, char **argv) unsigned opt; FILE *mount_table; struct mntent *mount_entry; - struct statfs s; + struct statvfs s; enum { OPT_KILO = (1 << 0), @@ -211,7 +211,7 @@ int df_main(int argc UNUSED_PARAM, char **argv) mount_point = mount_entry->mnt_dir; fs_type = mount_entry->mnt_type; - if (statfs(mount_point, &s) != 0) { + if (statvfs(mount_point, &s) != 0) { bb_simple_perror_msg(mount_point); goto set_error; } -- 2.14.1