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