merge with mainline
This commit is contained in:
commit
163dd4f7e9
63 changed files with 3999 additions and 1439 deletions
|
@ -467,13 +467,30 @@ clear_seen_devices (void)
|
|||
}
|
||||
|
||||
#ifdef __linux__
|
||||
/* Like strcmp, but doesn't require a cast for use as a qsort comparator. */
|
||||
static int
|
||||
compare_file_names (const void *a, const void *b)
|
||||
struct device
|
||||
{
|
||||
const char *left = *(const char **) a;
|
||||
const char *right = *(const char **) b;
|
||||
return strcmp (left, right);
|
||||
char *stable;
|
||||
char *kernel;
|
||||
};
|
||||
|
||||
/* Sort by the kernel name for preference since that most closely matches
|
||||
older device.map files, but sort by stable by-id names as a fallback.
|
||||
This is because /dev/disk/by-id/ usually has a few alternative
|
||||
identifications of devices (e.g. ATA vs. SATA).
|
||||
check_device_readable_unique will ensure that we only get one for any
|
||||
given disk, but sort the list so that the choice of which one we get is
|
||||
stable. */
|
||||
static int
|
||||
compare_devices (const void *a, const void *b)
|
||||
{
|
||||
const struct device *left = (const struct device *) a;
|
||||
const struct device *right = (const struct device *) b;
|
||||
int ret;
|
||||
ret = strcmp (left->kernel, right->kernel);
|
||||
if (ret)
|
||||
return ret;
|
||||
else
|
||||
return strcmp (left->stable, right->stable);
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
|
||||
|
@ -507,10 +524,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
|
|||
if (dir)
|
||||
{
|
||||
struct dirent *entry;
|
||||
char **names;
|
||||
size_t names_len = 0, names_max = 1024, i;
|
||||
struct device *devs;
|
||||
size_t devs_len = 0, devs_max = 1024, i;
|
||||
|
||||
names = xmalloc (names_max * sizeof (*names));
|
||||
devs = xmalloc (devs_max * sizeof (*devs));
|
||||
|
||||
/* Dump all the directory entries into names, resizing if
|
||||
necessary. */
|
||||
|
@ -526,35 +543,34 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
|
|||
/* Skip RAID entries; they are handled by upper layers. */
|
||||
if (strncmp (entry->d_name, "md-", sizeof ("md-") - 1) == 0)
|
||||
continue;
|
||||
if (names_len >= names_max)
|
||||
if (devs_len >= devs_max)
|
||||
{
|
||||
names_max *= 2;
|
||||
names = xrealloc (names, names_max * sizeof (*names));
|
||||
devs_max *= 2;
|
||||
devs = xrealloc (devs, devs_max * sizeof (*devs));
|
||||
}
|
||||
names[names_len++] = xasprintf (entry->d_name);
|
||||
devs[devs_len].stable =
|
||||
xasprintf ("/dev/disk/by-id/%s", entry->d_name);
|
||||
devs[devs_len].kernel =
|
||||
canonicalize_file_name (devs[devs_len].stable);
|
||||
devs_len++;
|
||||
}
|
||||
|
||||
/* /dev/disk/by-id/ usually has a few alternative identifications of
|
||||
devices (e.g. ATA vs. SATA). check_device_readable_unique will
|
||||
ensure that we only get one for any given disk, but sort the list
|
||||
so that the choice of which one we get is stable. */
|
||||
qsort (names, names_len, sizeof (*names), &compare_file_names);
|
||||
qsort (devs, devs_len, sizeof (*devs), &compare_devices);
|
||||
|
||||
closedir (dir);
|
||||
|
||||
/* Now add all the devices in sorted order. */
|
||||
for (i = 0; i < names_len; ++i)
|
||||
for (i = 0; i < devs_len; ++i)
|
||||
{
|
||||
char *path = xasprintf ("/dev/disk/by-id/%s", names[i]);
|
||||
if (check_device_readable_unique (path))
|
||||
if (check_device_readable_unique (devs[i].stable))
|
||||
{
|
||||
if (hook (path, 0))
|
||||
if (hook (devs[i].stable, 0))
|
||||
goto out;
|
||||
}
|
||||
free (path);
|
||||
free (names[i]);
|
||||
free (devs[i].stable);
|
||||
free (devs[i].kernel);
|
||||
}
|
||||
free (names);
|
||||
free (devs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
|
|||
sz = grub_file_read (file, buf, (len > BUF_SIZE) ? BUF_SIZE : len);
|
||||
if (sz < 0)
|
||||
{
|
||||
grub_util_error ("read error at offset %llu", ofs);
|
||||
grub_util_error ("read error at offset %llu: %s", ofs, grub_errmsg);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ cmd_cmp (char *src, char *dest)
|
|||
{
|
||||
if ((int) fread (buf_1, 1, len, ff) != len)
|
||||
{
|
||||
grub_util_error ("read error at offset %llu", ofs);
|
||||
grub_util_error ("read error at offset %llu: %s", ofs, grub_errmsg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ main (int argc, char **argv)
|
|||
fclose (in);
|
||||
fclose (out);
|
||||
free (buf);
|
||||
printf ("Invalid Mach-O fle\n");
|
||||
printf ("Invalid Mach-O file\n");
|
||||
return 4;
|
||||
}
|
||||
curcmd = (struct grub_macho_segment32 *) (buf + sizeof (*head));
|
||||
|
|
|
@ -296,6 +296,7 @@ if test -e "${efi64_dir}" || test -e "${efi32_dir}"; then
|
|||
|
||||
mformat -C -f 2880 -L 16 -i "${iso9660_dir}"/efi.img ::
|
||||
mcopy -s -i "${iso9660_dir}"/efi.img ${efi_dir}/efi ::/
|
||||
rm -rf ${efi_dir}
|
||||
grub_mkisofs_arguments="${grub_mkisofs_arguments} --efi-boot efi.img"
|
||||
fi
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
enum {
|
||||
PRINT_FS,
|
||||
PRINT_FS_UUID,
|
||||
PRINT_FS_LABEL,
|
||||
PRINT_DRIVE,
|
||||
PRINT_DEVICE,
|
||||
PRINT_PARTMAP,
|
||||
|
@ -291,6 +292,16 @@ probe (const char *path, char *device_name)
|
|||
|
||||
printf ("%s\n", uuid);
|
||||
}
|
||||
else if (print == PRINT_FS_LABEL)
|
||||
{
|
||||
char *label;
|
||||
if (! fs->label)
|
||||
grub_util_error ("%s does not support labels", fs->name);
|
||||
|
||||
fs->label (dev, &label);
|
||||
|
||||
printf ("%s\n", label);
|
||||
}
|
||||
|
||||
end:
|
||||
if (dev)
|
||||
|
@ -326,7 +337,7 @@ Probe device information for a given path (or device, if the -d option is given)
|
|||
\n\
|
||||
-d, --device given argument is a system device, not a path\n\
|
||||
-m, --device-map=FILE use FILE as the device map [default=%s]\n\
|
||||
-t, --target=(fs|fs_uuid|drive|device|partmap|abstraction)\n\
|
||||
-t, --target=(fs|fs_uuid|fs_label|drive|device|partmap|abstraction)\n\
|
||||
print filesystem module, GRUB drive, system device, partition map module or abstraction module [default=fs]\n\
|
||||
-h, --help display this message and exit\n\
|
||||
-V, --version print version information and exit\n\
|
||||
|
@ -375,6 +386,8 @@ main (int argc, char *argv[])
|
|||
print = PRINT_FS;
|
||||
else if (!strcmp (optarg, "fs_uuid"))
|
||||
print = PRINT_FS_UUID;
|
||||
else if (!strcmp (optarg, "fs_label"))
|
||||
print = PRINT_FS_LABEL;
|
||||
else if (!strcmp (optarg, "drive"))
|
||||
print = PRINT_DRIVE;
|
||||
else if (!strcmp (optarg, "device"))
|
||||
|
|
|
@ -73,7 +73,6 @@ grub_script_shift (grub_command_t cmd __attribute__((unused)),
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
grub_script_execute_argument_to_string (struct grub_script_arg *arg __attribute__ ((unused)))
|
||||
{
|
||||
|
|
|
@ -137,11 +137,7 @@ case x${GRUB_TERMINAL_INPUT} in
|
|||
;;
|
||||
x*)
|
||||
cat << EOF
|
||||
if terminal_input ${GRUB_TERMINAL_INPUT} ; then true ; else
|
||||
# For backward compatibility with versions of terminal.mod that don't
|
||||
# understand terminal_input
|
||||
terminal ${GRUB_TERMINAL_INPUT}
|
||||
fi
|
||||
terminal_input ${GRUB_TERMINAL_INPUT}
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
|
@ -152,11 +148,7 @@ case x${GRUB_TERMINAL_OUTPUT} in
|
|||
;;
|
||||
x*)
|
||||
cat << EOF
|
||||
if terminal_output ${GRUB_TERMINAL_OUTPUT} ; then true ; else
|
||||
# For backward compatibility with versions of terminal.mod that don't
|
||||
# understand terminal_output
|
||||
terminal ${GRUB_TERMINAL_OUTPUT}
|
||||
fi
|
||||
terminal_output ${GRUB_TERMINAL_OUTPUT}
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -51,6 +51,10 @@ kfreebsd_entry ()
|
|||
if [ -z "${prepare_boot_cache}" ]; then
|
||||
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
|
||||
fi
|
||||
if [ -z "${prepare_module_dir_cache}" ]; then
|
||||
prepare_module_dir_cache="$(prepare_grub_to_access_device $(grub-probe -t device "${module_dir}") | sed -e "s/^/\t/")"
|
||||
fi
|
||||
|
||||
printf '%s\n' "${prepare_boot_cache}"
|
||||
cat << EOF
|
||||
echo '$(printf "$(gettext_quoted "Loading kernel of FreeBSD %s ...")" ${version})'
|
||||
|
@ -63,14 +67,35 @@ EOF
|
|||
EOF
|
||||
fi
|
||||
|
||||
if test -n "${acpi_ko}" ; then
|
||||
if test -e "${module_dir}/acpi.ko" ; then
|
||||
printf '%s\n' "${prepare_module_dir_cache}"
|
||||
cat << EOF
|
||||
kfreebsd_module_elf ${acpi_ko_rel_dirname}/${acpi_ko_basename}
|
||||
kfreebsd_module_elf ${module_dir_rel}/acpi.ko
|
||||
EOF
|
||||
fi
|
||||
|
||||
case "${kfreebsd_fs}" in
|
||||
zfs)
|
||||
for i in "${module_dir}/opensolaris.ko" "${module_dir}/zfs.ko" \
|
||||
"${dirname}/zfs/zpool.cache" ; do
|
||||
ls "$i" > /dev/null
|
||||
done
|
||||
|
||||
printf '%s\n' "${prepare_module_dir_cache}"
|
||||
cat << EOF
|
||||
kfreebsd_module_elf ${module_dir_rel}/opensolaris.ko
|
||||
kfreebsd_module_elf ${module_dir_rel}/zfs.ko
|
||||
EOF
|
||||
|
||||
printf '%s\n' "${prepare_boot_cache}"
|
||||
cat << EOF
|
||||
set kFreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${GRUB_DEVICE}
|
||||
kfreebsd_module ${rel_dirname}/zfs/zpool.cache type=/boot/zfs/zpool.cache
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
|
||||
cat << EOF
|
||||
set kFreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${kfreebsd_device}
|
||||
set kFreeBSD.vfs.root.mountfrom.options=rw
|
||||
}
|
||||
EOF
|
||||
|
@ -100,22 +125,25 @@ while [ "x$list" != "x" ] ; do
|
|||
*) kfreebsd_fs=${GRUB_FS} ;;
|
||||
esac
|
||||
|
||||
case ${GRUB_FS} in
|
||||
zfs) kfreebsd_device=$(grub-probe -t fs_label --device ${GRUB_DEVICE}) ;;
|
||||
*) kfreebsd_device=${GRUB_DEVICE} ;;
|
||||
esac
|
||||
|
||||
version=`echo $basename | sed -e "s,^[^0-9]*-,,g;s/\.gz$//g"`
|
||||
alt_version=`echo $version | sed -e "s,\.old$,,g"`
|
||||
|
||||
acpi_ko=
|
||||
for i in "/lib/modules/${version}/acpi.ko" "/lib/modules/${alt_version}/acpi.ko" \
|
||||
"/boot/kernel/acpi.ko"; do
|
||||
module_dir=
|
||||
for i in "/lib/modules/${version}" "/lib/modules/${alt_version}" \
|
||||
"/boot/kernel"; do
|
||||
if test -e "$i" ; then
|
||||
acpi_ko="$i"
|
||||
module_dir="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -n "${acpi_ko}" ; then
|
||||
echo "Found ACPI module: ${acpi_ko}" >&2
|
||||
acpi_ko_basename=`basename ${acpi_ko}`
|
||||
acpi_ko_dirname=`dirname ${acpi_ko}`
|
||||
acpi_ko_rel_dirname=`make_system_path_relative_to_its_root $acpi_ko_dirname`
|
||||
if test -n "${module_dir}" ; then
|
||||
echo "Found kernel module directory: ${module_dir}" >&2
|
||||
module_dir_rel=$(make_system_path_relative_to_its_root $module_dir)
|
||||
fi
|
||||
|
||||
kfreebsd_entry "${OS}" "${version}"
|
||||
|
|
|
@ -44,7 +44,8 @@ case ${GRUB_DEVICE} in
|
|||
esac
|
||||
|
||||
if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
|
||||
|| ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then
|
||||
|| ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
|
||||
|| uses_abstraction "${GRUB_DEVICE}" lvm; then
|
||||
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
|
||||
else
|
||||
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
|
||||
|
|
|
@ -246,7 +246,7 @@ devabstraction_module=`$grub_probe --target=abstraction --device-map=${device_ma
|
|||
# The order in this list is critical. Be careful when modifying it.
|
||||
modules="$modules $fs_module $partmap_module $devabstraction_module"
|
||||
|
||||
$grub_mkimage -O ${target_cpu}-efi --output=${grubdir}/grub.efi $modules || exit 1
|
||||
$grub_mkimage -p "" -O ${target_cpu}-efi --output=${grubdir}/grub.efi $modules || exit 1
|
||||
|
||||
# Prompt the user to check if the device map is correct.
|
||||
echo "Installation finished. No error reported."
|
||||
|
|
|
@ -812,14 +812,14 @@ main (int argc, char *argv[])
|
|||
must_embed = 1;
|
||||
|
||||
if (root_dev[0] == 'm' && root_dev[1] == 'd'
|
||||
&& root_dev[2] >= '0' && root_dev[2] <= '9')
|
||||
&& ((root_dev[2] >= '0' && root_dev[2] <= '9') || root_dev[2] == '/'))
|
||||
{
|
||||
/* FIXME: we can avoid this on RAID1. */
|
||||
must_embed = 1;
|
||||
}
|
||||
|
||||
if (dest_dev[0] == 'm' && dest_dev[1] == 'd'
|
||||
&& dest_dev[2] >= '0' && dest_dev[2] <= '9')
|
||||
&& ((dest_dev[2] >= '0' && dest_dev[2] <= '9') || dest_dev[2] == '/'))
|
||||
{
|
||||
char **devicelist;
|
||||
int i;
|
||||
|
|
|
@ -212,7 +212,7 @@ fi
|
|||
# this command is allowed to fail (--target=fs already grants us that the
|
||||
# filesystem will be accessible).
|
||||
partmap_module=
|
||||
for x in `$grub_probe --target=partmap --device ${grub_device} 2> /dev/null`; do
|
||||
for x in `$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null`; do
|
||||
partmap_module="$partmap_module part_$x";
|
||||
done
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
import re
|
||||
import sys
|
||||
import os
|
||||
import datetime
|
||||
|
||||
if len (sys.argv) < 3:
|
||||
print ("Usage: %s SOURCE DESTINATION" % sys.argv[0])
|
||||
|
|
|
@ -293,7 +293,8 @@ grub_util_init_nls (void)
|
|||
textdomain (PACKAGE);
|
||||
#endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GRUB_UTIL */
|
||||
|
||||
int
|
||||
grub_dl_ref (grub_dl_t mod)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue