[PATCH rtems-libbsd 2/2] ping6: Honor file descriptor maximum

Christian Mauderer christian.mauderer at embedded-brains.de
Thu Feb 25 15:01:03 UTC 2021


This is basically the same as the patch for ping.
---
 freebsd/sbin/ping6/ping6.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/freebsd/sbin/ping6/ping6.c b/freebsd/sbin/ping6/ping6.c
index a56aae1dc..2d6e5adef 100644
--- a/freebsd/sbin/ping6/ping6.c
+++ b/freebsd/sbin/ping6/ping6.c
@@ -115,6 +115,7 @@ __FBSDID("$FreeBSD$");
 #include <getopt.h>
 #include <machine/rtems-bsd-program.h>
 #include <machine/rtems-bsd-commands.h>
+#include <rtems/libio_.h>
 #endif /* __rtems__ */
 #include <sys/param.h>
 #include <sys/capsicum.h>
@@ -1198,7 +1199,13 @@ main(int argc, char *argv[])
 		struct timespec now, timeout;
 		struct msghdr m;
 		struct iovec iov[2];
+#ifndef __rtems__
 		fd_set rfds;
+#else /* __rtems__ */
+		fd_set big_enough_rfds[howmany(rtems_libio_number_iops,
+		    sizeof(fd_set) * 8)];
+#define	rfds (*(fd_set *)(&big_enough_rfds[0]))
+#endif /* __rtems__ */
 		int n;
 
 		/* signal handling */
@@ -1211,7 +1218,11 @@ main(int argc, char *argv[])
 			continue;
 		}
 #endif
+#ifndef __rtems__
 		FD_ZERO(&rfds);
+#else /* __rtems__ */
+		memset(big_enough_rfds, 0, sizeof(big_enough_rfds));
+#endif /* __rtems__ */
 		FD_SET(srecv, &rfds);
 		clock_gettime(CLOCK_MONOTONIC, &now);
 		timespecadd(&last, &intvl, &timeout);
-- 
2.26.2



More information about the devel mailing list