merge mainline into hints

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-12-23 18:49:00 +01:00
commit 17785932df
448 changed files with 43023 additions and 10176 deletions

View file

@ -402,7 +402,7 @@ unset __grub_mkimage_program
#
# grub-mkpasswd-pbkdf2
#
_grub_mkpasswd-pbkdf2 () {
_grub_mkpasswd_pbkdf2 () {
local cur
COMPREPLY=()
@ -417,7 +417,7 @@ _grub_mkpasswd-pbkdf2 () {
}
__grub_mkpasswd_pbkdf2_program=$( echo grub-mkpasswd-pbkdf2 | sed "@program_transform_name@" )
have ${__grub_mkpasswd_pbkdf2_program} && \
complete -F _grub_mkpasswd-pbkdf2 -o filenames ${__grub_mkpasswd_pbkdf2_program}
complete -F _grub_mkpasswd_pbkdf2 -o filenames ${__grub_mkpasswd_pbkdf2_program}
unset __grub_mkpasswd_pbkdf2_program
@ -462,7 +462,7 @@ unset __grub_probe_program
#
# grub-script-check
#
_grub_script-check () {
_grub_script_check () {
local cur
COMPREPLY=()
@ -477,7 +477,7 @@ _grub_script-check () {
}
__grub_script_check_program=$( echo grub-script-check | sed "@program_transform_name@" )
have ${__grub_script_check_program} && \
complete -F _grub_script-check -o filenames ${__grub_script_check_program}
complete -F _grub_script_check -o filenames ${__grub_script_check_program}
# Local variables:

View file

@ -1,7 +1,7 @@
/* deviceiter.c - iterate over system devices */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008 Free Software Foundation, Inc.
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2011 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
@ -286,6 +286,26 @@ get_scsi_disk_name (char *name, int unit)
#endif
}
#ifdef __FreeBSD_kernel__
static void
get_ada_disk_name (char *name, int unit)
{
sprintf (name, "/dev/ada%d", unit);
}
static void
get_ataraid_disk_name (char *name, int unit)
{
sprintf (name, "/dev/ar%d", unit);
}
static void
get_mfi_disk_name (char *name, int unit)
{
sprintf (name, "/dev/mfid%d", unit);
}
#endif
#ifdef __linux__
static void
get_virtio_disk_name (char *name, int unit)
@ -620,6 +640,48 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
}
}
#ifdef __FreeBSD_kernel__
/* IDE disks using ATA Direct Access driver. */
if (get_kfreebsd_version () >= 800000)
for (i = 0; i < 96; i++)
{
char name[16];
get_ada_disk_name (name, i);
if (check_device_readable_unique (name))
{
if (hook (name, 0))
goto out;
}
}
/* ATARAID disks. */
for (i = 0; i < 8; i++)
{
char name[20];
get_ataraid_disk_name (name, i);
if (check_device_readable_unique (name))
{
if (hook (name, 0))
goto out;
}
}
/* LSI MegaRAID SAS. */
for (i = 0; i < 32; i++)
{
char name[20];
get_mfi_disk_name (name, i);
if (check_device_readable_unique (name))
{
if (hook (name, 0))
goto out;
}
}
#endif
#ifdef __linux__
/* Virtio disks. */
for (i = 0; i < 26; i++)

1645
util/getroot.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -115,26 +115,26 @@ create_envblk_file (const char *name)
buf = malloc (DEFAULT_ENVBLK_SIZE);
if (! buf)
grub_util_error ("out of memory");
grub_util_error (_("out of memory"));
namenew = xasprintf ("%s.new", name);
fp = fopen (namenew, "wb");
if (! fp)
grub_util_error ("cannot open the file %s", namenew);
grub_util_error (_("cannot open the file %s"), namenew);
memcpy (buf, GRUB_ENVBLK_SIGNATURE, sizeof (GRUB_ENVBLK_SIGNATURE) - 1);
memset (buf + sizeof (GRUB_ENVBLK_SIGNATURE) - 1, '#',
DEFAULT_ENVBLK_SIZE - sizeof (GRUB_ENVBLK_SIGNATURE) + 1);
if (fwrite (buf, 1, DEFAULT_ENVBLK_SIZE, fp) != DEFAULT_ENVBLK_SIZE)
grub_util_error ("cannot write to the file %s", namenew);
grub_util_error (_("cannot write to the file %s"), namenew);
fsync (fileno (fp));
free (buf);
fclose (fp);
if (rename (namenew, name) < 0)
grub_util_error ("cannot rename the file %s to %s", namenew, name);
grub_util_error (_("cannot rename the file %s to %s"), namenew, name);
free (namenew);
}
@ -153,29 +153,29 @@ open_envblk_file (const char *name)
create_envblk_file (name);
fp = fopen (name, "rb");
if (! fp)
grub_util_error ("cannot open the file %s", name);
grub_util_error (_("cannot open the file %s"), name);
}
if (fseek (fp, 0, SEEK_END) < 0)
grub_util_error ("cannot seek the file %s", name);
grub_util_error (_("cannot seek the file %s"), name);
size = (size_t) ftell (fp);
if (fseek (fp, 0, SEEK_SET) < 0)
grub_util_error ("cannot seek the file %s", name);
grub_util_error (_("cannot seek the file %s"), name);
buf = malloc (size);
if (! buf)
grub_util_error ("out of memory");
grub_util_error (_("out of memory"));
if (fread (buf, 1, size, fp) != size)
grub_util_error ("cannot read the file %s", name);
grub_util_error (_("cannot read the file %s"), name);
fclose (fp);
envblk = grub_envblk_open (buf, size);
if (! envblk)
grub_util_error ("invalid environment block");
grub_util_error (_("invalid environment block"));
return envblk;
}
@ -204,11 +204,11 @@ write_envblk (const char *name, grub_envblk_t envblk)
fp = fopen (name, "wb");
if (! fp)
grub_util_error ("cannot open the file %s", name);
grub_util_error (_("cannot open the file %s"), name);
if (fwrite (grub_envblk_buffer (envblk), 1, grub_envblk_size (envblk), fp)
!= grub_envblk_size (envblk))
grub_util_error ("cannot write to the file %s", name);
grub_util_error (_("cannot write to the file %s"), name);
fsync (fileno (fp));
fclose (fp);
@ -226,12 +226,12 @@ set_variables (const char *name, int argc, char *argv[])
p = strchr (argv[0], '=');
if (! p)
grub_util_error ("invalid parameter %s", argv[0]);
grub_util_error (_("invalid parameter %s"), argv[0]);
*(p++) = 0;
if (! grub_envblk_set (envblk, argv[0], p))
grub_util_error ("environment block too small");
grub_util_error (_("environment block too small"));
argc--;
argv++;

View file

@ -33,6 +33,7 @@
#include <grub/crypto.h>
#include <grub/command.h>
#include <grub/i18n.h>
#include <grub/zfs/zfs.h>
#include <stdio.h>
#include <unistd.h>
@ -61,12 +62,15 @@ enum {
CMD_CMP,
CMD_HEX,
CMD_CRC,
CMD_BLOCKLIST
CMD_BLOCKLIST,
CMD_TESTLOAD,
CMD_ZFSINFO,
CMD_XNU_UUID
};
#define BUF_SIZE 32256
static grub_disk_addr_t skip, leng;
static int uncompress = 0;
static void
read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
@ -110,7 +114,8 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
return;
}
grub_file_filter_disable_compression ();
if (uncompress == 0)
grub_file_filter_disable_compression ();
file = grub_file_open (pathname);
if (!file)
{
@ -178,7 +183,8 @@ cmd_cp (char *src, char *dest)
ff = fopen (dest, "wb");
if (ff == NULL)
{
grub_util_error (_("open error"));
grub_util_error (_("OS file %s open error: %s"), dest,
strerror (errno));
return;
}
read_file (src, cp_hook);
@ -237,7 +243,8 @@ cmd_cmp (char *src, char *dest)
ff = fopen (dest, "rb");
if (ff == NULL)
{
grub_util_error (_("open error"));
grub_util_error (_("OS file %s open error: %s"), dest,
strerror (errno));
return;
}
@ -298,6 +305,7 @@ static char **images = NULL;
static int cmd = 0;
static char *debug_str = NULL;
static char **args = NULL;
static int mount_crypt = 0;
static void
fstest (int n, char **args)
@ -327,6 +335,15 @@ fstest (int n, char **args)
grub_free (host_file);
}
{
char *argv[2] = { "-a", NULL};
if (mount_crypt)
{
if (execute_command ("cryptomount", 1, argv))
grub_util_error (_("cryptomount command fails: %s"), grub_errmsg);
}
}
grub_lvm_fini ();
grub_mdraid09_fini ();
grub_mdraid1x_fini ();
@ -341,6 +358,9 @@ fstest (int n, char **args)
case CMD_LS:
execute_command ("ls", n, args);
break;
case CMD_ZFSINFO:
execute_command ("zfsinfo", n, args);
break;
case CMD_CP:
cmd_cp (args[0], args[1]);
break;
@ -359,6 +379,32 @@ fstest (int n, char **args)
case CMD_BLOCKLIST:
execute_command ("blocklist", n, args);
grub_printf ("\n");
case CMD_TESTLOAD:
execute_command ("testload", n, args);
grub_printf ("\n");
case CMD_XNU_UUID:
{
grub_device_t dev;
grub_fs_t fs;
char *uuid = 0;
char *argv[3] = { "-l", NULL, NULL};
dev = grub_device_open (n ? args[0] : 0);
if (!dev)
grub_util_error (grub_errmsg);
fs = grub_fs_probe (dev);
if (!fs)
grub_util_error (grub_errmsg);
if (!fs->uuid)
grub_util_error (_("couldn't retrieve UUID"));
if (fs->uuid (dev, &uuid))
grub_util_error (grub_errmsg);
if (!uuid)
grub_util_error (_("couldn't retrieve UUID"));
argv[1] = uuid;
execute_command ("xnu_uuid", 2, argv);
grub_free (uuid);
grub_device_close (dev);
}
}
for (i = 0; i < num_disks; i++)
@ -387,13 +433,17 @@ static struct argp_option options[] = {
{N_("hex FILE"), 0, 0 , OPTION_DOC, N_("Hex dump FILE."), 1},
{N_("crc FILE"), 0, 0 , OPTION_DOC, N_("Get crc32 checksum of FILE."), 1},
{N_("blocklist FILE"), 0, 0, OPTION_DOC, N_("Display blocklist of FILE."), 1},
{N_("xnu_uuid"), 0, 0, OPTION_DOC, N_("Compute XNU UUID of the device."), 1},
{"root", 'r', N_("DEVICE_NAME"), 0, N_("Set root device."), 2},
{"skip", 's', "N", 0, N_("Skip N bytes from output file."), 2},
{"length", 'n', "N", 0, N_("Handle N bytes in output file."), 2},
{"diskcount", 'c', "N", 0, N_("N input files."), 2},
{"debug", 'd', "S", 0, N_("Set debug environment variable."), 2},
{"crypto", 'C', NULL, OPTION_ARG_OPTIONAL, N_("Mount crypto devices."), 2},
{"zfs-key", 'K', N_("FILE|prompt"), 0, N_("Load zfs crypto key."), 2},
{"verbose", 'v', NULL, OPTION_ARG_OPTIONAL, N_("Print verbose messages."), 2},
{"uncompress", 'u', NULL, OPTION_ARG_OPTIONAL, N_("Uncompress data."), 2},
{0, 0, 0, 0, 0, 0}
};
@ -416,6 +466,42 @@ argp_parser (int key, char *arg, struct argp_state *state)
root = arg;
return 0;
case 'K':
if (strcmp (arg, "prompt") == 0)
{
char buf[1024];
grub_puts_ (N_("Enter ZFS password: "));
if (grub_password_get (buf, 1023))
{
grub_zfs_add_key ((grub_uint8_t *) buf, grub_strlen (buf), 1);
}
}
else
{
FILE *f;
ssize_t real_size;
grub_uint8_t buf[1024];
f = fopen (arg, "rb");
if (!f)
{
printf (_("Error loading file %s: %s\n"), arg, strerror (errno));
return 0;
}
real_size = fread (buf, 1, 1024, f);
if (real_size < 0)
{
printf (_("Error loading file %s: %s\n"), arg, strerror (errno));
fclose (f);
return 0;
}
grub_zfs_add_key (buf, real_size, 0);
}
return 0;
case 'C':
mount_crypt = 1;
return 0;
case 's':
skip = grub_strtoul (arg, &p, 0);
if (*p == 's')
@ -450,6 +536,10 @@ argp_parser (int key, char *arg, struct argp_state *state)
verbosity++;
return 0;
case 'u':
uncompress = 1;
return 0;
case ARGP_KEY_END:
if (args_count < num_disks)
{
@ -472,14 +562,9 @@ argp_parser (int key, char *arg, struct argp_state *state)
if (args_count < num_disks)
{
if (arg[0] != '/')
{
fprintf (stderr, "%s", _("Must use absolute path.\n"));
argp_usage (state);
}
if (args_count == 0)
images = xmalloc (num_disks * sizeof (images[0]));
images[args_count] = xstrdup (arg);
images[args_count] = canonicalize_file_name (arg);
args_count++;
return 0;
}
@ -490,6 +575,10 @@ argp_parser (int key, char *arg, struct argp_state *state)
{
cmd = CMD_LS;
}
else if (!grub_strcmp (arg, "zfsinfo"))
{
cmd = CMD_ZFSINFO;
}
else if (!grub_strcmp (arg, "cp"))
{
cmd = CMD_CP;
@ -520,6 +609,16 @@ argp_parser (int key, char *arg, struct argp_state *state)
cmd = CMD_BLOCKLIST;
nparm = 1;
}
else if (!grub_strcmp (arg, "testload"))
{
cmd = CMD_TESTLOAD;
nparm = 1;
}
else if (grub_strcmp (arg, "xnu_uuid") == 0)
{
cmd = CMD_XNU_UUID;
nparm = 0;
}
else
{
fprintf (stderr, _("Invalid command %s.\n"), arg);
@ -555,6 +654,7 @@ main (int argc, char *argv[])
/* Initialize all modules. */
grub_init_all ();
grub_gcry_init_all ();
if (debug_str)
grub_env_set ("debug", debug_str);
@ -583,6 +683,7 @@ main (int argc, char *argv[])
fstest (args_count - 1 - num_disks, args);
/* Free resources. */
grub_gcry_fini_all ();
grub_fini_all ();
return 0;

View file

@ -31,6 +31,7 @@ PACKAGE_VERSION=@PACKAGE_VERSION@
target_cpu=@target_cpu@
platform=@platform@
host_os=@host_os@
datarootdir=@datarootdir@
pkglibdir="${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`"
localedir="@datadir@/locale"
@ -73,7 +74,7 @@ if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
elif [ "${platform}" = "ieee1275" ] || [ "${platform}" = "efi" ] ; then
disk_module=
else
disk_module=ata
disk_module=native
fi
# Usage: usage
@ -109,7 +110,7 @@ Install GRUB on your drive.
EOF
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
cat <<EOF
--disk-module=MODULE disk module to use
--disk-module=MODULE disk module to use (biosdisk or native)
EOF
fi
if [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ] ; then
@ -261,6 +262,8 @@ do
esac
done
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
if test "x$install_device" = x && ([ "${target_cpu}-${platform}" = "i386-pc" ] \
|| [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]); then
echo "install_device not specified." 1>&2
@ -331,6 +334,12 @@ if [ x"$platform" = xefi ]; then
if test "x$install_device" != "x`"$grub_mkdevicemap" --device-map=/dev/stdout | "$grub_probe" --target=device --device-map=/dev/stdin "${bootdir}"`"; then
efidir="${bootdir}/efi"
fi
elif test -d "${bootdir}/EFI"; then
install_device="`"$grub_mkdevicemap" --device-map=/dev/stdout | "$grub_probe" --target=device --device-map=/dev/stdin "${bootdir}/EFI"`"
# Is it a mount point?
if test "x$install_device" != "x`"$grub_mkdevicemap" --device-map=/dev/stdout | "$grub_probe" --target=device --device-map=/dev/stdin "${bootdir}"`"; then
efidir="${bootdir}/EFI"
fi
elif test -n "$rootdir" && test "x$rootdir" != "x/"; then
# The EFI System Partition may have been given directly using
# --root-directory.
@ -444,6 +453,8 @@ for dir in "${localedir}"/*; do
fi
done
is_path_readable_by_grub "${grubdir}" || (echo "${grubdir}" not readable 1>&2 ; exit 1)
# Write device to a variable so we don't have to traverse /dev every time.
grub_device="`"$grub_probe" --device-map="${device_map}" --target=device "${grubdir}"`" || exit 1
@ -477,6 +488,18 @@ done
# Device abstraction module, if any (lvm, raid).
devabstraction_module="`"$grub_probe" --device-map="${device_map}" --target=abstraction --device "${grub_device}"`"
if [ "x$disk_module" = xata ]; then
disk_module=pata
fi
if [ "x$disk_module" = xnative ]; then
disk_module="pata ahci ohci"
if [ "x$target_cpu" = "xi386" ] || [ "x$target_cpu" = "xx86_64" ]; then
disk_module="$disk_module uhci"
fi
disk_module="$disk_module usbms"
fi
# The order in this list is critical. Be careful when modifying it.
modules="$modules $disk_module"
modules="$modules $fs_module $partmap_module $devabstraction_module"
@ -510,11 +533,11 @@ if [ "x${devabstraction_module}" = "x" ] ; then
# Strip partition number
grub_partition="`echo "${grub_drive}" | sed -e 's/^[^,]*[,)]//; s/)$//'`"
grub_drive="`echo "${grub_drive}" | sed -e s/,[a-z0-9,]*//g`"
if [ "$disk_module" = ata ] || [ "x${grub_drive}" != "x${install_drive}" ] || ([ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${target_cpu}-${platform}" != x"sparc64-ieee1275" ]) ; then
if ([ "x$disk_module" != x ] && [ "x$disk_module" != xbiosdisk ]) || [ "x${grub_drive}" != "x${install_drive}" ] || ([ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${platform}" != x"ieee1275" ]); then
# generic method (used on coreboot and ata mod)
uuid="`"$grub_probe" --device-map="${device_map}" --target=fs_uuid --device "${grub_device}"`"
if [ "x${uuid}" = "x" ] ; then
if [ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${target_cpu}-${platform}" != x"sparc64-ieee1275" ]; then
if [ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${platform}" != x"ieee1275" ]; then
echo "UUID needed with $platform, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
elif [ "$disk_module" = ata ]; then
echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
@ -543,7 +566,7 @@ if [ "x${devabstraction_module}" = "x" ] ; then
echo 'set prefix=($root)'"${relative_grubdir}" >> "${grubdir}/load.cfg"
config_opt="-c ${grubdir}/load.cfg "
modules="$modules search_fs_uuid"
elif [ "x$platform" = xefi ] || [ "x$platform" = xpc ]; then
else
# we need to hardcode the partition number in the core image's prefix.
if [ x"$grub_partition" = x ]; then
prefix_drive="()"
@ -552,6 +575,13 @@ if [ "x${devabstraction_module}" = "x" ] ; then
fi
fi
else
if [ x$GRUB_CRYPTODISK_ENABLE = xy ]; then
for uuid in "`"${grub_probe}" --device "${grub_device}" --target=cryptodisk_uuid`"; do
echo "cryptomount -u $uuid" >> "${grubdir}/load.cfg"
done
config_opt="-c ${grubdir}/load.cfg "
fi
prefix_drive=`"$grub_probe" --device-map="${device_map}" --target=drive --device "${grub_device}"` || exit 1
fi

View file

@ -25,6 +25,8 @@
#include <string.h>
#include <stdlib.h>
/* Please don't internationalise this file. It's pointless. */
/* XXX: this file assumes particular Mach-O layout and does no checks. */
/* However as build system ensures correct usage of this tool this
shouldn't be a problem. */

View file

@ -24,6 +24,7 @@
#include <errno.h>
#include <grub/util/misc.h>
#include <grub/misc.h>
#include <grub/i18n.h>
int
main (int argc, char **argv)
@ -37,7 +38,7 @@ main (int argc, char **argv)
if (argc >= 2 && argv[1][0] == '-')
{
fprintf (stdout, "Usage: %s [INFILE [OUTFILE]]\n", argv[0]);
fprintf (stdout, _("Usage: %s [INFILE [OUTFILE]]\n"), argv[0]);
return 0;
}
@ -46,7 +47,7 @@ main (int argc, char **argv)
in = fopen (argv[1], "r");
if (!in)
{
fprintf (stderr, "Couldn't open %s for reading: %s\n",
fprintf (stderr, _("Couldn't open %s for reading: %s\n"),
argv[1], strerror (errno));
return 1;
}
@ -61,7 +62,7 @@ main (int argc, char **argv)
{
if (in != stdin)
fclose (in);
fprintf (stderr, "Couldn't open %s for writing: %s\n",
fprintf (stderr, _("Couldn't open %s for writing: %s\n"),
argv[2], strerror (errno));
return 1;
}

View file

@ -94,7 +94,7 @@ do
esac
done
. ${libdir}/grub/grub-mkconfig_lib
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
@ -226,6 +226,8 @@ export GRUB_DEFAULT \
GRUB_CMDLINE_LINUX_DEFAULT \
GRUB_CMDLINE_XEN \
GRUB_CMDLINE_XEN_DEFAULT \
GRUB_CMDLINE_LINUX_XEN_REPLACE \
GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT \
GRUB_CMDLINE_NETBSD \
GRUB_CMDLINE_NETBSD_DEFAULT \
GRUB_TERMINAL_INPUT \
@ -241,6 +243,7 @@ export GRUB_DEFAULT \
GRUB_DISABLE_OS_PROBER \
GRUB_INIT_TUNE \
GRUB_SAVEDEFAULT \
GRUB_ENABLE_CRYPTODISK \
GRUB_BADRAM
if test "x${grub_cfg}" != "x"; then

View file

@ -63,10 +63,22 @@ is_path_readable_by_grub ()
# ... or if we can't figure out the abstraction module, for example if
# memberlist fails on an LVM volume group.
if ${grub_probe} -t abstraction $path > /dev/null 2>&1 ; then : ; else
if abstractions="`"${grub_probe}" -t abstraction "$path"`" 2>&1 ; then
:
else
return 1
fi
if [ x$GRUB_CRYPTODISK_ENABLE = xy ]; then
return 0
fi
for abstraction in $abstractions; do
if [ "x$abstraction" = xcryptodisk ]; then
return 1
fi
done
return 0
}
@ -105,12 +117,6 @@ prepare_grub_to_access_device ()
{
device="$1"
# Abstraction modules aren't auto-loaded.
abstraction="`"${grub_probe}" --device "${device}" --target=abstraction`"
for module in ${abstraction} ; do
echo "insmod ${module}"
done
partmap="`"${grub_probe}" --device "${device}" --target=partmap`"
for module in ${partmap} ; do
case "${module}" in
@ -121,11 +127,23 @@ prepare_grub_to_access_device ()
esac
done
# Abstraction modules aren't auto-loaded.
abstraction="`"${grub_probe}" --device "${device}" --target=abstraction`"
for module in ${abstraction} ; do
echo "insmod ${module}"
done
fs="`"${grub_probe}" --device "${device}" --target=fs`"
for module in ${fs} ; do
echo "insmod ${module}"
done
if [ x$GRUB_CRYPTODISK_ENABLE = xy ]; then
for uuid in "`"${grub_probe}" --device "${device}" --target=cryptodisk_uuid`"; do
echo "cryptomount -u $uuid"
done
fi
# If there's a filesystem UUID that GRUB is capable of identifying, use it;
# otherwise set root as per value in device.map.
echo "set root='`"${grub_probe}" --device "${device}" --target=compatibility_hint`'"
@ -144,7 +162,7 @@ grub_file_is_not_garbage ()
if test -f "$1" ; then
case "$1" in
*.dpkg-*) return 1 ;; # debian dpkg
README*) return 1 ;; # documentation
README*|*/README*) return 1 ;; # documentation
esac
else
return 1
@ -154,21 +172,21 @@ grub_file_is_not_garbage ()
version_test_numeric ()
{
local a="$1"
local cmp="$2"
local b="$3"
if [ "$a" = "$b" ] ; then
case "$cmp" in
version_test_numeric_a="$1"
version_test_numeric_cmp="$2"
version_test_numeric_b="$3"
if [ "$version_test_numeric_a" = "$version_test_numeric_b" ] ; then
case "$version_test_numeric_cmp" in
ge|eq|le) return 0 ;;
gt|lt) return 1 ;;
esac
fi
if [ "$cmp" = "lt" ] ; then
c="$a"
a="$b"
b="$c"
if [ "$version_test_numeric_cmp" = "lt" ] ; then
version_test_numeric_c="$version_test_numeric_a"
version_test_numeric_a="$version_test_numeric_b"
version_test_numeric_b="$version_test_numeric_c"
fi
if (echo "$a" ; echo "$b") | sort -n | head -n 1 | grep -qx "$b" ; then
if (echo "$version_test_numeric_a" ; echo "$version_test_numeric_b") | sort -n | head -n 1 | grep -qx "$version_test_numeric_b" ; then
return 0
else
return 1
@ -177,30 +195,30 @@ version_test_numeric ()
version_test_gt ()
{
local a="`echo "$1" | sed -e "s/[^-]*-//"`"
local b="`echo "$2" | sed -e "s/[^-]*-//"`"
local cmp=gt
if [ "x$b" = "x" ] ; then
version_test_gt_a="`echo "$1" | sed -e "s/[^-]*-//"`"
version_test_gt_b="`echo "$2" | sed -e "s/[^-]*-//"`"
version_test_gt_cmp=gt
if [ "x$version_test_gt_b" = "x" ] ; then
return 0
fi
case "$a:$b" in
case "$version_test_gt_a:$version_test_gt_b" in
*.old:*.old) ;;
*.old:*) a="`echo -n "$a" | sed -e 's/\.old$//'`" ; cmp=gt ;;
*:*.old) b="`echo -n "$b" | sed -e 's/\.old$//'`" ; cmp=ge ;;
*.old:*) version_test_gt_a="`echo -n "$version_test_gt_a" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=gt ;;
*:*.old) version_test_gt_b="`echo -n "$version_test_gt_b" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=ge ;;
esac
version_test_numeric "$a" "$cmp" "$b"
version_test_numeric "$version_test_gt_a" "$version_test_gt_cmp" "$version_test_gt_b"
return "$?"
}
version_find_latest ()
{
local a=""
version_find_latest_a=""
for i in "$@" ; do
if version_test_gt "$i" "$a" ; then
a="$i"
if version_test_gt "$i" "$version_find_latest_a" ; then
version_find_latest_a="$i"
fi
done
echo "$a"
echo "$version_find_latest_a"
}
# One layer of quotation is eaten by "", the second by sed, and the third by
@ -214,9 +232,9 @@ gettext_quoted () {
# remaining arguments to printf. This is a useful abbreviation and tends to
# be easier to type.
gettext_printf () {
local format="$1"
gettext_printf_format="$1"
shift
printf "$(gettext_quoted "$format")" "$@"
printf "$(gettext_quoted "$gettext_printf_format")" "$@"
}
uses_abstraction () {

View file

@ -62,7 +62,7 @@ make_device_map (const char *device_map, int floppy_disks)
fp = fopen (device_map, "w");
if (! fp)
grub_util_error ("cannot open %s", device_map);
grub_util_error (_("cannot open %s"), device_map);
grub_util_iterate_devices (process_device, floppy_disks);
@ -86,9 +86,9 @@ usage (int status)
{
if (status)
fprintf (stderr,
"Try `%s --help' for more information.\n", program_name);
_("Try `%s --help' for more information.\n"), program_name);
else
printf ("\
printf (_("\
Usage: %s [OPTION]...\n\
\n\
Generate a device map file automatically.\n\
@ -101,7 +101,7 @@ Generate a device map file automatically.\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n\
", program_name,
"), program_name,
DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
exit (status);

View file

@ -121,9 +121,10 @@ static void
usage (int status)
{
if (status)
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
printf ("\
printf (_("\
Usage: %s [OPTIONS] FONT_FILES\n\
\nOptions:\n\
-o, --output=FILE_NAME set output file name\n\
@ -143,7 +144,7 @@ Usage: %s [OPTIONS] FONT_FILES\n\
-V, --version print version information and exit\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT);
Report bugs to <%s>.\n"), program_name, PACKAGE_BUGREPORT);
exit (status);
}
@ -188,12 +189,12 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face,
err = FT_Load_Glyph (face, glyph_idx, flag);
if (err)
{
printf ("Freetype Error %d loading glyph 0x%x for U+0x%x%s",
printf (_("Freetype Error %d loading glyph 0x%x for U+0x%x%s"),
err, glyph_idx, char_code & GRUB_FONT_CODE_CHAR_MASK,
char_code & GRUB_FONT_CODE_RIGHT_JOINED
? ((char_code & GRUB_FONT_CODE_LEFT_JOINED) ? " (medial)":
" (leftmost)")
: ((char_code & GRUB_FONT_CODE_LEFT_JOINED) ? " (rightmost)":
? ((char_code & GRUB_FONT_CODE_LEFT_JOINED) ? _(" (medial)"):
_(" (leftmost)"))
: ((char_code & GRUB_FONT_CODE_LEFT_JOINED) ? _(" (rightmost)"):
""));
if (err > 0 && err < (signed) ARRAY_SIZE (ft_errmsgs))
@ -519,7 +520,7 @@ process_cursive (struct gsub_feature *feature,
if (substtype == GSUB_SUBSTITUTION_DELTA)
add_subst (glyph, glyph + grub_be_to_cpu16 (sub->delta), target);
else if (i >= grub_be_to_cpu16 (sub->count))
printf ("Out of range substitution (%d, %d)\n", i,
printf (_("Out of range substitution (%d, %d)\n"), i,
grub_be_to_cpu16 (sub->count));
else
add_subst (glyph, grub_be_to_cpu16 (sub->repl[i++]), target);
@ -531,7 +532,7 @@ process_cursive (struct gsub_feature *feature,
struct gsub_lookup *lookup;
if (lookup_index >= grub_be_to_cpu16 (lookups->count))
{
printf ("Out of range lookup: %d\n", lookup_index);
printf (_("Out of range lookup: %d\n"), lookup_index);
continue;
}
lookup = (struct gsub_lookup *)
@ -539,13 +540,13 @@ process_cursive (struct gsub_feature *feature,
+ grub_be_to_cpu16 (lookups->offsets[lookup_index]));
if (grub_be_to_cpu16 (lookup->type) != GSUB_SINGLE_SUBSTITUTION)
{
printf ("Unsupported substitution type: %d\n",
printf (_("Unsupported substitution type: %d\n"),
grub_be_to_cpu16 (lookup->type));
continue;
}
if (grub_be_to_cpu16 (lookup->flag) & ~GSUB_RTL_CHAR)
{
printf ("Unsupported substitution flag: 0x%x\n",
printf (_("Unsupported substitution flag: 0x%x\n"),
grub_be_to_cpu16 (lookup->flag));
}
switch (feattag)
@ -575,7 +576,7 @@ process_cursive (struct gsub_feature *feature,
if (substtype != GSUB_SUBSTITUTION_MAP
&& substtype != GSUB_SUBSTITUTION_DELTA)
{
printf ("Unsupported substitution specification: %d\n",
printf (_("Unsupported substitution specification: %d\n"),
substtype);
continue;
}
@ -601,7 +602,7 @@ process_cursive (struct gsub_feature *feature,
subst (m);
}
else
printf ("Unsupported coverage specification: %d\n", covertype);
printf (_("Unsupported coverage specification: %d\n"), covertype);
}
}
}
@ -640,7 +641,7 @@ add_font (struct grub_font_info *font_info, FT_Face face, int nocut)
grub_uint32_t feattag
= grub_be_to_cpu32 (features->features[i].feature_tag);
if (feature->params)
printf ("WARNING: unsupported feature parameters: %x\n",
printf (_("WARNING: unsupported feature parameters: %x\n"),
grub_be_to_cpu16 (feature->params));
switch (feattag)
{
@ -670,7 +671,7 @@ add_font (struct grub_font_info *font_info, FT_Face face, int nocut)
for (j = 0; j < 4; j++)
if (!grub_isgraph (str[j]))
str[j] = '?';
printf ("Unknown gsub feature 0x%x (%s)\n", feattag, str);
printf (_("Unknown gsub feature 0x%x (%s)\n"), feattag, str);
}
}
}
@ -739,8 +740,8 @@ print_glyphs (struct grub_font_info *font_info)
int x, y, xmax, xmin, ymax, ymin;
grub_uint8_t *bitmap, mask;
printf ("\nGlyph #%d, U+%04x\n", num, glyph->char_code);
printf ("Width %d, Height %d, X offset %d, Y offset %d, Device width %d\n",
printf (_("\nGlyph #%d, U+%04x\n"), num, glyph->char_code);
printf (_("Width %d, Height %d, X offset %d, Y offset %d, Device width %d\n"),
glyph->width, glyph->height, glyph->x_ofs, glyph->y_ofs,
glyph->device_width);
@ -807,7 +808,7 @@ write_font_ascii_bitmap (struct grub_font_info *font_info, char *output_file)
file = fopen (output_file, "wb");
if (! file)
grub_util_error ("Can\'t write to file %s.", output_file);
grub_util_error (_("Can\'t write to file %s."), output_file);
int correct_size;
for (glyph = font_info->glyphs_sorted, num = 0; num < font_info->num_glyphs;
@ -843,7 +844,7 @@ write_font_width_spec (struct grub_font_info *font_info, char *output_file)
file = fopen (output_file, "wb");
if (! file)
grub_util_error ("Can\'t write to file %s.", output_file);
grub_util_error (_("Can\'t write to file %s."), output_file);
for (glyph = font_info->glyphs_sorted;
glyph < font_info->glyphs_sorted + font_info->num_glyphs; glyph++)
@ -866,7 +867,7 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
file = fopen (output_file, "wb");
if (! file)
grub_util_error ("can\'t write to file %s.", output_file);
grub_util_error (_("Can\'t write to file %s."), output_file);
offset = 0;
@ -1063,7 +1064,7 @@ main (int argc, char *argv[])
a = strtoul (p, &p, 0);
if (*p != '-')
grub_util_error ("invalid font range");
grub_util_error (_("invalid font range"));
b = strtoul (p + 1, &p, 0);
if ((font_info.num_range & (GRUB_FONT_RANGE_BLOCK - 1)) == 0)
font_info.ranges = xrealloc (font_info.ranges,
@ -1078,7 +1079,7 @@ main (int argc, char *argv[])
if (*p)
{
if (*p != ',')
grub_util_error ("invalid font range");
grub_util_error (_("invalid font range"));
else
p++;
}
@ -1124,7 +1125,7 @@ main (int argc, char *argv[])
if (file_format == ASCII_BITMAPS && font_info.num_range > 0)
{
grub_util_error ("Option --ascii-bitmaps doesn't accept ranges (use ASCII).");
grub_util_error (_("Option --ascii-bitmaps doesn't accept ranges (use ASCII)."));
return 1;
}
@ -1140,10 +1141,10 @@ main (int argc, char *argv[])
}
if (! output_file)
grub_util_error ("no output file is specified");
grub_util_error (_("no output file is specified"));
if (FT_Init_FreeType (&ft_lib))
grub_util_error ("FT_Init_FreeType fails");
grub_util_error (_("FT_Init_FreeType fails"));
for (; optind < argc; optind++)
{
@ -1154,8 +1155,8 @@ main (int argc, char *argv[])
err = FT_New_Face (ft_lib, argv[optind], font_index, &ft_face);
if (err)
{
grub_printf ("can't open file %s, index %d: error %d", argv[optind],
font_index, err);
grub_printf (_("can't open file %s, index %d: error %d"),
argv[optind], font_index, err);
if (err > 0 && err < (signed) ARRAY_SIZE (ft_errmsgs))
printf (": %s\n", ft_errmsgs[err]);
else
@ -1181,7 +1182,7 @@ main (int argc, char *argv[])
font_info.size = size;
if (FT_Set_Pixel_Sizes (ft_face, size, size))
grub_util_error ("can't set %dx%d font size", size, size);
grub_util_error (_("can't set %dx%d font size"), size, size);
add_font (&font_info, ft_face, file_format != PF2);
FT_Done_Face (ft_face);
}

View file

@ -32,6 +32,7 @@
#include <grub/crypto.h>
#include <grub/dl.h>
#include <time.h>
#include <multiboot.h>
#include <stdio.h>
#include <unistd.h>
@ -54,7 +55,7 @@
#define TARGET_NO_FIELD 0xffffffff
typedef enum {
COMPRESSION_AUTO, COMPRESSION_NONE, COMPRESSION_XZ
COMPRESSION_AUTO, COMPRESSION_NONE, COMPRESSION_XZ, COMPRESSION_LZMA
} grub_compression_t;
struct image_target_desc
@ -67,26 +68,23 @@ struct image_target_desc
IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT,
IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_I386_IEEE1275,
IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH,
IMAGE_FULOONG_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC
IMAGE_FULOONG2F_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC,
IMAGE_QEMU_MIPS_FLASH
} id;
enum
{
PLATFORM_FLAGS_NONE = 0,
PLATFORM_FLAGS_LZMA = 1,
PLATFORM_FLAGS_DECOMPRESSORS = 2,
PLATFORM_FLAGS_MODULES_BEFORE_KERNEL = 4,
} flags;
unsigned prefix;
unsigned prefix_end;
unsigned raw_size;
unsigned total_module_size;
unsigned kernel_image_size;
unsigned compressed_size;
unsigned decompressor_compressed_size;
unsigned decompressor_uncompressed_size;
unsigned decompressor_uncompressed_addr;
unsigned link_align;
grub_uint16_t elf_target;
unsigned section_align;
signed vaddr_offset;
unsigned install_dos_part, install_bsd_part;
grub_uint64_t link_addr;
unsigned mod_gap, mod_align;
grub_compression_t default_compression;
@ -109,16 +107,12 @@ struct image_target_desc image_targets[] =
.bigendian = 0,
.id = IMAGE_COREBOOT,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_I386_COREBOOT_PREFIX,
.prefix_end = GRUB_KERNEL_I386_COREBOOT_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.compressed_size = TARGET_NO_FIELD,
.decompressor_compressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_addr = 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,
@ -132,16 +126,12 @@ struct image_target_desc image_targets[] =
.bigendian = 0,
.id = IMAGE_COREBOOT,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_I386_MULTIBOOT_PREFIX,
.prefix_end = GRUB_KERNEL_I386_MULTIBOOT_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.compressed_size = TARGET_NO_FIELD,
.decompressor_compressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_addr = 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,
@ -154,17 +144,13 @@ struct image_target_desc image_targets[] =
.voidp_sizeof = 4,
.bigendian = 0,
.id = IMAGE_I386_PC,
.flags = PLATFORM_FLAGS_LZMA,
.prefix = GRUB_KERNEL_I386_PC_PREFIX,
.prefix_end = GRUB_KERNEL_I386_PC_PREFIX_END,
.raw_size = GRUB_KERNEL_I386_PC_RAW_SIZE,
.total_module_size = GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE,
.kernel_image_size = GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE,
.compressed_size = GRUB_KERNEL_I386_PC_COMPRESSED_SIZE,
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
.total_module_size = TARGET_NO_FIELD,
.decompressor_compressed_size = GRUB_DECOMPRESSOR_I386_PC_COMPRESSED_SIZE,
.decompressor_uncompressed_size = GRUB_DECOMPRESSOR_I386_PC_UNCOMPRESSED_SIZE,
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
.install_dos_part = GRUB_KERNEL_I386_PC_INSTALL_DOS_PART,
.install_bsd_part = GRUB_KERNEL_I386_PC_INSTALL_BSD_PART,
.link_addr = GRUB_KERNEL_I386_PC_LINK_ADDR
},
{
@ -173,17 +159,13 @@ struct image_target_desc image_targets[] =
.voidp_sizeof = 4,
.bigendian = 0,
.id = IMAGE_I386_PC_PXE,
.flags = PLATFORM_FLAGS_LZMA,
.prefix = GRUB_KERNEL_I386_PC_PREFIX,
.prefix_end = GRUB_KERNEL_I386_PC_PREFIX_END,
.raw_size = GRUB_KERNEL_I386_PC_RAW_SIZE,
.total_module_size = GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE,
.kernel_image_size = GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE,
.compressed_size = GRUB_KERNEL_I386_PC_COMPRESSED_SIZE,
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
.total_module_size = TARGET_NO_FIELD,
.decompressor_compressed_size = GRUB_DECOMPRESSOR_I386_PC_COMPRESSED_SIZE,
.decompressor_uncompressed_size = GRUB_DECOMPRESSOR_I386_PC_UNCOMPRESSED_SIZE,
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
.install_dos_part = GRUB_KERNEL_I386_PC_INSTALL_DOS_PART,
.install_bsd_part = GRUB_KERNEL_I386_PC_INSTALL_BSD_PART,
.link_addr = GRUB_KERNEL_I386_PC_LINK_ADDR
},
{
@ -193,12 +175,10 @@ struct image_target_desc image_targets[] =
.bigendian = 0,
.id = IMAGE_EFI,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_I386_EFI_PREFIX,
.prefix_end = GRUB_KERNEL_I386_EFI_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.compressed_size = TARGET_NO_FIELD,
.decompressor_compressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
.vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
+ GRUB_PE32_SIGNATURE_SIZE
@ -206,8 +186,6 @@ struct image_target_desc image_targets[] =
+ sizeof (struct grub_pe32_optional_header)
+ 4 * sizeof (struct grub_pe32_section_table),
GRUB_PE32_SECTION_ALIGNMENT),
.install_dos_part = TARGET_NO_FIELD,
.install_bsd_part = TARGET_NO_FIELD,
.pe_target = GRUB_PE32_MACHINE_I386,
.elf_target = EM_386,
},
@ -218,16 +196,12 @@ struct image_target_desc image_targets[] =
.bigendian = 0,
.id = IMAGE_I386_IEEE1275,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_I386_IEEE1275_PREFIX,
.prefix_end = GRUB_KERNEL_I386_IEEE1275_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.compressed_size = TARGET_NO_FIELD,
.decompressor_compressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_addr = 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_IEEE1275_LINK_ADDR,
.elf_target = EM_386,
.mod_gap = GRUB_KERNEL_I386_IEEE1275_MOD_GAP,
@ -241,16 +215,12 @@ struct image_target_desc image_targets[] =
.bigendian = 0,
.id = IMAGE_QEMU,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_I386_QEMU_PREFIX,
.prefix_end = GRUB_KERNEL_I386_QEMU_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.compressed_size = TARGET_NO_FIELD,
.kernel_image_size = GRUB_KERNEL_I386_QEMU_KERNEL_IMAGE_SIZE,
.decompressor_compressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_addr = 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_QEMU_LINK_ADDR
},
{
@ -260,16 +230,12 @@ struct image_target_desc image_targets[] =
.bigendian = 0,
.id = IMAGE_EFI,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_X86_64_EFI_PREFIX,
.prefix_end = GRUB_KERNEL_X86_64_EFI_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.compressed_size = TARGET_NO_FIELD,
.decompressor_compressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
.vaddr_offset = EFI64_HEADER_SIZE,
.install_dos_part = TARGET_NO_FIELD,
.install_bsd_part = TARGET_NO_FIELD,
.pe_target = GRUB_PE32_MACHINE_X86_64,
.elf_target = EM_X86_64,
},
@ -280,16 +246,12 @@ struct image_target_desc image_targets[] =
.bigendian = 0,
.id = IMAGE_YEELOONG_FLASH,
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
.prefix = GRUB_KERNEL_MIPS_LOONGSON_PREFIX,
.prefix_end = GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END,
.raw_size = 0,
.total_module_size = GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE,
.compressed_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.decompressor_compressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_COMPRESSED_SIZE,
.decompressor_uncompressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_SIZE,
.decompressor_uncompressed_addr = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
.install_dos_part = TARGET_NO_FIELD,
.install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN,
@ -297,21 +259,17 @@ struct image_target_desc image_targets[] =
},
{
.dirname = "mipsel-loongson",
.names = { "mipsel-fuloong-flash", NULL },
.names = { "mipsel-fuloong2f-flash", NULL },
.voidp_sizeof = 4,
.bigendian = 0,
.id = IMAGE_FULOONG_FLASH,
.id = IMAGE_FULOONG2F_FLASH,
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
.prefix = GRUB_KERNEL_MIPS_LOONGSON_PREFIX,
.prefix_end = GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END,
.raw_size = 0,
.total_module_size = GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE,
.compressed_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.decompressor_compressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_COMPRESSED_SIZE,
.decompressor_uncompressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_SIZE,
.decompressor_uncompressed_addr = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
.install_dos_part = TARGET_NO_FIELD,
.install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN,
@ -320,21 +278,18 @@ struct image_target_desc image_targets[] =
{
.dirname = "mipsel-loongson",
.names = { "mipsel-loongson-elf", "mipsel-yeeloong-elf",
"mipsel-fuloong2f-elf", "mipsel-fuloong2e-elf",
"mipsel-fuloong-elf", NULL },
.voidp_sizeof = 4,
.bigendian = 0,
.id = IMAGE_LOONGSON_ELF,
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
.prefix = GRUB_KERNEL_MIPS_LOONGSON_PREFIX,
.prefix_end = GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END,
.raw_size = 0,
.total_module_size = GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE,
.compressed_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.decompressor_compressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_COMPRESSED_SIZE,
.decompressor_uncompressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_SIZE,
.decompressor_uncompressed_addr = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
.install_dos_part = TARGET_NO_FIELD,
.install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN,
@ -347,16 +302,12 @@ struct image_target_desc image_targets[] =
.bigendian = 1,
.id = IMAGE_PPC,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_POWERPC_IEEE1275_PREFIX,
.prefix_end = GRUB_KERNEL_POWERPC_IEEE1275_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.compressed_size = TARGET_NO_FIELD,
.decompressor_compressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_addr = 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_POWERPC_IEEE1275_LINK_ADDR,
.elf_target = EM_PPC,
.mod_gap = GRUB_KERNEL_POWERPC_IEEE1275_MOD_GAP,
@ -370,16 +321,12 @@ struct image_target_desc image_targets[] =
.bigendian = 1,
.id = IMAGE_SPARC64_RAW,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX,
.prefix_end = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END,
.raw_size = GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE,
.total_module_size = GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE,
.kernel_image_size = GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE,
.compressed_size = GRUB_KERNEL_SPARC64_IEEE1275_COMPRESSED_SIZE,
.decompressor_compressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_addr = 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_SPARC64_IEEE1275_LINK_ADDR
},
{
@ -389,16 +336,12 @@ struct image_target_desc image_targets[] =
.bigendian = 1,
.id = IMAGE_SPARC64_AOUT,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX,
.prefix_end = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END,
.raw_size = GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE,
.total_module_size = GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE,
.kernel_image_size = GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE,
.compressed_size = GRUB_KERNEL_SPARC64_IEEE1275_COMPRESSED_SIZE,
.decompressor_compressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_addr = 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_SPARC64_IEEE1275_LINK_ADDR
},
{
@ -408,16 +351,12 @@ struct image_target_desc image_targets[] =
.bigendian = 0,
.id = IMAGE_EFI,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_IA64_EFI_PREFIX,
.prefix_end = GRUB_KERNEL_IA64_EFI_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.compressed_size = TARGET_NO_FIELD,
.decompressor_compressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
.vaddr_offset = EFI64_HEADER_SIZE,
.install_dos_part = TARGET_NO_FIELD,
.install_bsd_part = TARGET_NO_FIELD,
.pe_target = GRUB_PE32_MACHINE_IA64,
.elf_target = EM_IA_64,
},
@ -429,16 +368,12 @@ struct image_target_desc image_targets[] =
.id = IMAGE_MIPS_ARC,
.flags = (PLATFORM_FLAGS_DECOMPRESSORS
| PLATFORM_FLAGS_MODULES_BEFORE_KERNEL),
.prefix = GRUB_KERNEL_MIPS_ARC_PREFIX,
.prefix_end = GRUB_KERNEL_MIPS_ARC_PREFIX_END,
.raw_size = 0,
.total_module_size = GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE,
.compressed_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.decompressor_compressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_COMPRESSED_SIZE,
.decompressor_uncompressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_SIZE,
.decompressor_uncompressed_addr = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
.install_dos_part = TARGET_NO_FIELD,
.install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_ARC_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_ARC_LINK_ALIGN,
@ -451,16 +386,48 @@ struct image_target_desc image_targets[] =
.bigendian = 0,
.id = IMAGE_LOONGSON_ELF,
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
.prefix = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX,
.prefix_end = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END,
.raw_size = 0,
.total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
.compressed_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.decompressor_compressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_COMPRESSED_SIZE,
.decompressor_uncompressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_SIZE,
.decompressor_uncompressed_addr = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
.link_addr = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN,
.default_compression = COMPRESSION_NONE
},
{
.dirname = "mips-qemu_mips",
.names = { "mips-qemu_mips-flash", NULL },
.voidp_sizeof = 4,
.bigendian = 1,
.id = IMAGE_QEMU_MIPS_FLASH,
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
.total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
.decompressor_compressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_COMPRESSED_SIZE,
.decompressor_uncompressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_SIZE,
.decompressor_uncompressed_addr = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
.link_addr = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN,
.default_compression = COMPRESSION_NONE
},
{
.dirname = "mipsel-qemu_mips",
.names = { "mipsel-qemu_mips-flash", NULL },
.voidp_sizeof = 4,
.bigendian = 0,
.id = IMAGE_QEMU_MIPS_FLASH,
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
.total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
.decompressor_compressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_COMPRESSED_SIZE,
.decompressor_uncompressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_SIZE,
.decompressor_uncompressed_addr = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
.install_dos_part = TARGET_NO_FIELD,
.install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN,
@ -473,16 +440,12 @@ struct image_target_desc image_targets[] =
.bigendian = 1,
.id = IMAGE_LOONGSON_ELF,
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
.prefix = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX,
.prefix_end = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END,
.raw_size = 0,
.total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
.compressed_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.decompressor_compressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_COMPRESSED_SIZE,
.decompressor_uncompressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_SIZE,
.decompressor_uncompressed_addr = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
.install_dos_part = TARGET_NO_FIELD,
.install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN,
@ -610,7 +573,7 @@ static ISzAlloc g_Alloc = { SzAlloc, SzFree };
static void
compress_kernel_lzma (char *kernel_img, size_t kernel_size,
char **core_img, size_t *core_size, size_t raw_size)
char **core_img, size_t *core_size)
{
CLzmaEncProps props;
unsigned char out_props[5];
@ -623,27 +586,21 @@ compress_kernel_lzma (char *kernel_img, size_t kernel_size,
props.pb = 2;
props.numThreads = 1;
if (kernel_size < raw_size)
grub_util_error (_("the core image is too small"));
*core_img = xmalloc (kernel_size);
memcpy (*core_img, kernel_img, raw_size);
*core_size = kernel_size - raw_size;
if (LzmaEncode ((unsigned char *) *core_img + raw_size, core_size,
(unsigned char *) kernel_img + raw_size,
kernel_size - raw_size,
*core_size = kernel_size;
if (LzmaEncode ((unsigned char *) *core_img, core_size,
(unsigned char *) kernel_img,
kernel_size,
&props, out_props, &out_props_size,
0, NULL, &g_Alloc, &g_Alloc) != SZ_OK)
grub_util_error (_("cannot compress the kernel image"));
*core_size += raw_size;
}
#ifdef HAVE_LIBLZMA
static void
compress_kernel_xz (char *kernel_img, size_t kernel_size,
char **core_img, size_t *core_size, size_t raw_size)
char **core_img, size_t *core_size)
{
lzma_stream strm = LZMA_STREAM_INIT;
lzma_ret xzret;
@ -664,20 +621,16 @@ compress_kernel_xz (char *kernel_img, size_t kernel_size,
{ .id = LZMA_VLI_UNKNOWN, .options = NULL}
};
if (kernel_size < raw_size)
grub_util_error (_("the core image is too small"));
xzret = lzma_stream_encoder (&strm, fltrs, LZMA_CHECK_NONE);
if (xzret != LZMA_OK)
grub_util_error (_("cannot compress the kernel image"));
*core_img = xmalloc (kernel_size);
memcpy (*core_img, kernel_img, raw_size);
*core_size = kernel_size - raw_size;
strm.next_in = (unsigned char *) kernel_img + raw_size;
strm.avail_in = kernel_size - raw_size;
strm.next_out = (unsigned char *) *core_img + raw_size;
*core_size = kernel_size;
strm.next_in = (unsigned char *) kernel_img;
strm.avail_in = kernel_size;
strm.next_out = (unsigned char *) *core_img;
strm.avail_out = *core_size;
while (1)
@ -691,8 +644,6 @@ compress_kernel_xz (char *kernel_img, size_t kernel_size,
}
*core_size -= strm.avail_out;
*core_size += raw_size;
}
#endif
@ -701,26 +652,27 @@ compress_kernel (struct image_target_desc *image_target, char *kernel_img,
size_t kernel_size, char **core_img, size_t *core_size,
grub_compression_t comp)
{
if (image_target->flags & PLATFORM_FLAGS_LZMA)
{
compress_kernel_lzma (kernel_img, kernel_size, core_img,
core_size, image_target->raw_size);
return;
}
if (image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS
&& (comp == COMPRESSION_LZMA))
{
compress_kernel_lzma (kernel_img, kernel_size, core_img,
core_size);
return;
}
#ifdef HAVE_LIBLZMA
if (image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS
&& (comp == COMPRESSION_XZ))
{
compress_kernel_xz (kernel_img, kernel_size, core_img,
core_size, image_target->raw_size);
core_size);
return;
}
#endif
if (image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS
&& (comp != COMPRESSION_NONE))
grub_util_error ("unknown compression %d\n", comp);
grub_util_error (_("unknown compression %d\n"), comp);
*core_img = xmalloc (kernel_size);
memcpy (*core_img, kernel_img, kernel_size);
@ -751,6 +703,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
char *kernel_img, *core_img;
size_t kernel_size, total_module_size, core_size, exec_size;
size_t memdisk_size = 0, config_size = 0, config_size_pure = 0;
size_t prefix_size = 0;
char *kernel_path;
size_t offset;
struct grub_util_path_list *path_list, *p, *next;
@ -763,6 +716,10 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
if (comp == COMPRESSION_AUTO)
comp = image_target->default_compression;
if (image_target->id == IMAGE_I386_PC
|| image_target->id == IMAGE_I386_PC_PXE)
comp = COMPRESSION_LZMA;
path_list = grub_util_resolve_dependencies (dir, "moddep.lst", mods);
kernel_path = grub_util_get_path (dir, "kernel.img");
@ -787,6 +744,12 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
total_module_size += config_size + sizeof (struct grub_module_header);
}
if (prefix)
{
prefix_size = ALIGN_ADDR (strlen (prefix) + 1);
total_module_size += prefix_size + sizeof (struct grub_module_header);
}
for (p = path_list; p; p = p->next)
total_module_size += (ALIGN_ADDR (grub_util_get_image_size (p->name))
+ sizeof (struct grub_module_header));
@ -802,10 +765,6 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
total_module_size, &start_address, &rel_section,
&reloc_size, &align, image_target);
if (image_target->prefix + strlen (prefix) + 1 > image_target->prefix_end)
grub_util_error (_("prefix is too long"));
strcpy (kernel_img + image_target->prefix, prefix);
if ((image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS)
&& (image_target->total_module_size != TARGET_NO_FIELD))
*((grub_uint32_t *) (kernel_img + image_target->total_module_size))
@ -897,39 +856,32 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
offset += config_size;
}
if (prefix)
{
struct grub_module_header *header;
header = (struct grub_module_header *) (kernel_img + offset);
memset (header, 0, sizeof (struct grub_module_header));
header->type = grub_host_to_target32 (OBJ_TYPE_PREFIX);
header->size = grub_host_to_target32 (prefix_size + sizeof (*header));
offset += sizeof (*header);
grub_memset (kernel_img + offset, 0, prefix_size);
grub_strcpy (kernel_img + offset, prefix);
offset += prefix_size;
}
grub_util_info ("kernel_img=%p, kernel_size=0x%x", kernel_img, kernel_size);
compress_kernel (image_target, kernel_img, kernel_size + total_module_size,
&core_img, &core_size, comp);
free (kernel_img);
if (image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS)
kernel_img = core_img + total_module_size;
else
kernel_img = core_img;
grub_util_info ("the core size is 0x%x", core_size);
if (!(image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS)
&& image_target->total_module_size != TARGET_NO_FIELD)
*((grub_uint32_t *) (kernel_img + image_target->total_module_size))
*((grub_uint32_t *) (core_img + image_target->total_module_size))
= grub_host_to_target32 (total_module_size);
if (image_target->kernel_image_size != TARGET_NO_FIELD)
*((grub_uint32_t *) (kernel_img + image_target->kernel_image_size))
= grub_host_to_target32 (kernel_size);
if (image_target->compressed_size != TARGET_NO_FIELD)
*((grub_uint32_t *) (kernel_img + image_target->compressed_size))
= grub_host_to_target32 (core_size - image_target->raw_size);
/* If we included a drive in our prefix, let GRUB know it doesn't have to
prepend the drive told by BIOS. */
if (image_target->install_dos_part != TARGET_NO_FIELD
&& image_target->install_bsd_part != TARGET_NO_FIELD && prefix[0] == '(')
{
*((grub_int32_t *) (kernel_img + image_target->install_dos_part))
= grub_host_to_target32 (-2);
*((grub_int32_t *) (kernel_img + image_target->install_bsd_part))
= grub_host_to_target32 (-2);
}
if (image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS)
{
@ -943,30 +895,44 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
case COMPRESSION_XZ:
name = "xz_decompress.img";
break;
case COMPRESSION_LZMA:
name = "lzma_decompress.img";
break;
case COMPRESSION_NONE:
name = "none_decompress.img";
break;
default:
grub_util_error ("unknown compression %d\n", comp);
grub_util_error (_("unknown compression %d\n"), comp);
}
decompress_path = grub_util_get_path (dir, name);
decompress_size = grub_util_get_image_size (decompress_path);
decompress_img = grub_util_read_image (decompress_path);
*((grub_uint32_t *) (decompress_img + GRUB_KERNEL_MIPS_LOONGSON_COMPRESSED_SIZE))
= grub_host_to_target32 (core_size);
if ((image_target->id == IMAGE_I386_PC
|| image_target->id == IMAGE_I386_PC_PXE)
&& decompress_size > GRUB_KERNEL_I386_PC_LINK_ADDR - 0x8200)
grub_util_error (_("Decompressor is too big"));
*((grub_uint32_t *) (decompress_img + GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_SIZE))
= grub_host_to_target32 (kernel_size + total_module_size);
if (image_target->decompressor_compressed_size != TARGET_NO_FIELD)
*((grub_uint32_t *) (decompress_img
+ image_target->decompressor_compressed_size))
= grub_host_to_target32 (core_size);
if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL)
*((grub_uint32_t *) (decompress_img + GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR))
= grub_host_to_target_addr (image_target->link_addr - total_module_size);
else
*((grub_uint32_t *) (decompress_img + GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR))
= grub_host_to_target_addr (image_target->link_addr);
if (image_target->decompressor_uncompressed_size != TARGET_NO_FIELD)
*((grub_uint32_t *) (decompress_img
+ image_target->decompressor_uncompressed_size))
= grub_host_to_target32 (kernel_size + total_module_size);
if (image_target->decompressor_uncompressed_addr != TARGET_NO_FIELD)
{
if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL)
*((grub_uint32_t *) (decompress_img + image_target->decompressor_uncompressed_addr))
= grub_host_to_target_addr (image_target->link_addr - total_module_size);
else
*((grub_uint32_t *) (decompress_img + image_target->decompressor_uncompressed_addr))
= grub_host_to_target_addr (image_target->link_addr);
}
full_size = core_size + decompress_size;
full_img = xmalloc (full_size);
@ -993,10 +959,10 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
char *boot_path, *boot_img;
size_t boot_size;
if (GRUB_KERNEL_I386_PC_LINK_ADDR + core_size > GRUB_MEMORY_I386_PC_UPPER)
grub_util_error (_("core image is too big (%p > %p)"),
if (GRUB_KERNEL_I386_PC_LINK_ADDR + core_size > 0x78000)
grub_util_error (_("core image is too big (0x%x > 0x%x)"),
GRUB_KERNEL_I386_PC_LINK_ADDR + core_size,
GRUB_MEMORY_I386_PC_UPPER);
0x78000);
num = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
if (num > 0xffff)
@ -1006,6 +972,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
{
char *pxeboot_path, *pxeboot_img;
size_t pxeboot_size;
grub_uint32_t *ptr;
pxeboot_path = grub_util_get_path (dir, "pxeboot.img");
pxeboot_size = grub_util_get_image_size (pxeboot_path);
@ -1014,6 +981,18 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
grub_util_write_image (pxeboot_img, pxeboot_size, out);
free (pxeboot_img);
free (pxeboot_path);
/* Remove Multiboot header to avoid confusing ipxe. */
for (ptr = (grub_uint32_t *) core_img;
ptr < (grub_uint32_t *) (core_img + MULTIBOOT_SEARCH); ptr++)
if (*ptr == grub_host_to_target32 (MULTIBOOT_HEADER_MAGIC)
&& grub_target_to_host32 (ptr[0])
+ grub_target_to_host32 (ptr[1])
+ grub_target_to_host32 (ptr[2]) == 0)
{
*ptr = 0;
break;
}
}
boot_path = grub_util_get_path (dir, "diskboot.img");
@ -1251,7 +1230,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
rom_img = xmalloc (rom_size);
memset (rom_img, 0, rom_size);
*((grub_int32_t *) (kernel_img + GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR))
*((grub_int32_t *) (core_img + GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR))
= grub_host_to_target32 ((grub_uint32_t) -rom_size);
memcpy (rom_img, core_img, core_size);
@ -1278,6 +1257,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
aout_size = core_size + sizeof (*aout_head);
aout_img = xmalloc (aout_size);
aout_head = aout_img;
grub_memset (aout_head, 0, sizeof (*aout_head));
aout_head->a_midmag = grub_host_to_target32 ((AOUT_MID_SUN << 16)
| AOUT32_OMAGIC);
aout_head->a_text = grub_host_to_target32 (core_size);
@ -1302,7 +1282,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
boot_path = grub_util_get_path (dir, "diskboot.img");
boot_size = grub_util_get_image_size (boot_path);
if (boot_size != GRUB_DISK_SECTOR_SIZE)
grub_util_error ("diskboot.img is not one sector size");
grub_util_error (_("diskboot.img is not one sector size"));
boot_img = grub_util_read_image (boot_path);
@ -1316,7 +1296,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
}
break;
case IMAGE_YEELOONG_FLASH:
case IMAGE_FULOONG_FLASH:
case IMAGE_FULOONG2F_FLASH:
{
char *rom_img;
size_t rom_size;
@ -1335,7 +1315,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* None yet. */
const grub_uint8_t fuloong_fwstart_good_hash[512 / 8] =
const grub_uint8_t fuloong2f_fwstart_good_hash[512 / 8] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -1347,10 +1327,10 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
};
const grub_uint8_t *fwstart_good_hash;
if (image_target->id == IMAGE_FULOONG_FLASH)
if (image_target->id == IMAGE_FULOONG2F_FLASH)
{
fwstart_good_hash = fuloong_fwstart_good_hash;
boot_path = grub_util_get_path (dir, "fwstart_fuloong.img");
fwstart_good_hash = fuloong2f_fwstart_good_hash;
boot_path = grub_util_get_path (dir, "fwstart_fuloong2f.img");
}
else
{
@ -1367,11 +1347,11 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
GRUB_MD_SHA512->final (context);
if (grub_memcmp (GRUB_MD_SHA512->read (context), fwstart_good_hash,
GRUB_MD_SHA512->mdlen) != 0)
grub_util_warn ("fwstart.img doesn't match the known good version. "
"Proceed at your own risk");
grub_util_warn (_("fwstart.img doesn't match the known good version. "
"proceed at your own risk"));
if (core_size + boot_size > 512 * 1024)
grub_util_error ("firmware image is too big");
grub_util_error (_("firmware image is too big"));
rom_size = 512 * 1024;
rom_img = xmalloc (rom_size);
@ -1389,6 +1369,28 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
core_size = rom_size;
}
break;
case IMAGE_QEMU_MIPS_FLASH:
{
char *rom_img;
size_t rom_size;
if (core_size > 512 * 1024)
grub_util_error (_("firmware image is too big"));
rom_size = 512 * 1024;
rom_img = xmalloc (rom_size);
memset (rom_img, 0, rom_size);
memcpy (rom_img, core_img, core_size);
memset (rom_img + core_size, 0,
rom_size - core_size);
free (core_img);
core_img = rom_img;
core_size = rom_size;
}
break;
case IMAGE_MIPS_ARC:
{
char *ecoff_img;
@ -1741,7 +1743,7 @@ main (int argc, char *argv[])
image_target = &image_targets[i];
if (!image_target)
{
printf ("unknown target format %s\n", optarg);
printf (_("unknown target format %s\n"), optarg);
usage (1);
}
break;
@ -1782,14 +1784,14 @@ main (int argc, char *argv[])
#ifdef HAVE_LIBLZMA
comp = COMPRESSION_XZ;
#else
grub_util_error ("grub-mkimage is compiled without XZ support",
grub_util_error (_("grub-mkimage is compiled without XZ support"),
optarg);
#endif
}
else if (grub_strcmp (optarg, "none") == 0)
comp = COMPRESSION_NONE;
else
grub_util_error ("Unknown compression format %s", optarg);
grub_util_error (_("Unknown compression format %s"), optarg);
break;
case 'h':
@ -1819,7 +1821,7 @@ main (int argc, char *argv[])
if (!image_target)
{
printf ("Target format not specified (use the -O option).\n");
printf (_("Target format not specified (use the -O option).\n"));
usage (1);
}

View file

@ -260,9 +260,9 @@ static void
usage (int status)
{
if (status)
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name);
else
printf ("\
printf (_("\
Usage: %s [OPTIONS]\n\
-i, --input set input filename. Default is STDIN\n\
-o, --output set output filename. Default is STDOUT\n\
@ -270,7 +270,7 @@ Usage: %s [OPTIONS]\n\
-V, --version print version information and exit.\n\
-v, --verbose print verbose messages.\n\
\n\
Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT);
Report bugs to <%s>.\n"), program_name, PACKAGE_BUGREPORT);
exit (status);
}
@ -300,7 +300,7 @@ lookup (char *code, int shift)
if (strcmp (code, console_grub_equivalences_common[i].layout) == 0)
return console_grub_equivalences_common[i].grub;
fprintf (stderr, "Unknown key %s\n", code);
fprintf (stderr, _("Unknown key %s\n"), code);
return '\0';
}
@ -396,7 +396,7 @@ write_keymaps (FILE *in, FILE *out)
if (keycode_usb == 0
|| keycode_usb >= GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE)
{
fprintf (stderr, "Unknown keycode 0x%02x\n", keycode_linux);
fprintf (stderr, _("Unknown keycode 0x%02x\n"), keycode_linux);
continue;
}
if (keycode_usb < GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE)
@ -414,7 +414,7 @@ write_keymaps (FILE *in, FILE *out)
if (ok == 0)
{
fprintf (stderr, "ERROR: no keycodes found. Check output of %s.\n",
fprintf (stderr, _("ERROR: no keycodes found. Check output of %s.\n"),
CKBCOMP);
exit (1);
}
@ -479,7 +479,7 @@ main (int argc, char *argv[])
in = stdin;
if (!in)
grub_util_error ("Couldn't open input file: %s\n", strerror (errno));
grub_util_error (_("Couldn't open input file: %s\n"), strerror (errno));
if (outfile_name)
out = fopen (outfile_name, "wb");
@ -490,7 +490,7 @@ main (int argc, char *argv[])
{
if (in != stdin)
fclose (in);
grub_util_error ("Couldn't open output file: %s\n", strerror (errno));
grub_util_error (_("Couldn't open output file: %s\n"), strerror (errno));
}
write_keymaps (in, out);

View file

@ -29,6 +29,7 @@ PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
host_os=@host_os@
localedir=@datadir@/locale
datarootdir=@datarootdir@
pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst"
self=`basename $0`
@ -45,6 +46,12 @@ debug=no
debug_image=
subdir=`echo /boot/grub | sed ${transform}`
pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-pc
ppc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/powerpc-ieee1275
sparc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/sparc64-ieee1275
i386_ieee1275_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-ieee1275
efi32_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-efi
efi64_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/x86_64-efi
itanium_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/ia64-efi
# Usage: usage
# Print the usage.
@ -196,11 +203,20 @@ process_input_dir ()
config_opt="-c ${grubdir}/load.cfg "
fi
prefix="/${subdir}/${platform}";
case "${platform}" in
i386-pc) mkimage_target=i386-pc-pxe;
netmodules="pxe";
prefix="(pxe)/${subdir}/${platform}";
ext=0 ;;
sparc64-ieee1275) mkimage_target=sparc64-ieee1275-aout;
netmodules="ofnet";
ext=img ;;
*-ieee1275) mkimage_target="${platform}";
netmodules="ofnet";
ext=elf ;;
*-efi) mkimage_target="${platform}";
netmodules="efinet";
ext=efi ;;
*) echo Unsupported platform ${platform};
exit 1;;
esac
@ -209,13 +225,31 @@ process_input_dir ()
source ${subdir}/grub.cfg
EOF
$grub_mkimage ${config_opt} -d "${input_dir}" -O ${mkimage_target} --output=${grubdir}/core.$ext --prefix=$prefix $modules $netmodules || exit 1
$grub_mkimage ${config_opt} -d "${input_dir}" -O ${mkimage_target} --output=${grubdir}/core.$ext --prefix=$prefix $modules $netmodules tftp || exit 1
echo "Netboot directory for ${platform} created. Configure your DHCP server to point to ${subdir}/${platform}/core.$ext"
}
if [ "${override_dir}" = "" ] ; then
if test -e "${pc_dir}" ; then
process_input_dir ${pc_dir} i386-pc
process_input_dir "${pc_dir}" i386-pc
fi
if test -e "${ppc_dir}" ; then
process_input_dir "${ppc_dir}" powerpc-ieee1275
fi
if test -e "${sparc_dir}" ; then
process_input_dir ${sparc_dir} sparc64-ieee1275
fi
if test -e "${i386_ieee1275_dir}" ; then
process_input_dir "${i386_ieee1275_dir}" i386-ieee1275
fi
if test -e "${efi32_dir}" ; then
process_input_dir "${efi32_dir}" i386-efi
fi
if test -e "${efi64_dir}" ; then
process_input_dir "${efi64_dir}" x86_64-efi
fi
if test -e "${itanium_dir}" ; then
process_input_dir "${itanium_dir}" ia64-efi
fi
else
source "${override_dir}"/modinfo.sh

View file

@ -20,6 +20,7 @@
#include <grub/types.h>
#include <grub/crypto.h>
#include <grub/auth.h>
#include <grub/emu/misc.h>
#include <grub/util/misc.h>
#include <grub/i18n.h>
@ -29,7 +30,6 @@
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <termios.h>
#include "progname.h"
@ -46,16 +46,17 @@ static void
usage (int status)
{
if (status)
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
printf ("\
printf (_("\
Usage: %s [OPTIONS]\n\
\nOptions:\n\
-c number, --iteration-count=number Number of PBKDF2 iterations\n\
-l number, --buflen=number Length of generated hash\n\
-s number, --salt=number Length of salt\n\
\n\
Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT);
Report bugs to <%s>.\n"), program_name, PACKAGE_BUGREPORT);
exit (status);
}
@ -85,14 +86,12 @@ int
main (int argc, char *argv[])
{
unsigned int count = 10000, buflen = 64, saltlen = 64;
char *pass1, *pass2;
char *bufhex, *salthex;
gcry_err_code_t gcry_err;
grub_uint8_t *buf, *salt;
ssize_t nr;
FILE *in, *out;
struct termios s, t;
int tty_changed;
char pass1[GRUB_AUTH_MAX_PASSLEN];
char pass2[GRUB_AUTH_MAX_PASSLEN];
set_program_name (argv[0]);
@ -137,12 +136,12 @@ main (int argc, char *argv[])
bufhex = malloc (buflen * 2 + 1);
if (!bufhex)
grub_util_error ("out of memory");
grub_util_error (_("out of memory"));
buf = malloc (buflen);
if (!buf)
{
free (bufhex);
grub_util_error ("out of memory");
grub_util_error (_("out of memory"));
}
salt = malloc (saltlen);
@ -150,7 +149,7 @@ main (int argc, char *argv[])
{
free (bufhex);
free (buf);
grub_util_error ("out of memory");
grub_util_error (_("out of memory"));
}
salthex = malloc (saltlen * 2 + 1);
if (!salthex)
@ -158,91 +157,42 @@ main (int argc, char *argv[])
free (salt);
free (bufhex);
free (buf);
grub_util_error ("out of memory");
grub_util_error (_("out of memory"));
}
/* Disable echoing. Based on glibc. */
in = fopen ("/dev/tty", "w+c");
if (in == NULL)
{
in = stdin;
out = stderr;
}
else
out = in;
if (tcgetattr (fileno (in), &t) == 0)
{
/* Save the old one. */
s = t;
/* Tricky, tricky. */
t.c_lflag &= ~(ECHO|ISIG);
tty_changed = (tcsetattr (fileno (in), TCSAFLUSH, &t) == 0);
}
else
tty_changed = 0;
printf ("Enter password: ");
pass1 = NULL;
{
grub_size_t n;
nr = getline (&pass1, &n, stdin);
}
if (nr < 0 || !pass1)
printf ("%s", _("Enter password: "));
if (!grub_password_get (pass1, GRUB_AUTH_MAX_PASSLEN))
{
free (buf);
free (bufhex);
free (salthex);
free (salt);
/* Restore the original setting. */
if (tty_changed)
(void) tcsetattr (fileno (in), TCSAFLUSH, &s);
grub_util_error ("failure to read password");
grub_util_error (_("failure to read password"));
}
if (nr >= 1 && pass1[nr-1] == '\n')
pass1[nr-1] = 0;
printf ("\nReenter password: ");
pass2 = NULL;
{
grub_size_t n;
nr = getline (&pass2, &n, stdin);
}
/* Restore the original setting. */
if (tty_changed)
(void) tcsetattr (fileno (in), TCSAFLUSH, &s);
printf ("\n");
if (nr < 0 || !pass2)
printf ("\n%s", _("Reenter password: "));
if (!grub_password_get (pass2, GRUB_AUTH_MAX_PASSLEN))
{
memset (pass1, 0, strlen (pass1));
free (pass1);
free (buf);
free (bufhex);
free (salthex);
free (salt);
grub_util_error ("failure to read password");
grub_util_error (_("failure to read password"));
}
if (nr >= 1 && pass2[nr-1] == '\n')
pass2[nr-1] = 0;
if (strcmp (pass1, pass2) != 0)
{
memset (pass1, 0, strlen (pass1));
memset (pass2, 0, strlen (pass2));
free (pass1);
free (pass2);
memset (pass1, 0, sizeof (pass1));
memset (pass2, 0, sizeof (pass2));
free (buf);
free (bufhex);
free (salthex);
free (salt);
grub_util_error ("passwords don't match");
grub_util_error (_("passwords don't match"));
}
memset (pass2, 0, strlen (pass2));
free (pass2);
memset (pass2, 0, sizeof (pass2));
#if ! defined (__linux__) && ! defined (__FreeBSD__)
printf ("WARNING: your random generator isn't known to be secure\n");
printf ("%s", _("WARNING: your random generator isn't known to be secure\n"));
#endif
{
@ -251,27 +201,24 @@ main (int argc, char *argv[])
f = fopen ("/dev/urandom", "rb");
if (!f)
{
memset (pass1, 0, strlen (pass1));
free (pass1);
memset (pass1, 0, sizeof (pass1));
free (buf);
free (bufhex);
free (salthex);
free (salt);
fclose (f);
grub_util_error ("couldn't retrieve random data for salt");
grub_util_error (_("couldn't retrieve random data for salt"));
}
rd = fread (salt, 1, saltlen, f);
if (rd != saltlen)
{
fclose (f);
memset (pass1, 0, strlen (pass1));
free (pass1);
memset (pass1, 0, sizeof (pass1));
free (buf);
free (bufhex);
free (salthex);
free (salt);
fclose (f);
grub_util_error ("couldn't retrieve random data for salt");
grub_util_error (_("couldn't retrieve random data for salt"));
}
fclose (f);
}
@ -280,8 +227,7 @@ main (int argc, char *argv[])
(grub_uint8_t *) pass1, strlen (pass1),
salt, saltlen,
count, buf, buflen);
memset (pass1, 0, strlen (pass1));
free (pass1);
memset (pass1, 0, sizeof (pass1));
if (gcry_err)
{
@ -293,13 +239,13 @@ main (int argc, char *argv[])
memset (salthex, 0, 2 * saltlen);
free (salt);
free (salthex);
grub_util_error ("cryptographic error number %d", gcry_err);
grub_util_error (_("cryptographic error number %d"), gcry_err);
}
hexify (bufhex, buf, buflen);
hexify (salthex, salt, saltlen);
printf ("Your PBKDF2 is grub.pbkdf2.sha512.%d.%s.%s\n",
printf (_("Your PBKDF2 is grub.pbkdf2.sha512.%d.%s.%s\n"),
count, salthex, bufhex);
memset (buf, 0, buflen);
memset (bufhex, 0, 2 * buflen);

View file

@ -38,9 +38,9 @@ static void
usage (int status)
{
if (status)
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name);
else
printf ("\
printf (_("\
Usage: %s [OPTIONS] PATH\n\
\n\
Make a system path relative to its root.\n\
@ -49,7 +49,7 @@ Options:\n\
-h, --help display this message and exit\n\
-V, --version print version information and exit\n\
\n\
Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT);
Report bugs to <%s>.\n"), program_name, PACKAGE_BUGREPORT);
exit (status);
}
@ -89,13 +89,13 @@ main (int argc, char *argv[])
if (optind >= argc)
{
fprintf (stderr, "No path is specified.\n");
fprintf (stderr, _("No path is specified.\n"));
usage (1);
}
if (optind + 1 != argc)
{
fprintf (stderr, "Unknown extra argument `%s'.\n", argv[optind + 1]);
fprintf (stderr, _("Unknown extra argument `%s'.\n"), argv[optind + 1]);
usage (1);
}

View file

@ -31,15 +31,15 @@ pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst
self=`basename $0`
multiboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-multiboot
coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-coreboot
qemu_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-qemu
pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-pc
efi32_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-efi
efi64_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/x86_64-efi
multiboot_dir="${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-multiboot"
coreboot_dir="${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-coreboot"
qemu_dir="${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-qemu"
pc_dir="${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-pc"
efi32_dir="${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-efi"
efi64_dir="${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/x86_64-efi"
rom_directory=
override_dir=
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
grub_mkimage="${bindir}/`echo grub-mkimage | sed ${transform}`"
xorriso=xorriso
@ -129,7 +129,7 @@ do
--xorriso)
xorriso=`argument $option "$@"`; shift ;;
--xorriso=*)
xorriso=`echo "${option}/" | sed 's/--xorriso=//'` ;;
xorriso=`echo "${option}" | sed 's/--xorriso=//'` ;;
*)
source="${source} ${option} $@"; break ;;
@ -275,7 +275,7 @@ if test -e "${pc_dir}" ; then
fi
# build multiboot core.img
make_image "${multiboot_dir}" i386-multiboot "${iso9660_dir}/boot/multiboot.img" "ata at_keyboard"
make_image "${multiboot_dir}" i386-multiboot "${iso9660_dir}/boot/multiboot.img" "pata ahci at_keyboard"
if test -e "${efi64_dir}" || test -e "${efi32_dir}"; then
efi_dir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
@ -296,11 +296,11 @@ if test -e "${efi64_dir}" || test -e "${efi32_dir}"; then
grub_mkisofs_arguments="${grub_mkisofs_arguments} --efi-boot efi.img"
fi
make_image "${qemu_dir}" i386-qemu "${iso9660_dir}/boot/qemu.img" "ata at_keyboard"
make_image "${qemu_dir}" i386-qemu "${iso9660_dir}/boot/qemu.img" "pata at_keyboard"
if [ -e "${iso9660_dir}/boot/qemu.img" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/qemu.img" "${rom_directory}/qemu.img"
fi
make_image "${coreboot_dir}" i386-coreboot "${iso9660_dir}/boot/coreboot.elf" "ata at_keyboard"
make_image "${coreboot_dir}" i386-coreboot "${iso9660_dir}/boot/coreboot.elf" "pata ahci at_keyboard"
if [ -e "${iso9660_dir}/boot/coreboot.elf" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/coreboot.elf" "${rom_directory}/coreboot.elf"
fi

190
util/grub-mkstandalone.in Normal file
View file

@ -0,0 +1,190 @@
#! /bin/sh
set -e
# Make GRUB rescue image
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
# Initialize some variables.
transform="@program_transform_name@"
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst"
self=`basename $0`
source_directory=
compression=auto
format=
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
source=
# Usage: usage
# Print the usage.
usage () {
cat <<EOF
Usage: $self [OPTION] SOURCE...
Make GRUB rescue image.
-h, --help print this message and exit
-v, --version print the version information and exit
-o, --output=FILE save output in FILE [required]
-d, --directory=DIR use images and modules under DIR [default=%s/@platform@]
-O, --format=FORMAT generate an image in format
available formats: %s
-C, --compression=(xz|none|auto) choose the compression to use
--modules=MODULES pre-load specified modules MODULES
--grub-mkimage=FILE use FILE as grub-mkimage
$self generates a standalone image (containing all modules) in the selected format
Report bugs to <bug-grub@gnu.org>.
EOF
}
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
# Check the arguments.
while test $# -gt 0
do
option=$1
shift
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
-o | --output)
output_image=`argument $option "$@"`; shift ;;
--output=*)
output_image=`echo "$option" | sed 's/--output=//'` ;;
--directory | -d)
source_directory=`argument $option "$@"`; shift ;;
--directory=*)
source_directory=`echo "$option" | sed 's/--directory=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift ;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
--compression | -C)
compression=`argument $option "$@"`; shift ;;
--compression=*)
compression=`echo "${option}" | sed 's/--compression=//'` ;;
--format | -O)
format=`argument $option "$@"`; shift ;;
--format=*)
format=`echo "${option}" | sed 's/--format=//'` ;;
*)
source="${source} ${option} $@"; break ;;
esac
done
if [ "x${output_image}" = x ] ; then
echo "output file must be given" >&2
usage
exit 1
fi
if [ "x${format}" = x ] ; then
echo "format must be given" >&2
usage
exit 1
fi
if [ "x$source_directory" = x ] ; then
cpu="`echo $format | awk -F - '{ print $1; }'`"
platform="`echo $format | awk -F - '{ print $2; }'`"
case "$platform" in
yeeloong | fuloong | fuloong2f | fuloong2e)
platform=loongson ;;
esac
case "$cpu-$platform" in
mips-loongson)
cpu=mipsel ;;
esac
source_directory="${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/$cpu-$platform"
fi
set $grub_mkimage dummy
if test -f "$1"; then
:
else
echo "$1: Not found." 1>&2
exit 1
fi
memdisk_dir="`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
mkdir -p "${memdisk_dir}"/boot/grub
for file in "${source_directory}/"*.mod "${source_directory}/"efiemu32.o "${source_directory}/"efiemu64.o; do
if test -f "$file"; then
cp -f "$file" "${memdisk_dir}"/boot/grub/
fi
done
for file in ${pkglib_DATA}; do
if test -f "${source_directory}/${file}"; then
cp -f "${source_directory}/${file}" "${memdisk_dir}"/boot/grub/
fi
done
mkdir -p "${memdisk_dir}"/boot/grub/locale
for file in "${source_directory}"/po/*.mo; do
if test -f "$file"; then
cp -f "$file" "${memdisk_dir}"/boot/grub/locale/
fi
done
for file in $source; do
cp -f "$file" "${memdisk_dir}"/"$file";
done
memdisk_img=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
(cd "${memdisk_dir}"; tar -cf - * $source) > "${memdisk_img}"
rm -rf "${memdisk_dir}"
$grub_mkimage -O "${format}" -C "$compression" -d "${source_directory}" -m "${memdisk_img}" -o "$output_image" --prefix='(memdisk)/boot/grub' memdisk tar $modules
rm -rf "${memdisk_img}"
exit 0

569
util/grub-mount.c Normal file
View file

@ -0,0 +1,569 @@
/* grub-mount.c - FUSE driver for filesystems that GRUB understands */
/*
* GRUB -- GRand Unified Bootloader
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#define FUSE_USE_VERSION 26
#include <config.h>
#include <grub/types.h>
#include <grub/emu/misc.h>
#include <grub/util/misc.h>
#include <grub/misc.h>
#include <grub/device.h>
#include <grub/disk.h>
#include <grub/file.h>
#include <grub/fs.h>
#include <grub/env.h>
#include <grub/term.h>
#include <grub/mm.h>
#include <grub/lib/hexdump.h>
#include <grub/crypto.h>
#include <grub/command.h>
#include <grub/zfs/zfs.h>
#include <grub/i18n.h>
#include <fuse/fuse.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include "progname.h"
#include "argp.h"
static char *root = NULL;
grub_device_t dev = NULL;
grub_fs_t fs = NULL;
static char **images = NULL;
static char *debug_str = NULL;
static char **fuse_args = NULL;
static int fuse_argc = 0;
static int num_disks = 0;
static int mount_crypt = 0;
static grub_err_t
execute_command (char *name, int n, char **args)
{
grub_command_t cmd;
cmd = grub_command_find (name);
if (! cmd)
grub_util_error (_("can\'t find command %s"), name);
return (cmd->func) (cmd, n, args);
}
/* Translate GRUB error numbers into OS error numbers. Print any unexpected
errors. */
static int
translate_error (void)
{
int ret;
switch (grub_errno)
{
case GRUB_ERR_NONE:
ret = 0;
break;
case GRUB_ERR_OUT_OF_MEMORY:
grub_print_error ();
ret = -ENOMEM;
break;
case GRUB_ERR_BAD_FILE_TYPE:
/* This could also be EISDIR. Take a guess. */
ret = -ENOTDIR;
break;
case GRUB_ERR_FILE_NOT_FOUND:
ret = -ENOENT;
break;
case GRUB_ERR_FILE_READ_ERROR:
case GRUB_ERR_READ_ERROR:
case GRUB_ERR_IO:
grub_print_error ();
ret = -EIO;
break;
case GRUB_ERR_SYMLINK_LOOP:
ret = -ELOOP;
break;
default:
grub_print_error ();
ret = -EINVAL;
break;
}
/* Any previous errors were handled. */
grub_errno = GRUB_ERR_NONE;
return ret;
}
static int
fuse_getattr (const char *path, struct stat *st)
{
char *filename, *pathname, *path2;
const char *pathname_t;
struct grub_dirhook_info file_info;
int file_exists = 0;
/* A hook for iterating directories. */
auto int find_file (const char *cur_filename,
const struct grub_dirhook_info *info);
int find_file (const char *cur_filename,
const struct grub_dirhook_info *info)
{
if ((info->case_insensitive ? grub_strcasecmp (cur_filename, filename)
: grub_strcmp (cur_filename, filename)) == 0)
{
file_info = *info;
file_exists = 1;
return 1;
}
return 0;
}
if (path[0] == '/' && path[1] == 0)
{
st->st_dev = 0;
st->st_ino = 0;
st->st_mode = 0555 | S_IFDIR;
st->st_uid = 0;
st->st_gid = 0;
st->st_rdev = 0;
st->st_size = 0;
st->st_blksize = 512;
st->st_blocks = (st->st_blksize + 511) >> 9;
st->st_atime = st->st_mtime = st->st_ctime = 0;
return 0;
}
file_exists = 0;
pathname_t = grub_strchr (path, ')');
if (! pathname_t)
pathname_t = path;
else
pathname_t++;
pathname = xstrdup (pathname_t);
/* Remove trailing '/'. */
while (*pathname && pathname[grub_strlen (pathname) - 1] == '/')
pathname[grub_strlen (pathname) - 1] = 0;
/* Split into path and filename. */
filename = grub_strrchr (pathname, '/');
if (! filename)
{
path2 = grub_strdup ("/");
filename = pathname;
}
else
{
filename++;
path2 = grub_strdup (pathname);
path2[filename - pathname] = 0;
}
/* It's the whole device. */
(fs->dir) (dev, path2, find_file);
grub_free (path2);
if (!file_exists)
{
grub_errno = GRUB_ERR_NONE;
return -ENOENT;
}
st->st_dev = 0;
st->st_ino = 0;
st->st_mode = file_info.dir ? (0555 | S_IFDIR) : (0444 | S_IFREG);
st->st_uid = 0;
st->st_gid = 0;
st->st_rdev = 0;
if (!file_info.dir)
{
grub_file_t file;
file = grub_file_open (path);
if (! file)
return translate_error ();
st->st_size = file->size;
grub_file_close (file);
}
else
st->st_size = 0;
st->st_blksize = 512;
st->st_blocks = (st->st_size + 511) >> 9;
st->st_atime = st->st_mtime = st->st_ctime = file_info.mtimeset
? file_info.mtime : 0;
grub_errno = GRUB_ERR_NONE;
return 0;
}
static int
fuse_opendir (const char *path, struct fuse_file_info *fi)
{
return 0;
}
/* FIXME */
static grub_file_t files[65536];
static int first_fd = 1;
static int
fuse_open (const char *path, struct fuse_file_info *fi __attribute__ ((unused)))
{
grub_file_t file;
file = grub_file_open (path);
if (! file)
return translate_error ();
files[first_fd++] = file;
fi->fh = first_fd;
files[first_fd++] = file;
grub_errno = GRUB_ERR_NONE;
return 0;
}
static int
fuse_read (const char *path, char *buf, size_t sz, off_t off,
struct fuse_file_info *fi)
{
grub_file_t file = files[fi->fh];
grub_ssize_t size;
if (off > file->size)
return -EINVAL;
file->offset = off;
size = grub_file_read (file, buf, sz);
if (size < 0)
return translate_error ();
else
{
grub_errno = GRUB_ERR_NONE;
return size;
}
}
static int
fuse_release (const char *path, struct fuse_file_info *fi)
{
grub_file_close (files[fi->fh]);
files[fi->fh] = NULL;
grub_errno = GRUB_ERR_NONE;
return 0;
}
static int
fuse_readdir (const char *path, void *buf,
fuse_fill_dir_t fill, off_t off, struct fuse_file_info *fi)
{
char *pathname;
auto int call_fill (const char *filename,
const struct grub_dirhook_info *info);
int call_fill (const char *filename, const struct grub_dirhook_info *info)
{
struct stat st;
grub_memset (&st, 0, sizeof (st));
st.st_mode = info->dir ? (0555 | S_IFDIR) : (0444 | S_IFREG);
if (!info->dir)
{
grub_file_t file;
char *tmp;
tmp = xasprintf ("%s/%s", path, filename);
file = grub_file_open (tmp);
free (tmp);
if (! file)
return translate_error ();
st.st_size = file->size;
grub_file_close (file);
}
st.st_blksize = 512;
st.st_blocks = (st.st_size + 511) >> 9;
st.st_atime = st.st_mtime = st.st_ctime
= info->mtimeset ? info->mtime : 0;
fill (buf, filename, &st, 0);
return 0;
}
pathname = xstrdup (path);
/* Remove trailing '/'. */
while (pathname [0] && pathname[1]
&& pathname[grub_strlen (pathname) - 1] == '/')
pathname[grub_strlen (pathname) - 1] = 0;
(fs->dir) (dev, pathname, call_fill);
free (pathname);
grub_errno = GRUB_ERR_NONE;
return 0;
}
struct fuse_operations grub_opers = {
.getattr = fuse_getattr,
.open = fuse_open,
.release = fuse_release,
.opendir = fuse_opendir,
.readdir = fuse_readdir,
.read = fuse_read
};
static grub_err_t
fuse_init (void)
{
int i;
for (i = 0; i < num_disks; i++)
{
char *argv[2];
char *host_file;
char *loop_name;
loop_name = grub_xasprintf ("loop%d", i);
if (!loop_name)
grub_util_error (grub_errmsg);
host_file = grub_xasprintf ("(host)%s", images[i]);
if (!host_file)
grub_util_error (grub_errmsg);
argv[0] = loop_name;
argv[1] = host_file;
if (execute_command ("loopback", 2, argv))
grub_util_error (_("loopback command fails"));
grub_free (loop_name);
grub_free (host_file);
}
if (mount_crypt)
{
char *argv[2] = { "-a", NULL};
if (execute_command ("cryptomount", 1, argv))
grub_util_error (_("cryptomount command fails: %s"), grub_errmsg);
}
grub_lvm_fini ();
grub_mdraid09_fini ();
grub_mdraid1x_fini ();
grub_raid_fini ();
grub_raid_init ();
grub_mdraid09_init ();
grub_mdraid1x_init ();
grub_lvm_init ();
dev = grub_device_open (0);
if (! dev)
return grub_errno;
fs = grub_fs_probe (dev);
if (! fs)
{
grub_device_close (dev);
return grub_errno;
}
fuse_main (fuse_argc, fuse_args, &grub_opers, NULL);
for (i = 0; i < num_disks; i++)
{
char *argv[2];
char *loop_name;
loop_name = grub_xasprintf ("loop%d", i);
if (!loop_name)
grub_util_error (grub_errmsg);
argv[0] = "-d";
argv[1] = loop_name;
execute_command ("loopback", 2, argv);
grub_free (loop_name);
}
return GRUB_ERR_NONE;
}
static struct argp_option options[] = {
{"root", 'r', N_("DEVICE_NAME"), 0, N_("Set root device."), 2},
{"debug", 'd', "S", 0, N_("Set debug environment variable."), 2},
{"crypto", 'C', NULL, OPTION_ARG_OPTIONAL, N_("Mount crypto devices."), 2},
{"zfs-key", 'K', N_("FILE|prompt"), 0, N_("Load zfs crypto key."), 2},
{"verbose", 'v', NULL, OPTION_ARG_OPTIONAL, N_("Print verbose messages."), 2},
{0, 0, 0, 0, 0, 0}
};
/* Print the version information. */
static void
print_version (FILE *stream, struct argp_state *state)
{
fprintf (stream, "%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
}
void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
error_t
argp_parser (int key, char *arg, struct argp_state *state)
{
char *p;
switch (key)
{
case 'r':
root = arg;
return 0;
case 'K':
if (strcmp (arg, "prompt") == 0)
{
char buf[1024];
grub_printf ("%s", _("Enter ZFS password: "));
if (grub_password_get (buf, 1023))
{
grub_zfs_add_key ((grub_uint8_t *) buf, grub_strlen (buf), 1);
}
}
else
{
FILE *f;
ssize_t real_size;
grub_uint8_t buf[1024];
f = fopen (arg, "rb");
if (!f)
{
printf (_("Error loading file %s: %s\n"), arg, strerror (errno));
return 0;
}
real_size = fread (buf, 1, 1024, f);
if (real_size < 0)
{
printf (_("Error loading file %s: %s\n"), arg, strerror (errno));
fclose (f);
return 0;
}
grub_zfs_add_key (buf, real_size, 0);
}
return 0;
case 'C':
mount_crypt = 1;
return 0;
case 'd':
debug_str = arg;
return 0;
case 'v':
verbosity++;
return 0;
case ARGP_KEY_ARG:
if (arg[0] != '-')
break;
default:
if (!arg)
return 0;
fuse_args = xrealloc (fuse_args, (fuse_argc + 1) * sizeof (fuse_args[0]));
fuse_args[fuse_argc] = xstrdup (arg);
fuse_argc++;
return 0;
}
images = xrealloc (images, (num_disks + 1) * sizeof (images[0]));
images[num_disks] = canonicalize_file_name (arg);
num_disks++;
return 0;
}
struct argp argp = {
options, argp_parser, N_("IMAGE1 [IMAGE2 ...] MOUNTPOINT"),
N_("Debug tool for filesystem driver."),
NULL, NULL, NULL
};
int
main (int argc, char *argv[])
{
char *default_root, *alloc_root;
set_program_name (argv[0]);
grub_util_init_nls ();
fuse_args = xrealloc (fuse_args, (fuse_argc + 2) * sizeof (fuse_args[0]));
fuse_args[fuse_argc] = xstrdup (argv[0]);
fuse_argc++;
/* Run single-threaded. */
fuse_args[fuse_argc] = xstrdup ("-s");
fuse_argc++;
argp_parse (&argp, argc, argv, 0, 0, 0);
if (num_disks < 2)
grub_util_error (_("need an image and mountpoint"));
fuse_args = xrealloc (fuse_args, (fuse_argc + 2) * sizeof (fuse_args[0]));
fuse_args[fuse_argc] = images[num_disks - 1];
fuse_argc++;
num_disks--;
fuse_args[fuse_argc] = NULL;
/* Initialize all modules. */
grub_init_all ();
if (debug_str)
grub_env_set ("debug", debug_str);
default_root = (num_disks == 1) ? "loop0" : "md0";
alloc_root = 0;
if (root)
{
if ((*root >= '0') && (*root <= '9'))
{
alloc_root = xmalloc (strlen (default_root) + strlen (root) + 2);
sprintf (alloc_root, "%s,%s", default_root, root);
root = alloc_root;
}
}
else
root = default_root;
grub_env_set ("root", root);
if (alloc_root)
free (alloc_root);
/* Do it. */
fuse_init ();
if (grub_errno)
{
grub_print_error ();
return 1;
}
/* Free resources. */
grub_fini_all ();
return 0;
}

View file

@ -31,6 +31,8 @@
#include "progname.h"
/* Please don't internationalise this file. It's pointless. */
static struct option options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},

View file

@ -21,7 +21,6 @@
#include <grub/types.h>
#include <grub/emu/misc.h>
#include <grub/util/misc.h>
#include <grub/util/misc.h>
#include <grub/device.h>
#include <grub/disk.h>
#include <grub/file.h>
@ -36,6 +35,8 @@
#include <grub/i18n.h>
#include <grub/emu/misc.h>
#include <grub/util/ofpath.h>
#include <grub/crypto.h>
#include <grub/cryptodisk.h>
#include <stdio.h>
#include <unistd.h>
@ -56,6 +57,7 @@ enum {
PRINT_DEVICE,
PRINT_PARTMAP,
PRINT_ABSTRACTION,
PRINT_CRYPTODISK_UUID,
PRINT_HINT_STR,
PRINT_BIOS_HINT,
PRINT_IEEE1275_HINT,
@ -72,15 +74,49 @@ static void
probe_partmap (grub_disk_t disk)
{
grub_partition_t part;
grub_disk_memberlist_t list = NULL, tmp;
if (disk->partition == NULL)
{
grub_util_info ("no partition map found for %s", disk->name);
return;
}
for (part = disk->partition; part; part = part->parent)
printf ("%s\n", part->partmap->name);
printf ("%s ", part->partmap->name);
/* In case of LVM/RAID, check the member devices as well. */
if (disk->dev->memberlist)
{
list = disk->dev->memberlist (disk);
}
while (list)
{
probe_partmap (list->disk);
tmp = list->next;
free (list);
list = tmp;
}
}
static void
probe_cryptodisk_uuid (grub_disk_t disk)
{
grub_disk_memberlist_t list = NULL, tmp;
/* In case of LVM/RAID, check the member devices as well. */
if (disk->dev->memberlist)
{
list = disk->dev->memberlist (disk);
}
while (list)
{
probe_cryptodisk_uuid (list->disk);
tmp = list->next;
free (list);
list = tmp;
}
if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
grub_util_cryptodisk_print_uuid (disk);
}
static int
@ -222,6 +258,42 @@ print_full_name (const char *drive, grub_device_t dev)
printf ("%s", drive);
}
static void
probe_abstraction (grub_disk_t disk)
{
grub_disk_memberlist_t list = NULL, tmp;
int raid_level;
if (disk->dev->memberlist)
list = disk->dev->memberlist (disk);
while (list)
{
probe_abstraction (list->disk);
tmp = list->next;
free (list);
list = tmp;
}
if (disk->dev->id == GRUB_DISK_DEVICE_LVM_ID)
printf ("lvm ");
if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
grub_util_cryptodisk_print_abstraction (disk);
raid_level = probe_raid_level (disk);
if (raid_level >= 0)
{
printf ("raid ");
if (disk->dev->raidname)
printf ("%s ", disk->dev->raidname (disk));
}
if (raid_level == 5)
printf ("raid5rec ");
if (raid_level == 6)
printf ("raid6rec ");
}
static void
probe (const char *path, char *device_name)
{
@ -233,19 +305,22 @@ probe (const char *path, char *device_name)
if (path == NULL)
{
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__sun__)
if (! grub_util_check_char_device (device_name))
grub_util_error ("%s is not a character device", device_name);
grub_util_error (_("%s is not a character device"), device_name);
#else
if (! grub_util_check_block_device (device_name))
grub_util_error ("%s is not a block device", device_name);
grub_util_error (_("%s is not a block device"), device_name);
#endif
}
else
device_name = grub_guess_root_device (path);
{
grub_path = canonicalize_file_name (path);
device_name = grub_guess_root_device (grub_path);
}
if (! device_name)
grub_util_error ("cannot find a device for %s (is /dev mounted?)", path);
grub_util_error (_("cannot find a device for %s (is /dev mounted?)"), path);
if (print == PRINT_DEVICE)
{
@ -255,7 +330,8 @@ probe (const char *path, char *device_name)
drive_name = grub_util_get_grub_dev (device_name);
if (! drive_name)
grub_util_error ("cannot find a GRUB drive for %s. Check your device.map", device_name);
grub_util_error (_("cannot find a GRUB drive for %s. Check your device.map"),
device_name);
if (print == PRINT_DRIVE)
{
@ -266,7 +342,7 @@ probe (const char *path, char *device_name)
grub_util_info ("opening %s", drive_name);
dev = grub_device_open (drive_name);
if (! dev)
grub_util_error ("%s", grub_errmsg);
grub_util_error ("%s", _(grub_errmsg));
if (print == PRINT_HINT_STR)
{
@ -437,97 +513,29 @@ probe (const char *path, char *device_name)
if (print == PRINT_ABSTRACTION)
{
grub_disk_memberlist_t list = NULL, tmp;
const int is_lvm = (dev->disk->dev->id == GRUB_DISK_DEVICE_LVM_ID);
int is_raid = 0;
int is_raid5 = 0;
int is_raid6 = 0;
int raid_level;
grub_disk_t raid_disk;
raid_level = probe_raid_level (dev->disk);
if (raid_level >= 0)
{
is_raid = 1;
is_raid5 |= (raid_level == 5);
is_raid6 |= (raid_level == 6);
raid_disk = dev->disk;
}
if ((is_lvm) && (dev->disk->dev->memberlist))
list = dev->disk->dev->memberlist (dev->disk);
while (list)
{
raid_level = probe_raid_level (list->disk);
if (raid_level >= 0)
{
is_raid = 1;
is_raid5 |= (raid_level == 5);
is_raid6 |= (raid_level == 6);
raid_disk = list->disk;
}
tmp = list->next;
free (list);
list = tmp;
}
if (is_raid)
{
printf ("raid ");
if (is_raid5)
printf ("raid5rec ");
if (is_raid6)
printf ("raid6rec ");
if (raid_disk->dev->raidname)
printf ("%s ", raid_disk->dev->raidname (raid_disk));
}
if (is_lvm)
printf ("lvm ");
probe_abstraction (dev->disk);
printf ("\n");
goto end;
}
if (print == PRINT_CRYPTODISK_UUID)
{
probe_cryptodisk_uuid (dev->disk);
printf ("\n");
goto end;
}
if (print == PRINT_PARTMAP)
{
grub_disk_memberlist_t list = NULL, tmp;
/* Check if dev->disk itself is contained in a partmap. */
probe_partmap (dev->disk);
/* In case of LVM/RAID, check the member devices as well. */
if (dev->disk->dev->memberlist)
list = dev->disk->dev->memberlist (dev->disk);
while (list)
{
probe_partmap (list->disk);
/* LVM on RAID */
if (list->disk->dev->memberlist)
{
grub_disk_memberlist_t sub_list;
sub_list = list->disk->dev->memberlist (list->disk);
while (sub_list)
{
probe_partmap (sub_list->disk);
tmp = sub_list->next;
free (sub_list);
sub_list = tmp;
}
}
tmp = list->next;
free (list);
list = tmp;
}
printf ("\n");
goto end;
}
fs = grub_fs_probe (dev);
if (! fs)
grub_util_error ("%s", grub_errmsg);
grub_util_error ("%s", _(grub_errmsg));
if (print == PRINT_FS)
{
@ -537,7 +545,7 @@ probe (const char *path, char *device_name)
{
char *uuid;
if (! fs->uuid)
grub_util_error ("%s does not support UUIDs", fs->name);
grub_util_error (_("%s does not support UUIDs"), fs->name);
if (fs->uuid (dev, &uuid) != GRUB_ERR_NONE)
grub_util_error ("%s", grub_errmsg);
@ -548,10 +556,10 @@ probe (const char *path, char *device_name)
{
char *label;
if (! fs->label)
grub_util_error ("%s does not support labels", fs->name);
grub_util_error (_("%s does not support labels"), fs->name);
if (fs->label (dev, &label) != GRUB_ERR_NONE)
grub_util_error ("%s", grub_errmsg);
grub_util_error ("%s", _(grub_errmsg));
printf ("%s\n", label);
}
@ -581,23 +589,23 @@ usage (int status)
{
if (status)
fprintf (stderr,
"Try `%s --help' for more information.\n", program_name);
_("Try `%s --help' for more information.\n"), program_name);
else
printf ("\
printf (_("\
Usage: %s [OPTION]... [PATH|DEVICE]\n\
\n\
Probe device information for a given path (or device, if the -d option is given).\n\
\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|fs_label|drive|device|partmap|abstraction)\n\
print filesystem module, GRUB drive, system device, partition map module or abstraction module [default=fs]\n\
-t, --target=(fs|fs_uuid|fs_label|drive|device|partmap|abstraction|cryptodisk_uuid)\n\
print filesystem module, GRUB drive, system device, partition map module, abstraction module or CRYPTO UUID [default=fs]\n\
-h, --help display this message and exit\n\
-V, --version print version information and exit\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n\
", program_name,
"), program_name,
DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
exit (status);
@ -649,6 +657,8 @@ main (int argc, char *argv[])
print = PRINT_PARTMAP;
else if (!strcmp (optarg, "abstraction"))
print = PRINT_ABSTRACTION;
else if (!strcmp (optarg, "cryptodisk_uuid"))
print = PRINT_CRYPTODISK_UUID;
else if (!strcmp (optarg, "hints_string"))
print = PRINT_HINT_STR;
else if (!strcmp (optarg, "bios_hints"))
@ -691,13 +701,13 @@ main (int argc, char *argv[])
/* Obtain ARGUMENT. */
if (optind >= argc)
{
fprintf (stderr, "No path or device is specified.\n");
fprintf (stderr, _("No path or device is specified.\n"));
usage (1);
}
if (optind + 1 != argc)
{
fprintf (stderr, "Unknown extra argument `%s'.\n", argv[optind + 1]);
fprintf (stderr, _("Unknown extra argument `%s'.\n"), argv[optind + 1]);
usage (1);
}
@ -708,6 +718,7 @@ main (int argc, char *argv[])
/* Initialize all modules. */
grub_init_all ();
grub_gcry_init_all ();
grub_lvm_fini ();
grub_mdraid09_fini ();
@ -725,6 +736,7 @@ main (int argc, char *argv[])
probe (argument, NULL);
/* Free resources. */
grub_gcry_fini_all ();
grub_fini_all ();
grub_util_biosdisk_fini ();

View file

@ -51,9 +51,9 @@ usage (int status)
{
if (status)
fprintf (stderr,
"Try ``%s --help'' for more information.\n", program_name);
_("Try ``%s --help'' for more information.\n"), program_name);
else
printf ("\
printf (_("\
Usage: %s [PATH]\n\
\n\
Checks GRUB script configuration file for syntax errors.\n\
@ -63,7 +63,7 @@ Checks GRUB script configuration file for syntax errors.\n\
-v, --verbose print the script as it is being processed\n\
\n\
Report bugs to <%s>.\n\
", program_name,
"), program_name,
PACKAGE_BUGREPORT);
exit (status);
}
@ -157,7 +157,7 @@ main (int argc, char *argv[])
}
else if (optind + 1 != argc)
{
fprintf (stderr, "Unknown extra argument `%s'.\n", argv[optind + 1]);
fprintf (stderr, _("Unknown extra argument `%s'.\n"), argv[optind + 1]);
usage (1);
}
else
@ -193,7 +193,7 @@ main (int argc, char *argv[])
if (found_input && script == 0)
{
fprintf (stderr, "error: line no: %u\n", lineno);
fprintf (stderr, _("error: line no: %u\n"), lineno);
return 1;
}

View file

@ -1,7 +1,7 @@
/* grub-setup.c - make GRUB usable */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011 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
@ -32,7 +32,6 @@
#include <grub/machine/kernel.h>
#include <grub/term.h>
#include <grub/i18n.h>
#include <grub/util/raid.h>
#include <grub/util/lvm.h>
#ifdef GRUB_MACHINE_IEEE1275
#include <grub/util/ofpath.h>
@ -50,6 +49,7 @@
#include "progname.h"
#include <grub/reed_solomon.h>
#include <grub/msdos_partition.h>
#include <include/grub/crypto.h>
#define _GNU_SOURCE 1
#include <argp.h>
@ -101,56 +101,12 @@ write_rootdev (char *core_img, grub_device_t root_dev,
{
#ifdef GRUB_MACHINE_PCBIOS
{
grub_int32_t *install_dos_part, *install_bsd_part;
grub_int32_t dos_part, bsd_part;
grub_uint8_t *boot_drive;
grub_disk_addr_t *kernel_sector;
boot_drive = (grub_uint8_t *) (boot_img + GRUB_BOOT_MACHINE_BOOT_DRIVE);
kernel_sector = (grub_disk_addr_t *) (boot_img
+ GRUB_BOOT_MACHINE_KERNEL_SECTOR);
install_dos_part = (grub_int32_t *) (core_img + GRUB_DISK_SECTOR_SIZE
+ GRUB_KERNEL_MACHINE_INSTALL_DOS_PART);
install_bsd_part = (grub_int32_t *) (core_img + GRUB_DISK_SECTOR_SIZE
+ GRUB_KERNEL_MACHINE_INSTALL_BSD_PART);
/* If we hardcoded drive as part of prefix, we don't want to
override the current setting. */
if (*install_dos_part != -2)
{
/* Embed information about the installed location. */
if (root_dev->disk->partition)
{
if (root_dev->disk->partition->parent)
{
if (root_dev->disk->partition->parent->parent)
grub_util_error ("Installing on doubly nested partitions is "
"not supported");
dos_part = root_dev->disk->partition->parent->number;
bsd_part = root_dev->disk->partition->number;
}
else
{
dos_part = root_dev->disk->partition->number;
bsd_part = -1;
}
}
else
dos_part = bsd_part = -1;
}
else
{
dos_part = grub_le_to_cpu32 (*install_dos_part);
bsd_part = grub_le_to_cpu32 (*install_bsd_part);
}
grub_util_info ("dos partition is %d, bsd partition is %d",
dos_part, bsd_part);
*install_dos_part = grub_cpu_to_le32 (dos_part);
*install_bsd_part = grub_cpu_to_le32 (bsd_part);
/* FIXME: can this be skipped? */
*boot_drive = 0xFF;
@ -283,22 +239,22 @@ setup (const char *dir,
grub_util_info ("Opening root");
root_dev = grub_device_open (root);
if (! root_dev)
grub_util_error ("%s", grub_errmsg);
grub_util_error ("%s", _(grub_errmsg));
grub_util_info ("Opening dest");
dest_dev = grub_device_open (dest);
if (! dest_dev)
grub_util_error ("%s", grub_errmsg);
grub_util_error ("%s", _(grub_errmsg));
grub_util_info ("setting the root device to `%s'", root);
if (grub_env_set ("root", root) != GRUB_ERR_NONE)
grub_util_error ("%s", grub_errmsg);
grub_util_error ("%s", _(grub_errmsg));
#ifdef GRUB_MACHINE_PCBIOS
/* Read the original sector from the disk. */
tmp_img = xmalloc (GRUB_DISK_SECTOR_SIZE);
if (grub_disk_read (dest_dev->disk, 0, 0, GRUB_DISK_SECTOR_SIZE, tmp_img))
grub_util_error ("%s", grub_errmsg);
grub_util_error ("%s", _(grub_errmsg));
#endif
#ifdef GRUB_MACHINE_PCBIOS
@ -408,37 +364,59 @@ setup (const char *dir,
free (tmp_img);
if (! dest_partmap)
if (! dest_partmap && ! fs)
{
grub_util_warn (_("Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea."));
goto unable_to_embed;
}
if (multiple_partmaps || fs)
if (multiple_partmaps || (dest_partmap && fs))
{
grub_util_warn (_("Attempting to install GRUB to a disk with multiple partition labels or both partition label and filesystem. This is not supported yet."));
goto unable_to_embed;
}
if (!dest_partmap->embed)
if (dest_partmap && !dest_partmap->embed)
{
grub_util_warn ("Partition style '%s' doesn't support embeding",
grub_util_warn (_("Partition style '%s' doesn't support embeding"),
dest_partmap->name);
goto unable_to_embed;
}
if (fs && !fs->embed)
{
grub_util_warn (_("File system '%s' doesn't support embeding"),
fs->name);
goto unable_to_embed;
}
nsec = core_sectors;
err = dest_partmap->embed (dest_dev->disk, &nsec,
GRUB_EMBED_PCBIOS, &sectors);
if (nsec > 2 * core_sectors)
nsec = 2 * core_sectors;
if (dest_partmap)
err = dest_partmap->embed (dest_dev->disk, &nsec,
GRUB_EMBED_PCBIOS, &sectors);
else
err = fs->embed (dest_dev, &nsec,
GRUB_EMBED_PCBIOS, &sectors);
if (!err && nsec < core_sectors)
{
err = grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("Your embedding area is unusually small. "
"core.img won't fit in it."));
}
if (err)
{
grub_util_warn ("%s", grub_errmsg);
grub_util_warn ("%s", _(grub_errmsg));
grub_errno = GRUB_ERR_NONE;
goto unable_to_embed;
}
if (nsec > 2 * core_sectors)
nsec = 2 * core_sectors;
if (nsec > ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR)
>> GRUB_DISK_SECTOR_BITS))
nsec = ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR)
>> GRUB_DISK_SECTOR_BITS);
/* Clean out the blocklists. */
block = first_block;
while (block->len)
@ -448,7 +426,7 @@ setup (const char *dir,
block--;
if ((char *) block <= core_img)
grub_util_error ("No terminator in the core image");
grub_util_error (_("No terminator in the core image"));
}
save_first_sector (sectors[0] + grub_partition_get_start (container),
@ -470,10 +448,14 @@ setup (const char *dir,
+ GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY)
= grub_host_to_target32 (nsec * GRUB_DISK_SECTOR_SIZE - core_size);
void *tmp = xmalloc (core_size);
grub_memcpy (tmp, core_img, core_size);
grub_reed_solomon_add_redundancy (core_img + GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + GRUB_DISK_SECTOR_SIZE,
core_size - GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART - GRUB_DISK_SECTOR_SIZE,
nsec * GRUB_DISK_SECTOR_SIZE
- core_size);
assert (grub_memcmp (tmp, core_img, core_size) == 0);
free (tmp);
/* Make sure that the second blocklist is a terminator. */
block = first_block - 1;
@ -608,7 +590,7 @@ unable_to_embed:
grub_file_filter_disable_compression ();
file = grub_file_open (core_path_dev);
if (! file)
grub_util_error ("%s", grub_errmsg);
grub_util_error ("%s", _(grub_errmsg));
file->read_hook = save_first_sector;
if (grub_file_read (file, tmp_img, GRUB_DISK_SECTOR_SIZE)
@ -669,8 +651,7 @@ unable_to_embed:
/* Write the boot image onto the disk. */
if (grub_disk_write (dest_dev->disk, BOOT_SECTOR,
0, GRUB_DISK_SECTOR_SIZE, boot_img))
grub_util_error ("%s", grub_errmsg);
grub_util_error ("%s", _(grub_errmsg));
grub_util_biosdisk_flush (root_dev->disk);
grub_util_biosdisk_flush (dest_dev->disk);
@ -894,6 +875,7 @@ main (int argc, char *argv[])
/* Initialize all modules. */
grub_init_all ();
grub_gcry_init_all ();
grub_lvm_fini ();
grub_mdraid09_fini ();
@ -954,10 +936,12 @@ main (int argc, char *argv[])
arguments.dir ? : DEFAULT_DIRECTORY);
}
#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
if (grub_util_lvm_isvolume (root_dev))
must_embed = 1;
#endif
#ifdef __linux__
if (root_dev[0] == 'm' && root_dev[1] == 'd'
&& ((root_dev[2] >= '0' && root_dev[2] <= '9') || root_dev[2] == '/'))
{
@ -972,12 +956,12 @@ main (int argc, char *argv[])
int i;
if (arguments.device[0] == '/')
devicelist = grub_util_raid_getmembers (arguments.device);
devicelist = grub_util_raid_getmembers (arguments.device, 1);
else
{
char *devname;
devname = xasprintf ("/dev/%s", dest_dev);
devicelist = grub_util_raid_getmembers (dest_dev);
devicelist = grub_util_raid_getmembers (dest_dev, 1);
free (devname);
}

View file

@ -25,7 +25,7 @@ libdir=@libdir@
locale_dir=`echo ${GRUB_PREFIX}/locale | sed ${transform}`
grub_lang=`echo $LANG | cut -d . -f 1`
. ${libdir}/grub/grub-mkconfig_lib
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
# Do this as early as possible, since other commands might depend on it.
# (e.g. the `loadfont' command might need lvm or raid modules)
@ -36,7 +36,7 @@ done
if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi
if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=auto ; fi
if [ "x${GRUB_DEFAULT_BUTTON}" = "x" ] ; then GRUB_DEFAULT_BUTTON="$GRUB_DEFAULT" ; fi
if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_entry}' ; fi

View file

@ -20,7 +20,8 @@ set -e
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
datarootdir=@datarootdir@
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
CLASS="--class gnu --class os"

54
util/grub.d/10_illumos.in Normal file
View file

@ -0,0 +1,54 @@
#! /bin/sh
set -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009,2010,2011 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
datarootdir=@datarootdir@
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@localedir@
CLASS="--class os"
case "${GRUB_DISTRIBUTOR}" in
*)
OS="Illumos"
CLASS="--class illumos ${CLASS}"
;;
esac
echo "menuentry '${OS}' ${CLASS} {"
save_default_entry | sed -e "s/^/\t/"
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
message="$(gettext_printf "Loading kernel of Illumos ...")"
cat << EOF
insmod gzio
if cpuid -l ; then
ISADIR=amd64
else
ISADIR=
fi
zfs-bootfs $($grub_mkrelpath /) ZFS_BOOTFS
multiboot $($grub_mkrelpath /platform/i86pc/kernel)/\$ISADIR/unix /platform/i86pc/kernel/\$ISADIR/unix -B \$ZFS_BOOTFS,console=text
module $($grub_mkrelpath /platform/i86pc)/\$ISADIR/boot_archive /platform/i86pc/\$ISADIR/boot_archive
}
EOF

View file

@ -2,7 +2,7 @@
set -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
# Copyright (C) 2006,2007,2008,2009,2010,2011 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
@ -21,7 +21,8 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
datarootdir=@datarootdir@
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@localedir@
@ -98,6 +99,12 @@ EOF
load_kfreebsd_module acpi true
for abstraction in dummy $(grub-probe -t abstraction --device ${GRUB_DEVICE}) ; do
case $abstraction in
lvm) load_kfreebsd_module geom_linux_lvm false ;;
esac
done
case "${kfreebsd_fs}" in
zfs)
load_kfreebsd_module opensolaris false
@ -153,7 +160,7 @@ while [ "x$list" != "x" ] ; do
# zpool name
kfreebsd_device=$(grub-probe -t fs_label --device ${GRUB_DEVICE})
# filesystem name (empty string for the main filesystem)
kfreebsd_device="${kfreebsd_device}$(grub-mkrelpath / | sed -e "s,/*@$,,")"
kfreebsd_device="${kfreebsd_device}$(${grub_mkrelpath} / | sed -e "s,/*@$,,")"
;;
*)
kfreebsd_device=${kfreebsd_fs}id/${GRUB_DEVICE_UUID}

View file

@ -21,7 +21,8 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
datarootdir=@datarootdir@
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@localedir@
@ -155,7 +156,7 @@ while [ "x$list" != "x" ] ; do
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
initrd=
for i in "initrd.img-${version}" "initrd-${version}.img" \
for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
"initrd-${version}" "initramfs-${version}.img" \
"initrd.img-${alt_version}" "initrd-${alt_version}.img" \
"initrd-${alt_version}" "initramfs-${alt_version}.img" \

View file

@ -21,7 +21,8 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
datarootdir=@datarootdir@
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@localedir@

View file

@ -20,7 +20,8 @@ set -e
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
datarootdir=@datarootdir@
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
case "`uname 2>/dev/null`" in
CYGWIN*) ;;
@ -41,14 +42,14 @@ get_os_name_from_boot_ini ()
sort | uniq | wc -l`" = 1 || return 1
# Search 'default=PARTITION'
local part=`sed -n 's,^default=,,p' "$1" | sed 's,\\\\,/,g;s,[ \t\r]*$,,;1q'`
test -n "$part" || return 1
get_os_name_from_boot_ini_part=`sed -n 's,^default=,,p' "$1" | sed 's,\\\\,/,g;s,[ \t\r]*$,,;1q'`
test -n "$get_os_name_from_boot_ini_part" || return 1
# Search 'PARTITION="NAME" ...'
local name=`sed -n 's,\\\\,/,g;s,^'"$part"'="\([^"]*\)".*$,\1,p' "$1" | sed 1q`
test -n "$name" || return 1
get_os_name_from_boot_ini_name=`sed -n 's,\\\\,/,g;s,^'"$get_os_name_from_boot_ini_part"'="\([^"]*\)".*$,\1,p' "$1" | sed 1q`
test -n "$get_os_name_from_boot_ini_name" || return 1
echo "$name"
echo "$get_os_name_from_boot_ini_name"
}

View file

@ -21,7 +21,8 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
datarootdir=@datarootdir@
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@localedir@

View file

@ -21,7 +21,7 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
exit 0

View file

@ -24,6 +24,8 @@
#include "progname.h"
#include <string.h>
int main(int argc, char **argv)
{
char *of_path;
@ -32,9 +34,14 @@ int main(int argc, char **argv)
grub_util_init_nls ();
if (argc != 2)
if (argc != 2 || strcmp (argv[1], "--help") == 0)
{
printf("Usage: %s DEVICE\n", program_name);
printf(_("Usage: %s DEVICE\n"), program_name);
return 1;
}
if (strcmp (argv[1], "--version") == 0)
{
printf ("%s\n", PACKAGE_STRING);
return 1;
}

View file

@ -23,6 +23,7 @@
#include <grub/types.h>
#include <grub/util/misc.h>
#include <grub/util/ofpath.h>
#include <grub/i18n.h>
#endif
#include <limits.h>
@ -53,6 +54,7 @@ grub_util_error (const char *fmt, ...)
exit (1);
}
#define _(x) x
#endif
static void
@ -106,7 +108,7 @@ find_obppath(char *of_path, const char *sysfs_path_orig)
{
kill_trailing_dir(sysfs_path);
if (!strcmp(sysfs_path, "/sys"))
grub_util_error("'obppath' not found in parent dirs of %s",
grub_util_error(_("'obppath' not found in parent dirs of %s"),
sysfs_path_orig);
continue;
}
@ -131,12 +133,12 @@ block_device_get_sysfs_path_and_link(const char *devicenode,
snprintf(sysfs_path, sysfs_path_len, "/sys/block/%s", devicenode);
if (!realpath (sysfs_path, rpath))
grub_util_error ("cannot get the real path of `%s'", sysfs_path);
grub_util_error (_("cannot get the real path of `%s'"), sysfs_path);
strcat(rpath, "/device");
if (!realpath (rpath, sysfs_path))
grub_util_error ("cannot get the real path of `%s'", rpath);
grub_util_error (_("cannot get the real path of `%s'"), rpath);
free (rpath);
}
@ -247,12 +249,12 @@ vendor_is_ATA(const char *path)
snprintf(buf, PATH_MAX, "%s/vendor", path);
fd = open(buf, O_RDONLY);
if (fd < 0)
grub_util_error ("cannot open 'vendor' node of `%s'", path);
grub_util_error (_("cannot open 'vendor' node of `%s'"), path);
memset(buf, 0, PATH_MAX);
err = read(fd, buf, PATH_MAX);
if (err < 0)
grub_util_error ("cannot read 'vendor' node of `%s'", path);
grub_util_error (_("cannot read 'vendor' node of `%s'"), path);
close(fd);
@ -288,7 +290,7 @@ check_sas (char *sysfs_path, int *tgt)
fd = open(path, O_RDONLY);
if (fd < 0)
grub_util_error("cannot open SAS PHY ID `%s'\n", path);
grub_util_error(_("cannot open SAS PHY ID `%s'\n"), path);
memset (phy, 0, sizeof (phy));
read (fd, phy, sizeof (phy));
@ -297,6 +299,7 @@ check_sas (char *sysfs_path, int *tgt)
free (path);
free (p);
close (fd);
}
static void
@ -375,7 +378,7 @@ grub_util_devname_to_ofpath (const char *devname)
name_buf = xmalloc (PATH_MAX);
name_buf = realpath (devname, name_buf);
if (! name_buf)
grub_util_error ("cannot get the real path of `%s'", devname);
grub_util_error (_("cannot get the real path of `%s'"), devname);
device = get_basename (name_buf);
devnode = strip_trailing_digits (name_buf);
@ -397,7 +400,7 @@ grub_util_devname_to_ofpath (const char *devname)
New models have no floppy at all. */
strcpy (ofpath, "floppy");
else
grub_util_error ("unknown device type %s\n", device);
grub_util_error (_("unknown device type %s\n"), device);
free (devnode);
free (devicenode);
@ -413,12 +416,13 @@ int main(int argc, char **argv)
if (argc != 2)
{
printf("Usage: grub-ofpathname DEVICE\n");
printf(_("Usage: %s DEVICE\n"), argv[0]);
return 1;
}
of_path = grub_util_devname_to_ofpath (argv[1]);
printf("%s\n", of_path);
free (of_path);
return 0;
}

View file

@ -20,6 +20,7 @@ import re
import sys
import os
import datetime
import codecs
if len (sys.argv) < 3:
print ("Usage: %s SOURCE DESTINATION" % sys.argv[0])
@ -40,9 +41,17 @@ except:
print ("WARNING: %s already exists" % cipher_dir_out)
cipher_files = os.listdir (cipher_dir_in)
conf = open (os.path.join ("grub-core", "Makefile.gcry.def"), "w")
conf = codecs.open (os.path.join ("grub-core", "Makefile.gcry.def"), "w", "utf-8")
conf.write ("AutoGen definitions Makefile.tpl;\n\n")
confutil = codecs.open ("Makefile.utilgcry.def", "w", "utf-8")
confutil.write ("AutoGen definitions Makefile.tpl;\n\n")
confutil.write ("library = {\n");
confutil.write (" name = libgrubgcry.a;\n");
confutil.write (" cflags = '$(CFLAGS_GCRY)';\n");
confutil.write (" cppflags = '$(CPPFLAGS_GCRY)';\n");
confutil.write ("\n");
chlog = ""
modules = []
# Strictly speaking CRC32/CRC24 work on bytes so this value should be 1
# But libgcrypt uses 64. Let's keep the value for compatibility. Since
@ -61,7 +70,7 @@ mdblocksizes = {"_gcry_digest_spec_crc32" : 64,
"_gcry_digest_spec_tiger" : 64,
"_gcry_digest_spec_whirlpool" : 64}
cryptolist = open (os.path.join (cipher_dir_out, "crypto.lst"), "w")
cryptolist = codecs.open (os.path.join (cipher_dir_out, "crypto.lst"), "w", "utf-8")
# rijndael is the only cipher using aliases. So no need for mangling, just
# hardcode it
@ -73,6 +82,9 @@ cryptolist.write ("AES-128: gcry_rijndael\n");
cryptolist.write ("AES-192: gcry_rijndael\n");
cryptolist.write ("AES-256: gcry_rijndael\n");
cryptolist.write ("ADLER32: adler32\n");
cryptolist.write ("CRC64: crc64\n");
for cipher_file in cipher_files:
infile = os.path.join (cipher_dir_in, cipher_file)
outfile = os.path.join (cipher_dir_out, cipher_file)
@ -88,11 +100,23 @@ for cipher_file in cipher_files:
nch = False
if re.match (".*\.[ch]$", cipher_file):
isc = re.match (".*\.c$", cipher_file)
f = open (infile, "r")
fw = open (outfile, "w")
f = codecs.open (infile, "r", "utf-8")
fw = codecs.open (outfile, "w", "utf-8")
fw.write ("/* This file was automatically imported with \n")
fw.write (" import_gcry.py. Please don't modify it */\n")
fw.write ("#include <grub/dl.h>\n")
if cipher_file == "camellia.h":
fw.write ("#include <grub/misc.h>\n")
fw.write ("void camellia_setup128(const unsigned char *key, grub_uint32_t *subkey);\n")
fw.write ("void camellia_setup192(const unsigned char *key, grub_uint32_t *subkey);\n")
fw.write ("void camellia_setup256(const unsigned char *key, grub_uint32_t *subkey);\n")
fw.write ("void camellia_encrypt128(const grub_uint32_t *subkey, grub_uint32_t *io);\n")
fw.write ("void camellia_encrypt192(const grub_uint32_t *subkey, grub_uint32_t *io);\n")
fw.write ("void camellia_encrypt256(const grub_uint32_t *subkey, grub_uint32_t *io);\n")
fw.write ("void camellia_decrypt128(const grub_uint32_t *subkey, grub_uint32_t *io);\n")
fw.write ("void camellia_decrypt192(const grub_uint32_t *subkey, grub_uint32_t *io);\n")
fw.write ("void camellia_decrypt256(const grub_uint32_t *subkey, grub_uint32_t *io);\n")
fw.write ("#define memcpy grub_memcpy\n")
# Whole libgcrypt is distributed under GPLv3+ or compatible
if isc:
fw.write ("GRUB_MOD_LICENSE (\"GPLv3+\");\n")
@ -103,6 +127,7 @@ for cipher_file in cipher_files:
skip = False
skip2 = False
ismd = False
iscipher = False
iscryptostart = False
iscomma = False
isglue = False
@ -114,6 +139,7 @@ for cipher_file in cipher_files:
isglue = True
modname = "gcry_%s" % modname
for line in f:
line = line
if skip_statement:
if not re.search (";", line) is None:
skip_statement = False
@ -132,15 +158,22 @@ for cipher_file in cipher_files:
sg = s.groups()[0]
cryptolist.write (("%s: %s\n") % (sg, modname))
iscryptostart = False
if ismd:
if ismd or iscipher:
if not re.search (" *};", line) is None:
if not mdblocksizes.has_key (mdname):
print ("ERROR: Unknown digest blocksize: %s\n" % mdname)
exit (1)
if not iscomma:
fw.write (" ,\n")
fw.write (" .blocksize = %s\n" % mdblocksizes [mdname])
fw.write ("#ifdef GRUB_UTIL\n");
fw.write (" .modname = \"%s\",\n" % modname);
fw.write ("#endif\n");
if ismd:
if not (mdname in mdblocksizes):
print ("ERROR: Unknown digest blocksize: %s\n"
% mdname)
exit (1)
fw.write (" .blocksize = %s\n"
% mdblocksizes [mdname])
ismd = False
iscipher = False
iscomma = not re.search (",$", line) is None
# Used only for selftests.
m = re.match ("(static byte|static unsigned char) (weak_keys_chksum)\[[0-9]*\] =", line)
@ -157,8 +190,10 @@ for cipher_file in cipher_files:
if hold:
hold = False
# We're optimising for size.
if not re.match ("(run_selftests|selftest|_gcry_aes_c.._..c|_gcry_[a-z0-9]*_hash_buffer|tripledes_set2keys|do_tripledes_set_extra_info)", line) is None:
if not re.match ("(run_selftests|selftest|_gcry_aes_c.._..c|_gcry_[a-z0-9]*_hash_buffer|tripledes_set2keys|do_tripledes_set_extra_info|_gcry_rmd160_mixblock|serpent_test)", line) is None:
skip = True
if not re.match ("serpent_test", line) is None:
fw.write ("static const char *serpent_test (void) { return 0; }\n");
fname = re.match ("[a-zA-Z0-9_]*", line).group ()
chmsg = "(%s): Removed." % fname
if nch:
@ -169,10 +204,9 @@ for cipher_file in cipher_files:
continue
else:
fw.write (holdline)
m = re.match ("#include <.*>", line)
m = re.match ("# *include <(.*)>", line)
if not m is None:
chmsg = "Removed including of %s" % \
m.group () [len ("#include <"):len (m.group ()) - 1]
chmsg = "Removed including of %s" % m.groups ()[0]
if nch:
chlognew = "%s\n %s" % (chlognew, chmsg)
else:
@ -181,14 +215,18 @@ for cipher_file in cipher_files:
continue
m = re.match ("gcry_cipher_spec_t", line)
if isc and not m is None:
assert (not iscryptostart)
assert (not iscipher)
assert (not iscryptostart)
ciphername = line [len ("gcry_cipher_spec_t"):].strip ()
ciphername = re.match("[a-zA-Z0-9_]*",ciphername).group ()
ciphernames.append (ciphername)
iscipher = True
iscryptostart = True
m = re.match ("gcry_md_spec_t", line)
if isc and not m is None:
assert (not ismd)
assert (not iscipher)
assert (not iscryptostart)
mdname = line [len ("gcry_md_spec_t"):].strip ()
mdname = re.match("[a-zA-Z0-9_]*",mdname).group ()
@ -249,6 +287,7 @@ for cipher_file in cipher_files:
% (cipher_file, cipher_file.replace ("-glue.c", ".c"))
else:
modfiles = "lib/libgcrypt-grub/cipher/%s" % cipher_file
modules.append (modname)
chmsg = "(GRUB_MOD_INIT(%s)): New function\n" % modname
if nch:
chlognew = "%s\n %s" % (chlognew, chmsg)
@ -283,6 +322,7 @@ for cipher_file in cipher_files:
conf.write (" name = %s;\n" % modname)
for src in modfiles.split():
conf.write (" common = %s;\n" % src)
confutil.write (" common = grub-core/%s;\n" % src)
conf.write (" cflags = '$(CFLAGS_GCRY)';\n");
conf.write (" cppflags = '$(CPPFLAGS_GCRY)';\n");
conf.write ("};\n\n")
@ -300,28 +340,28 @@ cryptolist.close ()
chlog = "%s * crypto.lst: New file.\n" % chlog
outfile = os.path.join (cipher_dir_out, "types.h")
fw=open (outfile, "w")
fw=codecs.open (outfile, "w", "utf-8")
fw.write ("#include <grub/types.h>\n")
fw.write ("#include <cipher_wrap.h>\n")
chlog = "%s * types.h: New file.\n" % chlog
fw.close ()
outfile = os.path.join (cipher_dir_out, "memory.h")
fw=open (outfile, "w")
fw=codecs.open (outfile, "w", "utf-8")
fw.write ("#include <cipher_wrap.h>\n")
chlog = "%s * memory.h: New file.\n" % chlog
fw.close ()
outfile = os.path.join (cipher_dir_out, "cipher.h")
fw=open (outfile, "w")
fw=codecs.open (outfile, "w", "utf-8")
fw.write ("#include <grub/crypto.h>\n")
fw.write ("#include <cipher_wrap.h>\n")
chlog = "%s * cipher.h: Likewise.\n" % chlog
fw.close ()
outfile = os.path.join (cipher_dir_out, "g10lib.h")
fw=open (outfile, "w")
fw=codecs.open (outfile, "w", "utf-8")
fw.write ("#include <cipher_wrap.h>\n")
chlog = "%s * g10lib.h: Likewise.\n" % chlog
fw.close ()
@ -329,9 +369,35 @@ fw.close ()
infile = os.path.join (cipher_dir_in, "ChangeLog")
outfile = os.path.join (cipher_dir_out, "ChangeLog")
conf.close ();
f=open (infile, "r")
fw=open (outfile, "w")
initfile = codecs.open (os.path.join (cipher_dir_out, "init.c"), "w", "utf-8")
for module in modules:
initfile.write ("extern void grub_%s_init (void);\n" % module)
initfile.write ("extern void grub_%s_fini (void);\n" % module)
initfile.write ("\n")
initfile.write ("void\n")
initfile.write ("grub_gcry_init_all (void)\n")
initfile.write ("{\n")
for module in modules:
initfile.write (" grub_%s_init ();\n" % module)
initfile.write ("}\n")
initfile.write ("\n")
initfile.write ("void\n")
initfile.write ("grub_gcry_fini_all (void)\n")
initfile.write ("{\n")
for module in modules:
initfile.write (" grub_%s_fini ();\n" % module)
initfile.write ("}\n")
initfile.close ()
confutil.write (" common = grub-core/lib/libgcrypt-grub/cipher/init.c;\n")
confutil.write ("};\n");
confutil.close ();
f=codecs.open (infile, "r", "utf-8")
fw=codecs.open (outfile, "w", "utf-8")
dt = datetime.date.today ()
fw.write ("%04d-%02d-%02d Automatic import tool\n" % \
(dt.year,dt.month, dt.day))

View file

@ -1,7 +1,7 @@
/* lvm.c - LVM support for GRUB utils. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
* Copyright (C) 2006,2007,2008,2011 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
@ -17,8 +17,7 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
/* We only support LVM on Linux. */
#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <grub/emu/misc.h>
#include <grub/util/misc.h>
#include <grub/util/lvm.h>
@ -26,8 +25,6 @@
#include <string.h>
#include <sys/stat.h>
#define LVM_DEV_MAPPER_STRING "/dev/mapper/"
int
grub_util_lvm_isvolume (char *name)
{
@ -49,4 +46,4 @@ grub_util_lvm_isvolume (char *name)
return 1;
}
#endif /* ! __linux__ */
#endif

View file

@ -55,6 +55,7 @@
#ifdef __MINGW32__
#include <windows.h>
#include <winioctl.h>
#include "dirname.h"
#endif
#ifdef GRUB_UTIL
@ -88,10 +89,10 @@ grub_util_get_fp_size (FILE *fp)
struct stat st;
if (fflush (fp) == EOF)
grub_util_error ("fflush failed");
grub_util_error (_("fflush failed"));
if (fstat (fileno (fp), &st) == -1)
grub_util_error ("fstat failed");
grub_util_error (_("fstat failed"));
return st.st_size;
}
@ -104,7 +105,7 @@ grub_util_get_image_size (const char *path)
grub_util_info ("getting the size of %s", path);
if (stat (path, &st) == -1)
grub_util_error ("cannot stat %s", path);
grub_util_error (_("cannot stat %s"), path);
return st.st_size;
}
@ -113,10 +114,10 @@ void
grub_util_read_at (void *img, size_t size, off_t offset, FILE *fp)
{
if (fseeko (fp, offset, SEEK_SET) == -1)
grub_util_error ("seek failed");
grub_util_error (_("seek failed"));
if (fread (img, 1, size, fp) != size)
grub_util_error ("read failed");
grub_util_error (_("read failed"));
}
char *
@ -133,7 +134,7 @@ grub_util_read_image (const char *path)
fp = fopen (path, "rb");
if (! fp)
grub_util_error ("cannot open %s", path);
grub_util_error (_("cannot open %s"), path);
grub_util_read_at (img, size, 0, fp);
@ -154,10 +155,10 @@ grub_util_load_image (const char *path, char *buf)
fp = fopen (path, "rb");
if (! fp)
grub_util_error ("cannot open %s", path);
grub_util_error (_("cannot open %s"), path);
if (fread (buf, 1, size, fp) != size)
grub_util_error ("cannot read %s", path);
grub_util_error (_("cannot read %s"), path);
fclose (fp);
}
@ -167,9 +168,9 @@ grub_util_write_image_at (const void *img, size_t size, off_t offset, FILE *out)
{
grub_util_info ("writing 0x%x bytes at offset 0x%x", size, offset);
if (fseeko (out, offset, SEEK_SET) == -1)
grub_util_error ("seek failed");
grub_util_error (_("seek failed"));
if (fwrite (img, 1, size, out) != size)
grub_util_error ("write failed");
grub_util_error (_("write failed"));
}
void
@ -177,7 +178,7 @@ grub_util_write_image (const char *img, size_t size, FILE *out)
{
grub_util_info ("writing 0x%x bytes", size);
if (fwrite (img, 1, size, out) != size)
grub_util_error ("write failed");
grub_util_error (_("write failed"));
}
char *
@ -316,17 +317,13 @@ int fsync (int fno __attribute__ ((unused)))
return 0;
}
void sleep (int s)
{
Sleep (s * 1000);
}
grub_int64_t
grub_util_get_disk_size (char *name)
{
HANDLE hd;
grub_int64_t size = -1LL;
strip_trailing_slashes(name);
hd = CreateFile (name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
0, OPEN_EXISTING, 0, 0);

View file

@ -21,7 +21,6 @@
#ifdef __linux__
#include <grub/emu/misc.h>
#include <grub/util/misc.h>
#include <grub/util/raid.h>
#include <grub/emu/getroot.h>
#include <string.h>
@ -34,9 +33,10 @@
#include <linux/major.h>
#include <linux/raid/md_p.h>
#include <linux/raid/md_u.h>
#include <grub/i18n.h>
char **
grub_util_raid_getmembers (const char *name)
grub_util_raid_getmembers (const char *name, int bootable)
{
int fd, ret, i, j;
char **devicelist;
@ -47,19 +47,26 @@ grub_util_raid_getmembers (const char *name)
fd = open (name, O_RDONLY);
if (fd == -1)
grub_util_error ("can't open %s: %s", name, strerror (errno));
grub_util_error (_("can't open %s: %s"), name, strerror (errno));
ret = ioctl (fd, RAID_VERSION, &version);
if (ret != 0)
grub_util_error ("ioctl RAID_VERSION error: %s", strerror (errno));
grub_util_error (_("ioctl RAID_VERSION error: %s"), strerror (errno));
if (version.major != 0 || version.minor != 90)
grub_util_error ("unsupported RAID version: %d.%d",
if ((version.major != 0 || version.minor != 90)
&& (version.major != 1 || version.minor != 0)
&& (version.major != 1 || version.minor != 1)
&& (version.major != 1 || version.minor != 2))
grub_util_error (_("unsupported RAID version: %d.%d"),
version.major, version.minor);
if (bootable && (version.major != 0 || version.minor != 90))
grub_util_error (_("unsupported RAID version: %d.%d"),
version.major, version.minor);
ret = ioctl (fd, GET_ARRAY_INFO, &info);
if (ret != 0)
grub_util_error ("ioctl GET_ARRAY_INFO error: %s", strerror (errno));
grub_util_error (_("ioctl GET_ARRAY_INFO error: %s"), strerror (errno));
devicelist = xmalloc ((info.nr_disks + 1) * sizeof (char *));
@ -68,7 +75,7 @@ grub_util_raid_getmembers (const char *name)
disk.number = i;
ret = ioctl (fd, GET_DISK_INFO, &disk);
if (ret != 0)
grub_util_error ("ioctl GET_DISK_INFO error: %s", strerror (errno));
grub_util_error (_("ioctl GET_DISK_INFO error: %s"), strerror (errno));
if (disk.state & (1 << MD_DISK_ACTIVE))
{
@ -80,6 +87,8 @@ grub_util_raid_getmembers (const char *name)
devicelist[j] = NULL;
close (fd);
return devicelist;
}

View file

@ -26,6 +26,7 @@
#include <grub/emu/misc.h>
#include <grub/util/misc.h>
#include <grub/util/resolve.h>
#include <grub/i18n.h>
/* Module. */
struct mod_list
@ -87,7 +88,7 @@ read_dep_list (FILE *fp)
/* Get the target name. */
p = strchr (buf, ':');
if (! p)
grub_util_error ("invalid line format: %s", buf);
grub_util_error (_("invalid line format: %s"), buf);
*p++ = '\0';
@ -240,7 +241,7 @@ grub_util_resolve_dependencies (const char *prefix,
path = grub_util_get_path (prefix, dep_list_file);
fp = fopen (path, "r");
if (! fp)
grub_util_error ("cannot open %s", path);
grub_util_error (_("cannot open %s"), path);
free (path);
dep_list = read_dep_list (fp);

View file

@ -18,6 +18,6 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
grub_warn "update-grub_lib is deprecated, use grub-mkconfig_lib instead"