[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] Fix non-Linux builds
From:       Michael Tokarev <mjt () tls ! msk ! ru>
Date:       2022-11-04 16:49:48
Message-ID: 20221104164948.95918-1-mjt () msgid ! tls ! msk ! ru
[Download RAW message or body]

From: Samuel Thibault <samuel.thibault@ens-lyon.org>

Some features are Linux-only.

Also, libresolv is used on all GNU platforms, notably GNU/Hurd and
GNU/kfreeBSD.
---
 coreutils/dd.c          | 20 ++++++++++++++++++--
 networking/traceroute.c |  2 ++
 2 files changed, 20 insertions(+), 2 deletions(-)

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/networking/traceroute.c b/networking/traceroute.c
index fb9315db5..760ed6d64 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -964,8 +964,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
-- 
2.30.2

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic