merge from trunk

This commit is contained in:
Colin Watson 2009-12-08 00:55:17 +00:00
commit e8b2988803
108 changed files with 3024 additions and 5764 deletions

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2004,2005,2006,2007,2008 Free Software Foundation, Inc.
* Copyright (C) 2004,2005,2006,2007,2008,2009 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
@ -31,6 +31,9 @@
#include <grub/util/resolve.h>
#include <grub/kernel.h>
#include <grub/cpu/kernel.h>
#include <grub/i18n.h>
#include "progname.h"
#define GRUB_IEEE1275_NOTE_NAME "PowerPC"
#define GRUB_IEEE1275_NOTE_TYPE 0x1275
@ -325,10 +328,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\
@ -342,7 +345,7 @@ Make a bootable image of GRUB.\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n\
", GRUB_LIBDIR, PACKAGE_BUGREPORT);
", program_name, GRUB_LIBDIR, PACKAGE_BUGREPORT);
exit (status);
}
@ -357,7 +360,10 @@ main (int argc, char *argv[])
char *memdisk = NULL;
int chrp = 0;
progname = "grub-mkimage";
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
while (1)
{

View file

@ -30,6 +30,12 @@
# define DEV_CYGDRIVE_MAJOR 98
#endif
#ifdef __GNU__
#include <hurd.h>
#include <hurd/lookup.h>
#include <hurd/fs.h>
#endif
#include <grub/util/misc.h>
#include <grub/util/hostdisk.h>
#include <grub/util/getroot.h>
@ -378,8 +384,65 @@ find_cygwin_root_device (const char *path, dev_t dev)
char *
grub_guess_root_device (const char *dir)
{
struct stat st;
char *os_dev;
#ifdef __GNU__
file_t file;
mach_port_t *ports;
int *ints;
loff_t *offsets;
char *data;
error_t err;
mach_msg_type_number_t num_ports = 0, num_ints = 0, num_offsets = 0, data_len = 0;
size_t name_len;
file = file_name_lookup (dir, 0, 0);
if (file == MACH_PORT_NULL)
return 0;
err = file_get_storage_info (file,
&ports, &num_ports,
&ints, &num_ints,
&offsets, &num_offsets,
&data, &data_len);
if (num_ints < 1)
grub_util_error ("Storage info for `%s' does not include type", dir);
if (ints[0] != STORAGE_DEVICE)
grub_util_error ("Filesystem of `%s' is not stored on local disk", dir);
if (num_ints < 5)
grub_util_error ("Storage info for `%s' does not include name", dir);
name_len = ints[4];
if (name_len < data_len)
grub_util_error ("Bogus name length for storage info for `%s'", dir);
if (data[name_len - 1] != '\0')
grub_util_error ("Storage name for `%s' not NUL-terminated", dir);
os_dev = xmalloc (strlen ("/dev/") + data_len);
memcpy (os_dev, "/dev/", strlen ("/dev/"));
memcpy (os_dev + strlen ("/dev/"), data, data_len);
if (ports && num_ports > 0)
{
mach_msg_type_number_t i;
for (i = 0; i < num_ports; i++)
{
mach_port_t port = ports[i];
if (port != MACH_PORT_NULL)
mach_port_deallocate (mach_task_self(), port);
}
munmap ((caddr_t) ports, num_ports * sizeof (*ports));
}
if (ints && num_ints > 0)
munmap ((caddr_t) ints, num_ints * sizeof (*ints));
if (offsets && num_offsets > 0)
munmap ((caddr_t) offsets, num_offsets * sizeof (*offsets));
if (data && data_len > 0)
munmap (data, data_len);
mach_port_deallocate (mach_task_self (), file);
#else /* !__GNU__ */
struct stat st;
if (stat (dir, &st) < 0)
grub_util_error ("Cannot stat `%s'", dir);
@ -393,16 +456,45 @@ grub_guess_root_device (const char *dir)
/* This might be truly slow, but is there any better way? */
os_dev = find_root_device ("/dev", st.st_dev);
#endif
#endif /* !__GNU__ */
return os_dev;
}
int
grub_util_is_dmraid (const char *os_dev)
{
if (! strncmp (os_dev, "/dev/mapper/nvidia_", 19))
return 1;
else if (! strncmp (os_dev, "/dev/mapper/isw_", 16))
return 1;
else if (! strncmp (os_dev, "/dev/mapper/hpt37x_", 19))
return 1;
else if (! strncmp (os_dev, "/dev/mapper/hpt45x_", 19))
return 1;
else if (! strncmp (os_dev, "/dev/mapper/via_", 16))
return 1;
else if (! strncmp (os_dev, "/dev/mapper/lsi_", 16))
return 1;
else if (! strncmp (os_dev, "/dev/mapper/pdc_", 16))
return 1;
else if (! strncmp (os_dev, "/dev/mapper/jmicron_", 20))
return 1;
else if (! strncmp (os_dev, "/dev/mapper/asr_", 16))
return 1;
else if (! strncmp (os_dev, "/dev/mapper/sil_", 16))
return 1;
return 0;
}
int
grub_util_get_dev_abstraction (const char *os_dev UNUSED)
{
#ifdef __linux__
/* Check for LVM. */
if (!strncmp (os_dev, "/dev/mapper/", 12))
if (!strncmp (os_dev, "/dev/mapper/", 12)
&& ! grub_util_is_dmraid (os_dev)
&& strncmp (os_dev, "/dev/mapper/mpath", 17) != 0)
return GRUB_DEV_ABSTRACTION_LVM;
/* Check for RAID. */
@ -454,7 +546,7 @@ grub_util_get_grub_dev (const char *os_dev)
if (q)
*q = ',';
asprintf (&grub_dev, "md%s", p);
grub_dev = xasprintf ("md%s", p);
free (p);
}
else if (os_dev[7] == '/' && os_dev[8] == 'd')
@ -469,7 +561,7 @@ grub_util_get_grub_dev (const char *os_dev)
if (q)
*q = ',';
asprintf (&grub_dev, "md%s", p);
grub_dev = xasprintf ("md%s", p);
free (p);
}
else if (os_dev[7] >= '0' && os_dev[7] <= '9')
@ -482,7 +574,7 @@ grub_util_get_grub_dev (const char *os_dev)
if (q)
*q = ',';
asprintf (&grub_dev, "md%s", p);
grub_dev = xasprintf ("md%s", p);
free (p);
}
else if (os_dev[7] == '/' && os_dev[8] >= '0' && os_dev[8] <= '9')
@ -495,7 +587,7 @@ grub_util_get_grub_dev (const char *os_dev)
if (q)
*q = ',';
asprintf (&grub_dev, "md%s", p);
grub_dev = xasprintf ("md%s", p);
free (p);
}
else

View file

@ -22,6 +22,7 @@
#include <grub/util/misc.h>
#include <grub/lib/envblk.h>
#include <grub/handler.h>
#include <grub/i18n.h>
#include <stdio.h>
#include <unistd.h>
@ -29,6 +30,8 @@
#include <stdlib.h>
#include <getopt.h>
#include "progname.h"
#define DEFAULT_ENVBLK_SIZE 1024
void
@ -104,7 +107,7 @@ create_envblk_file (const char *name)
if (! buf)
grub_util_error ("out of memory");
asprintf (&namenew, "%s.new", name);
namenew = xasprintf ("%s.new", name);
fp = fopen (namenew, "wb");
if (! fp)
grub_util_error ("cannot open the file %s", namenew);
@ -252,7 +255,10 @@ main (int argc, char *argv[])
char *filename;
char *command;
progname = "grub-editenv";
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
/* Check for options. */
while (1)
@ -269,7 +275,7 @@ main (int argc, char *argv[])
break;
case 'V':
printf ("%s (%s) %s\n", progname, PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
* Copyright (C) 2003,2004,2005,2006,2007,2008,2009 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
@ -36,19 +36,22 @@
#include <grub/util/getroot.h>
#include <grub/env.h>
#include <grub/partition.h>
#include <grub/i18n.h>
#include <grub_emu_init.h>
#include "progname.h"
/* Used for going back to the main function. */
static jmp_buf main_env;
/* Store the prefix specified by an argument. */
static char *prefix = 0;
static char *prefix = NULL;
grub_addr_t
grub_arch_modules_addr (void)
{
return 0;
return NULL;
}
grub_err_t
@ -155,7 +158,10 @@ main (int argc, char *argv[])
volatile int hold = 0;
int opt;
progname = "grub-emu";
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
while ((opt = getopt_long (argc, argv, "r:d:m:vH:hV", options, 0)) != -1)
switch (opt)
@ -178,7 +184,7 @@ main (int argc, char *argv[])
case 'h':
return usage (0);
case 'V':
printf ("%s (%s) %s\n", progname, PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
default:
return usage (1);
@ -193,7 +199,7 @@ main (int argc, char *argv[])
/* Wait until the ARGS.HOLD variable is cleared by an attached debugger. */
if (hold && verbosity > 0)
printf ("Run \"gdb %s %d\", and set ARGS.HOLD to zero.\n",
progname, (int) getpid ());
program_name, (int) getpid ());
while (hold)
{
if (hold > 0)

View file

@ -1,7 +1,7 @@
/* grub-fstest.c - debug tool for filesystem driver */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
* Copyright (C) 2008,2009 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
@ -31,6 +31,7 @@
#include <grub/lib/hexdump.h>
#include <grub/lib/crc.h>
#include <grub/command.h>
#include <grub/i18n.h>
#include <grub_fstest_init.h>
@ -40,6 +41,8 @@
#include <stdlib.h>
#include <getopt.h>
#include "progname.h"
void
grub_putchar (int c)
{
@ -346,10 +349,10 @@ static void
usage (int status)
{
if (status)
fprintf (stderr, "Try ``grub-fstest --help'' for more information.\n");
fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name);
else
printf ("\
Usage: grub-fstest [OPTION]... IMAGE_PATH COMMANDS\n\
Usage: %s [OPTION]... IMAGE_PATH COMMANDS\n\
\n\
Debug tool for filesystem driver.\n\
\nCommands:\n\
@ -369,7 +372,7 @@ Debug tool for filesystem driver.\n\
-V, --version print version information and exit\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT);
exit (status);
}
@ -377,10 +380,13 @@ Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
int
main (int argc, char *argv[])
{
char *debug_str = 0, *root = 0, *default_root, *alloc_root;
char *debug_str = NULL, *root = NULL, *default_root, *alloc_root;
int i, cmd, num_opts, image_index, num_disks = 1;
progname = "grub-fstest";
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
/* Find the first non option entry. */
for (num_opts = 1; num_opts < argc; num_opts++)
@ -442,7 +448,7 @@ main (int argc, char *argv[])
break;
case 'V':
printf ("%s (%s) %s\n", progname, PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':

View file

@ -248,6 +248,14 @@ if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
done
fi
# Copy gettext files
mkdir -p ${grubdir}/locale/
for file in ${grubdir}/locale/*.mo ${pkglibdir}/locale/*.mo; do
if test -f "$file"; then
cp -f "$file" ${grubdir}/locale/
fi
done
# Write device to a variable so we don't have to traverse /dev every time.
grub_device=`$grub_probe --target=device ${grubdir}`

View file

@ -20,10 +20,12 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
datarootdir=@datarootdir@
datadir=@datadir@
bindir=@bindir@
sbindir=@sbindir@
pkgdatadir=${datadir}/`echo @PACKAGE_TARNAME@ | sed "${transform}"`
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
grub_mkrelpath=${bindir}/`echo grub-mkrelpath | sed ${transform}`
grub_warn ()
{
@ -32,49 +34,7 @@ grub_warn ()
make_system_path_relative_to_its_root ()
{
path=$1
# abort if file doesn't exist
if test -e $path ; then : ;else
return 1
fi
# canonicalize
if path=`readlink -f $path` ; then : ; else
return 1
fi
# if not a directory, climb up to the directory containing it
if test -d $path ; then
dir=$path
else
dir=`echo $path | sed -e "s,/[^/]*$,,g"`
fi
num=`stat -c %d $dir`
# this loop sets $dir to the root directory of the filesystem we're inspecting
while : ; do
parent=`readlink -f $dir/..`
if [ "x`stat -c %d $parent`" = "x$num" ] ; then : ; else
# $parent is another filesystem; we found it.
break
fi
if [ "x$dir" = "x/" ] ; then
# / is our root.
break
fi
dir=$parent
done
# This function never prints trailing slashes (so that its output can be
# appended a slash unconditionally). Each slash in $dir is considered a
# preceding slash, and therefore the root directory is an empty string.
if [ "$dir" = "/" ] ; then
dir=""
fi
# XXX: This fails if $dir contains ','.
path=`echo "$path" | sed -e "s,^$dir,,g"` || return 1
path="`${grub_mkrelpath} $1`"
case "`uname 2>/dev/null`" in
CYGWIN*)

View file

@ -1,7 +1,7 @@
/* grub-mkdevicemap.c - make a device map file automatically */
/*
* 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,2009 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
@ -31,10 +31,13 @@
#include <grub/util/misc.h>
#include <grub/util/deviceiter.h>
#include <grub/i18n.h>
#define _GNU_SOURCE 1
#include <getopt.h>
#include "progname.h"
static void
make_device_map (const char *device_map, int floppy_disks)
{
@ -81,10 +84,10 @@ usage (int status)
{
if (status)
fprintf (stderr,
"Try ``grub-mkdevicemap --help'' for more information.\n");
"Try ``%s --help'' for more information.\n", program_name);
else
printf ("\
Usage: grub-mkdevicemap [OPTION]...\n\
Usage: %s [OPTION]...\n\
\n\
Generate a device map file automatically.\n\
\n\
@ -96,7 +99,7 @@ Generate a device map file automatically.\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n\
",
", program_name,
DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
exit (status);
@ -108,7 +111,10 @@ main (int argc, char *argv[])
char *dev_map = 0;
int floppy_disks = 1;
progname = "grub-mkdevicemap";
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
/* Check for options. */
while (1)
@ -140,7 +146,7 @@ main (int argc, char *argv[])
break;
case 'V':
printf ("%s (%s) %s\n", progname, PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':

View file

@ -19,6 +19,7 @@
#include <config.h>
#include <grub/types.h>
#include <grub/util/misc.h>
#include <grub/i18n.h>
#include <stdio.h>
#include <stdlib.h>
@ -29,6 +30,8 @@
#include FT_FREETYPE_H
#include <freetype/ftsynth.h>
#include "progname.h"
#define GRUB_FONT_DEFAULT_SIZE 16
#define GRUB_FONT_RANGE_BLOCK 1024
@ -90,10 +93,10 @@ static void
usage (int status)
{
if (status)
fprintf (stderr, "Try ``grub-mkfont --help'' for more information.\n");
fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name);
else
printf ("\
Usage: grub-mkfont [OPTIONS] FONT_FILES\n\
Usage: %s [OPTIONS] FONT_FILES\n\
\nOptions:\n\
-o, --output=FILE_NAME set output file name\n\
-i, --index=N set face index\n\
@ -109,7 +112,7 @@ Usage: grub-mkfont [OPTIONS] FONT_FILES\n\
-V, --version print version information and exit\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT);
exit (status);
}
@ -363,8 +366,8 @@ write_font (struct grub_font_info *font_info, char *output_file)
if (! style_name[0])
strcpy (style_name, " Regular");
asprintf (&font_name, "%s %s %d", font_info->name, &style_name[1],
font_info->size);
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);
@ -472,7 +475,10 @@ main (int argc, char *argv[])
memset (&font_info, 0, sizeof (font_info));
progname = "grub-mkfont";
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
/* Check for options. */
while (1)
@ -560,7 +566,7 @@ main (int argc, char *argv[])
break;
case 'V':
printf ("%s (%s) %s\n", progname, PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':

105
util/grub-mkrelpath.c Normal file
View file

@ -0,0 +1,105 @@
/* grub-mkrelpath.c - make a system path relative to its root */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 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 <grub/util/misc.h>
#include <grub/i18n.h>
#include <getopt.h>
#include "progname.h"
static struct option options[] =
{
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
};
static void
usage (int status)
{
if (status)
fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name);
else
printf ("\
Usage: %s [OPTIONS] PATH\n\
\n\
Make a system path relative to it's root.\n\
\n\
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);
exit (status);
}
int
main (int argc, char *argv[])
{
char *argument, *relpath;
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
/* Check for options. */
while (1)
{
int c = getopt_long (argc, argv, "hV", 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)
{
fprintf (stderr, "No path is specified.\n");
usage (1);
}
if (optind + 1 != argc)
{
fprintf (stderr, "Unknown extra argument `%s'.\n", argv[optind + 1]);
usage (1);
}
argument = argv[optind];
relpath = make_system_path_relative_to_its_root (argument);
printf ("%s\n", relpath);
free (relpath);
return 0;
}

View file

@ -27,10 +27,10 @@ PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
target_cpu=@target_cpu@
native_platform=@platform@
coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-coreboot
pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-pc
grub_mkisofs="grub-mkisofs"
# Usage: usage
# Print the usage.
@ -42,7 +42,7 @@ Make GRUB rescue image.
-h, --help print this message and exit
-v, --version print the version information and exit
--modules=MODULES pre-load specified modules MODULES
--output=FILE save output in FILE
--output=FILE save output in FILE [required]
$0 generates a bootable rescue image with specified source files or directories.
@ -63,6 +63,12 @@ for option in "$@"; do
modules=`echo "$option" | sed 's/--modules=//'` ;;
--output=*)
output_image=`echo "$option" | sed 's/--output=//'` ;;
# Intentionally undocumented
--override-directory=*)
override_dir=`echo "${option}/" | sed 's/--override-directory=//'`
PATH=${override_dir}:$PATH
export PATH
;;
-*)
echo "Unrecognized option \`$option'" 1>&2
usage
@ -73,25 +79,56 @@ for option in "$@"; do
esac
done
if [ "x${output_image}" = x ] ; then
echo "output file must be given" >&2
usage
exit 1
fi
iso9660_dir=`mktemp -d`
mkdir -p ${iso9660_dir}/boot/grub
for platform in pc coreboot ; do
input_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-${platform}
if test -e ${input_dir} ; then
mkdir -p ${iso9660_dir}/boot/grub/${target_cpu}-${platform}
for file in ${input_dir}/*.mod ${input_dir}/efiemu??.o \
${input_dir}/command.lst ${input_dir}/moddep.lst ${input_dir}/fs.lst \
${input_dir}/handler.lst ${input_dir}/parttool.lst; do
if test -f "$file"; then
cp -f "$file" ${iso9660_dir}/boot/grub/${target_cpu}-${platform}/
fi
done
process_input_dir ()
{
input_dir="$1"
platform="$2"
mkdir -p ${iso9660_dir}/boot/grub/${target_cpu}-${platform}
for file in ${input_dir}/*.mod ${input_dir}/efiemu??.o \
${input_dir}/command.lst ${input_dir}/moddep.lst ${input_dir}/fs.lst \
${input_dir}/handler.lst ${input_dir}/parttool.lst; do
if test -f "$file"; then
cp -f "$file" ${iso9660_dir}/boot/grub/${target_cpu}-${platform}/
fi
done
mkdir -p ${iso9660_dir}/boot/grub/locale
for file in ${input_dir}/po/*.mo; do
if test -f "$file"; then
cp -f "$file" ${iso9660_dir}/boot/grub/locale/
fi
done
}
if [ "${override_dir}" = "" ] ; then
if test -e "${coreboot_dir}" ; then
process_input_dir ${coreboot_dir} coreboot
fi
done
if test -e "${pc_dir}" ; then
process_input_dir ${pc_dir} pc
fi
else
process_input_dir ${override_dir} ${native_platform}
coreboot_dir=
pc_dir=
case "${native_platform}" in
coreboot) coreboot_dir=${override_dir} ;;
pc) pc_dir=${override_dir} ;;
esac
fi
# build coreboot core.img
if test -e ${coreboot_dir} ; then
if test -e "${coreboot_dir}" ; then
echo "Generates coreboot"
memdisk_img=`mktemp`
memdisk_dir=`mktemp -d`
mkdir -p ${memdisk_dir}/boot/grub
@ -115,18 +152,12 @@ EOF
memdisk tar search iso9660 configfile sh \
ata at_keyboard
rm -f ${memdisk_img}
grub_mkisofs="${grub_mkisofs} --modification-date=$(echo ${iso_uuid} | sed -e s/-//g)"
fi
if [ "${source}" != "" ] ; then
for d in ${source}; do
echo "Processing $d"
cp -dpRl "${d}" ${iso9660_dir}/
done
grub_mkisofs_arguments="${grub_mkisofs_arguments} --modification-date=$(echo ${iso_uuid} | sed -e s/-//g)"
fi
# build eltorito core.img
if test -e ${pc_dir} ; then
if test -e "${pc_dir}" ; then
echo "Generates eltorito"
core_img=`mktemp`
grub-mkimage -d ${pc_dir}/ -o ${core_img} --prefix=/boot/grub/i386-pc \
memdisk tar search iso9660 configfile sh \
@ -141,11 +172,11 @@ if test -e ${pc_dir} ; then
echo "source /boot/grub/grub.cfg") \
> ${iso9660_dir}/boot/grub/i386-pc/grub.cfg
grub_mkisofs="${grub_mkisofs} -b boot/grub/i386-pc/eltorito.img -boot-info-table"
grub_mkisofs_arguments="${grub_mkisofs_arguments} -b boot/grub/i386-pc/eltorito.img -boot-info-table"
fi
# build iso image
${grub_mkisofs} -o ${output_image} -r -J ${iso9660_dir}
grub-mkisofs ${grub_mkisofs_arguments} -o ${output_image} -r ${iso9660_dir} ${source}
rm -rf ${iso9660_dir}
exit 0

View file

@ -1,7 +1,7 @@
/* grub-pe2elf.c - tool to convert pe image to elf. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
* Copyright (C) 2008,2009 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
@ -40,10 +40,10 @@ static void
usage (int status)
{
if (status)
fprintf (stderr, "Try ``grub-pe2elf --help'' for more information.\n");
fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name);
else
printf ("\
Usage: grub-pe2elf [OPTIONS] input [output]\n\
Usage: %s [OPTIONS] input [output]\n\
\n\
Tool to convert pe image to elf.\n\
\nOptions:\n\
@ -51,7 +51,7 @@ Tool to convert pe image to elf.\n\
-V, --version print version information and exit\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT);
exit (status);
}
@ -467,7 +467,7 @@ main (int argc, char *argv[])
char *image;
FILE* fp;
progname = "grub-pe2elf";
set_program_name (argv[0]);
/* Check for options. */
while (1)
@ -484,7 +484,7 @@ main (int argc, char *argv[])
break;
case 'V':
printf ("%s (%s) %s\n", progname, PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':

View file

@ -31,6 +31,7 @@
#include <grub/term.h>
#include <grub/env.h>
#include <grub/raid.h>
#include <grub/i18n.h>
#include <grub_probe_init.h>
@ -43,6 +44,8 @@
#define _GNU_SOURCE 1
#include <getopt.h>
#include "progname.h"
enum {
PRINT_FS,
PRINT_FS_UUID,
@ -235,33 +238,37 @@ probe (const char *path, char *device_name)
if (print == PRINT_FS)
{
/* FIXME: `path' can't be used to read a file via GRUB facilities,
because it's not relative to its root. */
#if 0
struct stat st;
if (path)
{
struct stat st;
stat (path, &st);
stat (path, &st);
if (S_ISREG (st.st_mode))
{
/* Regular file. Verify that we can read it properly. */
if (S_ISREG (st.st_mode))
{
/* Regular file. Verify that we can read it properly. */
grub_file_t file;
grub_util_info ("reading %s via OS facilities", path);
filebuf_via_sys = grub_util_read_image (path);
grub_file_t file;
char *rel_path;
grub_util_info ("reading %s via OS facilities", path);
filebuf_via_sys = grub_util_read_image (path);
grub_util_info ("reading %s via GRUB facilities", path);
asprintf (&grub_path, "(%s)%s", drive_name, path);
file = grub_file_open (grub_path);
filebuf_via_grub = xmalloc (file->size);
grub_file_read (file, filebuf_via_grub, file->size);
rel_path = make_system_path_relative_to_its_root (path);
grub_path = xasprintf ("(%s)%s", drive_name, rel_path);
free (rel_path);
grub_util_info ("reading %s via GRUB facilities", grub_path);
file = grub_file_open (grub_path);
if (! file)
grub_util_error ("can not open %s via GRUB facilities", grub_path);
filebuf_via_grub = xmalloc (file->size);
grub_file_read (file, filebuf_via_grub, file->size);
grub_util_info ("comparing");
grub_util_info ("comparing");
if (memcmp (filebuf_via_grub, filebuf_via_sys, file->size))
grub_util_error ("files differ");
if (memcmp (filebuf_via_grub, filebuf_via_sys, file->size))
grub_util_error ("files differ");
}
}
#endif
printf ("%s\n", fs->name);
}
@ -302,10 +309,10 @@ usage (int status)
{
if (status)
fprintf (stderr,
"Try ``grub-probe --help'' for more information.\n");
"Try ``%s --help'' for more information.\n", program_name);
else
printf ("\
Usage: grub-probe [OPTION]... [PATH|DEVICE]\n\
Usage: %s [OPTION]... [PATH|DEVICE]\n\
\n\
Probe device information for a given path (or device, if the -d option is given).\n\
\n\
@ -318,7 +325,7 @@ Probe device information for a given path (or device, if the -d option is given)
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n\
",
", program_name,
DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
exit (status);
@ -330,7 +337,10 @@ main (int argc, char *argv[])
char *dev_map = 0;
char *argument;
progname = "grub-probe";
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
/* Check for options. */
while (1)
@ -375,7 +385,7 @@ main (int argc, char *argv[])
break;
case 'V':
printf ("%s (%s) %s\n", progname, PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':

View file

@ -22,6 +22,8 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
grub_prefix=`echo /boot/grub | sed ${transform}`
locale_dir=`echo /boot/grub/locale | sed ${transform}`
grub_lang=`echo $LANG | cut -d _ -f 1`
. ${libdir}/grub/grub-mkconfig_lib
@ -108,6 +110,15 @@ EOF
;;
esac
# Gettext variables and module
if [ "x${LANG}" != "xC" ] ; then
cat << EOF
set locale_dir=${locale_dir}
set lang=${grub_lang}
insmod gettext
EOF
fi
if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then
if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
verbose=

View file

@ -24,7 +24,7 @@ libdir=@libdir@
. ${bindir}/gettext.sh
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@LOCALEDIR@
export TEXTDOMAINDIR=@localedir@
case "${GRUB_DISTRIBUTOR}" in
Debian) OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD" ;;
@ -38,7 +38,7 @@ kfreebsd_entry ()
recovery="$3" # not used yet
args="$4" # not used yet
title="$(gettext "%s, with kFreeBSD %s")"
printf "menuentry \"${title}\" {" ${os} ${version}
printf "menuentry \"${title}\" {\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/")"

View file

@ -24,7 +24,7 @@ libdir=@libdir@
. ${bindir}/gettext.sh
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@LOCALEDIR@
export TEXTDOMAINDIR=@localedir@
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
@ -58,7 +58,7 @@ linux_entry ()
else
title="$(gettext "%s, with Linux %s")"
fi
printf "menuentry \"${title}\" {" ${os} ${version}
printf "menuentry \"${title}\" {\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/")"

View file

@ -89,11 +89,16 @@ EOF
LLABEL="${LONGNAME}"
fi
if [ "${LROOT}" != "${LBOOT}" ]; then
LKERNEL="${LKERNEL#/boot}"
LINITRD="${LINITRD#/boot}"
fi
cat << EOF
menuentry "${LLABEL} (on ${DEVICE})" {
EOF
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/")"
prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | sed -e "s/^/\t/")"
fi
printf '%s\n' "${prepare_boot_cache}"
cat << EOF

View file

@ -25,6 +25,7 @@
#include <grub/util/misc.h>
#include <grub/util/hostdisk.h>
#include <grub/misc.h>
#include <grub/i18n.h>
#include <stdio.h>
#include <stdlib.h>
@ -127,7 +128,7 @@ find_grub_drive (const char *name)
if (name)
{
for (i = 0; i < sizeof (map) / sizeof (map[0]); i++)
for (i = 0; i < ARRAY_SIZE (map); i++)
if (map[i].drive && ! strcmp (map[i].drive, name))
return i;
}
@ -565,7 +566,10 @@ read_device_map (const char *dev_map)
fp = fopen (dev_map, "r");
if (! fp)
grub_util_error ("Cannot open `%s'", dev_map);
{
grub_util_info (_("Cannot open `%s'"), dev_map);
return;
}
while (fgets (buf, sizeof (buf), fp))
{
@ -670,34 +674,27 @@ grub_util_biosdisk_fini (void)
static char *
make_device_name (int drive, int dos_part, int bsd_part)
{
int len = strlen(map[drive].drive);
char *p;
char *ret;
char *dos_part_str = NULL;
char *bsd_part_str = NULL;
if (dos_part >= 0)
{
/* Add in char length of dos_part+1 */
int tmp = dos_part + 1;
len++;
while ((tmp /= 10) != 0)
len++;
}
if (bsd_part >= 0)
len += 2;
/* Length to alloc is: char length of map[drive].drive, plus
* char length of (dos_part+1) or of bsd_part, plus
* 2 for the comma and a null/end of string (\0)
*/
p = xmalloc (len + 2);
sprintf (p, "%s", map[drive].drive);
if (dos_part >= 0)
sprintf (p + strlen (p), ",%d", dos_part + 1);
dos_part_str = xasprintf (",%d", dos_part + 1);
if (bsd_part >= 0)
sprintf (p + strlen (p), ",%c", bsd_part + 'a');
bsd_part_str = xasprintf (",%c", dos_part + 'a');
return p;
ret = xasprintf ("%s%s%s", map[drive].drive,
dos_part_str ? : "",
bsd_part_str ? : "");
if (dos_part_str)
free (dos_part_str);
if (bsd_part_str)
free (bsd_part_str);
return ret;
}
static char *
@ -706,7 +703,7 @@ convert_system_partition_to_system_disk (const char *os_dev)
#if defined(__linux__)
char *path = xmalloc (PATH_MAX);
if (! realpath (os_dev, path))
return 0;
return NULL;
if (strncmp ("/dev/", path, 5) == 0)
{
@ -876,22 +873,29 @@ device_is_wholedisk (const char *os_dev)
static int
find_system_device (const char *os_dev)
{
int i;
unsigned int i;
char *os_disk;
os_disk = convert_system_partition_to_system_disk (os_dev);
if (! os_disk)
return -1;
for (i = 0; i < (int) (sizeof (map) / sizeof (map[0])); i++)
if (map[i].device && strcmp (map[i].device, os_disk) == 0)
for (i = 0; i < ARRAY_SIZE (map); i++)
if (! map[i].device)
break;
else if (strcmp (map[i].device, os_disk) == 0)
{
free (os_disk);
return i;
}
free (os_disk);
return -1;
if (i == ARRAY_SIZE (map))
grub_util_error (_("device count exceeds limit"));
map[i].device = os_disk;
map[i].drive = xstrdup (os_disk);
return i;
}
char *

View file

@ -30,6 +30,7 @@
#include <grub/kernel.h>
#include <grub/efi/pe32.h>
#include <grub/machine/kernel.h>
#include "progname.h"
#if GRUB_TARGET_WORDSIZE == 32
# define grub_le_to_cpu(val) grub_le_to_cpu32(val)
@ -54,12 +55,12 @@ align_pe32_section (Elf_Addr addr)
/* Read the whole kernel image. Return the pointer to a read image,
and store the size in bytes in *SIZE. */
static char *
read_kernel_module (const char *dir, size_t *size)
read_kernel_image (const char *dir, size_t *size)
{
char *kernel_image;
char *kernel_path;
kernel_path = grub_util_get_path (dir, "kernel.mod");
kernel_path = grub_util_get_path (dir, "kernel.img");
*size = grub_util_get_image_size (kernel_path);
kernel_image = grub_util_read_image (kernel_path);
free (kernel_path);
@ -944,7 +945,7 @@ convert_elf (const char *dir, char *prefix, FILE *out, char *mods[])
int i;
/* Get the kernel image and check the format. */
kernel_image = read_kernel_module (dir, &kernel_size);
kernel_image = read_kernel_image (dir, &kernel_size);
e = (Elf_Ehdr *) kernel_image;
if (! check_elf_header (e, kernel_size))
grub_util_error ("invalid ELF header");
@ -1056,7 +1057,7 @@ main (int argc, char *argv[])
char *dir = NULL;
char *prefix = NULL;
progname = "grub-mkimage";
program_name = "grub-mkimage";
while (1)
{

View file

@ -114,14 +114,14 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
if (memdisk_path)
{
memdisk_size = ALIGN_UP(grub_util_get_image_size (memdisk_path), 512);
grub_util_info (_("the size of memory disk is 0x%x"), memdisk_size);
grub_util_info ("the size of memory disk is 0x%x", memdisk_size);
total_module_size += memdisk_size + sizeof (struct grub_module_header);
}
if (config_path)
{
config_size = grub_util_get_image_size (config_path) + 1;
grub_util_info (_("the size of config file is 0x%x"), config_size);
grub_util_info ("the size of config file is 0x%x", config_size);
total_module_size += config_size + sizeof (struct grub_module_header);
}
@ -129,7 +129,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
total_module_size += (grub_util_get_image_size (p->name)
+ sizeof (struct grub_module_header));
grub_util_info (_("the total module size is 0x%x"), total_module_size);
grub_util_info ("the total module size is 0x%x", total_module_size);
kernel_img = xmalloc (kernel_size + total_module_size);
grub_util_load_image (kernel_path, kernel_img);
@ -196,7 +196,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
compress_kernel (kernel_img, kernel_size + total_module_size,
&core_img, &core_size);
grub_util_info (_("the core size is 0x%x"), core_size);
grub_util_info ("the core size is 0x%x", core_size);
#if defined(GRUB_MACHINE_PCBIOS)
{

View file

@ -90,7 +90,7 @@ setup (const char *dir,
const char *boot_file, const char *core_file,
const char *root, const char *dest, int must_embed, int force, int fs_probe)
{
char *boot_path, *core_path, *core_path_dev;
char *boot_path, *core_path, *core_path_dev, *core_path_dev_full;
char *boot_img, *core_img;
size_t boot_size, core_size;
grub_uint16_t core_sectors;
@ -159,7 +159,7 @@ setup (const char *dir,
void NESTED_FUNC_ATTR save_first_sector (grub_disk_addr_t sector, unsigned offset,
unsigned length)
{
grub_util_info (_("the first sector is <%llu,%u,%u>"),
grub_util_info ("the first sector is <%llu,%u,%u>",
sector, offset, length);
if (offset != 0 || length != GRUB_DISK_SECTOR_SIZE)
@ -173,7 +173,7 @@ setup (const char *dir,
{
struct boot_blocklist *prev = block + 1;
grub_util_info (_("saving <%llu,%u,%u> with the segment 0x%x"),
grub_util_info ("saving <%llu,%u,%u> with the segment 0x%x",
sector, offset, length, (unsigned) current_segment);
if (offset != 0 || last_length != GRUB_DISK_SECTOR_SIZE)
@ -244,7 +244,7 @@ setup (const char *dir,
if (! dest_dev)
grub_util_error ("%s", grub_errmsg);
grub_util_info (_("setting the root device to `%s'"), root);
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);
@ -322,7 +322,7 @@ setup (const char *dir,
bsd_part = grub_le_to_cpu32 (*install_bsd_part);
}
grub_util_info (_("dos partition is %d, bsd partition is %d"),
grub_util_info ("dos partition is %d, bsd partition is %d",
dos_part, bsd_part);
if (! dest_dev->disk->has_partitions)
@ -378,7 +378,7 @@ setup (const char *dir,
}
grub_util_info (_("the core image will be embedded at sector 0x%llx"), embed_region.start);
grub_util_info ("the core image will be embedded at sector 0x%llx", embed_region.start);
*install_dos_part = grub_cpu_to_le32 (dos_part);
*install_bsd_part = grub_cpu_to_le32 (bsd_part);
@ -426,7 +426,9 @@ unable_to_embed:
/* Make sure that GRUB reads the identical image as the OS. */
tmp_img = xmalloc (core_size);
core_path_dev = grub_util_get_path (dir, core_file);
core_path_dev_full = grub_util_get_path (dir, core_file);
core_path_dev = make_system_path_relative_to_its_root (core_path_dev_full);
free (core_path_dev_full);
/* It is a Good Thing to sync two times. */
sync ();
@ -446,11 +448,11 @@ unable_to_embed:
if (file)
{
if (grub_file_size (file) != core_size)
grub_util_info (_("succeeded in opening the core image but the size is different (%d != %d)"),
grub_util_info ("succeeded in opening the core image but the size is different (%d != %d)",
(int) grub_file_size (file), (int) core_size);
else if (grub_file_read (file, tmp_img, core_size)
!= (grub_ssize_t) core_size)
grub_util_info (_("succeeded in opening the core image but cannot read %d bytes"),
grub_util_info ("succeeded in opening the core image but cannot read %d bytes",
(int) core_size);
else if (memcmp (core_img, tmp_img, core_size) != 0)
{
@ -473,7 +475,7 @@ unable_to_embed:
}
#endif
grub_util_info (_("succeeded in opening the core image but the data is different"));
grub_util_info ("succeeded in opening the core image but the data is different");
}
else
{
@ -484,10 +486,10 @@ unable_to_embed:
grub_file_close (file);
}
else
grub_util_info (_("couldn't open the core image"));
grub_util_info ("couldn't open the core image");
if (grub_errno)
grub_util_info (_("error message = %s"), grub_errmsg);
grub_util_info ("error message = %s", grub_errmsg);
grub_errno = GRUB_ERR_NONE;
sync ();
@ -541,7 +543,7 @@ unable_to_embed:
*install_bsd_part = grub_cpu_to_le32 (bsd_part);
/* Write the first two sectors of the core image onto the disk. */
grub_util_info (_("opening the core image `%s'"), core_path);
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);
@ -763,7 +765,7 @@ main (int argc, char *argv[])
root_dev = grub_util_get_grub_dev (grub_guess_root_device (dir ? : DEFAULT_DIRECTORY));
if (! root_dev)
{
grub_util_info (_("guessing the root device failed, because of `%s'"),
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''."));
}

View file

@ -18,16 +18,19 @@
#include <config.h>
#include <errno.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include <time.h>
#include <errno.h>
#include <grub/kernel.h>
#include <grub/misc.h>
@ -36,8 +39,8 @@
#include <grub/mm.h>
#include <grub/term.h>
#include <grub/time.h>
#include <grub/machine/time.h>
#include <grub/machine/machine.h>
#include "progname.h"
/* Include malloc.h, only if memalign is available. It is known that
memalign is declared in malloc.h in all systems, if present. */
@ -50,7 +53,6 @@
#include <winioctl.h>
#endif
char *progname = 0;
int verbosity = 0;
void
@ -58,7 +60,7 @@ grub_util_warn (const char *fmt, ...)
{
va_list ap;
fprintf (stderr, "%s: warn: ", progname);
fprintf (stderr, "%s: warn: ", program_name);
va_start (ap, fmt);
vfprintf (stderr, fmt, ap);
va_end (ap);
@ -73,7 +75,7 @@ grub_util_info (const char *fmt, ...)
{
va_list ap;
fprintf (stderr, "%s: info: ", progname);
fprintf (stderr, "%s: info: ", program_name);
va_start (ap, fmt);
vfprintf (stderr, fmt, ap);
va_end (ap);
@ -87,7 +89,7 @@ grub_util_error (const char *fmt, ...)
{
va_list ap;
fprintf (stderr, "%s: error: ", progname);
fprintf (stderr, "%s: error: ", program_name);
va_start (ap, fmt);
vfprintf (stderr, fmt, ap);
va_end (ap);
@ -369,6 +371,19 @@ grub_arch_sync_caches (void *address __attribute__ ((unused)),
{
}
#ifndef HAVE_VASPRINTF
int
vasprintf (char **buf, const char *fmt, va_list ap)
{
/* Should be large enough. */
*buf = xmalloc (512);
return vsprintf (*buf, fmt, ap);
}
#endif
#ifndef HAVE_ASPRINTF
int
@ -377,11 +392,8 @@ asprintf (char **buf, const char *fmt, ...)
int status;
va_list ap;
/* Should be large enough. */
*buf = xmalloc (512);
va_start (ap, fmt);
status = vsprintf (*buf, fmt, ap);
status = vasprintf (*buf, fmt, ap);
va_end (ap);
return status;
@ -389,6 +401,23 @@ asprintf (char **buf, const char *fmt, ...)
#endif
char *
xasprintf (const char *fmt, ...)
{
va_list ap;
char *result;
va_start (ap, fmt);
if (vasprintf (&result, fmt, ap) < 0)
{
if (errno == ENOMEM)
grub_util_error ("out of memory");
return NULL;
}
return result;
}
#ifdef __MINGW32__
void sync (void)
@ -449,3 +478,92 @@ fail:
}
#endif /* __MINGW32__ */
/* This function never prints trailing slashes (so that its output
can be appended a slash unconditionally). */
char *
make_system_path_relative_to_its_root (const char *path)
{
struct stat st;
char *p, *buf, *buf2, *buf3;
uintptr_t offset = 0;
dev_t num;
size_t len;
/* canonicalize. */
p = realpath (path, NULL);
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)");
}
len = strlen (p) + 1;
buf = strdup (p);
free (p);
if (stat (buf, &st) < 0)
grub_util_error ("can not stat %s: %s", buf, strerror (errno));
buf2 = strdup (buf);
num = st.st_dev;
/* This loop sets offset to the number of chars of the root
directory we're inspecting. */
while (1)
{
p = strrchr (buf, '/');
if (p == NULL)
/* This should never happen. */
grub_util_error ("FIXME: no / in buf. (make_system_path_relative_to_its_root)");
if (p != buf)
*p = 0;
else
*++p = 0;
if (stat (buf, &st) < 0)
grub_util_error ("can not stat %s: %s", buf, strerror (errno));
/* buf is another filesystem; we found it. */
if (st.st_dev != num)
{
/* offset == 0 means path given is the mount point. */
if (offset == 0)
{
free (buf);
free (buf2);
return strdup ("/");
}
else
break;
}
offset = p - buf;
/* offset == 1 means root directory. */
if (offset == 1)
{
free (buf);
len = strlen (buf2);
while (buf2[len - 1] == '/' && len > 1)
{
buf2[len - 1] = '\0';
len--;
}
return buf2;
}
}
free (buf);
buf3 = strdup (buf2 + offset);
free (buf2);
len = strlen (buf3);
while (buf3[len - 1] == '/' && len > 1)
{
buf3[len - 1] = '\0';
len--;
}
return buf3;
}

View file

@ -200,107 +200,107 @@ struct ld_option
static const struct ld_option ld_options[] =
{
{ {"all-files", no_argument, NULL, 'a'},
'a', NULL, "Process all files (don't skip backup files)", ONE_DASH },
'a', NULL, N_("Process all files (don't skip backup files)"), ONE_DASH },
{ {"abstract", required_argument, NULL, OPTION_ABSTRACT},
'\0', "FILE", "Set Abstract filename" , ONE_DASH },
'\0', N_("FILE"), N_("Set Abstract filename"), ONE_DASH },
{ {"appid", required_argument, NULL, 'A'},
'A', "ID", "Set Application ID" , ONE_DASH },
'A', N_("ID"), N_("Set Application ID"), ONE_DASH },
{ {"biblio", required_argument, NULL, OPTION_BIBLIO},
'\0', "FILE", "Set Bibliographic filename" , ONE_DASH },
'\0', N_("FILE"), N_("Set Bibliographic filename"), ONE_DASH },
{ {"copyright", required_argument, NULL, OPTION_COPYRIGHT},
'\0', "FILE", "Set Copyright filename" , ONE_DASH },
'\0', N_("FILE"), N_("Set Copyright filename"), ONE_DASH },
{ {"eltorito-boot", required_argument, NULL, 'b'},
'b', "FILE", "Set El Torito boot image name" , ONE_DASH },
'b', N_("FILE"), N_("Set El Torito boot image name"), ONE_DASH },
{ {"eltorito-catalog", required_argument, NULL, 'c'},
'c', "FILE", "Set El Torito boot catalog name" , ONE_DASH },
'c', N_("FILE"), N_("Set El Torito boot catalog name"), ONE_DASH },
{ {"boot-info-table", no_argument, NULL, OPTION_BOOT_INFO_TABLE },
'\0', NULL, "Patch Boot Info Table in El Torito boot image" , ONE_DASH },
'\0', NULL, N_("Patch Boot Info Table in El Torito boot image"), ONE_DASH },
{ {"no-emul-boot", no_argument, NULL, OPTION_NO_EMUL_BOOT },
'\0', NULL, "Dummy option for backward compatibility" , ONE_DASH },
'\0', NULL, N_("Dummy option for backward compatibility"), ONE_DASH },
{ {"eltorito-emul-floppy", no_argument, NULL, OPTION_ELTORITO_EMUL_FLOPPY },
'\0', NULL, "Enable floppy drive emulation for El Torito" , TWO_DASHES },
'\0', NULL, N_("Enable floppy drive emulation for El Torito"), TWO_DASHES },
{ {"cdwrite-params", required_argument, NULL, 'C'},
'C', "PARAMS", "Magic parameters from cdrecord" , ONE_DASH },
'C', N_("PARAMS"), N_("Magic parameters from cdrecord"), ONE_DASH },
{ {"omit-period", no_argument, NULL, 'd'},
'd', NULL, "Omit trailing periods from filenames", ONE_DASH },
'd', NULL, N_("Omit trailing periods from filenames"), ONE_DASH },
{ {"disable-deep-relocation", no_argument, NULL, 'D'},
'D', NULL, "Disable deep directory relocation", ONE_DASH },
'D', NULL, N_("Disable deep directory relocation"), ONE_DASH },
{ {"follow-links", no_argument, NULL, 'f'},
'f', NULL, "Follow symbolic links", ONE_DASH },
'f', NULL, N_("Follow symbolic links"), ONE_DASH },
{ {"help", no_argument, NULL, OPTION_HELP},
'\0', NULL, "Print option help", ONE_DASH },
'\0', NULL, N_("Print option help"), ONE_DASH },
{ {"help", no_argument, NULL, OPTION_HELP},
'\0', NULL, "Print option help", TWO_DASHES },
'\0', NULL, N_("Print option help"), TWO_DASHES },
{ {"version", no_argument, NULL, OPTION_VERSION},
'\0', NULL, "Print version information and exit", TWO_DASHES },
'\0', NULL, N_("Print version information and exit"), TWO_DASHES },
{ {"hide", required_argument, NULL, OPTION_I_HIDE},
'\0', "GLOBFILE", "Hide ISO9660/RR file" , ONE_DASH },
'\0', N_("GLOBFILE"), N_("Hide ISO9660/RR file"), ONE_DASH },
{ {"hide-joliet", required_argument, NULL, OPTION_J_HIDE},
'\0', "GLOBFILE", "Hide Joliet file" , ONE_DASH },
'\0', N_("GLOBFILE"), N_("Hide Joliet file"), ONE_DASH },
{ {NULL, required_argument, NULL, 'i'},
'i', "ADD_FILES", "No longer supported" , TWO_DASHES },
'i', N_("ADD_FILES"), N_("No longer supported"), TWO_DASHES },
{ {"joliet", no_argument, NULL, 'J'},
'J', NULL, "Generate Joliet directory information", ONE_DASH },
'J', NULL, N_("Generate Joliet directory information"), ONE_DASH },
{ {"full-iso9660-filenames", no_argument, NULL, 'l'},
'l', NULL, "Allow full 32 character filenames for iso9660 names", ONE_DASH },
'l', NULL, N_("Allow full 32 character filenames for iso9660 names"), ONE_DASH },
{ {"allow-leading-dots", no_argument, NULL, 'L'},
'L', NULL, "Allow iso9660 filenames to start with '.'", ONE_DASH },
'L', NULL, N_("Allow iso9660 filenames to start with '.'"), ONE_DASH },
{ {"log-file", required_argument, NULL, OPTION_LOG_FILE},
'\0', "LOG_FILE", "Re-direct messages to LOG_FILE", ONE_DASH },
'\0', N_("LOG_FILE"), N_("Re-direct messages to LOG_FILE"), ONE_DASH },
{ {"exclude", required_argument, NULL, 'm'},
'm', "GLOBFILE", "Exclude file name" , ONE_DASH },
'm', N_("GLOBFILE"), N_("Exclude file name"), ONE_DASH },
{ {"prev-session", required_argument, NULL, 'M'},
'M', "FILE", "Set path to previous session to merge" , ONE_DASH },
'M', N_("FILE"), N_("Set path to previous session to merge"), ONE_DASH },
{ {"omit-version-number", no_argument, NULL, 'N'},
'N', NULL, "Omit version number from iso9660 filename", ONE_DASH },
'N', NULL, N_("Omit version number from iso9660 filename"), ONE_DASH },
{ {"no-split-symlink-components", no_argument, NULL, 0},
0, NULL, "Inhibit splitting symlink components" , ONE_DASH },
0, NULL, N_("Inhibit splitting symlink components"), ONE_DASH },
{ {"no-split-symlink-fields", no_argument, NULL, 0},
0, NULL, "Inhibit splitting symlink fields" , ONE_DASH },
0, NULL, N_("Inhibit splitting symlink fields"), ONE_DASH },
{ {"output", required_argument, NULL, 'o'},
'o', "FILE", "Set output file name" , ONE_DASH },
'o', N_("FILE"), N_("Set output file name"), ONE_DASH },
{ {"preparer", required_argument, NULL, 'p'},
'p', "PREP", "Set Volume preparer" , ONE_DASH },
'p', N_("PREP"), N_("Set Volume preparer"), ONE_DASH },
{ {"print-size", no_argument, NULL, OPTION_PRINT_SIZE},
'\0', NULL, "Print estimated filesystem size and exit", ONE_DASH },
'\0', NULL, N_("Print estimated filesystem size and exit"), ONE_DASH },
{ {"publisher", required_argument, NULL, 'P'},
'P', "PUB", "Set Volume publisher" , ONE_DASH },
'P', N_("PUB"), N_("Set Volume publisher"), ONE_DASH },
{ {"quiet", no_argument, NULL, OPTION_QUIET},
'\0', NULL, "Run quietly", ONE_DASH },
'\0', NULL, N_("Run quietly"), ONE_DASH },
{ {"rational-rock", no_argument, NULL, 'r'},
'r', NULL, "Generate rationalized Rock Ridge directory information", ONE_DASH },
'r', NULL, N_("Generate rationalized Rock Ridge directory information"), ONE_DASH },
{ {"rock", no_argument, NULL, 'R'},
'R', NULL, "Generate Rock Ridge directory information", ONE_DASH },
'R', NULL, N_("Generate Rock Ridge directory information"), ONE_DASH },
{ {"split-output", no_argument, NULL, OPTION_SPLIT_OUTPUT},
'\0', NULL, "Split output into files of approx. 1GB size", ONE_DASH },
'\0', NULL, N_("Split output into files of approx. 1GB size"), ONE_DASH },
{ {"sysid", required_argument, NULL, OPTION_SYSID},
'\0', "ID", "Set System ID" , ONE_DASH },
'\0', N_("ID"), N_("Set System ID"), ONE_DASH },
{ {"translation-table", no_argument, NULL, 'T'},
'T', NULL, "Generate translation tables for systems that don't understand long filenames", ONE_DASH },
'T', NULL, N_("Generate translation tables for systems that don't understand long filenames"), ONE_DASH },
{ {"verbose", no_argument, NULL, 'v'},
'v', NULL, "Verbose", ONE_DASH },
'v', NULL, N_("Verbose"), ONE_DASH },
{ {"volid", required_argument, NULL, 'V'},
'V', "ID", "Set Volume ID" , ONE_DASH },
'V', N_("ID"), N_("Set Volume ID"), ONE_DASH },
{ {"volset", required_argument, NULL, OPTION_VOLSET},
'\0', "ID", "Set Volume set ID" , ONE_DASH },
'\0', N_("ID"), N_("Set Volume set ID"), ONE_DASH },
{ {"volset-size", required_argument, NULL, OPTION_VOLSET_SIZE},
'\0', "#", "Set Volume set size" , ONE_DASH },
'\0', "#", N_("Set Volume set size"), ONE_DASH },
{ {"volset-seqno", required_argument, NULL, OPTION_VOLSET_SEQ_NUM},
'\0', "#", "Set Volume set sequence number" , ONE_DASH },
'\0', "#", N_("Set Volume set sequence number"), ONE_DASH },
{ {"old-exclude", required_argument, NULL, 'x'},
'x', "FILE", "Exclude file name(depreciated)" , ONE_DASH },
'x', N_("FILE"), N_("Exclude file name (deprecated)"), ONE_DASH },
#ifdef ERIC_neverdef
{ {"transparent-compression", no_argument, NULL, 'z'},
'z', NULL, "Enable transparent compression of files", ONE_DASH },
#endif
{ {"creation-date", required_argument, NULL, OPTION_CREAT_DATE },
'\0', NULL, "Override creation date", TWO_DASHES },
'\0', NULL, N_("Override creation date"), TWO_DASHES },
{ {"modification-date", required_argument, NULL, OPTION_MODIF_DATE },
'\0', NULL, "Override modification date", TWO_DASHES },
'\0', NULL, N_("Override modification date"), TWO_DASHES },
{ {"expiration-date", required_argument, NULL, OPTION_EXPIR_DATE },
'\0', NULL, "Override expiration date", TWO_DASHES },
'\0', NULL, N_("Override expiration date"), TWO_DASHES },
{ {"effective-date", required_argument, NULL, OPTION_EFFEC_DATE },
'\0', NULL, "Override effective date", TWO_DASHES },
'\0', NULL, N_("Override effective date"), TWO_DASHES },
};
#define OPTION_COUNT (sizeof ld_options / sizeof ld_options[0])
@ -481,6 +481,7 @@ void usage(){
int comma;
int len;
unsigned int j;
char *arg;
printf (" ");
@ -502,8 +503,9 @@ void usage(){
putchar (' ');
++len;
}
printf ("%s", ld_options[j].arg);
len += strlen (ld_options[j].arg);
arg = gettext (ld_options[j].arg);
printf ("%s", arg);
len += strlen (arg);
}
comma = TRUE;
}
@ -527,8 +529,9 @@ void usage(){
+ strlen (ld_options[j].opt.name));
if (ld_options[j].arg != NULL)
{
printf (" %s", ld_options[j].arg);
len += 1 + strlen (ld_options[j].arg);
arg = gettext (ld_options[j].arg);
printf (" %s", arg);
len += 1 + strlen (arg);
}
comma = TRUE;
}
@ -545,7 +548,7 @@ void usage(){
for (; len < 30; len++)
putchar (' ');
printf ("%s\n", ld_options[i].doc);
printf ("%s\n", gettext (ld_options[i].doc));
}
}
exit(1);

View file

@ -33,6 +33,7 @@
#include <locale.h>
#include <libintl.h>
#define _(str) gettext(str)
#define N_(str) str
/* This symbol is used to indicate that we do not have things like
symlinks, devices, and so forth available. Just files and dirs */

View file

@ -21,6 +21,7 @@
#include <grub/machine/boot.h>
#include <grub/machine/kernel.h>
#include <grub/kernel.h>
#include <grub/i18n.h>
#include <grub/disk.h>
#include <grub/util/misc.h>
#include <grub/util/resolve.h>
@ -34,6 +35,8 @@
#define _GNU_SOURCE 1
#include <getopt.h>
#include "progname.h"
static void
compress_kernel (char *kernel_img, size_t kernel_size,
char **core_img, size_t *core_size)
@ -188,10 +191,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 [OPTION]... [MODULES]\n\
Usage: %s [OPTION]... [MODULES]\n\
\n\
Make a bootable image of GRUB.\n\
\n\
@ -204,7 +207,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);
}
@ -218,7 +221,11 @@ main (int argc, char *argv[])
char *memdisk = NULL;
FILE *fp = stdout;
progname = "grub-mkimage";
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
while (1)
{
int c = getopt_long (argc, argv, "d:p:m:o:hVv", options, 0);

View file

@ -20,15 +20,22 @@
#include <grub/util/misc.h>
#include <grub/util/ofpath.h>
#include <grub/i18n.h>
#include "progname.h"
int main(int argc, char **argv)
{
char *of_path;
progname = "grub-ofpathname";
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
if (argc != 2)
{
printf("Usage: grub-ofpathname DEVICE\n");
printf("Usage: %s DEVICE\n", program_name);
return 1;
}

View file

@ -21,6 +21,7 @@
#include <grub/types.h>
#include <grub/util/misc.h>
#include <grub/device.h>
#include <grub/i18n.h>
#include <grub/disk.h>
#include <grub/file.h>
#include <grub/fs.h>
@ -49,6 +50,8 @@
#define _GNU_SOURCE 1
#include <getopt.h>
#include "progname.h"
/* This program fills in various fields inside of the 'boot' and 'core'
* image files.
*
@ -401,10 +404,10 @@ static void
usage (int status)
{
if (status)
fprintf (stderr, "Try ``grub-setup --help'' for more information.\n");
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\
@ -419,7 +422,7 @@ DEVICE must be a GRUB device (e.g. ``(hd0,1)'').\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n\
",
", program_name,
DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY,
DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
@ -616,7 +619,10 @@ main (int argc, char *argv[])
{
struct grub_setup_info ginfo;
progname = "grub-setup";
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
init_info (&ginfo);
if (!parse_options (&ginfo, argc, argv))