gnu: Add python-mediafile.
[jackhill/guix/guix.git] / gnu / packages / patches / inetutils-hurd.patch
CommitLineData
3d3ca76f
JN
1Support compiling on the Hurd.
2
3Taken from https://git.hadrons.org/cgit/debian/pkgs/inetutils.git/tree/debian/patches/0002-ifconfig-Improve-the-support-for-GNU-Hurd.patch
4
5From 9a90d9b9119906df23cb2db1503cb0f099942dd9 Mon Sep 17 00:00:00 2001
6From: Mats Erik Andersson <gnu@gisladisker.se>
7Date: Sat, 18 Jul 2015 01:12:41 +0200
8Subject: [PATCH 02/35] ifconfig: Improve the support for GNU/Hurd.
9
10Use system specific code instead of generic code.
11This provides abilities similar to other systems.
12---
13 ChangeLog | 17 +++
14 ifconfig/system.c | 10 +-
15 ifconfig/system.h | 2 +
16 ifconfig/system/Makefile.am | 4 +-
17 ifconfig/system/generic.c | 14 +-
18 ifconfig/system/hurd.c | 292 ++++++++++++++++++++++++++++++++++++
19 ifconfig/system/hurd.h | 50 ++++++
20 7 files changed, 381 insertions(+), 8 deletions(-)
21 create mode 100644 ifconfig/system/hurd.c
22 create mode 100644 ifconfig/system/hurd.h
23
24diff --git a/ifconfig/system.c b/ifconfig/system.c
25index 30677e41..e108dc2e 100644
26--- a/ifconfig/system.c
27+++ b/ifconfig/system.c
28@@ -25,10 +25,12 @@
29 # include "system/solaris.c"
30 #elif defined __QNX__
31 # include "system/qnx.c"
32-# elif defined __DragonFly__ || defined __FreeBSD__ || \
33- defined __FreeBSD_kernel__ || \
34- defined __NetBSD__ || defined __OpenBSD__
35-# include "system/bsd.c"
36+#elif defined __DragonFly__ || defined __FreeBSD__ || \
37+ defined __FreeBSD_kernel__ || \
38+ defined __NetBSD__ || defined __OpenBSD__
39+# include "system/bsd.c"
40+#elif defined __GNU__
41+# include "system/hurd.c"
42 #else
43 # include "system/generic.c"
44 #endif
45diff --git a/ifconfig/system.h b/ifconfig/system.h
46index 8521ad95..66878d3a 100644
47--- a/ifconfig/system.h
48+++ b/ifconfig/system.h
49@@ -97,6 +97,8 @@ extern struct if_nameindex* (*system_if_nameindex) (void);
50 defined __FreeBSD_kernel__ || \
51 defined __NetBSD__ || defined __OpenBSD__
52 # include "system/bsd.h"
53+# elif defined __GNU__
54+# include "system/hurd.h"
55 # else
56 # include "system/generic.h"
57 # endif
58diff --git a/ifconfig/system/Makefile.am b/ifconfig/system/Makefile.am
59index 954c6774..62a9f1c4 100644
60--- a/ifconfig/system/Makefile.am
61+++ b/ifconfig/system/Makefile.am
62@@ -26,8 +26,10 @@ noinst_HEADERS = \
63 linux.h \
64 solaris.h \
65 qnx.h \
66+ hurd.h \
67 bsd.c \
68 generic.c \
69 linux.c \
70 solaris.c \
71- qnx.c
72+ qnx.c \
73+ hurd.c
74diff --git a/ifconfig/system/generic.c b/ifconfig/system/generic.c
75index 9a2bda55..20a78bde 100644
76--- a/ifconfig/system/generic.c
77+++ b/ifconfig/system/generic.c
78@@ -22,6 +22,8 @@
79 #include <config.h>
80
81 #include "../ifconfig.h"
82+
83+#include <unused-parameter.h>
84 \f
85
86 /* Output format stuff. */
87@@ -36,19 +38,25 @@ const char *system_help;
88 struct argp_child system_argp_child;
89
90 int
91-system_parse_opt (struct ifconfig **ifp, char option, char *optarg)
92+system_parse_opt (struct ifconfig **ifp _GL_UNUSED_PARAMETER,
93+ char option _GL_UNUSED_PARAMETER,
94+ char *optarg _GL_UNUSED_PARAMETER)
95 {
96 return 0;
97 }
98
99 int
100-system_parse_opt_rest (struct ifconfig **ifp, int argc, char *argv[])
101+system_parse_opt_rest (struct ifconfig **ifp _GL_UNUSED_PARAMETER,
102+ int argc _GL_UNUSED_PARAMETER,
103+ char *argv[] _GL_UNUSED_PARAMETER)
104 {
105 return 0;
106 }
107
108 int
109-system_configure (int sfd, struct ifreq *ifr, struct system_ifconfig *ifs)
110+system_configure (int sfd _GL_UNUSED_PARAMETER,
111+ struct ifreq *ifr _GL_UNUSED_PARAMETER,
112+ struct system_ifconfig *ifs _GL_UNUSED_PARAMETER)
113 {
114 return 0;
115 }
116diff --git a/ifconfig/system/hurd.c b/ifconfig/system/hurd.c
117new file mode 100644
118index 00000000..3bd19775
119--- /dev/null
120+++ b/ifconfig/system/hurd.c
121@@ -0,0 +1,292 @@
122+/* hurd.c -- Code for ifconfig specific to GNU/Hurd.
123+ Copyright (C) 2015 Free Software Foundation, Inc.
124+
125+ This file is part of GNU Inetutils.
126+
127+ GNU Inetutils is free software: you can redistribute it and/or modify
128+ it under the terms of the GNU General Public License as published by
129+ the Free Software Foundation, either version 3 of the License, or (at
130+ your option) any later version.
131+
132+ GNU Inetutils is distributed in the hope that it will be useful, but
133+ WITHOUT ANY WARRANTY; without even the implied warranty of
134+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
135+ General Public License for more details.
136+
137+ You should have received a copy of the GNU General Public License
138+ along with this program. If not, see `http://www.gnu.org/licenses/'. */
139+
140+/* Mostly written by Marcus Brinkmann.
141+ Adaptions to GNU/Hurd by Mats Erik Andersson. */
142+
143+#include <config.h>
144+
145+#include <stdlib.h>
146+#include <sys/ioctl.h>
147+#include <net/if_arp.h>
148+#include "../ifconfig.h"
149+
150+#include <unused-parameter.h>
151+\f
152+
153+/* Output format stuff. */
154+
155+const char *system_default_format = "gnu";
156+\f
157+
158+/* Argument parsing stuff. */
159+
160+const char *system_help = "NAME [ADDR]\
161+ [broadcast BRDADDR] [netmask MASK]\
162+ [mtu N] [up|down] [FLAGS]";
163+
164+struct argp_child system_argp_child;
165+
166+int
167+system_parse_opt (struct ifconfig **ifp _GL_UNUSED_PARAMETER,
168+ char option _GL_UNUSED_PARAMETER,
169+ char *optarg _GL_UNUSED_PARAMETER)
170+{
171+ return 0;
172+}
173+
174+int
175+system_parse_opt_rest (struct ifconfig **ifp, int argc, char *argv[])
176+{
177+ int i = 0, mask, rev;
178+ enum {
179+ EXPECT_NOTHING,
180+ EXPECT_AF,
181+ EXPECT_BROADCAST,
182+ EXPECT_NETMASK,
183+ EXPECT_METRIC,
184+ EXPECT_MTU
185+ } expect = EXPECT_AF;
186+
187+ *ifp = parse_opt_new_ifs (argv[0]);
188+
189+ while (++i < argc)
190+ {
191+ switch (expect)
192+ {
193+ case EXPECT_BROADCAST:
194+ parse_opt_set_brdaddr (*ifp, argv[i]);
195+ break;
196+
197+ case EXPECT_NETMASK:
198+ parse_opt_set_netmask (*ifp, argv[i]);
199+ break;
200+
201+ case EXPECT_MTU:
202+ parse_opt_set_mtu (*ifp, argv[i]);
203+ break;
204+
205+ /* XXX: 2015-07-18, GNU/Hurd does not yet support
206+ ioctl(SIOCSIFMETRIC), but we let the code
207+ handle this standard ability anyway!
208+ */
209+ case EXPECT_METRIC:
210+ parse_opt_set_metric (*ifp, argv[i]);
211+ break;
212+
213+ case EXPECT_AF:
214+ expect = EXPECT_NOTHING;
215+ if (!strcmp (argv[i], "inet"))
216+ continue;
217+ else if (!strcmp (argv[i], "inet6"))
218+ {
219+ error (0, 0, "%s is not a supported address family", argv[i]);
220+ return 0;
221+ }
222+ break;
223+
224+ case EXPECT_NOTHING:
225+ break;
226+ }
227+
228+ if (expect != EXPECT_NOTHING)
229+ expect = EXPECT_NOTHING;
230+ else if (!strcmp (argv[i], "broadcast"))
231+ expect = EXPECT_BROADCAST;
232+ else if (!strcmp (argv[i], "netmask"))
233+ expect = EXPECT_NETMASK;
234+ else if (!strcmp (argv[i], "metric"))
235+ expect = EXPECT_METRIC;
236+ else if (!strcmp (argv[i], "mtu"))
237+ expect = EXPECT_MTU;
238+ else if (!strcmp (argv[i], "up"))
239+ parse_opt_set_flag (*ifp, IFF_UP | IFF_RUNNING, 0);
240+ else if (!strcmp (argv[i], "down"))
241+ parse_opt_set_flag (*ifp, IFF_UP, 1);
242+ else if (((mask = if_nameztoflag (argv[i], &rev))
243+ & ~IU_IFF_CANTCHANGE) != 0)
244+ parse_opt_set_flag (*ifp, mask, rev);
245+ else
246+ {
247+ if (!((*ifp)->valid & IF_VALID_ADDR))
248+ parse_opt_set_address (*ifp, argv[i]);
249+ else if (!((*ifp)->valid & IF_VALID_DSTADDR))
250+ parse_opt_set_dstaddr (*ifp, argv[i]);
251+ }
252+ }
253+
254+ switch (expect)
255+ {
256+ case EXPECT_BROADCAST:
257+ error (0, 0, "option `broadcast' requires an argument");
258+ break;
259+
260+ case EXPECT_NETMASK:
261+ error (0, 0, "option `netmask' requires an argument");
262+ break;
263+
264+ case EXPECT_METRIC:
265+ error (0, 0, "option `metric' requires an argument");
266+ break;
267+
268+ case EXPECT_MTU:
269+ error (0, 0, "option `mtu' requires an argument");
270+ break;
271+
272+ case EXPECT_AF:
273+ case EXPECT_NOTHING:
274+ return 1;
275+ }
276+
277+ return 0;
278+}
279+
280+int
281+system_configure (int sfd _GL_UNUSED_PARAMETER,
282+ struct ifreq *ifr _GL_UNUSED_PARAMETER,
283+ struct system_ifconfig *ifs _GL_UNUSED_PARAMETER)
284+{
285+ return 0;
286+}
287+
288+struct if_nameindex* (*system_if_nameindex) (void) = if_nameindex;
289+
290+static void
291+print_hwaddr_ether (format_data_t form _GL_UNUSED_PARAMETER,
292+ unsigned char *data)
293+{
294+ *column += printf ("%02X:%02X:%02X:%02X:%02X:%02X",
295+ data[0], data[1], data[2], data[3], data[4], data[5]);
296+ had_output = 1;
297+}
298+
299+struct arphrd_symbol
300+{
301+ const char *name;
302+ const char *title;
303+ int value;
304+ void (*print_hwaddr) (format_data_t form, unsigned char *data);
305+} arphrd_symbols[] =
306+ {
307+#ifdef ARPHRD_ETHER /* Ethernet 10/100Mbps. */
308+ { "ETHER", "Ethernet", ARPHRD_ETHER, print_hwaddr_ether},
309+#endif
310+#ifdef ARPHRD_LOOPBACK /* Loopback device. */
311+ { "LOOPBACK", "Local Loopback", ARPHRD_LOOPBACK, NULL},
312+#endif
313+ /* XXX: The image debian-hurd-20150424 returns the value 4
314+ instead of expected ARPHRD_LOOPBACK. This has been
315+ discussed in the list debian-hurd, where I was asked
316+ to resist the temptation of a work around!
317+ */
318+ { NULL, NULL, 0, NULL}
319+ };
320+
321+struct arphrd_symbol *
322+arphrd_findvalue (int value)
323+{
324+ struct arphrd_symbol *arp = arphrd_symbols;
325+ while (arp->name != NULL)
326+ {
327+ if (arp->value == value)
328+ break;
329+ arp++;
330+ }
331+ if (arp->name)
332+ return arp;
333+ else
334+ return NULL;
335+}
336+
337+void
338+system_fh_hwaddr_query (format_data_t form, int argc, char *argv[])
339+{
340+#ifdef SIOCGIFHWADDR
341+ struct arphrd_symbol *arp;
342+
343+ if (ioctl (form->sfd, SIOCGIFHWADDR, form->ifr) < 0)
344+ select_arg (form, argc, argv, 1);
345+
346+ arp = arphrd_findvalue (form->ifr->ifr_hwaddr.sa_family);
347+ select_arg (form, argc, argv, (arp && arp->print_hwaddr) ? 0 : 1);
348+#else
349+ select_arg (form, argc, argv, 1);
350+#endif
351+}
352+
353+void
354+system_fh_hwaddr (format_data_t form, int argc _GL_UNUSED_PARAMETER,
355+ char *argv[] _GL_UNUSED_PARAMETER)
356+{
357+#ifdef SIOCGIFHWADDR
358+ if (ioctl (form->sfd, SIOCGIFHWADDR, form->ifr) < 0)
359+ error (EXIT_FAILURE, errno,
360+ "SIOCGIFHWADDR failed for interface `%s'",
361+ form->ifr->ifr_name);
362+ else
363+ {
364+ struct arphrd_symbol *arp;
365+
366+ arp = arphrd_findvalue (form->ifr->ifr_hwaddr.sa_family);
367+ if (arp && arp->print_hwaddr)
368+ arp->print_hwaddr (form,
369+ (unsigned char *) form->ifr->ifr_hwaddr.sa_data);
370+ else
371+ put_string (form, "(hwaddr unknown)");
372+ }
373+#else
374+ *column += printf ("(not available)");
375+ had_output = 1;
376+#endif
377+}
378+
379+void
380+system_fh_hwtype_query (format_data_t form, int argc, char *argv[])
381+{
382+#ifdef SIOCGIFHWADDR
383+ if (ioctl (form->sfd, SIOCGIFHWADDR, form->ifr) >= 0)
384+ select_arg (form, argc, argv, 0);
385+ else
386+#endif
387+ select_arg (form, argc, argv, 1);
388+}
389+
390+void
391+system_fh_hwtype (format_data_t form, int argc _GL_UNUSED_PARAMETER,
392+ char *argv[] _GL_UNUSED_PARAMETER)
393+{
394+#ifdef SIOCGIFHWADDR
395+ if (ioctl (form->sfd, SIOCGIFHWADDR, form->ifr) < 0)
396+ error (EXIT_FAILURE, errno,
397+ "SIOCGIFHWADDR failed for interface `%s'",
398+ form->ifr->ifr_name);
399+ else
400+ {
401+ struct arphrd_symbol *arp;
402+
403+ arp = arphrd_findvalue (form->ifr->ifr_hwaddr.sa_family);
404+ if (arp)
405+ put_string (form, arp->title);
406+ else
407+ put_string (form, "(hwtype unknown)");
408+ }
409+#else
410+ *column += printf ("(not available)");
411+ had_output = 1;
412+#endif
413+}
414diff --git a/ifconfig/system/hurd.h b/ifconfig/system/hurd.h
415new file mode 100644
416index 00000000..bab14565
417--- /dev/null
418+++ b/ifconfig/system/hurd.h
419@@ -0,0 +1,50 @@
420+/*
421+ Copyright (C) 2015 Free Software Foundation, Inc.
422+
423+ This file is part of GNU Inetutils.
424+
425+ GNU Inetutils is free software: you can redistribute it and/or modify
426+ it under the terms of the GNU General Public License as published by
427+ the Free Software Foundation, either version 3 of the License, or (at
428+ your option) any later version.
429+
430+ GNU Inetutils is distributed in the hope that it will be useful, but
431+ WITHOUT ANY WARRANTY; without even the implied warranty of
432+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
433+ General Public License for more details.
434+
435+ You should have received a copy of the GNU General Public License
436+ along with this program. If not, see `http://www.gnu.org/licenses/'. */
437+
438+/* Written by Mats Erik Andersson. */
439+
440+#ifndef IFCONFIG_SYSTEM_HURD_H
441+# define IFCONFIG_SYSTEM_HURD_H
442+
443+# include "../printif.h"
444+# include "../options.h"
445+\f
446+
447+/* Option support. */
448+
449+struct system_ifconfig
450+{
451+ int valid;
452+};
453+\f
454+
455+/* Output format support. */
456+
457+# define SYSTEM_FORMAT_HANDLER \
458+ { "hurd", fh_nothing}, \
459+ { "hwaddr?", system_fh_hwaddr_query}, \
460+ { "hwaddr", system_fh_hwaddr}, \
461+ { "hwtype?", system_fh_hwtype_query}, \
462+ { "hwtype", system_fh_hwtype},
463+
464+void system_fh_hwaddr_query (format_data_t form, int argc, char *argv[]);
465+void system_fh_hwaddr (format_data_t form, int argc, char *argv[]);
466+void system_fh_hwtype_query (format_data_t form, int argc, char *argv[]);
467+void system_fh_hwtype (format_data_t form, int argc, char *argv[]);
468+
469+#endif /* !IFCONFIG_SYSTEM_HURD_H */
470--
4712.23.0.rc1.170.gbd704faa3e
472
473From 589dab9c7d3119da82837dabae34c8a3d16cbe49 Mon Sep 17 00:00:00 2001
474From: Mats Erik Andersson <gnu@gisladisker.se>
475Date: Thu, 30 Jul 2015 01:06:42 +0200
476Subject: [PATCH 07/35] ifconfig: Hardware detection in GNU/Hurd.
477
478A work-around needed to distinguish hardware type.
479---
480 ChangeLog | 10 ++++++++++
481 ifconfig/system/hurd.c | 19 ++++++++++++-------
482 2 files changed, 22 insertions(+), 7 deletions(-)
483
484diff --git a/ifconfig/system/hurd.c b/ifconfig/system/hurd.c
485index 3bd19775..b6261a00 100644
486--- a/ifconfig/system/hurd.c
487+++ b/ifconfig/system/hurd.c
488@@ -175,6 +175,16 @@ print_hwaddr_ether (format_data_t form _GL_UNUSED_PARAMETER,
489 had_output = 1;
490 }
491
492+/* GNU/Hurd and Mach are using a mixture of BSD definitions
493+ * and GNU/Linux interface headers, which in this situation
494+ * means that sa_family_t is an unsigned char, from BSD, while
495+ * all ARPHRD_* come from GNU/Linux and are thus 16 bits wide.
496+ * We must account for this. The following bitmask will
497+ * adapt to any future change!
498+ */
499+
500+#define _ARP_MASK ((sizeof (sa_family_t) == 1) ? 0xff : 0xffff)
501+
502 struct arphrd_symbol
503 {
504 const char *name;
505@@ -184,16 +194,11 @@ struct arphrd_symbol
506 } arphrd_symbols[] =
507 {
508 #ifdef ARPHRD_ETHER /* Ethernet 10/100Mbps. */
509- { "ETHER", "Ethernet", ARPHRD_ETHER, print_hwaddr_ether},
510+ { "ETHER", "Ethernet", ARPHRD_ETHER & _ARP_MASK, print_hwaddr_ether},
511 #endif
512 #ifdef ARPHRD_LOOPBACK /* Loopback device. */
513- { "LOOPBACK", "Local Loopback", ARPHRD_LOOPBACK, NULL},
514+ { "LOOPBACK", "Local Loopback", ARPHRD_LOOPBACK & _ARP_MASK, NULL},
515 #endif
516- /* XXX: The image debian-hurd-20150424 returns the value 4
517- instead of expected ARPHRD_LOOPBACK. This has been
518- discussed in the list debian-hurd, where I was asked
519- to resist the temptation of a work around!
520- */
521 { NULL, NULL, 0, NULL}
522 };
523
524--
5252.23.0.rc1.170.gbd704faa3e
526
527From d379784b4461d17b2536effd1b52bae21cd28a32 Mon Sep 17 00:00:00 2001
528From: Guillem Jover <guillem@hadrons.org>
529Date: Fri, 16 Aug 2019 00:34:03 +0200
530Subject: [PATCH 35/35] telnet: Several ioctls have been disabled in the Hurd's
531 glibc
532
533But not the related option macros. inetutils uses those macros to decide
534whether the ioctls are available, so it is FTBFS now. The Hurd's glibc
535is being fixed, but we'll use this for now to get the builds going.
536---
537 telnet/sys_bsd.c | 7 ++++++-
538 1 file changed, 6 insertions(+), 1 deletion(-)
539
540diff --git a/telnet/sys_bsd.c b/telnet/sys_bsd.c
541index 662536ab..5eb35cb5 100644
542--- a/telnet/sys_bsd.c
543+++ b/telnet/sys_bsd.c
544@@ -63,6 +63,7 @@
545 #include <errno.h>
546 #include <arpa/telnet.h>
547 #include <sys/select.h>
548+#include <sys/ioctl.h>
549 #include <unused-parameter.h>
550
551 #include "ring.h"
552@@ -157,7 +158,7 @@ TerminalRead (char *buf, int n)
553 int
554 TerminalAutoFlush (void)
555 {
556-#if defined LNOFLSH
557+#if defined TIOCLGET && defined LNOFLSH
558 int flush;
559
560 ioctl (0, TIOCLGET, (char *) &flush);
561@@ -260,7 +261,9 @@ TerminalSaveState (void)
562 ioctl (0, TIOCGETP, (char *) &ottyb);
563 ioctl (0, TIOCGETC, (char *) &otc);
564 ioctl (0, TIOCGLTC, (char *) &oltc);
565+#ifdef TIOCLGET
566 ioctl (0, TIOCLGET, (char *) &olmode);
567+#endif
568
569 ntc = otc;
570 nltc = oltc;
571@@ -755,7 +758,9 @@ TerminalNewMode (register int f)
572 #endif
573 }
574 #ifndef USE_TERMIO
575+#ifdef TIOCLSET
576 ioctl (tin, TIOCLSET, (char *) &lmode);
577+#endif
578 ioctl (tin, TIOCSLTC, (char *) &ltc);
579 ioctl (tin, TIOCSETC, (char *) &tc);
580 ioctl (tin, TIOCSETN, (char *) &sb);
581--
5822.23.0.rc1.170.gbd704faa3e
583