]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Fix FreeBSD compilation.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 8 Nov 2011 18:34:19 +0000 (19:34 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 8 Nov 2011 18:34:19 +0000 (19:34 +0100)
* grub-core/disk/geli.c (GRUB_MD_SHA256) [GRUB_UTIL]: Redefine in a way
to avoid circular dependency.
(GRUB_MD_SHA512) [GRUB_UTIL]: Likewise.
* util/getroot.c (grub_util_follow_gpart_up): Move from here...
* grub-core/kern/emu/hostdisk.c (+grub_util_follow_gpart_up): ... here.

ChangeLog
grub-core/disk/geli.c
grub-core/kern/emu/hostdisk.c
util/getroot.c

index 194bd13fa0a1090b64780eeb4fb80634d35f7c8d..925b798bc5ddd23c42df49c76ed25fb55628b17f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-11-08  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Fix FreeBSD compilation.
+
+       * grub-core/disk/geli.c (GRUB_MD_SHA256) [GRUB_UTIL]: Redefine in a way
+       to avoid circular dependency.
+       (GRUB_MD_SHA512) [GRUB_UTIL]: Likewise.
+       * util/getroot.c (grub_util_follow_gpart_up): Move from here...
+       * grub-core/kern/emu/hostdisk.c (+grub_util_follow_gpart_up): ... here.
+
 2011-11-08  Vladimir Serbinenko  <phcoder@gmail.com>
 
        Fix ZFS crypto error types.
index d2ae5da56feb93ed2fb46d540f967addab9d79ff..ab94b413169c53d9d7d3f70ce728d99db49fe71c 100644 (file)
 
 GRUB_MOD_LICENSE ("GPLv3+");
 
+/* Dirty trick to solve circular dependency.  */
+#ifdef GRUB_UTIL
+
+#include <grub/util/misc.h>
+
+#undef GRUB_MD_SHA256
+#undef GRUB_MD_SHA512
+
+static const gcry_md_spec_t *
+grub_md_sha256_real (void)
+{
+  const gcry_md_spec_t *ret;
+  ret = grub_crypto_lookup_md_by_name ("sha256");
+  if (!ret)
+    grub_util_error ("Coulnd't load sha256");
+  return ret;
+}
+
+static const gcry_md_spec_t *
+grub_md_sha512_real (void)
+{
+  const gcry_md_spec_t *ret;
+  ret = grub_crypto_lookup_md_by_name ("sha512");
+  if (!ret)
+    grub_util_error ("Coulnd't load sha512");
+  return ret;
+}
+
+#define GRUB_MD_SHA256 grub_md_sha256_real()
+#define GRUB_MD_SHA512 grub_md_sha512_real()
+#endif
+
 struct grub_geli_key
 {
   grub_uint8_t iv_key[64];
index 7074fa8c11d451e26522b0bc2344869935642c84..7bfc66fefbdc54c9d91ab17e4a8ac320332de15c 100644 (file)
@@ -94,6 +94,8 @@ struct hd_geometry
 # include <sys/disk.h> /* DIOCGMEDIASIZE */
 # include <sys/param.h>
 # include <sys/sysctl.h>
+# include <sys/mount.h>
+#include <libgeom.h>
 # define MAJOR(dev) major(dev)
 # define FLOPPY_MAJOR  2
 #endif
@@ -423,8 +425,59 @@ grub_util_device_is_mapped (const char *dev)
 #endif /* HAVE_DEVICE_MAPPER */
 }
 
+
 #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
 
+/* FIXME: geom actually gives us the whole container hierarchy.
+   It can be used more efficiently than this.  */
+void
+grub_util_follow_gpart_up (const char *name, grub_disk_addr_t *off_out, char **name_out)
+{
+  struct gmesh mesh;
+  struct gclass *class;
+  int error;
+  struct ggeom *geom;
+
+  grub_util_info ("following geom '%s'", name);
+
+  error = geom_gettree (&mesh);
+  if (error != 0)
+    grub_util_error ("couldn't open geom");
+
+  LIST_FOREACH (class, &mesh.lg_class, lg_class)
+    if (strcasecmp (class->lg_name, "part") == 0)
+      break;
+  if (!class)
+    grub_util_error ("couldn't open geom part");
+
+  LIST_FOREACH (geom, &class->lg_geom, lg_geom)
+    { 
+      struct gprovider *provider;
+      LIST_FOREACH (provider, &geom->lg_provider, lg_provider)
+       if (strcmp (provider->lg_name, name) == 0)
+         {
+           char *name_tmp = xstrdup (geom->lg_name);
+           grub_disk_addr_t off = 0;
+           struct gconfig *config;
+           grub_util_info ("geom '%s' has parent '%s'", name, geom->lg_name);
+
+           grub_util_follow_gpart_up (name_tmp, &off, name_out);
+           free (name_tmp);
+           LIST_FOREACH (config, &provider->lg_config, lg_config)
+             if (strcasecmp (config->lg_name, "start") == 0)
+               off += strtoull (config->lg_val, 0, 10);
+           if (off_out)
+             *off_out = off;
+           return;
+         }
+    }
+  grub_util_info ("geom '%s' has no parent", name);
+  if (name_out)
+    *name_out = xstrdup (name);
+  if (off_out)
+    *off_out = 0;
+}
+
 static grub_disk_addr_t
 find_partition_start (const char *dev)
 {
index 8fce283bc2d5b3d680f520c39981cd3d2e3fd650..41fbdec10305217a0370823f1bd5b9f805b4b1a2 100644 (file)
@@ -790,56 +790,6 @@ grub_util_get_dm_abstraction (const char *os_dev)
 #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include <libgeom.h>
 
-/* FIXME: geom actually gives us the whole container hierarchy.
-   It can be used more efficiently than this.  */
-void
-grub_util_follow_gpart_up (const char *name, grub_disk_addr_t *off_out, char **name_out)
-{
-  struct gmesh mesh;
-  struct gclass *class;
-  int error;
-  struct ggeom *geom;
-
-  grub_util_info ("following geom '%s'", name);
-
-  error = geom_gettree (&mesh);
-  if (error != 0)
-    grub_util_error ("couldn't open geom");
-
-  LIST_FOREACH (class, &mesh.lg_class, lg_class)
-    if (strcasecmp (class->lg_name, "part") == 0)
-      break;
-  if (!class)
-    grub_util_error ("couldn't open geom part");
-
-  LIST_FOREACH (geom, &class->lg_geom, lg_geom)
-    { 
-      struct gprovider *provider;
-      LIST_FOREACH (provider, &geom->lg_provider, lg_provider)
-       if (strcmp (provider->lg_name, name) == 0)
-         {
-           char *name_tmp = xstrdup (geom->lg_name);
-           grub_disk_addr_t off = 0;
-           struct gconfig *config;
-           grub_util_info ("geom '%s' has parent '%s'", name, geom->lg_name);
-
-           grub_util_follow_gpart_up (name_tmp, &off, name_out);
-           free (name_tmp);
-           LIST_FOREACH (config, &provider->lg_config, lg_config)
-             if (strcasecmp (config->lg_name, "start") == 0)
-               off += strtoull (config->lg_val, 0, 10);
-           if (off_out)
-             *off_out = off;
-           return;
-         }
-    }
-  grub_util_info ("geom '%s' has no parent", name);
-  if (name_out)
-    *name_out = xstrdup (name);
-  if (off_out)
-    *off_out = 0;
-}
-
 static const char *
 grub_util_get_geom_abstraction (const char *dev)
 {