+2007-05-16 Jeroen Dekkers <jeroen@dekkers.cx>
+
+ * util/getroot.c (grub_guess_root_device): Remove RAID and LVM
+ code, first search for device in /dev/mapper, then in /dev.
+ (grub_util_get_grub_dev): New function.
+ * include/grub/util/getroot.h (grub_util_get_grub_dev): Add
+ prototype.
+ * util/grub-probe.c (probe): Remove check for RAID, call
+ grub_util_get_grub_dev() instead of
+ grub_util_biosdisk_get_grub_dev().
+ * util/grub-emu.c (main): Call grub_util_get_grub_dev() instead of
+ grub_util_biosdisk_get_grub_dev().
+ * util/i386/pc/grub-setup.c (main): Likewise.
+
2007-05-16 Robert Millan <rmh@aybabtu.com>
* DISTLIST: Update for the latest changes.
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2003 Free Software Foundation, Inc.
+ * Copyright (C) 2003, 2007 Free Software Foundation, Inc.
*
* GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
char *grub_guess_root_device (const char *dir);
char *grub_get_prefix (const char *dir);
+char *grub_util_get_grub_dev (const char *os_dev);
#endif /* ! GRUB_UTIL_GETROOT_HEADER */
/* getroot.c - Get root device */
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 1999,2000,2001,2002,2003,2006 Free Software Foundation, Inc.
+ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007 Free Software Foundation, Inc.
*
* GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
if (stat (dir, &st) < 0)
grub_util_error ("Cannot stat `%s'", dir);
- /* This might be truly slow, but is there any better way? */
- os_dev = find_root_device ("/dev", st.st_dev);
- if (! os_dev)
- return 0;
-
#ifdef __linux__
+ /* We first try to find the device in the /dev/mapper directory. If
+ we don't do this, we get useless device names like /dev/dm-0 for
+ LVM. */
+ os_dev = find_root_device ("/dev/mapper", st.st_dev);
+ if (!os_dev)
+#endif __linux_
+ {
+ /* This might be truly slow, but is there any better way? */
+ os_dev = find_root_device ("/dev", st.st_dev);
+ }
+
+ return os_dev;
+}
+
+char *
+grub_util_get_grub_dev (const char *os_dev)
+{
/* Check for LVM. */
if (!strncmp (os_dev, "/dev/mapper/", 12))
{
- char *grub_dev = xmalloc (strlen (os_dev) - 12);
+ char *grub_dev = xmalloc (strlen (os_dev) - 12 + 1);
strcpy (grub_dev, os_dev+12);
return grub_dev;
}
+ /* Check for RAID. */
if (!strncmp (os_dev, "/dev/md", 7))
{
char *p, *grub_dev = xmalloc (8);
p = strchr (os_dev, 'm');
- strncpy (grub_dev, p, 8);
+ memcpy (grub_dev, p, 7);
+ grub_dev[7] = '\0';
return grub_dev;
}
-#endif
-
- return os_dev;
+
+ /* If it's not RAID or LVM, it should be a biosdisk. */
+ return grub_util_biosdisk_get_grub_dev (os_dev);
}
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2003,2004,2005,2006 Free Software Foundation, Inc.
+ * Copyright (C) 2003,2004,2005,2006,2007 Free Software Foundation, Inc.
*
* GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/* Make sure that there is a root device. */
if (! args.root_dev)
{
- args.root_dev = grub_util_biosdisk_get_grub_dev (grub_guess_root_device (args.dir ? : DEFAULT_DIRECTORY));
+ args.root_dev = grub_util_get_grub_dev (grub_guess_root_device (args.dir ? : DEFAULT_DIRECTORY));
if (! args.root_dev)
{
grub_util_info ("guessing the root device failed, because of `%s'",
/* grub-probe.c - probe device information for a given path */
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2005,2006 Free Software Foundation, Inc.
+ * Copyright (C) 2005,2006,2007 Free Software Foundation, Inc.
*
* GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
goto end;
}
- if (device_name[0] == 'm' && device_name[1] == 'd'
- && device_name[2] >= '0' && device_name[2] <= '9')
+ drive_name = grub_util_get_grub_dev (device_name);
+ if (! drive_name)
{
- drive_name = xstrdup (device_name);
- }
- else
- {
- drive_name = grub_util_biosdisk_get_grub_dev (device_name);
- if (! drive_name)
- {
- fprintf (stderr, "cannot find a GRUB drive for %s.\n", device_name);
- goto end;
- }
+ fprintf (stderr, "cannot find a GRUB drive for %s.\n", device_name);
+ goto end;
}
if (print == PRINT_DRIVE)
if (! dest_dev)
{
/* Possibly, the user specified an OS device file. */
- dest_dev = grub_util_biosdisk_get_grub_dev (argv[optind]);
+ dest_dev = grub_util_get_grub_dev (argv[optind]);
if (! dest_dev)
{
fprintf (stderr, "Invalid device `%s'.\n", argv[optind]);
}
else
{
- root_dev = grub_util_biosdisk_get_grub_dev (grub_guess_root_device (dir ? : DEFAULT_DIRECTORY));
+ root_dev = grub_util_get_grub_dev (grub_guess_root_device (dir ? : DEFAULT_DIRECTORY));
if (! root_dev)
{
grub_util_info ("guessing the root device failed, because of `%s'",
dir ? : DEFAULT_DIRECTORY,
boot_file ? : DEFAULT_BOOT_FILE,
core_file ? : DEFAULT_CORE_FILE,
- root_dev, grub_util_biosdisk_get_grub_dev (devicelist[i]), 1);
+ root_dev, grub_util_get_grub_dev (devicelist[i]), 1);
}
free (raid_prefix);