merge with mainline
This commit is contained in:
commit
e9c5186cf8
16 changed files with 593 additions and 99 deletions
|
@ -31,6 +31,8 @@
|
|||
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/util/deviceiter.h>
|
||||
#include <grub/list.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
#ifdef __linux__
|
||||
# if !defined(__GLIBC__) || \
|
||||
|
@ -62,12 +64,23 @@ struct hd_geometry
|
|||
| ((unsigned int) (__dev >> 32) & ~0xfff); \
|
||||
})
|
||||
# endif /* ! MAJOR */
|
||||
# ifndef MINOR
|
||||
# define MINOR(dev) \
|
||||
({ \
|
||||
unsigned long long __dev = (dev); \
|
||||
(unsigned) (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff); \
|
||||
})
|
||||
# endif /* ! MINOR */
|
||||
# ifndef CDROM_GET_CAPABILITY
|
||||
# define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */
|
||||
# endif /* ! CDROM_GET_CAPABILITY */
|
||||
# ifndef BLKGETSIZE
|
||||
# define BLKGETSIZE _IO(0x12,96) /* return device size */
|
||||
# endif /* ! BLKGETSIZE */
|
||||
|
||||
#ifdef HAVE_DEVICE_MAPPER
|
||||
# include <libdevmapper.h>
|
||||
#endif
|
||||
#endif /* __linux__ */
|
||||
|
||||
/* Use __FreeBSD_kernel__ instead of __FreeBSD__ for compatibility with
|
||||
|
@ -411,6 +424,16 @@ check_device (const char *device)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
# ifdef HAVE_DEVICE_MAPPER
|
||||
struct dmraid_seen
|
||||
{
|
||||
struct dmraid_seen *next;
|
||||
const char *name;
|
||||
};
|
||||
# endif /* HAVE_DEVICE_MAPPER */
|
||||
#endif /* __linux__ */
|
||||
|
||||
void
|
||||
grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
|
||||
int floppy_disks)
|
||||
|
@ -643,6 +666,123 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
# ifdef HAVE_DEVICE_MAPPER
|
||||
# define dmraid_check(cond, ...) \
|
||||
if (! (cond)) \
|
||||
{ \
|
||||
grub_dprintf ("deviceiter", __VA_ARGS__); \
|
||||
goto dmraid_end; \
|
||||
}
|
||||
|
||||
/* DM-RAID. */
|
||||
{
|
||||
struct dm_tree *tree = NULL;
|
||||
struct dm_task *task = NULL;
|
||||
struct dm_names *names = NULL;
|
||||
unsigned int next = 0;
|
||||
void *top_handle, *second_handle;
|
||||
struct dm_tree_node *root, *top, *second;
|
||||
struct dmraid_seen *seen = NULL;
|
||||
|
||||
/* Build DM tree for all devices. */
|
||||
tree = dm_tree_create ();
|
||||
dmraid_check (tree, "dm_tree_create failed\n");
|
||||
task = dm_task_create (DM_DEVICE_LIST);
|
||||
dmraid_check (task, "dm_task_create failed\n");
|
||||
dmraid_check (dm_task_run (task), "dm_task_run failed\n");
|
||||
names = dm_task_get_names (task);
|
||||
dmraid_check (names, "dm_task_get_names failed\n");
|
||||
dmraid_check (names->dev, "No DM devices found\n");
|
||||
do
|
||||
{
|
||||
names = (void *) names + next;
|
||||
dmraid_check (dm_tree_add_dev (tree, MAJOR (names->dev),
|
||||
MINOR (names->dev)),
|
||||
"dm_tree_add_dev (%s) failed\n", names->name);
|
||||
next = names->next;
|
||||
}
|
||||
while (next);
|
||||
|
||||
/* Walk the second-level children of the inverted tree; that is, devices
|
||||
which are directly composed of non-DM devices such as hard disks.
|
||||
This class includes all DM-RAID disks and excludes all DM-RAID
|
||||
partitions. */
|
||||
root = dm_tree_find_node (tree, 0, 0);
|
||||
top_handle = NULL;
|
||||
top = dm_tree_next_child (&top_handle, root, 1);
|
||||
while (top)
|
||||
{
|
||||
second_handle = NULL;
|
||||
second = dm_tree_next_child (&second_handle, top, 1);
|
||||
while (second)
|
||||
{
|
||||
const char *node_name, *node_uuid;
|
||||
char *name;
|
||||
struct dmraid_seen *seen_elt;
|
||||
|
||||
node_name = dm_tree_node_get_name (second);
|
||||
dmraid_check (node_name, "dm_tree_node_get_name failed\n");
|
||||
node_uuid = dm_tree_node_get_uuid (second);
|
||||
dmraid_check (node_uuid, "dm_tree_node_get_uuid failed\n");
|
||||
if (strncmp (node_uuid, "DMRAID-", 7) != 0)
|
||||
{
|
||||
grub_dprintf ("deviceiter", "%s is not DM-RAID\n", node_name);
|
||||
goto dmraid_next_child;
|
||||
}
|
||||
|
||||
/* Have we already seen this node? There are typically very few
|
||||
DM-RAID disks, so a list should be fast enough. */
|
||||
if (grub_named_list_find (GRUB_AS_NAMED_LIST (seen), node_name))
|
||||
{
|
||||
grub_dprintf ("deviceiter", "Already seen DM device %s\n",
|
||||
node_name);
|
||||
goto dmraid_next_child;
|
||||
}
|
||||
|
||||
name = xasprintf ("/dev/mapper/%s", node_name);
|
||||
if (check_device (name))
|
||||
{
|
||||
if (hook (name, 0))
|
||||
{
|
||||
free (name);
|
||||
while (seen)
|
||||
{
|
||||
struct dmraid_seen *seen_elt =
|
||||
grub_list_pop (GRUB_AS_LIST_P (&seen));
|
||||
free (seen_elt);
|
||||
}
|
||||
if (task)
|
||||
dm_task_destroy (task);
|
||||
if (tree)
|
||||
dm_tree_free (tree);
|
||||
return;
|
||||
}
|
||||
}
|
||||
free (name);
|
||||
|
||||
seen_elt = xmalloc (sizeof *seen_elt);
|
||||
seen_elt->name = node_name;
|
||||
grub_list_push (GRUB_AS_LIST_P (&seen), GRUB_AS_LIST (seen_elt));
|
||||
|
||||
dmraid_next_child:
|
||||
second = dm_tree_next_child (&second_handle, top, 1);
|
||||
}
|
||||
top = dm_tree_next_child (&top_handle, root, 1);
|
||||
}
|
||||
|
||||
dmraid_end:
|
||||
while (seen)
|
||||
{
|
||||
struct dmraid_seen *seen_elt = grub_list_pop (GRUB_AS_LIST_P (&seen));
|
||||
free (seen_elt);
|
||||
}
|
||||
if (task)
|
||||
dm_task_destroy (task);
|
||||
if (tree)
|
||||
dm_tree_free (tree);
|
||||
}
|
||||
# endif /* HAVE_DEVICE_MAPPER */
|
||||
#endif /* __linux__ */
|
||||
}
|
||||
|
||||
|
|
|
@ -342,7 +342,7 @@ else
|
|||
prefix_drive=`$grub_probe --target=drive --device ${grub_device}` || exit 1
|
||||
fi
|
||||
|
||||
case "${target_cpu}-${platform}"
|
||||
case "${target_cpu}-${platform}" in
|
||||
i386-pc) mkimage_target=i386-pc ;;
|
||||
sparc64-ieee1275) mkimage_target=sparc64-ieee1275-raw ;;
|
||||
mips-yeeloong) mkimage_target=mipsel-yeeloong-elf ;;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/util/deviceiter.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
#define _GNU_SOURCE 1
|
||||
|
@ -38,6 +39,24 @@
|
|||
|
||||
#include "progname.h"
|
||||
|
||||
void
|
||||
grub_putchar (int c)
|
||||
{
|
||||
putchar (c);
|
||||
}
|
||||
|
||||
int
|
||||
grub_getkey (void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
grub_refresh (void)
|
||||
{
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
static void
|
||||
make_device_map (const char *device_map, int floppy_disks)
|
||||
{
|
||||
|
@ -158,6 +177,9 @@ main (int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (verbosity > 1)
|
||||
grub_env_set ("debug", "all");
|
||||
|
||||
make_device_map (dev_map ? : DEFAULT_DEVICE_MAP, floppy_disks);
|
||||
|
||||
free (dev_map);
|
||||
|
|
|
@ -99,6 +99,28 @@ struct image_target_desc image_targets[] =
|
|||
.mod_gap = GRUB_KERNEL_I386_COREBOOT_MOD_GAP,
|
||||
.mod_align = GRUB_KERNEL_I386_COREBOOT_MOD_ALIGN
|
||||
},
|
||||
{
|
||||
.name = "i386-multiboot",
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_COREBOOT,
|
||||
.flags = PLATFORM_FLAGS_NONE,
|
||||
.prefix = GRUB_KERNEL_I386_COREBOOT_PREFIX,
|
||||
.data_end = GRUB_KERNEL_I386_COREBOOT_DATA_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
.link_addr = GRUB_KERNEL_I386_COREBOOT_LINK_ADDR,
|
||||
.elf_target = EM_386,
|
||||
.link_align = 4,
|
||||
.mod_gap = GRUB_KERNEL_I386_COREBOOT_MOD_GAP,
|
||||
.mod_align = GRUB_KERNEL_I386_COREBOOT_MOD_ALIGN
|
||||
},
|
||||
{
|
||||
.name = "i386-pc",
|
||||
.voidp_sizeof = 4,
|
||||
|
@ -1182,7 +1204,7 @@ Make a bootable image of GRUB.\n\
|
|||
\n\
|
||||
Report bugs to <%s>.\n\
|
||||
"),
|
||||
program_name, GRUB_LIBDIR, DEFAULT_DIRECTORY,
|
||||
program_name, GRUB_PKGLIBROOTDIR, DEFAULT_DIRECTORY,
|
||||
formats,
|
||||
PACKAGE_BUGREPORT);
|
||||
free (formats);
|
||||
|
@ -1320,14 +1342,16 @@ main (int argc, char *argv[])
|
|||
last = strchr (last + 1, '-');
|
||||
if (!last)
|
||||
last = image_target->name + strlen (image_target->name);
|
||||
dir = xmalloc (sizeof (GRUB_LIBDIR) + (last - image_target->name));
|
||||
memcpy (dir, GRUB_LIBDIR, sizeof (GRUB_LIBDIR) - 1);
|
||||
memcpy (dir + sizeof (GRUB_LIBDIR) - 1, image_target->name,
|
||||
dir = xmalloc (sizeof (GRUB_PKGLIBROOTDIR) + (last - image_target->name)
|
||||
+ 1);
|
||||
memcpy (dir, GRUB_PKGLIBROOTDIR, sizeof (GRUB_PKGLIBROOTDIR) - 1);
|
||||
*(dir + sizeof (GRUB_PKGLIBROOTDIR) - 1) = '/';
|
||||
memcpy (dir + sizeof (GRUB_PKGLIBROOTDIR), image_target->name,
|
||||
last - image_target->name);
|
||||
*(dir + sizeof (GRUB_LIBDIR) - 1 + (last - image_target->name)) = 0;
|
||||
*(dir + sizeof (GRUB_PKGLIBROOTDIR) + (last - image_target->name)) = 0;
|
||||
}
|
||||
|
||||
generate_image (dir ? : GRUB_LIBDIR, prefix ? : DEFAULT_DIRECTORY, fp,
|
||||
generate_image (dir, prefix ? : DEFAULT_DIRECTORY, fp,
|
||||
argv + optind, memdisk, font, config,
|
||||
image_target, note);
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ grub_mkisofs_arguments="${grub_mkisofs_arguments} --modification-date=$(echo ${i
|
|||
if test -e "${pc_dir}" ; then
|
||||
echo "Enabling BIOS support ..."
|
||||
core_img=`mktemp "$MKTEMP_TEMPLATE"`
|
||||
$grub_mkimage -O i386-pc -d ${pc_dir}/ -O i386-pc -o ${core_img} --prefix=/boot/grub/i386-pc \
|
||||
$grub_mkimage -O i386-pc -d ${pc_dir}/ -o ${core_img} --prefix=/boot/grub/i386-pc \
|
||||
iso9660 biosdisk
|
||||
cat ${pc_dir}/cdboot.img ${core_img} > ${iso9660_dir}/boot/grub/i386-pc/eltorito.img
|
||||
|
||||
|
|
|
@ -35,13 +35,13 @@ all_of_them=true
|
|||
|
||||
# FIXME: add l4 here?
|
||||
kernel=
|
||||
for i in /boot/gnumach.gz /boot/gnumach ; do
|
||||
for i in /boot/gnumach* ; do
|
||||
if test -e $i ; then
|
||||
basename=`basename $i`
|
||||
dirname=`dirname $i`
|
||||
rel_dirname=`make_system_path_relative_to_its_root $dirname`
|
||||
echo "Found GNU Mach: $i" >&2
|
||||
kernel=${rel_dirname}/${basename}
|
||||
kernels="${kernels} ${rel_dirname}/${basename}"
|
||||
at_least_one=true
|
||||
fi
|
||||
done
|
||||
|
@ -71,17 +71,22 @@ if ${all_of_them} && test -e /lib/ld.so.1 ; then : ; else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
cat << EOF
|
||||
menuentry "${OS}" ${CLASS} {
|
||||
for kernel in ${kernels}
|
||||
do
|
||||
kernel_base="`basename "${kernel}"`"
|
||||
KERNEL="using ${kernel_base}"
|
||||
|
||||
cat << EOF
|
||||
menuentry "${OS} ${KERNEL}" ${CLASS} {
|
||||
EOF
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
|
||||
cat << EOF
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading GNU Mach ...")'
|
||||
multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/}
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
|
||||
cat << EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading the Hurd ...")'
|
||||
module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
|
||||
--multiboot-command-line='\${kernel-command-line}' \\
|
||||
|
@ -93,17 +98,17 @@ cat << EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
cat << EOF
|
||||
menuentry "${OS} (recovery mode)" {
|
||||
cat << EOF
|
||||
menuentry "${OS} ${KERNEL} (recovery mode)" ${CLASS} {
|
||||
EOF
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
|
||||
cat << EOF
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading GNU Mach ...")'
|
||||
multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} -s
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
|
||||
cat << EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading the Hurd ...")'
|
||||
module /hurd/${hurd_fs}.static ${hurd_fs} \\
|
||||
--multiboot-command-line='\${kernel-command-line}' \\
|
||||
|
@ -114,3 +119,5 @@ cat << EOF
|
|||
module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
|
||||
}
|
||||
EOF
|
||||
|
||||
done
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/sh -e
|
||||
|
||||
# grub-mkconfig helper script.
|
||||
# Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2008,2009,2010 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
|
||||
|
@ -28,8 +28,8 @@ esac
|
|||
|
||||
# Try C: even if current system is on other partition.
|
||||
case "$SYSTEMDRIVE" in
|
||||
[Cc]:) dirlist="C:" ;;
|
||||
[D-Zd-z]:) dirlist="C: $SYSTEMDRIVE" ;;
|
||||
[Cc]:) drives="C:" ;;
|
||||
[D-Zd-z]:) drives="C: $SYSTEMDRIVE" ;;
|
||||
*) exit 0 ;;
|
||||
esac
|
||||
|
||||
|
@ -51,7 +51,13 @@ get_os_name_from_boot_ini ()
|
|||
}
|
||||
|
||||
|
||||
for dir in $dirlist ; do
|
||||
for drv in $drives ; do
|
||||
|
||||
# Convert to Cygwin path.
|
||||
dir=`cygpath "$drv"`
|
||||
test -n "$dir" || continue
|
||||
|
||||
needmap=
|
||||
|
||||
# Check for Vista bootmgr.
|
||||
if [ -f "$dir"/bootmgr -a -f "$dir"/boot/bcd ] ; then
|
||||
|
@ -60,6 +66,7 @@ for dir in $dirlist ; do
|
|||
# Check for NTLDR.
|
||||
elif [ -f "$dir"/ntldr -a -f "$dir"/ntdetect.com -a -f "$dir"/boot.ini ] ; then
|
||||
OS=`get_os_name_from_boot_ini "$dir"/boot.ini` || OS="Windows NT/2000/XP loader"
|
||||
needmap=t
|
||||
|
||||
else
|
||||
continue
|
||||
|
@ -68,14 +75,16 @@ for dir in $dirlist ; do
|
|||
# Get boot /dev/ice.
|
||||
dev=`${grub_probe} -t device "$dir" 2>/dev/null` || continue
|
||||
|
||||
echo "Found $OS on $dir ($dev)" >&2
|
||||
echo "Found $OS on $drv ($dev)" >&2
|
||||
cat << EOF
|
||||
menuentry "$OS" {
|
||||
EOF
|
||||
|
||||
save_default_entry | sed -e 's,^,\t,'
|
||||
prepare_grub_to_access_device "$dev" | sed 's,^,\t,'
|
||||
|
||||
test -z "$needmap" || cat <<EOF
|
||||
drivemap -s (hd0) \$root
|
||||
EOF
|
||||
cat << EOF
|
||||
chainloader +1
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue