Blame SOURCES/0045-Fix-grub-emu-build-on-FreeBSD.patch

f96e0b
From b37a32bb89c476b0ead4c40900de29fe8d73d27e Mon Sep 17 00:00:00 2001
f96e0b
From: Colin Watson <cjwatson@ubuntu.com>
f96e0b
Date: Sat, 22 Sep 2012 21:19:58 +0100
f96e0b
Subject: [PATCH 045/482] Fix grub-emu build on FreeBSD.
f96e0b
f96e0b
* Makefile.util.def (grub-mount): Add LIBGEOM to ldadd.
f96e0b
* grub-core/net/drivers/emu/emunet.c: Only include Linux-specific
f96e0b
headers on Linux.
f96e0b
(GRUB_MOD_INIT): Return immediately on non-Linux platforms; this
f96e0b
implementation is currently Linux-specific.
f96e0b
* util/getroot.c (exec_pipe): Define only on Linux or when either
f96e0b
libzfs or libnvpair is unavailable.
f96e0b
(find_root_devices_from_poolname): Remove unused path variable.
f96e0b
---
f96e0b
 ChangeLog                          | 13 +++++++++++++
f96e0b
 Makefile.util.def                  |  2 +-
f96e0b
 grub-core/net/drivers/emu/emunet.c | 11 +++++++++--
f96e0b
 util/getroot.c                     |  7 ++++++-
f96e0b
 4 files changed, 29 insertions(+), 4 deletions(-)
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index 5db804e..3eda38f 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,3 +1,16 @@
f96e0b
+2012-09-22  Colin Watson  <cjwatson@ubuntu.com>
f96e0b
+
f96e0b
+	Fix grub-emu build on FreeBSD.
f96e0b
+
f96e0b
+	* Makefile.util.def (grub-mount): Add LIBGEOM to ldadd.
f96e0b
+	* grub-core/net/drivers/emu/emunet.c: Only include Linux-specific
f96e0b
+	headers on Linux.
f96e0b
+	(GRUB_MOD_INIT): Return immediately on non-Linux platforms; this
f96e0b
+	implementation is currently Linux-specific.
f96e0b
+	* util/getroot.c (exec_pipe): Define only on Linux or when either
f96e0b
+	libzfs or libnvpair is unavailable.
f96e0b
+	(find_root_devices_from_poolname): Remove unused path variable.
f96e0b
+
f96e0b
 2012-09-19  Colin Watson  <cjwatson@ubuntu.com>
f96e0b
 
f96e0b
 	* grub-core/partmap/msdos.c (pc_partition_map_embed): Revert
f96e0b
diff --git a/Makefile.util.def b/Makefile.util.def
f96e0b
index b80187c..72057cf 100644
f96e0b
--- a/Makefile.util.def
f96e0b
+++ b/Makefile.util.def
f96e0b
@@ -266,7 +266,7 @@ program = {
f96e0b
   ldadd = libgrubgcry.a;
f96e0b
   ldadd = libgrubkern.a;
f96e0b
   ldadd = grub-core/gnulib/libgnu.a;
f96e0b
-  ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) -lfuse';
f96e0b
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM) -lfuse';
f96e0b
   condition = COND_GRUB_MOUNT;
f96e0b
 };
f96e0b
 
f96e0b
diff --git a/grub-core/net/drivers/emu/emunet.c b/grub-core/net/drivers/emu/emunet.c
f96e0b
index 7a7aeaf..6b533dd 100644
f96e0b
--- a/grub-core/net/drivers/emu/emunet.c
f96e0b
+++ b/grub-core/net/drivers/emu/emunet.c
f96e0b
@@ -21,8 +21,10 @@
f96e0b
 #include <sys/socket.h>
f96e0b
 #include <grub/net.h>
f96e0b
 #include <sys/types.h>
f96e0b
-#include <linux/if.h>
f96e0b
-#include <linux/if_tun.h>
f96e0b
+#ifdef __linux__
f96e0b
+# include <linux/if.h>
f96e0b
+# include <linux/if_tun.h>
f96e0b
+#endif /* __linux__ */
f96e0b
 #include <sys/ioctl.h>
f96e0b
 #include <fcntl.h>
f96e0b
 #include <unistd.h>
f96e0b
@@ -97,6 +99,7 @@ static struct grub_net_card emucard =
f96e0b
 
f96e0b
 GRUB_MOD_INIT(emunet)
f96e0b
 {
f96e0b
+#ifdef __linux__
f96e0b
   struct ifreq ifr;
f96e0b
   fd = open ("/dev/net/tun", O_RDWR | O_NONBLOCK);
f96e0b
   if (fd < 0)
f96e0b
@@ -110,6 +113,10 @@ GRUB_MOD_INIT(emunet)
f96e0b
       return;
f96e0b
     }
f96e0b
   grub_net_card_register (&emucard);
f96e0b
+#else /* !__linux__ */
f96e0b
+  fd = -1;
f96e0b
+  return;
f96e0b
+#endif /* __linux__ */
f96e0b
 }
f96e0b
 
f96e0b
 GRUB_MOD_FINI(emunet)
f96e0b
diff --git a/util/getroot.c b/util/getroot.c
f96e0b
index b97bea6..c2a25c9 100644
f96e0b
--- a/util/getroot.c
f96e0b
+++ b/util/getroot.c
f96e0b
@@ -220,6 +220,9 @@ xgetcwd (void)
f96e0b
 
f96e0b
 #if !defined (__MINGW32__) && !defined (__CYGWIN__) && !defined (__GNU__)
f96e0b
 
f96e0b
+#if (defined (__linux__) || \
f96e0b
+     !defined (HAVE_LIBZFS) || !defined (HAVE_LIBNVPAIR))
f96e0b
+
f96e0b
 static pid_t
f96e0b
 exec_pipe (char **argv, int *fd)
f96e0b
 {
f96e0b
@@ -258,6 +261,8 @@ exec_pipe (char **argv, int *fd)
f96e0b
     }
f96e0b
 }
f96e0b
 
f96e0b
+#endif
f96e0b
+
f96e0b
 static char **
f96e0b
 find_root_devices_from_poolname (char *poolname)
f96e0b
 {
f96e0b
@@ -269,7 +274,7 @@ find_root_devices_from_poolname (char *poolname)
f96e0b
   zpool_handle_t *zpool;
f96e0b
   libzfs_handle_t *libzfs;
f96e0b
   nvlist_t *config, *vdev_tree;
f96e0b
-  nvlist_t **children, **path;
f96e0b
+  nvlist_t **children;
f96e0b
   unsigned int nvlist_count;
f96e0b
   unsigned int i;
f96e0b
   char *device = 0;
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b