Merge mainline into gfxmenu

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-02-03 01:24:07 +01:00
commit 1f534b6908
279 changed files with 9437 additions and 3021 deletions

127
util/bin2h.c Normal file
View file

@ -0,0 +1,127 @@
/*
* Copyright (C) 2008,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/>.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#define _GNU_SOURCE 1
#include <getopt.h>
#include "progname.h"
static struct option options[] =
{
{"help", no_argument, 0, 'h' },
{"version", no_argument, 0, 'V' },
{0, 0, 0, 0 }
};
static void
usage (int status)
{
if (status)
fprintf (stderr,
"Try ``%s --help'' for more information.\n", program_name);
else
printf ("\
Usage: %s [OPTIONS] SYMBOL-NAME\n\
\n\
Convert a binary file to a C header.\n\
\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);
exit (status);
}
int
main (int argc, char *argv[])
{
int b, i;
char *sym;
set_program_name (argv[0]);
/* Check for options. */
while (1)
{
int c = getopt_long (argc, argv, "snm:r:hVv", options, 0);
if (c == -1)
break;
else
switch (c)
{
case 'h':
usage (0);
break;
case 'V':
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
default:
usage (1);
break;
}
}
if (optind >= argc)
usage (1);
if (optind + 1 != argc)
usage (1);
sym = argv[optind];
b = getchar ();
if (b == EOF)
goto abort;
printf ("/* THIS CHUNK OF BYTES IS AUTOMATICALY GENERATED */\n"
"unsigned char %s[] =\n{\n", sym);
while (1)
{
printf ("0x%02x", b);
b = getchar ();
if (b == EOF)
goto end;
for (i = 0; i < 16 - 1; i++)
{
printf (", 0x%02x", b);
b = getchar ();
if (b == EOF)
goto end;
}
printf (",\n");
}
end:
printf ("\n};\n");
abort:
exit (0);
}

View file

@ -373,8 +373,8 @@ static struct grub_term_output grub_ncurses_term_output =
void
grub_console_init (void)
{
grub_term_register_output_active ("console", &grub_ncurses_term_output);
grub_term_register_input_active ("console", &grub_ncurses_term_input);
grub_term_register_output ("console", &grub_ncurses_term_output);
grub_term_register_input ("console", &grub_ncurses_term_input);
}
void

View file

@ -100,7 +100,7 @@ load_note (Elf32_Phdr *phdr, FILE *out)
void
load_modules (grub_addr_t modbase, Elf32_Phdr *phdr, const char *dir,
char *mods[], FILE *out, char *memdisk_path)
char *mods[], FILE *out, char *memdisk_path, char *config_path)
{
char *module_img;
struct grub_util_path_list *path_list;
@ -109,6 +109,7 @@ load_modules (grub_addr_t modbase, Elf32_Phdr *phdr, const char *dir,
size_t offset;
size_t total_module_size;
size_t memdisk_size = 0;
size_t config_size = 0;
path_list = grub_util_resolve_dependencies (dir, "moddep.lst", mods);
@ -122,6 +123,13 @@ load_modules (grub_addr_t modbase, Elf32_Phdr *phdr, const char *dir,
total_module_size += memdisk_size + sizeof (struct grub_module_header);
}
if (config_path)
{
config_size = ALIGN_UP(grub_util_get_image_size (config_path), 512);
grub_util_info ("the size of memory disk is 0x%x", config_size);
total_module_size += config_size + sizeof (struct grub_module_header);
}
for (p = path_list; p; p = p->next)
{
total_module_size += (grub_util_get_image_size (p->name)
@ -168,6 +176,19 @@ load_modules (grub_addr_t modbase, Elf32_Phdr *phdr, const char *dir,
offset += memdisk_size;
}
if (config_path)
{
struct grub_module_header *header;
header = (struct grub_module_header *) (module_img + offset);
header->type = OBJ_TYPE_CONFIG;
header->size = grub_host_to_target32 (config_size + sizeof (*header));
offset += sizeof (*header);
grub_util_load_image (config_path, module_img + offset);
offset += config_size;
}
/* Write the module data to the new segment. */
grub_util_write_image_at (module_img, total_module_size,
@ -184,7 +205,7 @@ load_modules (grub_addr_t modbase, Elf32_Phdr *phdr, const char *dir,
}
void
add_segments (char *dir, char *prefix, FILE *out, int chrp, char *mods[], char *memdisk_path)
add_segments (char *dir, char *prefix, FILE *out, int chrp, char *mods[], char *memdisk_path, char *config_path)
{
Elf32_Ehdr ehdr;
Elf32_Phdr *phdrs = NULL;
@ -273,7 +294,7 @@ add_segments (char *dir, char *prefix, FILE *out, int chrp, char *mods[], char *
phdr->p_offset = grub_host_to_target32 (ALIGN_UP (grub_util_get_fp_size (out),
GRUB_TARGET_SIZEOF_LONG));
load_modules (modbase, phdr, dir, mods, out, memdisk_path);
load_modules (modbase, phdr, dir, mods, out, memdisk_path, config_path);
}
if (chrp)
@ -316,6 +337,7 @@ static struct option options[] =
{"directory", required_argument, 0, 'd'},
{"prefix", required_argument, 0, 'p'},
{"memdisk", required_argument, 0, 'm'},
{"config", required_argument, 0, 'c'},
{"output", required_argument, 0, 'o'},
{"help", no_argument, 0, 'h'},
{"note", no_argument, 0, 'n'},
@ -328,7 +350,7 @@ 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 ("\
Usage: %s -o FILE [OPTION]... [MODULES]\n\
@ -338,6 +360,7 @@ Make a bootable image of GRUB.\n\
-d, --directory=DIR use images and modules under DIR [default=%s]\n\
-p, --prefix=DIR set grub_prefix directory\n\
-m, --memdisk=FILE embed FILE as a memdisk image\n\
-c, --config=FILE embed FILE as boot config\n\
-o, --output=FILE output a generated image to FILE\n\
-h, --help display this message and exit\n\
-n, --note add NOTE segment for CHRP Open Firmware\n\
@ -358,6 +381,7 @@ main (int argc, char *argv[])
char *dir = NULL;
char *prefix = NULL;
char *memdisk = NULL;
char *config = NULL;
int chrp = 0;
set_program_name (argv[0]);
@ -366,7 +390,7 @@ main (int argc, char *argv[])
while (1)
{
int c = getopt_long (argc, argv, "d:p:m:o:hVvn", options, 0);
int c = getopt_long (argc, argv, "d:p:m:c:o:hVvn", options, 0);
if (c == -1)
break;
@ -392,6 +416,13 @@ main (int argc, char *argv[])
prefix = xstrdup ("(memdisk)/boot/grub");
break;
case 'c':
if (config)
free (config);
config = xstrdup (optarg);
break;
case 'h':
usage (0);
break;
@ -422,7 +453,8 @@ main (int argc, char *argv[])
if (! fp)
grub_util_error ("cannot open %s", output);
add_segments (dir ? : GRUB_LIBDIR, prefix, fp, chrp, argv + optind, memdisk);
add_segments (dir ? : GRUB_LIBDIR, prefix, fp, chrp, argv + optind, memdisk,
config);
fclose (fp);

View file

@ -115,14 +115,14 @@ grub_get_prefix (const char *dir)
saved_cwd = xgetcwd ();
if (chdir (dir) < 0)
grub_util_error ("Cannot change directory to `%s'", dir);
grub_util_error ("cannot change directory to `%s'", dir);
abs_dir = xgetcwd ();
strip_extra_slashes (abs_dir);
prev_dir = xstrdup (abs_dir);
if (stat (".", &prev_st) < 0)
grub_util_error ("Cannot stat `%s'", dir);
grub_util_error ("cannot stat `%s'", dir);
if (! S_ISDIR (prev_st.st_mode))
grub_util_error ("`%s' is not a directory", dir);
@ -130,13 +130,13 @@ grub_get_prefix (const char *dir)
while (1)
{
if (chdir ("..") < 0)
grub_util_error ("Cannot change directory to the parent");
grub_util_error ("cannot change directory to the parent");
if (stat (".", &st) < 0)
grub_util_error ("Cannot stat current directory");
grub_util_error ("cannot stat current directory");
if (! S_ISDIR (st.st_mode))
grub_util_error ("Current directory is not a directory???");
grub_util_error ("current directory is not a directory???");
if (prev_st.st_dev != st.st_dev || prev_st.st_ino == st.st_ino)
break;
@ -153,7 +153,7 @@ grub_get_prefix (const char *dir)
strip_extra_slashes (prefix);
if (chdir (saved_cwd) < 0)
grub_util_error ("Cannot change directory to `%s'", dir);
grub_util_error ("cannot change directory to `%s'", dir);
#ifdef __CYGWIN__
if (st.st_dev != (DEV_CYGDRIVE_MAJOR << 16))
@ -236,7 +236,7 @@ find_root_device (const char *dir, dev_t dev)
if (res)
{
if (chdir (saved_cwd) < 0)
grub_util_error ("Cannot restore the original directory");
grub_util_error ("cannot restore the original directory");
free (saved_cwd);
closedir (dp);
@ -279,7 +279,7 @@ find_root_device (const char *dir, dev_t dev)
continue;
if (chdir (saved_cwd) < 0)
grub_util_error ("Cannot restore the original directory");
grub_util_error ("cannot restore the original directory");
free (saved_cwd);
closedir (dp);
@ -288,7 +288,7 @@ find_root_device (const char *dir, dev_t dev)
}
if (chdir (saved_cwd) < 0)
grub_util_error ("Cannot restore the original directory");
grub_util_error ("cannot restore the original directory");
free (saved_cwd);
closedir (dp);
@ -445,7 +445,7 @@ grub_guess_root_device (const char *dir)
struct stat st;
if (stat (dir, &st) < 0)
grub_util_error ("Cannot stat `%s'", dir);
grub_util_error ("cannot stat `%s'", dir);
#ifdef __CYGWIN__
/* Cygwin specific function. */
@ -591,7 +591,7 @@ grub_util_get_grub_dev (const char *os_dev)
free (p);
}
else
grub_util_error ("Unknown kind of RAID device `%s'", os_dev);
grub_util_error ("unknown kind of RAID device `%s'", os_dev);
break;
@ -608,7 +608,7 @@ grub_util_check_block_device (const char *blk_dev)
struct stat st;
if (stat (blk_dev, &st) < 0)
grub_util_error ("Cannot stat `%s'", blk_dev);
grub_util_error ("cannot stat `%s'", blk_dev);
if (S_ISBLK (st.st_mode))
return (blk_dev);
@ -622,7 +622,7 @@ grub_util_check_char_device (const char *blk_dev)
struct stat st;
if (stat (blk_dev, &st) < 0)
grub_util_error ("Cannot stat `%s'", blk_dev);
grub_util_error ("cannot stat `%s'", blk_dev);
if (S_ISCHR (st.st_mode))
return (blk_dev);

View file

@ -69,10 +69,10 @@ static void
usage (int status)
{
if (status)
fprintf (stderr, "Try ``grub-editenv --help'' for more information.\n");
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
else
printf ("\
Usage: grub-editenv [OPTIONS] [FILENAME] COMMAND\n\
Usage: %s [OPTIONS] [FILENAME] COMMAND\n\
\n\
Tool to edit environment block.\n\
\nCommands:\n\
@ -88,7 +88,7 @@ Tool to edit environment block.\n\
If not given explicitly, FILENAME defaults to %s.\n\
\n\
Report bugs to <%s>.\n",
DEFAULT_DIRECTORY "/" GRUB_ENVBLK_DEFCFG, PACKAGE_BUGREPORT);
program_name, DEFAULT_DIRECTORY "/" GRUB_ENVBLK_DEFCFG, PACKAGE_BUGREPORT);
exit (status);
}

View file

@ -129,10 +129,10 @@ usage (int status)
{
if (status)
fprintf (stderr,
"Try ``grub-emu --help'' for more information.\n");
"Try `%s --help' for more information.\n", program_name);
else
printf (
"Usage: grub-emu [OPTION]...\n"
"Usage: %s [OPTION]...\n"
"\n"
"GRUB emulator.\n"
"\n"
@ -144,7 +144,7 @@ usage (int status)
" -h, --help display this message and exit\n"
" -V, --version print version information and exit\n"
"\n"
"Report bugs to <%s>.\n", DEFAULT_DEVICE_MAP, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
"Report bugs to <%s>.\n", program_name, DEFAULT_DEVICE_MAP, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
return status;
}
@ -220,14 +220,14 @@ main (int argc, char *argv[])
{
char *device_name = grub_guess_root_device (dir);
if (! device_name)
grub_util_error ("cannot find a device for %s.\n", dir);
grub_util_error ("cannot find a device for %s", dir);
root_dev = grub_util_get_grub_dev (device_name);
if (! root_dev)
{
grub_util_info ("guessing the root device failed, because of `%s'",
grub_errmsg);
grub_util_error ("Cannot guess the root device. Specify the option ``--root-device''.");
grub_util_error ("cannot guess the root device. Specify the option `--root-device'");
}
}

View file

@ -71,7 +71,7 @@ execute_command (char *name, int n, char **args)
cmd = grub_command_find (name);
if (! cmd)
grub_util_error ("Can\'t find command %s", name);
grub_util_error ("can\'t find command %s", name);
return (cmd->func) (cmd, n, args);
}
@ -100,9 +100,9 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
dev = grub_device_open (0);
if ((! dev) || (! dev->disk))
grub_util_error ("Can\'t open device.");
grub_util_error ("can\'t open device");
grub_util_info ("total sectors : %lld.",
grub_util_info ("total sectors : %lld",
(unsigned long long) dev->disk->total_sectors);
if (! leng)
@ -115,7 +115,7 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
len = (leng > BUF_SIZE) ? BUF_SIZE : leng;
if (grub_disk_read (dev->disk, 0, skip, len, buf))
grub_util_error ("Disk read fails at offset %lld, length %d.",
grub_util_error ("disk read fails at offset %lld, length %d",
skip, len);
if (hook (skip, buf, len))
@ -132,15 +132,15 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
file = grub_file_open (pathname);
if (!file)
{
grub_util_error ("cannot open file %s.", pathname);
grub_util_error ("cannot open file %s", pathname);
return;
}
grub_util_info ("file size : %lld.", (unsigned long long) file->size);
grub_util_info ("file size : %lld", (unsigned long long) file->size);
if (skip > file->size)
{
grub_util_error ("invalid skip value %lld.", (unsigned long long) skip);
grub_util_error ("invalid skip value %lld", (unsigned long long) skip);
return;
}
@ -158,7 +158,7 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
sz = grub_file_read (file, buf, (len > BUF_SIZE) ? BUF_SIZE : len);
if (sz < 0)
{
grub_util_error ("read error at offset %llu.", ofs);
grub_util_error ("read error at offset %llu", ofs);
break;
}
@ -184,7 +184,7 @@ cmd_cp (char *src, char *dest)
if ((int) fwrite (buf, 1, len, ff) != len)
{
grub_util_error ("write error.");
grub_util_error ("write error");
return 1;
}
@ -194,7 +194,7 @@ cmd_cp (char *src, char *dest)
ff = fopen (dest, "wb");
if (ff == NULL)
{
grub_util_error ("open error.");
grub_util_error ("open error");
return;
}
read_file (src, cp_hook);
@ -212,7 +212,7 @@ cmd_cmp (char *src, char *dest)
{
if ((int) fread (buf_1, 1, len, ff) != len)
{
grub_util_error ("read error at offset %llu.", ofs);
grub_util_error ("read error at offset %llu", ofs);
return 1;
}
@ -223,7 +223,7 @@ cmd_cmp (char *src, char *dest)
for (i = 0; i < len; i++, ofs++)
if (buf_1[i] != buf[i])
{
grub_util_error ("compare fail at offset %llu.", ofs);
grub_util_error ("compare fail at offset %llu", ofs);
return 1;
}
}
@ -233,12 +233,12 @@ cmd_cmp (char *src, char *dest)
ff = fopen (dest, "rb");
if (ff == NULL)
{
grub_util_error ("open error.");
grub_util_error ("open error");
return;
}
if ((skip) && (fseeko (ff, skip, SEEK_SET)))
grub_util_error ("seek error.");
grub_util_error ("seek error");
read_file (src, cmp_hook);
fclose (ff);
@ -278,21 +278,31 @@ cmd_crc (char *pathname)
static void
fstest (char **images, int num_disks, int cmd, int n, char **args)
{
char host_file[128];
char loop_name[8];
char *argv[3] = { "-p", loop_name, host_file};
char *host_file;
char *loop_name;
char *argv[3];
int i;
argv[0] = "-p";
for (i = 0; i < num_disks; i++)
{
if (grub_strlen (images[i]) + 7 > sizeof (host_file))
grub_util_error ("Pathname %s too long.", images[i]);
loop_name = grub_xasprintf ("loop%d", i);
if (!loop_name)
grub_util_error (grub_errmsg);
grub_sprintf (loop_name, "loop%d", i);
grub_sprintf (host_file, "(host)%s", images[i]);
host_file = grub_xasprintf ("(host)%s", images[i]);
if (!host_file)
grub_util_error (grub_errmsg);
argv[1] = loop_name;
argv[2] = host_file;
if (execute_command ("loopback", 3, argv))
grub_util_error ("loopback command fails.");
grub_util_error ("loopback command fails");
grub_free (loop_name);
grub_free (host_file);
}
grub_lvm_fini ();
@ -328,8 +338,15 @@ fstest (char **images, int num_disks, int cmd, int n, char **args)
for (i = 0; i < num_disks; i++)
{
grub_sprintf (loop_name, "loop%d", i);
loop_name = grub_xasprintf ("loop%d", i);
if (!loop_name)
grub_util_error (grub_errmsg);
argv[1] = loop_name;
execute_command ("loopback", 2, argv);
grub_free (loop_name);
}
}
@ -349,7 +366,7 @@ 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 ("\
Usage: %s [OPTION]... IMAGE_PATH COMMANDS\n\

View file

@ -30,10 +30,11 @@ PACKAGE_VERSION=@PACKAGE_VERSION@
target_cpu=@target_cpu@
platform=@platform@
host_os=@host_os@
font=@datadir@/@PACKAGE_TARNAME@/ascii.pf2
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
grub_setup=${sbindir}/`echo grub-setup | sed ${transform}`
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] || [ "${target_cpu}-${platform}" = "mips-yeeloong" ] ; then
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
else
grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}`
@ -83,14 +84,21 @@ if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
cat <<EOF
--disk-module=MODULE disk module to use
EOF
fi
if [ "${target_cpu}-${platform}" = "mips-yeeloong" ] ; then
cat <<EOF
--font=FILE font file to use
EOF
fi
cat <<EOF
INSTALL_DEVICE can be a GRUB device name or a system device filename.
grub-install copies GRUB images into the DIR/boot directory specified by
--root-directory, and uses grub-setup to install grub into the boot
sector.
grub-install copies GRUB images into /boot/grub (or /grub on NetBSD and
OpenBSD), and uses grub-setup to install grub into the boot sector.
If the --root-directory option is used, then grub-install will copy
images into the operating system installation rooted at that directory.
Report bugs to <bug-grub@gnu.org>.
EOF
@ -107,6 +115,8 @@ for option in "$@"; do
exit 0 ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
--font=*)
font=`echo "$option" | sed 's/--font=//'` ;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
--grub-setup=*)
@ -148,7 +158,7 @@ done
# for make_system_path_relative_to_its_root()
. ${libdir}/grub/grub-mkconfig_lib
if test "x$install_device" = x; then
if test "x$install_device" = x && test "${target_cpu}-${platform}" != "mips-yeeloong"; then
echo "install_device not specified." 1>&2
usage
exit 1
@ -295,15 +305,17 @@ prefix_drive=
config_opt=
if [ "x${devabstraction_module}" = "x" ] ; then
if echo "${install_device}" | grep -qx "(.*)" ; then
install_drive="${install_device}"
else
install_drive="`$grub_probe --target=drive --device ${install_device}`"
if [ x"${install_device}" != x ]; then
if echo "${install_device}" | grep -qx "(.*)" ; then
install_drive="${install_device}"
else
install_drive="`$grub_probe --target=drive --device ${install_device}`"
fi
install_drive="`echo ${install_drive} | sed -e s/,[0-9]*[a-z]*//g`"
fi
grub_drive="`$grub_probe --target=drive --device ${grub_device}`"
# Strip partition number
install_drive="`echo ${install_drive} | sed -e s/,[0-9]*[a-z]*//g`"
grub_drive="`echo ${grub_drive} | sed -e s/,[0-9]*[a-z]*//g`"
if [ "$disk_module" = ata ] ; then
# generic method (used on coreboot and ata mod)
@ -337,6 +349,8 @@ if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}"
# Now perform the installation.
$grub_setup ${setup_verbose} ${setup_force} --directory=${grubdir} --device-map=${device_map} \
${install_device} || exit 1
elif [ "${target_cpu}-${platform}" = "mips-yeeloong" ] ; then
$grub_mkimage ${config_opt} -f ${font} -d ${pkglibdir} -O elf --output=/boot/grub.elf --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
else
$grub_mkimage ${config_opt} -d ${pkglibdir} --output=/boot/multiboot.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
fi

View file

@ -97,8 +97,9 @@ convert_system_path_to_grub_path ()
save_default_entry ()
{
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then
echo 'saved_entry=${chosen}'
echo 'save_env saved_entry'
cat << EOF
savedefault
EOF
fi
}

View file

@ -84,7 +84,7 @@ 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 ("\
Usage: %s [OPTION]...\n\

View file

@ -20,6 +20,7 @@
#include <grub/types.h>
#include <grub/util/misc.h>
#include <grub/i18n.h>
#include <grub/fontformat.h>
#include <stdio.h>
#include <stdlib.h>
@ -49,6 +50,12 @@ struct grub_glyph_info
grub_uint8_t bitmap[0];
};
enum file_formats
{
PF2,
ASCII_BITMAPS
};
#define GRUB_FONT_FLAG_BOLD 1
#define GRUB_FONT_FLAG_NOBITMAP 2
#define GRUB_FONT_FLAG_NOHINTING 4
@ -59,10 +66,12 @@ struct grub_font_info
char* name;
int style;
int desc;
int asce;
int size;
int max_width;
int max_height;
int min_y;
int max_y;
int flags;
int num_range;
grub_uint32_t *ranges;
@ -77,6 +86,7 @@ static struct option options[] =
{"range", required_argument, 0, 'r'},
{"size", required_argument, 0, 's'},
{"desc", required_argument, 0, 'd'},
{"asce", required_argument, 0, 'c'},
{"bold", no_argument, 0, 'b'},
{"no-bitmap", no_argument, 0, 0x100},
{"no-hinting", no_argument, 0, 0x101},
@ -84,6 +94,7 @@ static struct option options[] =
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"verbose", no_argument, 0, 'v'},
{"ascii-bitmaps", no_argument, 0, 0x102},
{0, 0, 0, 0}
};
@ -93,17 +104,19 @@ 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 ("\
Usage: %s [OPTIONS] FONT_FILES\n\
\nOptions:\n\
-o, --output=FILE_NAME set output file name\n\
--ascii-bitmaps save only the ASCII bitmaps\n\
-i, --index=N set face index\n\
-r, --range=A-B[,C-D] set font range\n\
-n, --name=S set font family name\n\
-s, --size=N set font size\n\
-d, --desc=N set font descent\n\
-c, --asce=N set font ascent\n\
-b, --bold convert to bold font\n\
-a, --force-autohint force autohint\n\
--no-hinting disable hinting\n\
@ -193,9 +206,12 @@ add_char (struct grub_font_info *font_info, FT_Face face,
if (height > font_info->max_height)
font_info->max_height = height;
if (glyph_info->y_ofs < font_info->min_y)
if (glyph_info->y_ofs < font_info->min_y && glyph_info->y_ofs > -font_info->size)
font_info->min_y = glyph_info->y_ofs;
if (glyph_info->y_ofs + height > font_info->max_y)
font_info->max_y = glyph_info->y_ofs + height;
mask = 0;
data = &glyph_info->bitmap[0] - 1;
for (j = 0; j < height; j++)
@ -284,8 +300,8 @@ print_glyphs (struct grub_font_info *font_info)
xmin = 0;
ymax = glyph->y_ofs + glyph->height;
if (ymax < font_info->size - font_info->desc)
ymax = font_info->size - font_info->desc;
if (ymax < font_info->asce)
ymax = font_info->asce;
ymin = glyph->y_ofs;
if (ymin > - font_info->desc)
@ -316,7 +332,7 @@ print_glyphs (struct grub_font_info *font_info)
else if ((x >= 0) &&
(x < glyph->device_width) &&
(y >= - font_info->desc) &&
(y < font_info->size - font_info->desc))
(y < font_info->asce))
{
line[line_pos++] = ((x == 0) || (y == 0)) ? '+' : '.';
}
@ -330,7 +346,39 @@ print_glyphs (struct grub_font_info *font_info)
}
void
write_font (struct grub_font_info *font_info, char *output_file)
write_font_ascii_bitmap (struct grub_font_info *font_info, char *output_file)
{
FILE *file;
struct grub_glyph_info *glyph;
int num;
file = fopen (output_file, "wb");
if (! file)
grub_util_error ("Can\'t write to file %s.", output_file);
int correct_size;
for (glyph = font_info->glyph, num = 0; glyph; glyph = glyph->next, num++)
{
correct_size = 1;
if (glyph->width != 8 || glyph->height != 16)
{
/* printf ("Width or height from glyph U+%04x not supported, skipping.\n", glyph->char_code); */
correct_size = 0;
}
int row;
for (row = 0; row < glyph->height; row++)
{
if (correct_size)
fwrite (&glyph->bitmap[row], sizeof(glyph->bitmap[row]), 1, file);
else
fwrite (&correct_size, 1, 1, file);
}
}
fclose (file);
}
void
write_font_pf2 (struct grub_font_info *font_info, char *output_file)
{
FILE *file;
grub_uint32_t leng, data;
@ -340,14 +388,15 @@ write_font (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;
leng = grub_cpu_to_be32 (4);
grub_util_write_image ("FILE", 4, file);
grub_util_write_image (FONT_FORMAT_SECTION_NAMES_FILE,
sizeof(FONT_FORMAT_SECTION_NAMES_FILE) - 1, file);
grub_util_write_image ((char *) &leng, 4, file);
grub_util_write_image ("PFF2", 4, file);
grub_util_write_image (FONT_FORMAT_PFF2_MAGIC, 4, file);
offset += 12;
if (! font_info->name)
@ -369,20 +418,25 @@ write_font (struct grub_font_info *font_info, char *output_file)
font_name = xasprintf ("%s %s %d", font_info->name, &style_name[1],
font_info->size);
write_string_section ("NAME", font_name, &offset, file);
write_string_section ("FAMI", font_info->name, &offset, file);
write_string_section ("WEIG",
write_string_section (FONT_FORMAT_SECTION_NAMES_FONT_NAME,
font_name, &offset, file);
write_string_section (FONT_FORMAT_SECTION_NAMES_FAMILY,
font_info->name, &offset, file);
write_string_section (FONT_FORMAT_SECTION_NAMES_WEIGHT,
(font_info->style & FT_STYLE_FLAG_BOLD) ?
"bold" : "normal",
&offset, file);
write_string_section ("SLAN",
write_string_section (FONT_FORMAT_SECTION_NAMES_SLAN,
(font_info->style & FT_STYLE_FLAG_ITALIC) ?
"italic" : "normal",
&offset, file);
write_be16_section ("PTSZ", font_info->size, &offset, file);
write_be16_section ("MAXW", font_info->max_width, &offset, file);
write_be16_section ("MAXH", font_info->max_height, &offset, file);
write_be16_section (FONT_FORMAT_SECTION_NAMES_POINT_SIZE,
font_info->size, &offset, file);
write_be16_section (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH,
font_info->max_width, &offset, file);
write_be16_section (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT,
font_info->max_height, &offset, file);
if (! font_info->desc)
{
@ -392,15 +446,25 @@ write_font (struct grub_font_info *font_info, char *output_file)
font_info->desc = - font_info->min_y;
}
write_be16_section ("ASCE", font_info->size - font_info->desc, &offset, file);
write_be16_section ("DESC", font_info->desc, &offset, file);
if (! font_info->asce)
{
if (font_info->max_y <= 0)
font_info->asce = 1;
else
font_info->asce = font_info->max_y;
}
write_be16_section (FONT_FORMAT_SECTION_NAMES_ASCENT,
font_info->asce, &offset, file);
write_be16_section (FONT_FORMAT_SECTION_NAMES_DESCENT,
font_info->desc, &offset, file);
if (font_verbosity > 0)
{
printf ("Font name: %s\n", font_name);
printf ("Max width: %d\n", font_info->max_width);
printf ("Max height: %d\n", font_info->max_height);
printf ("Font ascent: %d\n", font_info->size - font_info->desc);
printf ("Font ascent: %d\n", font_info->asce);
printf ("Font descent: %d\n", font_info->desc);
}
@ -424,7 +488,9 @@ write_font (struct grub_font_info *font_info, char *output_file)
printf ("Number of glyph: %d\n", num);
leng = grub_cpu_to_be32 (num * 9);
grub_util_write_image ("CHIX", 4, file);
grub_util_write_image (FONT_FORMAT_SECTION_NAMES_CHAR_INDEX,
sizeof(FONT_FORMAT_SECTION_NAMES_CHAR_INDEX) - 1,
file);
grub_util_write_image ((char *) &leng, 4, file);
offset += 8 + num * 9 + 8;
@ -440,7 +506,8 @@ write_font (struct grub_font_info *font_info, char *output_file)
}
leng = 0xffffffff;
grub_util_write_image ("DATA", 4, file);
grub_util_write_image (FONT_FORMAT_SECTION_NAMES_DATA,
sizeof(FONT_FORMAT_SECTION_NAMES_DATA) - 1, file);
grub_util_write_image ((char *) &leng, 4, file);
for (cur = font_info->glyph; cur; cur = cur->next)
@ -458,9 +525,6 @@ write_font (struct grub_font_info *font_info, char *output_file)
grub_util_write_image ((char *) &cur->bitmap[0], cur->bitmap_size, file);
}
if (font_verbosity > 1)
print_glyphs (font_info);
fclose (file);
}
@ -472,6 +536,7 @@ main (int argc, char *argv[])
int font_index = 0;
int font_size = 0;
char *output_file = NULL;
enum file_formats file_format = PF2;
memset (&font_info, 0, sizeof (font_info));
@ -531,13 +596,13 @@ 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,
(font_info.num_range +
GRUB_FONT_RANGE_BLOCK) *
sizeof (int) * 2);
sizeof (grub_uint32_t) * 2);
font_info.ranges[font_info.num_range * 2] = a;
font_info.ranges[font_info.num_range * 2 + 1] = b;
@ -546,7 +611,7 @@ main (int argc, char *argv[])
if (*p)
{
if (*p != ',')
grub_util_error ("Invalid font range");
grub_util_error ("invalid font range");
else
p++;
}
@ -560,6 +625,10 @@ main (int argc, char *argv[])
font_info.desc = strtoul (optarg, NULL, 0);
break;
case 'e':
font_info.asce = strtoul (optarg, NULL, 0);
break;
case 'h':
usage (0);
break;
@ -572,14 +641,35 @@ main (int argc, char *argv[])
font_verbosity++;
break;
case 0x102:
file_format = ASCII_BITMAPS;
break;
default:
usage (1);
break;
}
}
if (file_format == ASCII_BITMAPS && font_info.num_range > 0)
{
grub_util_error ("Option --ascii-bitmaps doesn't accept ranges (use ASCII).");
return 1;
}
else if (file_format == ASCII_BITMAPS)
{
font_info.ranges = xrealloc (font_info.ranges,
GRUB_FONT_RANGE_BLOCK *
sizeof (grub_uint32_t) * 2);
font_info.ranges[0] = (grub_uint32_t) 0x00;
font_info.ranges[1] = (grub_uint32_t) 0x7f;
font_info.num_range = 1;
}
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");
@ -591,7 +681,7 @@ main (int argc, char *argv[])
if (FT_New_Face (ft_lib, argv[optind], font_index, &ft_face))
{
grub_util_info ("Can't open file %s, index %d\n", argv[optind],
grub_util_info ("can't open file %s, index %d", argv[optind],
font_index);
continue;
}
@ -619,7 +709,13 @@ main (int argc, char *argv[])
FT_Done_FreeType (ft_lib);
write_font (&font_info, output_file);
if (file_format == PF2)
write_font_pf2 (&font_info, output_file);
else if (file_format == ASCII_BITMAPS)
write_font_ascii_bitmap (&font_info, output_file);
if (font_verbosity > 1)
print_glyphs (&font_info);
return 0;
}

View file

@ -50,9 +50,9 @@ grub_vprintf (const char *fmt, va_list args)
}
int
grub_vsprintf (char *str, const char *fmt, va_list args)
grub_vsnprintf (char *str, grub_size_t n, const char *fmt, va_list args)
{
return vsprintf (str, fmt, args);
return vsnprintf (str, n, fmt, args);
}
void
@ -74,16 +74,16 @@ static void
usage (int status)
{
if (status)
fprintf (stderr, "Try ``grub-scrypt --help'' for more information.\n");
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
else
printf ("\
Usage: grub-scrypt [OPTIONS]\n\
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", PACKAGE_BUGREPORT);
Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT);
exit (status);
}
@ -123,9 +123,8 @@ main (int argc, char *argv[])
int tty_changed;
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
grub_util_init_nls ();
/* Check for options. */
while (1)
@ -166,12 +165,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);
@ -179,7 +178,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)
@ -187,7 +186,7 @@ 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. */
@ -226,7 +225,7 @@ main (int argc, char *argv[])
/* 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;
@ -250,7 +249,7 @@ main (int argc, char *argv[])
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;
@ -265,7 +264,7 @@ main (int argc, char *argv[])
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);
@ -287,7 +286,7 @@ main (int argc, char *argv[])
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)
@ -300,7 +299,7 @@ main (int argc, char *argv[])
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);
}
@ -322,7 +321,7 @@ 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);

View file

@ -22,6 +22,7 @@
#include <grub/machine/boot.h>
#include <grub/machine/kernel.h>
#include <grub/machine/memory.h>
#include <grub/elf.h>
#include <grub/i18n.h>
#include <grub/kernel.h>
#include <grub/disk.h>
@ -95,12 +96,19 @@ compress_kernel (char *kernel_img, size_t kernel_size,
static void
generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
char *memdisk_path, char *config_path)
char *memdisk_path, char *font_path, char *config_path,
#ifdef GRUB_PLATFORM_IMAGE_DEFAULT
grub_platform_image_format_t format
#else
int dummy __attribute__ ((unused))
#endif
)
{
char *kernel_img, *boot_img, *core_img;
size_t kernel_size, boot_size, total_module_size, core_size;
size_t memdisk_size = 0, config_size = 0;
char *kernel_path, *boot_path;
char *kernel_img, *core_img;
size_t kernel_size, total_module_size, core_size;
size_t memdisk_size = 0, font_size = 0, config_size = 0, config_size_pure = 0;
char *kernel_path;
size_t offset;
struct grub_util_path_list *path_list, *p, *next;
struct grub_module_info *modinfo;
@ -119,9 +127,16 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
total_module_size += memdisk_size + sizeof (struct grub_module_header);
}
if (font_path)
{
font_size = ALIGN_UP(grub_util_get_image_size (font_path), 4);
total_module_size += font_size + sizeof (struct grub_module_header);
}
if (config_path)
{
config_size = grub_util_get_image_size (config_path) + 1;
config_size_pure = grub_util_get_image_size (config_path) + 1;
config_size = ALIGN_UP(config_size_pure, 4);
grub_util_info ("the size of config file is 0x%x", config_size);
total_module_size += config_size + sizeof (struct grub_module_header);
}
@ -150,15 +165,17 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
for (p = path_list; p; p = p->next)
{
struct grub_module_header *header;
size_t mod_size;
size_t mod_size, orig_size;
mod_size = grub_util_get_image_size (p->name);
orig_size = grub_util_get_image_size (p->name);
mod_size = ALIGN_UP(orig_size, 4);
header = (struct grub_module_header *) (kernel_img + offset);
memset (header, 0, sizeof (struct grub_module_header));
header->type = OBJ_TYPE_ELF;
header->size = grub_host_to_target32 (mod_size + sizeof (*header));
offset += sizeof (*header);
memset (kernel_img + offset + orig_size, 0, mod_size - orig_size);
grub_util_load_image (p->name, kernel_img + offset);
offset += mod_size;
@ -178,6 +195,20 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
offset += memdisk_size;
}
if (font_path)
{
struct grub_module_header *header;
header = (struct grub_module_header *) (kernel_img + offset);
memset (header, 0, sizeof (struct grub_module_header));
header->type = OBJ_TYPE_FONT;
header->size = grub_host_to_target32 (font_size + sizeof (*header));
offset += sizeof (*header);
grub_util_load_image (font_path, kernel_img + offset);
offset += font_size;
}
if (config_path)
{
struct grub_module_header *header;
@ -189,8 +220,8 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
offset += sizeof (*header);
grub_util_load_image (config_path, kernel_img + offset);
*(kernel_img + offset + config_size_pure - 1) = 0;
offset += config_size;
*(kernel_img + offset - 1) = 0;
}
grub_util_info ("kernel_img=%p, kernel_size=0x%x", kernel_img, kernel_size);
@ -202,29 +233,33 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
#if defined(GRUB_MACHINE_PCBIOS)
{
unsigned num;
char *boot_path, *boot_img;
size_t boot_size;
num = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
if (num > 0xffff)
grub_util_error (_("the core image is too big"));
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 size must be %u bytes"), GRUB_DISK_SECTOR_SIZE);
grub_util_error (_("diskboot.img size must be %u bytes"),
GRUB_DISK_SECTOR_SIZE);
boot_img = grub_util_read_image (boot_path);
{
struct grub_boot_blocklist *block;
block = (struct grub_boot_blocklist *) (boot_img
+ GRUB_DISK_SECTOR_SIZE
- sizeof (*block));
+ GRUB_DISK_SECTOR_SIZE
- sizeof (*block));
block->len = grub_host_to_target16 (num);
/* This is filled elsewhere. Verify it just in case. */
assert (block->segment == grub_host_to_target16 (GRUB_BOOT_MACHINE_KERNEL_SEG
+ (GRUB_DISK_SECTOR_SIZE >> 4)));
assert (block->segment
== grub_host_to_target16 (GRUB_BOOT_MACHINE_KERNEL_SEG
+ (GRUB_DISK_SECTOR_SIZE >> 4)));
}
grub_util_write_image (boot_img, boot_size, out);
free (boot_img);
free (boot_path);
@ -233,6 +268,8 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
{
char *rom_img;
size_t rom_size;
char *boot_path, *boot_img;
size_t boot_size;
boot_path = grub_util_get_path (dir, "boot.img");
boot_size = grub_util_get_image_size (boot_path);
@ -245,12 +282,12 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
memset (rom_img, 0, rom_size);
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_CORE_ENTRY_ADDR))
= grub_cpu_to_le32 ((grub_uint32_t) -rom_size);
= grub_host_to_target32 ((grub_uint32_t) -rom_size);
memcpy (rom_img, core_img, core_size);
*((grub_int32_t *) (boot_img + GRUB_BOOT_MACHINE_CORE_ENTRY_ADDR))
= grub_cpu_to_le32 ((grub_uint32_t) -rom_size);
= grub_host_to_target32 ((grub_uint32_t) -rom_size);
memcpy (rom_img + rom_size - boot_size, boot_img, boot_size);
@ -261,18 +298,17 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
free (boot_img);
free (boot_path);
}
#endif
#ifdef GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE))
= grub_cpu_to_le32 (total_module_size);
= grub_host_to_target32 (total_module_size);
#endif
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE))
= grub_cpu_to_le32 (kernel_size);
= grub_host_to_target32 (kernel_size);
#ifdef GRUB_KERNEL_MACHINE_COMPRESSED_SIZE
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE))
= grub_cpu_to_le32 (core_size - GRUB_KERNEL_MACHINE_RAW_SIZE);
= grub_host_to_target32 (core_size - GRUB_KERNEL_MACHINE_RAW_SIZE);
#endif
#if defined(GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) && defined(GRUB_KERNEL_MACHINE_INSTALL_BSD_PART)
@ -281,16 +317,79 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
if (prefix[0] == '(')
{
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART))
= grub_cpu_to_le32 (-2);
= grub_host_to_target32 (-2);
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART))
= grub_cpu_to_le32 (-2);
= grub_host_to_target32 (-2);
}
#endif
#ifdef GRUB_MACHINE_PCBIOS
if (GRUB_KERNEL_MACHINE_LINK_ADDR + core_size > GRUB_MEMORY_MACHINE_UPPER)
grub_util_error (_("Core image is too big (%p > %p)\n"),
GRUB_KERNEL_MACHINE_LINK_ADDR + core_size, GRUB_MEMORY_MACHINE_UPPER);
grub_util_error (_("core image is too big (%p > %p)"),
GRUB_KERNEL_MACHINE_LINK_ADDR + core_size,
GRUB_MEMORY_MACHINE_UPPER);
#endif
#if defined(GRUB_MACHINE_MIPS)
if (format == GRUB_PLATFORM_IMAGE_ELF)
{
char *elf_img;
size_t program_size;
Elf32_Ehdr *ehdr;
Elf32_Phdr *phdr;
grub_uint32_t target_addr;
program_size = ALIGN_UP (core_size, 4);
elf_img = xmalloc (program_size + sizeof (*ehdr) + sizeof (*phdr));
memset (elf_img, 0, program_size + sizeof (*ehdr) + sizeof (*phdr));
memcpy (elf_img + sizeof (*ehdr) + sizeof (*phdr), core_img, core_size);
ehdr = (void *) elf_img;
phdr = (void *) (elf_img + sizeof (*ehdr));
memcpy (ehdr->e_ident, ELFMAG, SELFMAG);
ehdr->e_ident[EI_CLASS] = ELFCLASS32;
#ifdef GRUB_CPU_MIPSEL
ehdr->e_ident[EI_DATA] = ELFDATA2LSB;
#else
ehdr->e_ident[EI_DATA] = ELFDATA2MSB;
#endif
ehdr->e_ident[EI_VERSION] = EV_CURRENT;
ehdr->e_ident[EI_OSABI] = ELFOSABI_NONE;
ehdr->e_type = grub_host_to_target16 (ET_EXEC);
ehdr->e_machine = grub_host_to_target16 (EM_MIPS);
ehdr->e_version = grub_host_to_target32 (EV_CURRENT);
ehdr->e_phoff = grub_host_to_target32 ((char *) phdr - (char *) ehdr);
ehdr->e_phentsize = grub_host_to_target16 (sizeof (*phdr));
ehdr->e_phnum = grub_host_to_target16 (1);
/* No section headers. */
ehdr->e_shoff = grub_host_to_target32 (0);
ehdr->e_shentsize = grub_host_to_target16 (0);
ehdr->e_shnum = grub_host_to_target16 (0);
ehdr->e_shstrndx = grub_host_to_target16 (0);
ehdr->e_ehsize = grub_host_to_target16 (sizeof (*ehdr));
phdr->p_type = grub_host_to_target32 (PT_LOAD);
phdr->p_offset = grub_host_to_target32 (sizeof (*ehdr) + sizeof (*phdr));
phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X);
target_addr = ALIGN_UP (GRUB_KERNEL_MACHINE_LINK_ADDR
+ kernel_size + total_module_size, 32);
ehdr->e_entry = grub_host_to_target32 (target_addr);
phdr->p_vaddr = grub_host_to_target32 (target_addr);
phdr->p_paddr = grub_host_to_target32 (target_addr);
phdr->p_align = grub_host_to_target32 (GRUB_KERNEL_MACHINE_LINK_ALIGN);
ehdr->e_flags = grub_host_to_target32 (0x1000 | EF_MIPS_NOREORDER
| EF_MIPS_PIC | EF_MIPS_CPIC);
phdr->p_filesz = grub_host_to_target32 (core_size);
phdr->p_memsz = grub_host_to_target32 (core_size);
free (core_img);
core_img = elf_img;
core_size = program_size + sizeof (*ehdr) + sizeof (*phdr);
}
#endif
grub_util_write_image (core_img, core_size, out);
@ -314,8 +413,12 @@ static struct option options[] =
{"directory", required_argument, 0, 'd'},
{"prefix", required_argument, 0, 'p'},
{"memdisk", required_argument, 0, 'm'},
{"font", required_argument, 0, 'f'},
{"config", required_argument, 0, 'c'},
{"output", required_argument, 0, 'o'},
#ifdef GRUB_PLATFORM_IMAGE_DEFAULT
{"format", required_argument, 0, 'O'},
#endif
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"verbose", no_argument, 0, 'v'},
@ -326,24 +429,33 @@ 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 (_("\
Usage: grub-mkimage [OPTION]... [MODULES]\n\
Usage: %s [OPTION]... [MODULES]\n\
\n\
Make a bootable image of GRUB.\n\
\n\
-d, --directory=DIR use images and modules under DIR [default=%s]\n\
-p, --prefix=DIR set grub_prefix directory [default=%s]\n\
-m, --memdisk=FILE embed FILE as a memdisk image\n\
-f, --font=FILE embed FILE as a boot font\n\
-c, --config=FILE embed FILE as boot config\n\
-o, --output=FILE output a generated image to FILE [default=stdout]\n\
-o, --output=FILE output a generated image to FILE [default=stdout]\n"
#ifdef GRUB_PLATFORM_IMAGE_DEFAULT
"\
-O, --format=FORMAT generate an image in format [default="
GRUB_PLATFORM_IMAGE_DEFAULT_FORMAT "]\n \
available formats: "
GRUB_PLATFORM_IMAGE_FORMATS "\n"
#endif
"\
-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\
"), GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
"), program_name, GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
exit (status);
}
@ -355,16 +467,18 @@ main (int argc, char *argv[])
char *dir = NULL;
char *prefix = NULL;
char *memdisk = NULL;
char *font = NULL;
char *config = NULL;
FILE *fp = stdout;
set_program_name (argv[0]);
#ifdef GRUB_PLATFORM_IMAGE_DEFAULT
grub_platform_image_format_t format = GRUB_PLATFORM_IMAGE_DEFAULT;
#endif
grub_util_init_nls ();
while (1)
{
int c = getopt_long (argc, argv, "d:p:m:c:o:hVv", options, 0);
int c = getopt_long (argc, argv, "d:p:m:c:o:O:f:hVv", options, 0);
if (c == -1)
break;
@ -378,6 +492,22 @@ main (int argc, char *argv[])
output = xstrdup (optarg);
break;
#ifdef GRUB_PLATFORM_IMAGE_DEFAULT
case 'O':
#ifdef GRUB_PLATFORM_IMAGE_RAW
if (strcmp (optarg, "raw") == 0)
format = GRUB_PLATFORM_IMAGE_RAW;
else
#endif
#ifdef GRUB_PLATFORM_IMAGE_ELF
if (strcmp (optarg, "elf") == 0)
format = GRUB_PLATFORM_IMAGE_ELF;
else
#endif
usage (1);
break;
#endif
case 'd':
if (dir)
free (dir);
@ -397,6 +527,13 @@ main (int argc, char *argv[])
prefix = xstrdup ("(memdisk)/boot/grub");
break;
case 'f':
if (font)
free (font);
font = xstrdup (optarg);
break;
case 'c':
if (config)
free (config);
@ -438,7 +575,13 @@ main (int argc, char *argv[])
}
generate_image (dir ? : GRUB_LIBDIR, prefix ? : DEFAULT_DIRECTORY, fp,
argv + optind, memdisk, config);
argv + optind, memdisk, font, config,
#ifdef GRUB_PLATFORM_IMAGE_DEFAULT
format
#else
0
#endif
);
fclose (fp);

View file

@ -34,7 +34,7 @@ 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 ("\
Usage: %s [OPTIONS] PATH\n\

View file

@ -40,7 +40,7 @@ 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 ("\
Usage: %s [OPTIONS] input [output]\n\
@ -182,7 +182,7 @@ write_section_data (FILE* fp, char *image,
char name[5 + strlen (pe_shdr->name)];
if (num_sections >= MAX_SECTIONS)
grub_util_error ("Too many sections");
grub_util_error ("too many sections");
sprintf (name, ".rel%s", pe_shdr->name);
@ -230,14 +230,14 @@ write_reloc_section (FILE* fp, char *image,
if ((pe_rel->symtab_index >= pe_chdr->num_symbols) ||
(symtab_map[pe_rel->symtab_index] == -1))
grub_util_error ("Invalid symbol");
grub_util_error ("invalid symbol");
if (pe_rel->type == GRUB_PE32_REL_I386_DIR32)
type = R_386_32;
else if (pe_rel->type == GRUB_PE32_REL_I386_REL32)
type = R_386_PC32;
else
grub_util_error ("Unknown pe relocation type %d\n", pe_rel->type);
grub_util_error ("unknown pe relocation type %d\n", pe_rel->type);
ofs = pe_rel->offset - pe_sec->virtual_address;
addr = (grub_uint32_t *)(image + pe_sec->raw_data_offset + ofs);
@ -248,14 +248,14 @@ write_reloc_section (FILE* fp, char *image,
code = image[pe_sec->raw_data_offset + ofs - 1];
if (((code != 0xe8) && (code != 0xe9)) || (*addr))
grub_util_error ("Invalid relocation (%x %x)", code, *addr);
grub_util_error ("invalid relocation (%x %x)", code, *addr);
modified = 1;
if (symtab[symtab_map[pe_rel->symtab_index]].st_shndx)
{
if (symtab[symtab_map[pe_rel->symtab_index]].st_shndx
!= shdr[i].sh_info)
grub_util_error ("Cross section call is not allowed");
grub_util_error ("cross section call is not allowed");
*addr = (symtab[symtab_map[pe_rel->symtab_index]].st_value
- ofs - 4);
@ -440,7 +440,7 @@ convert_pe (FILE* fp, char *image)
pe_chdr = (struct grub_pe32_coff_header *) image;
if (grub_le_to_cpu16 (pe_chdr->machine) != GRUB_PE32_MACHINE_I386)
grub_util_error ("Invalid coff image");
grub_util_error ("invalid coff image");
strtab = xmalloc (STRTAB_BLOCK);
strtab_max = STRTAB_BLOCK;

View file

@ -84,7 +84,7 @@ probe_partmap (grub_disk_t disk)
{
if (disk->partition == NULL)
{
grub_util_info ("No partition map found for %s", disk->name);
grub_util_info ("no partition map found for %s", disk->name);
return;
}
@ -94,6 +94,11 @@ probe_partmap (grub_disk_t disk)
static int
probe_raid_level (grub_disk_t disk)
{
/* disk might be NULL in the case of a LVM physical volume with no LVM
signature. Ignore such cases here. */
if (!disk)
return -1;
if (disk->dev->id != GRUB_DISK_DEVICE_RAID_ID)
return -1;
@ -113,17 +118,17 @@ probe (const char *path, char *device_name)
{
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
if (! grub_util_check_char_device (device_name))
grub_util_error ("%s is not a character device.\n", 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.\n", device_name);
grub_util_error ("%s is not a block device", device_name);
#endif
}
else
device_name = grub_guess_root_device (path);
if (! device_name)
grub_util_error ("cannot find a device for %s (is /dev mounted?).\n", path);
grub_util_error ("cannot find a device for %s (is /dev mounted?)", path);
if (print == PRINT_DEVICE)
{
@ -133,7 +138,7 @@ 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.\n", device_name);
grub_util_error ("cannot find a GRUB drive for %s. Check your device.map", device_name);
if (print == PRINT_DRIVE)
{
@ -309,7 +314,7 @@ 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 ("\
Usage: %s [OPTION]... [PATH|DEVICE]\n\

View file

@ -51,7 +51,7 @@ for option in "$@"; do
usage
exit 0 ;;
-v | --version)
echo "grub-install (GNU GRUB ${PACKAGE_VERSION})"
echo "grub-reboot (GNU GRUB ${PACKAGE_VERSION})"
exit 0 ;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
@ -96,7 +96,11 @@ prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry
if [ "$prev_saved_entry" ]; then
$grub_editenv ${grubdir}/grubenv set prev_saved_entry="$prev_saved_entry"
else
$grub_editenv ${grubdir}/grubenv unset prev_saved_entry
# We need some non-empty value for prev_saved_entry so that GRUB will
# recognise that grub-reboot has been used and restore the previous
# saved entry. "0" is the same as an empty value, i.e. the first menu
# entry.
$grub_editenv ${grubdir}/grubenv set prev_saved_entry=0
fi
$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"

254
util/grub-script-check.c Normal file
View file

@ -0,0 +1,254 @@
/* grub-script-check.c - check grub script file for syntax errors */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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/>.
*/
#include <config.h>
#include <grub/types.h>
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/util/misc.h>
#include <grub/i18n.h>
#include <grub/parser.h>
#include <grub/script_sh.h>
#include <grub_script_check_init.h>
#define _GNU_SOURCE 1
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include "progname.h"
void
grub_putchar (int c)
{
putchar (c);
}
int
grub_getkey (void)
{
return -1;
}
void
grub_refresh (void)
{
fflush (stdout);
}
char *
grub_script_execute_argument_to_string (struct grub_script_arg *arg __attribute__ ((unused)))
{
return 0;
}
grub_err_t
grub_script_execute_cmdline (struct grub_script_cmd *cmd __attribute__ ((unused)))
{
return 0;
}
grub_err_t
grub_script_execute_cmdblock (struct grub_script_cmd *cmd __attribute__ ((unused)))
{
return 0;
}
grub_err_t
grub_script_execute_cmdif (struct grub_script_cmd *cmd __attribute__ ((unused)))
{
return 0;
}
grub_err_t
grub_script_execute_menuentry (struct grub_script_cmd *cmd __attribute__ ((unused)))
{
return 0;
}
grub_err_t
grub_script_execute (struct grub_script *script)
{
if (script == 0 || script->cmd == 0)
return 0;
return script->cmd->exec (script->cmd);
}
static struct option options[] =
{
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"verbose", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
static void
usage (int status)
{
if (status)
fprintf (stderr,
"Try ``%s --help'' for more information.\n", program_name);
else
printf ("\
Usage: %s [PATH]\n\
\n\
Checks GRUB script configuration file for syntax errors.\n\
\n\
-h, --help display this message and exit\n\
-V, --version print version information and exit\n\
-v, --verbose print script being processed\n\
\n\
Report bugs to <%s>.\n\
", program_name,
PACKAGE_BUGREPORT);
exit (status);
}
int
main (int argc, char *argv[])
{
char *argument;
char *input;
FILE *file = 0;
int verbose = 0;
struct grub_script *script;
auto grub_err_t get_config_line (char **line, int cont);
grub_err_t get_config_line (char **line, int cont __attribute__ ((unused)))
{
int i;
char *cmdline = 0;
size_t len = 0;
ssize_t read;
read = getline(&cmdline, &len, (file ?: stdin));
if (read == -1)
{
*line = 0;
grub_errno = GRUB_ERR_READ_ERROR;
if (cmdline)
free (cmdline);
return grub_errno;
}
if (verbose)
grub_printf("%s", cmdline);
for (i = 0; cmdline[i] != '\0'; i++)
{
/* Replace tabs and carriage returns with spaces. */
if (cmdline[i] == '\t' || cmdline[i] == '\r')
cmdline[i] = ' ';
/* Replace '\n' with '\0'. */
if (cmdline[i] == '\n')
cmdline[i] = '\0';
}
*line = grub_strdup (cmdline);
free (cmdline);
return 0;
}
set_program_name (argv[0]);
grub_util_init_nls ();
/* Check for options. */
while (1)
{
int c = getopt_long (argc, argv, "hvV", options, 0);
if (c == -1)
break;
else
switch (c)
{
case 'h':
usage (0);
break;
case 'V':
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':
verbose = 1;
break;
default:
usage (1);
break;
}
}
/* Obtain ARGUMENT. */
if (optind >= argc)
{
file = 0; /* read from stdin */
}
else if (optind + 1 != argc)
{
fprintf (stderr, "Unknown extra argument `%s'.\n", argv[optind + 1]);
usage (1);
}
else
{
argument = argv[optind];
file = fopen (argument, "r");
if (! file)
{
fprintf (stderr, "%s: %s: %s\n", program_name, argument, strerror(errno));
usage (1);
}
}
/* Initialize all modules. */
grub_init_all ();
do
{
input = 0;
get_config_line(&input, 0);
if (! input)
break;
script = grub_script_parse (input, get_config_line);
if (script)
{
grub_script_execute (script);
grub_script_free (script);
}
grub_free (input);
} while (script != 0);
/* Free resources. */
grub_fini_all ();
if (file) fclose (file);
return (script == 0);
}

View file

@ -51,7 +51,7 @@ for option in "$@"; do
usage
exit 0 ;;
-v | --version)
echo "grub-install (GNU GRUB ${PACKAGE_VERSION})"
echo "grub-set-default (GNU GRUB ${PACKAGE_VERSION})"
exit 0 ;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;

View file

@ -39,14 +39,24 @@ if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi
cat << EOF
load_env
set default=${GRUB_DEFAULT}
if [ \${prev_saved_entry} ]; then
saved_entry=\${prev_saved_entry}
save_env saved_entry
prev_saved_entry=
save_env prev_saved_entry
if [ -s \$prefix/grubenv ]; then
load_env
fi
set default="${GRUB_DEFAULT}"
if [ \${prev_saved_entry} ]; then
set saved_entry=\${prev_saved_entry}
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi
function savedefault {
if [ -z \${boot_once} ]; then
saved_entry=\${chosen}
save_env saved_entry
fi
}
EOF
case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in
@ -124,8 +134,9 @@ esac
# Gettext variables and module
if [ "x${LANG}" != "xC" ] ; then
prepare_grub_to_access_device $(${grub_probe} --target=device ${locale_dir})
cat << EOF
set locale_dir=${locale_dir}
set locale_dir=(\$root)$(make_system_path_relative_to_its_root ${locale_dir})
set lang=${grub_lang}
insmod gettext
EOF

View file

@ -76,17 +76,41 @@ menuentry "${OS}" ${CLASS} {
EOF
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
cat << EOF
multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/}
echo $(gettext "Loading GNU Mach ...")
multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/}
EOF
save_default_entry | sed -e "s/^/\t/"
prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
cat << EOF
module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
echo $(gettext "Loading the Hurd ...")
module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
--multiboot-command-line='\${kernel-command-line}' \\
--host-priv-port='\${host-port}' \\
--device-master-port='\${device-port}' \\
--exec-server-task='\${exec-task}' -T typed '\${root}' \\
'\$(task-create)' '\$(task-resume)'
module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
}
EOF
cat << EOF
menuentry "${OS} (recovery mode)" {
EOF
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
cat << EOF
echo $(gettext "Loading GNU Mach ...")
multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} -s
EOF
save_default_entry | sed -e "s/^/\t/"
prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
cat << EOF
echo $(gettext "Loading the Hurd ...")
module /hurd/${hurd_fs}.static ${hurd_fs} \\
--multiboot-command-line='\${kernel-command-line}' \\
--host-priv-port='\${host-port}' \\
--device-master-port='\${device-port}' \\
--exec-server-task='\${exec-task}' -T typed '\${root}' \\
'\$(task-create)' '\$(task-resume)'
module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
}
EOF

View file

@ -22,7 +22,6 @@ bindir=@bindir@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
. ${bindir}/gettext.sh
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@LOCALEDIR@
@ -46,19 +45,20 @@ kfreebsd_entry ()
recovery="$3" # not used yet
args="$4" # not used yet
title="$(gettext "%s, with kFreeBSD %s")"
printf "menuentry \"${title}\" ${CLASS} {" ${os} ${version}
printf "menuentry \"${title}\" ${CLASS} {\n" "${os}" "${version}"
save_default_entry | sed -e "s/^/\t/"
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
fi
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
kfreebsd ${rel_dirname}/${basename}
echo $(printf "$(gettext "Loading kernel of FreeBSD %s ...")" ${version})
kfreebsd ${rel_dirname}/${basename}
EOF
if test -n "${devices}" ; then
cat << EOF
kfreebsd_loadenv ${devices_rel_dirname}/${devices_basename}
kfreebsd_loadenv ${devices_rel_dirname}/${devices_basename}
EOF
fi

View file

@ -22,7 +22,6 @@ bindir=@bindir@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
. ${bindir}/gettext.sh
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@LOCALEDIR@
@ -61,17 +60,28 @@ linux_entry ()
else
title="$(gettext "%s, with Linux %s")"
fi
printf "menuentry \"${title}\" ${CLASS} {" ${os} ${version}
printf "menuentry \"${title}\" ${CLASS} {\n" "${os}" "${version}"
save_default_entry | sed -e "s/^/\t/"
# Use ELILO's generic "efifb" when it's known to be available.
# FIXME: We need an interface to select vesafb in case efifb can't be used.
if grep -qx "CONFIG_FB_EFI=y" /boot/config-${version} 2> /dev/null ; then
cat << EOF
set gfxpayload=keep
EOF
fi
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
fi
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
echo $(printf "$(gettext "Loading Linux %s ...")" ${version})
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
EOF
if test -n "${initrd}" ; then
cat << EOF
echo $(gettext "Loading initial ramdisk ...")
initrd ${rel_dirname}/${initrd}
EOF
fi

View file

@ -41,13 +41,14 @@ osx_entry() {
cat << EOF
menuentry "${LONGNAME} (${2}-bit) (on ${DEVICE})" {
EOF
save_default_entry | sed -e "s/^/\t/"
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
cat << EOF
insmod ${GRUB_VIDEO_BACKEND}
do_resume=0
set do_resume=0
if [ /var/vm/sleepimage -nt10 / ]; then
if xnu_resume /var/vm/sleepimage; then
do_resume=1
set do_resume=1
fi
fi
if [ \$do_resume == 0 ]; then
@ -147,6 +148,7 @@ EOF
cat << EOF
menuentry "${LLABEL} (on ${DEVICE})" {
EOF
save_default_entry | sed -e "s/^/\t/"
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | sed -e "s/^/\t/")"
fi
@ -173,6 +175,7 @@ EOF
cat << EOF
menuentry "${LONGNAME} (on ${DEVICE})" {
EOF
save_default_entry | sed -e "s/^/\t/"
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
grub_device="`${grub_probe} --device ${DEVICE} --target=drive`"
mach_device="`echo "${grub_device}" | tr -d '()' | tr , s`"

View file

@ -336,11 +336,12 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
char dev[PATH_MAX];
strcpy (dev, map[disk->id].device);
if (disk->partition && strncmp (map[disk->id].device, "/dev/", 5) == 0)
if (disk->partition && sector >= disk->partition->start
&& strncmp (map[disk->id].device, "/dev/", 5) == 0)
is_partition = linux_find_partition (dev, disk->partition->start);
/* Open the partition. */
grub_dprintf ("hostdisk", "opening the device `%s' in open_device()", dev);
grub_dprintf ("hostdisk", "opening the device `%s' in open_device()\n", dev);
fd = open (dev, flags);
if (fd < 0)
{
@ -490,6 +491,23 @@ grub_util_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
{
int fd;
/* Split pre-partition and partition reads. */
if (disk->partition && sector < disk->partition->start
&& sector + size > disk->partition->start)
{
grub_err_t err;
err = grub_util_biosdisk_read (disk, sector,
disk->partition->start - sector,
buf);
if (err)
return err;
return grub_util_biosdisk_read (disk, disk->partition->start,
size - (disk->partition->start - sector),
buf + ((disk->partition->start - sector)
<< GRUB_DISK_SECTOR_BITS));
}
fd = open_device (disk, sector, O_RDONLY);
if (fd < 0)
return grub_errno;
@ -527,6 +545,23 @@ grub_util_biosdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
{
int fd;
/* Split pre-partition and partition writes. */
if (disk->partition && sector < disk->partition->start
&& sector + size > disk->partition->start)
{
grub_err_t err;
err = grub_util_biosdisk_write (disk, sector,
disk->partition->start - sector,
buf);
if (err)
return err;
return grub_util_biosdisk_write (disk, disk->partition->start,
size - (disk->partition->start - sector),
buf + ((disk->partition->start - sector)
<< GRUB_DISK_SECTOR_BITS));
}
fd = open_device (disk, sector, O_WRONLY);
if (fd < 0)
return grub_errno;
@ -568,7 +603,7 @@ read_device_map (const char *dev_map)
fp = fopen (dev_map, "r");
if (! fp)
{
grub_util_info (_("Cannot open `%s'"), dev_map);
grub_util_info (_("cannot open `%s'"), dev_map);
return;
}
@ -639,7 +674,7 @@ read_device_map (const char *dev_map)
symbolic links. */
map[drive].device = xmalloc (PATH_MAX);
if (! realpath (p, map[drive].device))
grub_util_error ("Cannot get the real path of `%s'", p);
grub_util_error ("cannot get the real path of `%s'", p);
#else
map[drive].device = xstrdup (p);
#endif

View file

@ -1,7 +1,7 @@
/* hostfs.c - Dummy filesystem to provide access to the hosts filesystem */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
* Copyright (C) 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
@ -26,6 +26,7 @@
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
/* dirent.d_type is a BSD extension, not part of POSIX */
@ -118,10 +119,17 @@ grub_hostfs_read (grub_file_t file, char *buf, grub_size_t len)
FILE *f;
f = (FILE *) file->data;
fseeko (f, file->offset, SEEK_SET);
int s = fread (buf, 1, len, f);
if (fseeko (f, file->offset, SEEK_SET) != 0)
{
grub_error (GRUB_ERR_OUT_OF_RANGE, "fseeko: %s", strerror (errno));
return -1;
}
return s;
unsigned int s = fread (buf, 1, len, f);
if (s != len)
grub_error (GRUB_ERR_FILE_READ_ERROR, "fread: %s", strerror (errno));
return (signed) s;
}
static grub_err_t

View file

@ -778,7 +778,7 @@ make_reloc_section (FILE *out, Elf_Addr current_address, Elf_Ehdr *e,
if ((ELF_R_TYPE (info) == R_X86_64_32) ||
(ELF_R_TYPE (info) == R_X86_64_32S))
{
grub_util_error ("Can\'t add fixup entry for R_X86_64_32(S)");
grub_util_error ("can\'t add fixup entry for R_X86_64_32(S)");
}
else if (ELF_R_TYPE (info) == R_X86_64_64)
{
@ -1029,10 +1029,10 @@ static void
usage (int status)
{
if (status)
fprintf (stderr, "Try ``grub-mkimage --help'' for more information.\n");
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
else
printf ("\
Usage: grub-mkimage -o FILE [OPTION]... [MODULES]\n\
Usage: %s -o FILE [OPTION]... [MODULES]\n\
\n\
Make a bootable image of GRUB.\n\
\n\
@ -1044,7 +1044,7 @@ Make a bootable image of GRUB.\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n\
", GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
", program_name, GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
exit (status);
}

View file

@ -156,7 +156,7 @@ setup (const char *dir,
sector, offset, length);
if (offset != 0 || length != GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("The first sector of the core file is not sector-aligned"));
grub_util_error (_("the first sector of the core file is not sector-aligned"));
first_sector = sector;
}
@ -170,7 +170,7 @@ setup (const char *dir,
sector, offset, length, (unsigned) current_segment);
if (offset != 0 || last_length != GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("Non-sector-aligned data is found in the core file"));
grub_util_error (_("non-sector-aligned data is found in the core file"));
if (block != first_block
&& (grub_le_to_cpu64 (prev->start)
@ -184,7 +184,7 @@ setup (const char *dir,
block--;
if (block->len)
grub_util_error (_("The sectors of the core file are too fragmented"));
grub_util_error (_("the sectors of the core file are too fragmented"));
}
last_length = length;
@ -195,7 +195,7 @@ setup (const char *dir,
boot_path = grub_util_get_path (dir, boot_file);
boot_size = grub_util_get_image_size (boot_path);
if (boot_size != GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("The size of `%s' is not %u"),
grub_util_error (_("the size of `%s' is not %u"),
boot_path, GRUB_DISK_SECTOR_SIZE);
boot_img = grub_util_read_image (boot_path);
free (boot_path);
@ -212,9 +212,9 @@ setup (const char *dir,
core_sectors = ((core_size + GRUB_DISK_SECTOR_SIZE - 1)
>> GRUB_DISK_SECTOR_BITS);
if (core_size < GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("The size of `%s' is too small"), core_path);
grub_util_error (_("the size of `%s' is too small"), core_path);
else if (core_size > 0xFFFF * GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("The size of `%s' is too large"), core_path);
grub_util_error (_("the size of `%s' is too large"), core_path);
core_img = grub_util_read_image (core_path);
@ -251,7 +251,7 @@ setup (const char *dir,
grub_fs_t fs;
fs = grub_fs_probe (dest_dev);
if (! fs)
grub_util_error (_("Unable to identify a filesystem in %s; safety check can't be performed"),
grub_util_error (_("unable to identify a filesystem in %s; safety check can't be performed"),
dest_dev->disk->name);
if (! fs->reserved_first_sector)
@ -304,7 +304,7 @@ setup (const char *dir,
bsd_part = -1;
}
else
grub_util_error (_("No DOS-style partitions found"));
grub_util_error (_("no DOS-style partitions found"));
}
else
dos_part = bsd_part = -1;
@ -413,14 +413,14 @@ setup (const char *dir,
unable_to_embed:
if (must_embed)
grub_util_error (_("Embedding is not possible, but this is required when "
"the root device is on a RAID array or LVM volume."));
grub_util_error (_("embedding is not possible, but this is required when "
"the root device is on a RAID array or LVM volume"));
grub_util_warn (_("Embedding is not possible. GRUB can only be installed in this "
"setup by using blocklists. However, blocklists are UNRELIABLE and "
"its use is discouraged."));
if (! force)
grub_util_error (_("If you really want blocklists, use --force."));
grub_util_error (_("if you really want blocklists, use --force"));
/* Make sure that GRUB reads the identical image as the OS. */
tmp_img = xmalloc (core_size);
@ -495,7 +495,7 @@ unable_to_embed:
}
if (i == MAX_TRIES)
grub_util_error (_("Cannot read `%s' correctly"), core_path_dev);
grub_util_error (_("cannot read `%s' correctly"), core_path_dev);
/* Clean out the blocklists. */
block = first_block;
@ -508,7 +508,7 @@ unable_to_embed:
block--;
if ((char *) block <= core_img)
grub_util_error (_("No terminator in the core image"));
grub_util_error (_("no terminator in the core image"));
}
/* Now read the core image to determine where the sectors are. */
@ -519,13 +519,13 @@ unable_to_embed:
file->read_hook = save_first_sector;
if (grub_file_read (file, tmp_img, GRUB_DISK_SECTOR_SIZE)
!= GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("Failed to read the first sector of the core image"));
grub_util_error (_("failed to read the first sector of the core image"));
block = first_block;
file->read_hook = save_blocklists;
if (grub_file_read (file, tmp_img, core_size - GRUB_DISK_SECTOR_SIZE)
!= (grub_ssize_t) core_size - GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("Failed to read the rest sectors of the core image"));
grub_util_error (_("failed to read the rest sectors of the core image"));
grub_file_close (file);
@ -544,7 +544,7 @@ unable_to_embed:
grub_util_info ("opening the core image `%s'", core_path);
fp = fopen (core_path, "r+b");
if (! fp)
grub_util_error (_("Cannot open `%s'"), core_path);
grub_util_error (_("cannot open `%s'"), core_path);
grub_util_write_image (core_img, GRUB_DISK_SECTOR_SIZE * 2, fp);
fclose (fp);
@ -584,13 +584,13 @@ 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 (_("\
Usage: grub-setup [OPTION]... DEVICE\n\
Usage: %s [OPTION]... DEVICE\n\
\n\
Set up images to boot from DEVICE.\n\
DEVICE must be a GRUB device (e.g. ``(hd0,1)'').\n\
DEVICE must be a GRUB device (e.g. `(hd0,1)').\n\
\n\
-b, --boot-image=FILE use FILE as the boot image [default=%s]\n\
-c, --core-image=FILE use FILE as the core image [default=%s]\n\
@ -605,6 +605,7 @@ DEVICE must be a GRUB device (e.g. ``(hd0,1)'').\n\
\n\
Report bugs to <%s>.\n\
"),
program_name,
DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY,
DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
@ -751,7 +752,7 @@ main (int argc, char *argv[])
char *tmp = get_device_name (root_dev);
if (! tmp)
grub_util_error (_("Invalid root device `%s'"), root_dev);
grub_util_error (_("invalid root device `%s'"), root_dev);
tmp = xstrdup (tmp);
free (root_dev);
@ -764,7 +765,7 @@ main (int argc, char *argv[])
{
grub_util_info ("guessing the root device failed, because of `%s'",
grub_errmsg);
grub_util_error (_("Cannot guess the root device. Specify the option ``--root-device''."));
grub_util_error (_("cannot guess the root device. Specify the option `--root-device'"));
}
}

View file

@ -46,8 +46,8 @@ install_device=
debug=no
update_nvram=yes
ofpathname=/usr/sbin/ofpathname
nvsetenv=/sbin/nvsetenv
ofpathname=`which ofpathname`
nvsetenv=`which nvsetenv`
# Usage: usage
# Print the usage.
@ -216,11 +216,11 @@ if test $update_nvram = yes; then
}
# Point boot-device at the new grub install
boot_device="boot-device $ofpath:$partno,\\grub"
"$nvsetenv" "$boot_device" || {
boot_device="$ofpath:$partno,\\grub"
"$nvsetenv" boot-device "$boot_device" || {
echo "$nvsetenv failed."
echo "You will have to set boot-device manually. At the Open Firmware prompt, type:"
echo " setenv $boot_device"
echo " setenv boot-device $boot_device"
exit 1
}
fi

View file

@ -131,12 +131,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 +247,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 +288,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));
@ -375,7 +375,7 @@ grub_util_devname_to_ofpath (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 (devname);
devnode = strip_trailing_digits (devname);

View file

@ -26,6 +26,8 @@
#include <string.h>
#include <sys/stat.h>
#define LVM_DEV_MAPPER_STRING "/dev/mapper/"
int
grub_util_lvm_isvolume (char *name)
{
@ -33,10 +35,10 @@ grub_util_lvm_isvolume (char *name)
struct stat st;
int err;
devname = xmalloc (strlen (name) + 13);
devname = xmalloc (strlen (name) + sizeof (LVM_DEV_MAPPER_STRING));
strcpy (devname, "/dev/mapper/");
strcpy (devname+12, name);
strcpy (devname, LVM_DEV_MAPPER_STRING);
strcpy (devname + sizeof(LVM_DEV_MAPPER_STRING) - 1, name);
err = stat (devname, &st);
free (devname);

View file

@ -30,6 +30,9 @@
#include <sys/time.h>
#include <unistd.h>
#include <time.h>
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#include <grub/kernel.h>
#include <grub/misc.h>
@ -60,11 +63,12 @@ grub_util_warn (const char *fmt, ...)
{
va_list ap;
fprintf (stderr, "%s: warn: ", program_name);
fprintf (stderr, _("%s: warn:"), program_name);
fprintf (stderr, " ");
va_start (ap, fmt);
vfprintf (stderr, fmt, ap);
va_end (ap);
fputc ('\n', stderr);
fprintf (stderr, ".\n");
fflush (stderr);
}
@ -75,11 +79,12 @@ grub_util_info (const char *fmt, ...)
{
va_list ap;
fprintf (stderr, "%s: info: ", program_name);
fprintf (stderr, _("%s: info:"), program_name);
fprintf (stderr, " ");
va_start (ap, fmt);
vfprintf (stderr, fmt, ap);
va_end (ap);
fputc ('\n', stderr);
fprintf (stderr, ".\n");
fflush (stderr);
}
}
@ -89,11 +94,12 @@ grub_util_error (const char *fmt, ...)
{
va_list ap;
fprintf (stderr, "%s: error: ", program_name);
fprintf (stderr, _("%s: error:"), program_name);
fprintf (stderr, " ");
va_start (ap, fmt);
vfprintf (stderr, fmt, ap);
va_end (ap);
fputc ('\n', stderr);
fprintf (stderr, ".\n");
exit (1);
}
@ -479,6 +485,19 @@ fail:
#endif /* __MINGW32__ */
char *
canonicalize_file_name (const char *path)
{
char *ret;
#ifdef PATH_MAX
ret = xmalloc (PATH_MAX);
(void) realpath (path, ret);
#else
ret = realpath (path, NULL);
#endif
return ret;
}
/* This function never prints trailing slashes (so that its output
can be appended a slash unconditionally). */
char *
@ -491,23 +510,19 @@ make_system_path_relative_to_its_root (const char *path)
size_t len;
/* canonicalize. */
p = realpath (path, NULL);
p = canonicalize_file_name (path);
if (p == NULL)
{
if (errno != EINVAL)
grub_util_error ("failed to get realpath of %s", path);
else
grub_util_error ("realpath not supporting (path, NULL)");
}
grub_util_error ("failed to get canonical path of %s", path);
len = strlen (p) + 1;
buf = strdup (p);
buf = xstrdup (p);
free (p);
if (stat (buf, &st) < 0)
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
buf2 = strdup (buf);
buf2 = xstrdup (buf);
num = st.st_dev;
/* This loop sets offset to the number of chars of the root
@ -529,12 +544,16 @@ make_system_path_relative_to_its_root (const char *path)
/* buf is another filesystem; we found it. */
if (st.st_dev != num)
{
/* offset == 0 means path given is the mount point. */
/* offset == 0 means path given is the mount point.
This works around special-casing of "/" in Un*x. This function never
prints trailing slashes (so that its output can be appended a slash
unconditionally). Each slash in is considered a preceding slash, and
therefore the root directory is an empty string. */
if (offset == 0)
{
free (buf);
free (buf2);
return strdup ("/");
return xstrdup ("");
}
else
break;
@ -551,11 +570,19 @@ make_system_path_relative_to_its_root (const char *path)
buf2[len - 1] = '\0';
len--;
}
return buf2;
if (len > 1)
return buf2;
else
{
/* This means path given is just a backslash. As above
we have to return an empty string. */
free (buf2);
return xstrdup ("");
}
}
}
free (buf);
buf3 = strdup (buf2 + offset);
buf3 = xstrdup (buf2 + offset);
free (buf2);
len = strlen (buf3);

View file

@ -8,7 +8,7 @@
#define PREPARER_DEFAULT NULL
#define PUBLISHER_DEFAULT NULL
#ifndef APPID_DEFAULT
#define APPID_DEFAULT "MKISOFS ISO 9660 FILESYSTEM BUILDER"
#define APPID_DEFAULT PACKAGE_NAME " ISO 9660 filesystem builder"
#endif
#define COPYRIGHT_DEFAULT NULL
#define BIBLIO_DEFAULT NULL
@ -17,38 +17,4 @@
#define VOLUME_ID_DEFAULT "CDROM"
#define BOOT_CATALOG_DEFAULT "boot.catalog"
#define BOOT_IMAGE_DEFAULT NULL
#ifdef __QNX__
#define SYSTEM_ID_DEFAULT "QNX"
#endif
#ifdef __osf__
#define SYSTEM_ID_DEFAULT "OSF"
#endif
#ifdef __sun
#ifdef __SVR4
#define SYSTEM_ID_DEFAULT "Solaris"
#else
#define SYSTEM_ID_DEFAULT "SunOS"
#endif
#endif
#ifdef __hpux
#define SYSTEM_ID_DEFAULT "HP-UX"
#endif
#ifdef __sgi
#define SYSTEM_ID_DEFAULT "SGI"
#endif
#ifdef _AIX
#define SYSTEM_ID_DEFAULT "AIX"
#endif
#ifdef _WIN
#define SYSTEM_ID_DEFAULT "Win32"
#endif /* _WIN */
#ifndef SYSTEM_ID_DEFAULT
#define SYSTEM_ID_DEFAULT "LINUX"
#endif
#define SYSTEM_ID_DEFAULT "GNU"

View file

@ -288,7 +288,7 @@ void FDECL1(get_torito_desc, struct eltorito_boot_descriptor *, boot_desc)
struct eltorito_boot_info bi_table;
bootimage = fopen (de->whole_name, "r+b");
if (bootimage == NULL)
error (1, errno, _("Error opening boot image file '%s' for update"),
error (1, errno, _("Error opening boot image file `%s' for update"),
de->whole_name);
/* Compute checksum of boot image, sans 64 bytes */
total_len = 0;
@ -296,7 +296,7 @@ void FDECL1(get_torito_desc, struct eltorito_boot_descriptor *, boot_desc)
while ((len = fread (csum_buffer, 1, SECTOR_SIZE, bootimage)) > 0)
{
if (total_len & 3)
error (1, 0, _("Odd alignment at non-end-of-file in boot image '%s'"),
error (1, 0, _("Odd alignment at non-end-of-file in boot image `%s'"),
de->whole_name);
if (total_len < 64)
memset (csum_buffer, 0, 64 - total_len);
@ -308,7 +308,7 @@ void FDECL1(get_torito_desc, struct eltorito_boot_descriptor *, boot_desc)
}
if (total_len != de->size)
error (1, 0, _("Boot image file '%s' changed unexpectedly"),
error (1, 0, _("Boot image file `%s' changed unexpectedly"),
de->whole_name);
/* End of file, set position to byte 8 */
fseeko (bootimage, (off_t) 8, SEEK_SET);

View file

@ -26,12 +26,7 @@
#include "config.h"
#include "mkisofs.h"
#include "match.h"
#ifdef linux
#include <getopt.h>
#else
#include "getopt.h"
#endif
#include "iso9660.h"
#include <ctype.h>
@ -914,7 +909,7 @@ int FDECL2(main, int, argc, char **, argv){
exit (0);
break;
case OPTION_VERSION:
printf ("%s (%s %s)\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION);
exit (0);
break;
case OPTION_NOSPLIT_SL_COMPONENT:

View file

@ -5,7 +5,7 @@
Copyright 1993 Yggdrasil Computing, Incorporated
Copyright (C) 2009 Free Software Foundation, Inc.
Copyright (C) 2009,2010 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -306,7 +306,7 @@ int deep_opt;
* the symbolic link won't fit into one SL System Use Field
* print an error message and continue with splited one
*/
fprintf(stderr, _("symbolic link ``%s'' to long for one SL System Use Field, splitting"), cpnt);
fprintf (stderr, _("symbolic link `%s' too long for one SL System Use Field, splitting"), cpnt);
}
if(MAYBE_ADD_CE_ENTRY(SL_SIZE + sl_bytes)) add_CE_entry();
}

View file

@ -158,7 +158,7 @@ void FDECL4(xfwrite, void *, buffer, uint64_t, count, uint64_t, size, FILE *, fi
sprintf(nbuf, "%s_%02d", outfile, idx++);
file = freopen(nbuf, "wb", file);
if (file == NULL)
error (1, errno, _("Cannot open '%s'"), nbuf);
error (1, errno, _("Cannot open `%s'"), nbuf);
}
while(count)

View file

@ -26,7 +26,7 @@ grub_pci_make_address (grub_pci_device_t dev, int reg)
{
grub_pci_address_t ret;
ret.dev = dev;
ret.pos = reg << 2;
ret.pos = reg;
return ret;
}

View file

@ -50,7 +50,7 @@ grub_util_getdiskname (int major, int minor)
else if (major == SCSI_DISK0_MAJOR)
sprintf (name, "/dev/sd%c", 'a' + minor / 16);
else
grub_util_error ("Unknown device number: %d, %d", major, minor);
grub_util_error ("unknown device number: %d, %d", major, minor);
return name;
}
@ -72,7 +72,7 @@ grub_util_raid_getmembers (char *name)
fd = open (devname, O_RDONLY);
if (fd == -1)
grub_util_error ("Can't open %s: %s", devname, strerror (errno));
grub_util_error ("can't open %s: %s", devname, strerror (errno));
free (devname);
@ -81,7 +81,7 @@ grub_util_raid_getmembers (char *name)
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",
grub_util_error ("unsupported RAID version: %d.%d",
version.major, version.minor);
ret = ioctl (fd, GET_ARRAY_INFO, &info);

View file

@ -191,7 +191,7 @@ 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 ("\
Usage: %s [OPTION]... [MODULES]\n\

View file

@ -161,7 +161,7 @@ setup (const char *prefix, const char *dir,
grub_util_info ("first sector is <%llu,%u,%u>", sector, offset, length);
if (offset != 0 || length != GRUB_DISK_SECTOR_SIZE)
grub_util_error ("The first sector of the core file "
grub_util_error ("the first sector of the core file "
"is not sector-aligned");
first_sector = sector;
@ -176,7 +176,7 @@ setup (const char *prefix, const char *dir,
grub_util_info ("saving <%llu,%u,%u>", sector, offset, length);
if (offset != 0 || last_length != GRUB_DISK_SECTOR_SIZE)
grub_util_error ("Non-sector-aligned data is found in the core file");
grub_util_error ("non-sector-aligned data is found in the core file");
if (block != first_block
&& (grub_be_to_cpu64 (prev->start)
@ -189,7 +189,7 @@ setup (const char *prefix, const char *dir,
block--;
if (block->len)
grub_util_error ("The sectors of the core file are too fragmented");
grub_util_error ("the sectors of the core file are too fragmented");
}
last_length = length;
@ -201,7 +201,7 @@ setup (const char *prefix, const char *dir,
boot_path = grub_util_get_path (dir, boot_file);
boot_size = grub_util_get_image_size (boot_path);
if (boot_size != GRUB_DISK_SECTOR_SIZE)
grub_util_error ("The size of `%s' is not %d",
grub_util_error ("the size of `%s' is not %d",
boot_path, GRUB_DISK_SECTOR_SIZE);
boot_img = grub_util_read_image (boot_path);
free (boot_path);
@ -219,7 +219,7 @@ setup (const char *prefix, const char *dir,
core_sectors = ((core_size + GRUB_DISK_SECTOR_SIZE - 1)
>> GRUB_DISK_SECTOR_BITS);
if (core_size < GRUB_DISK_SECTOR_SIZE)
grub_util_error ("The size of `%s' is too small", core_path);
grub_util_error ("the size of `%s' is too small", core_path);
core_img = grub_util_read_image (core_path);
free (core_path);
@ -229,7 +229,7 @@ setup (const char *prefix, const char *dir,
+ GRUB_DISK_SECTOR_SIZE
- sizeof (*block));
grub_util_info ("root is '%s', dest is '%s', and dest_ofpath is '%s'",
grub_util_info ("root is `%s', dest is `%s', and dest_ofpath is `%s'",
root, dest, dest_ofpath);
/* Open the root device and the destination device. */
@ -320,7 +320,7 @@ setup (const char *prefix, const char *dir,
}
if (i == MAX_TRIES)
grub_util_error ("Cannot read `%s' correctly", core_path);
grub_util_error ("cannot read `%s' correctly", core_path);
/* Clean out the blocklists. */
block = first_block;
@ -332,7 +332,7 @@ setup (const char *prefix, 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");
}
/* Now read the core image to determine where the sectors are. */
@ -343,13 +343,13 @@ setup (const char *prefix, const char *dir,
file->read_hook = save_first_sector;
if (grub_file_read (file, tmp_img, GRUB_DISK_SECTOR_SIZE)
!= GRUB_DISK_SECTOR_SIZE)
grub_util_error ("Failed to read the first sector of the core image");
grub_util_error ("failed to read the first sector of the core image");
block = first_block;
file->read_hook = save_blocklists;
if (grub_file_read (file, tmp_img, core_size - GRUB_DISK_SECTOR_SIZE)
!= (grub_ssize_t) core_size - GRUB_DISK_SECTOR_SIZE)
grub_util_error ("Failed to read the rest sectors of the core image");
grub_util_error ("failed to read the rest sectors of the core image");
grub_file_close (file);
@ -368,7 +368,7 @@ setup (const char *prefix, const char *dir,
grub_util_info ("opening the core image `%s'", core_path);
fp = fopen (core_path, "r+b");
if (! fp)
grub_util_error ("Cannot open `%s'", core_path);
grub_util_error ("cannot open `%s'", core_path);
grub_util_write_image (core_img, GRUB_DISK_SECTOR_SIZE, fp);
fclose (fp);
@ -404,13 +404,13 @@ 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 ("\
Usage: %s [OPTION]... DEVICE\n\
\n\
Set up images to boot from DEVICE.\n\
DEVICE must be a GRUB device (e.g. ``(hd0,1)'').\n\
DEVICE must be a GRUB device (e.g. `(hd0,1)').\n\
\n\
-b, --boot-image=FILE use FILE as the boot image [default=%s]\n\
-c, --core-image=FILE use FILE as the core image [default=%s]\n\
@ -559,14 +559,14 @@ find_dest_dev (struct grub_setup_info *gp, char *argv[])
fprintf (stderr, "Invalid device `%s'.\n", argv[optind]);
usage (1);
}
grub_util_info ("transformed OS device '%s' into GRUB device '%s'",
grub_util_info ("transformed OS device `%s' into GRUB device `%s'",
argv[optind], gp->dest_dev);
}
else
{
/* For simplicity. */
gp->dest_dev = xstrdup (gp->dest_dev);
grub_util_info ("Using '%s' as GRUB device", gp->dest_dev);
grub_util_info ("Using `%s' as GRUB device", gp->dest_dev);
}
}
@ -578,7 +578,7 @@ check_root_dev (struct grub_setup_info *gp)
char *tmp = get_device_name (gp->root_dev);
if (! tmp)
grub_util_error ("Invalid root device `%s'", gp->root_dev);
grub_util_error ("invalid root device `%s'", gp->root_dev);
tmp = xstrdup (tmp);
free (gp->root_dev);
@ -594,11 +594,11 @@ check_root_dev (struct grub_setup_info *gp)
{
grub_util_info ("guessing the root device failed, because of `%s'",
grub_errmsg);
grub_util_error ("Cannot guess the root device. "
"Specify the option ``--root-device''.");
grub_util_error ("cannot guess the root device. "
"Specify the option `--root-device'");
}
grub_util_info ("Guessed root device '%s' and root_dev '%s' from "
"dir '%s'", root_device, gp->root_dev, dir);
grub_util_info ("guessed root device `%s' and root_dev `%s' from "
"dir `%s'", root_device, gp->root_dev, dir);
}
}