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.
This commit is contained in:
parent
4a19b6017d
commit
27610c3836
4 changed files with 95 additions and 50 deletions
10
ChangeLog
10
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.
|
||||
|
|
|
@ -58,6 +58,38 @@
|
|||
|
||||
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];
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue