* kern/emu/misc.c (device_mapper_null_log): New function.
(grub_device_mapper_supported): New function. * include/grub/emu/misc.h (grub_device_mapper_supported): Add prototype. * kern/emu/hostdisk.c (find_partition_start): Check whether device-mapper is supported before trying to use it. * util/deviceiter.c (grub_util_iterate_devices): Likewise.
This commit is contained in:
parent
da90820083
commit
e0f4c43882
5 changed files with 152 additions and 97 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2010-06-07 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* kern/emu/misc.c (device_mapper_null_log): New function.
|
||||
(grub_device_mapper_supported): New function.
|
||||
* include/grub/emu/misc.h (grub_device_mapper_supported): Add
|
||||
prototype.
|
||||
* kern/emu/hostdisk.c (find_partition_start): Check whether
|
||||
device-mapper is supported before trying to use it.
|
||||
* util/deviceiter.c (grub_util_iterate_devices): Likewise.
|
||||
|
||||
2010-06-07 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* docs/grub.texi (Naming convention): Use GRUB 2 syntax.
|
||||
|
|
|
@ -48,4 +48,8 @@ int EXPORT_FUNC(asprintf) (char **buf, const char *fmt, ...);
|
|||
char * EXPORT_FUNC(xasprintf) (const char *fmt, ...);
|
||||
extern char * canonicalize_file_name (const char *path);
|
||||
|
||||
#ifdef HAVE_DEVICE_MAPPER
|
||||
int grub_device_mapper_supported (void);
|
||||
#endif
|
||||
|
||||
#endif /* GRUB_EMU_MISC_H */
|
||||
|
|
|
@ -342,7 +342,7 @@ find_partition_start (const char *dev)
|
|||
# endif /* !defined(__NetBSD__) */
|
||||
|
||||
# ifdef HAVE_DEVICE_MAPPER
|
||||
if (device_is_mapped (dev)) {
|
||||
if (grub_device_mapper_supported () && device_is_mapped (dev)) {
|
||||
struct dm_task *task = NULL;
|
||||
grub_uint64_t start, length;
|
||||
char *target_type, *params, *space;
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
#include <grub/time.h>
|
||||
#include <grub/emu/misc.h>
|
||||
|
||||
#ifdef HAVE_DEVICE_MAPPER
|
||||
# include <libdevmapper.h>
|
||||
#endif
|
||||
|
||||
int verbosity;
|
||||
|
||||
void
|
||||
|
@ -311,3 +315,38 @@ grub_make_system_path_relative_to_its_root (const char *path)
|
|||
|
||||
return buf3;
|
||||
}
|
||||
|
||||
#ifdef HAVE_DEVICE_MAPPER
|
||||
static void device_mapper_null_log (int level __attribute__ ((unused)),
|
||||
const char *file __attribute__ ((unused)),
|
||||
int line __attribute__ ((unused)),
|
||||
int dm_errno __attribute__ ((unused)),
|
||||
const char *f __attribute__ ((unused)),
|
||||
...)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
grub_device_mapper_supported (void)
|
||||
{
|
||||
static int supported = -1;
|
||||
|
||||
if (supported == -1)
|
||||
{
|
||||
struct dm_task *dmt;
|
||||
|
||||
/* Suppress annoying log messages. */
|
||||
dm_log_with_errno_init (&device_mapper_null_log);
|
||||
|
||||
dmt = dm_task_create (DM_DEVICE_VERSION);
|
||||
supported = (dmt != NULL);
|
||||
if (dmt)
|
||||
dm_task_destroy (dmt);
|
||||
|
||||
/* Restore the original logger. */
|
||||
dm_log_with_errno_init (NULL);
|
||||
}
|
||||
|
||||
return supported;
|
||||
}
|
||||
#endif /* HAVE_DEVICE_MAPPER */
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <grub/util/deviceiter.h>
|
||||
#include <grub/list.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/emu/misc.h>
|
||||
|
||||
#ifdef __linux__
|
||||
# if !defined(__GLIBC__) || \
|
||||
|
@ -676,6 +677,7 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
|
|||
}
|
||||
|
||||
/* DM-RAID. */
|
||||
if (grub_device_mapper_supported ())
|
||||
{
|
||||
struct dm_tree *tree = NULL;
|
||||
struct dm_task *task = NULL;
|
||||
|
|
Loading…
Add table
Reference in a new issue