merge trunk

This commit is contained in:
BVK Chaitanya 2010-01-18 16:58:03 +05:30
commit d8d4217e3c
133 changed files with 5807 additions and 2525 deletions

View file

@ -19,14 +19,6 @@
#include <config.h>
#if defined(HAVE_NCURSES_CURSES_H)
# include <ncurses/curses.h>
#elif defined(HAVE_NCURSES_H)
# include <ncurses.h>
#elif defined(HAVE_CURSES_H)
# include <curses.h>
#endif
/* For compatibility. */
#ifndef A_NORMAL
# define A_NORMAL 0
@ -39,6 +31,14 @@
#include <grub/term.h>
#include <grub/types.h>
#if defined(HAVE_NCURSES_CURSES_H)
# include <ncurses/curses.h>
#elif defined(HAVE_NCURSES_H)
# include <ncurses.h>
#elif defined(HAVE_CURSES_H)
# include <curses.h>
#endif
static int grub_console_attr = A_NORMAL;
grub_uint8_t grub_console_cur_color = 7;
@ -367,8 +367,7 @@ static struct grub_term_output grub_ncurses_term_output =
.setcolor = grub_ncurses_setcolor,
.getcolor = grub_ncurses_getcolor,
.setcursor = grub_ncurses_setcursor,
.refresh = grub_ncurses_refresh,
.flags = 0,
.refresh = grub_ncurses_refresh
};
void
@ -376,8 +375,6 @@ grub_console_init (void)
{
grub_term_register_output ("console", &grub_ncurses_term_output);
grub_term_register_input ("console", &grub_ncurses_term_input);
grub_term_set_current_output (&grub_ncurses_term_output);
grub_term_set_current_input (&grub_ncurses_term_input);
}
void

View file

@ -328,7 +328,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\

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

@ -46,9 +46,6 @@ grub_refresh (void)
fflush (stdout);
}
struct grub_handler_class grub_term_input_class;
struct grub_handler_class grub_term_output_class;
int
grub_getkey (void)
{
@ -72,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\
@ -91,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);
@ -286,13 +286,13 @@ fstest (char **images, int num_disks, int cmd, int n, char **args)
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]);
grub_util_error ("pathname %s too long", images[i]);
grub_sprintf (loop_name, "loop%d", i);
grub_sprintf (host_file, "(host)%s", images[i]);
if (execute_command ("loopback", 3, argv))
grub_util_error ("loopback command fails.");
grub_util_error ("loopback command fails");
}
grub_lvm_fini ();
@ -349,7 +349,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

@ -40,6 +40,7 @@ else
fi
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir=
grub_prefix=`echo /boot/grub | sed ${transform}`
modules=
@ -87,9 +88,11 @@ fi
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
@ -261,6 +264,10 @@ done
# Write device to a variable so we don't have to traverse /dev every time.
grub_device=`$grub_probe --target=device ${grubdir}`
if ! test -f ${grubdir}/grubenv; then
$grub_editenv ${grubdir}/grubenv create
fi
# Create the core image. First, auto-detect the filesystem module.
fs_module=`$grub_probe --target=fs --device ${grub_device}`
if test "x$fs_module" = x -a "x$modules" = x; then

View file

@ -94,6 +94,15 @@ convert_system_path_to_grub_path ()
echo ${drive}${relative_path}
}
save_default_entry ()
{
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then
cat << EOF
savedefault
EOF
fi
}
prepare_grub_to_access_device ()
{
device=$1

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

@ -96,7 +96,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] FONT_FILES\n\
@ -347,7 +347,7 @@ 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;
@ -546,7 +546,7 @@ main (int argc, char *argv[])
a = strtoul (p, &p, 0);
if (*p != '-')
grub_util_error ("Invalid font range");
grub_util_error ("invalid font range");
b = strtoul (p + 1, &p, 0);
if ((font_info.num_range & (GRUB_FONT_RANGE_BLOCK - 1)) == 0)
font_info.ranges = xrealloc (font_info.ranges,
@ -561,7 +561,7 @@ main (int argc, char *argv[])
if (*p)
{
if (*p != ',')
grub_util_error ("Invalid font range");
grub_util_error ("invalid font range");
else
p++;
}
@ -598,7 +598,7 @@ main (int argc, char *argv[])
}
if (! output_file)
grub_util_error ("No output file is specified.");
grub_util_error ("no output file is specified");
if (FT_Init_FreeType (&ft_lib))
grub_util_error ("FT_Init_FreeType fails");
@ -610,7 +610,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;
}

View file

@ -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

@ -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;
}
@ -113,17 +113,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 +133,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 +309,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\

108
util/grub-reboot.in Normal file
View file

@ -0,0 +1,108 @@
#! /bin/sh
#
# Set a default boot entry for GRUB, for the next boot only.
# Copyright (C) 2004,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/>.
# Initialize some variables.
transform="@program_transform_name@"
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir=
# Usage: usage
# Print the usage.
usage () {
cat <<EOF
Usage: $0 [OPTION] entry
Set the default boot entry for GRUB, for the next boot only.
-h, --help print this message and exit
-v, --version print the version information and exit
--root-directory=DIR expect GRUB images under the directory DIR
instead of the root directory
ENTRY is a number or a menu item title.
Report bugs to <bug-grub@gnu.org>.
EOF
}
# Check the arguments.
for option in "$@"; do
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "grub-reboot (GNU GRUB ${PACKAGE_VERSION})"
exit 0 ;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
-*)
echo "Unrecognized option \`$option'" 1>&2
usage
exit 1
;;
*)
if test "x$entry" != x; then
echo "More than one entry?" 1>&2
usage
exit 1
fi
entry="${option}" ;;
esac
done
if test "x$entry" = x; then
echo "entry not specified." 1>&2
usage
exit 1
fi
# Initialize these directories here, since ROOTDIR was initialized.
case "$host_os" in
netbsd* | openbsd*)
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
# instead of /boot/grub.
grub_prefix=`echo /grub | sed ${transform}`
bootdir=${rootdir}
;;
*)
# Use /boot/grub by default.
bootdir=${rootdir}/boot
;;
esac
grubdir=${bootdir}/`echo grub | sed ${transform}`
prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'`
if [ "$prev_saved_entry" ]; then
$grub_editenv ${grubdir}/grubenv set prev_saved_entry="$prev_saved_entry"
else
# 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"
# Bye.
exit 0

View file

@ -21,6 +21,7 @@
#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>
@ -56,9 +57,6 @@ grub_refresh (void)
fflush (stdout);
}
struct grub_handler_class grub_term_input_class;
struct grub_handler_class grub_term_output_class;
char *
grub_script_execute_argument_to_string (struct grub_script_arg *arg __attribute__ ((unused)))
{
@ -173,9 +171,7 @@ main (int argc, char *argv[])
}
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
grub_util_init_nls ();
/* Check for options. */
while (1)
@ -208,7 +204,7 @@ main (int argc, char *argv[])
/* Obtain ARGUMENT. */
if (optind >= argc)
{
file = 0; // read from stdin
file = 0; /* read from stdin */
}
else if (optind + 1 != argc)
{

99
util/grub-set-default.in Normal file
View file

@ -0,0 +1,99 @@
#! /bin/sh
#
# Set a default boot entry for GRUB.
# Copyright (C) 2004,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/>.
# Initialize some variables.
transform="@program_transform_name@"
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir=
# Usage: usage
# Print the usage.
usage () {
cat <<EOF
Usage: $0 [OPTION] entry
Set the default boot entry for GRUB.
-h, --help print this message and exit
-v, --version print the version information and exit
--root-directory=DIR expect GRUB images under the directory DIR
instead of the root directory
ENTRY is a number or a menu item title.
Report bugs to <bug-grub@gnu.org>.
EOF
}
# Check the arguments.
for option in "$@"; do
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "grub-set-default (GNU GRUB ${PACKAGE_VERSION})"
exit 0 ;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
-*)
echo "Unrecognized option \`$option'" 1>&2
usage
exit 1
;;
*)
if test "x$entry" != x; then
echo "More than one entry?" 1>&2
usage
exit 1
fi
entry="${option}" ;;
esac
done
if test "x$entry" = x; then
echo "entry not specified." 1>&2
usage
exit 1
fi
# Initialize these directories here, since ROOTDIR was initialized.
case "$host_os" in
netbsd* | openbsd*)
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
# instead of /boot/grub.
grub_prefix=`echo /grub | sed ${transform}`
bootdir=${rootdir}
;;
*)
# Use /boot/grub by default.
bootdir=${rootdir}/boot
;;
esac
grubdir=${bootdir}/`echo grub | sed ${transform}`
$grub_editenv ${grubdir}/grubenv unset prev_saved_entry
$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"
# Bye.
exit 0

View file

@ -34,11 +34,29 @@ for i in ${GRUB_PRELOAD_MODULES} ; do
done
if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi
cat << EOF
set default=${GRUB_DEFAULT}
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

View file

@ -1,7 +1,7 @@
#! /bin/sh -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
# Copyright (C) 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
@ -73,16 +73,19 @@ menuentry "${OS}" {
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

View file

@ -1,7 +1,7 @@
#! /bin/sh -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
# Copyright (C) 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
@ -39,17 +39,19 @@ kfreebsd_entry ()
args="$4" # not used yet
title="$(gettext "%s, with kFreeBSD %s")"
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/")"
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

@ -1,7 +1,7 @@
#! /bin/sh -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
# Copyright (C) 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
@ -59,15 +59,18 @@ linux_entry ()
title="$(gettext "%s, with Linux %s")"
fi
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/")"
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

@ -73,6 +73,7 @@ for dir in $dirlist ; do
menuentry "$OS" {
EOF
save_default_entry | sed -e 's,^,\t,'
prepare_grub_to_access_device "$dev" | sed 's,^,\t,'
cat << EOF

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
@ -105,6 +106,7 @@ for OS in ${OSPROBED} ; do
cat << EOF
menuentry "${LONGNAME} (on ${DEVICE})" {
EOF
save_default_entry | sed -e "s/^/\t/"
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
case ${LONGNAME} in
@ -146,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
@ -172,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

@ -568,7 +568,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 +639,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

@ -35,6 +35,7 @@ pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${t
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir=
grub_prefix=`echo /boot/grub | sed ${transform}`
modules=
@ -179,6 +180,10 @@ for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do
cp -f $file ${grubdir} || exit 1
done
if ! test -f ${grubdir}/grubenv; then
$grub_editenv ${grubdir}/grubenv create
fi
# Create the core image. First, auto-detect the filesystem module.
fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}`
if test "x$fs_module" = xfat; then :; else

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

@ -289,7 +289,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
#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_util_error (_("core image is too big (%p > %p)"),
GRUB_KERNEL_MACHINE_LINK_ADDR + core_size, GRUB_MEMORY_MACHINE_UPPER);
#endif
@ -326,10 +326,10 @@ static void
usage (int status)
{
if (status)
fprintf (stderr, _("Try ``%s --help'' for more information.\n"), program_name);
fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name);
else
printf (_("\
Usage: grub-mkimage [OPTION]... [MODULES]\n\
Usage: %s [OPTION]... [MODULES]\n\
\n\
Make a bootable image of GRUB.\n\
\n\
@ -343,7 +343,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

@ -37,6 +37,7 @@ pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${t
grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}`
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir=
grub_prefix=`echo /boot/grub | sed ${transform}`
modules=
@ -163,6 +164,10 @@ for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst ; do
cp -f $file ${grubdir} || exit 1
done
if ! test -f ${grubdir}/grubenv; then
$grub_editenv ${grubdir}/grubenv create
fi
# Create the core image. First, auto-detect the filesystem module.
fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}`
if test "x$fs_module" = x -a "x$modules" = x; then

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

@ -60,11 +60,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 +76,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 +91,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 +482,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,15 +507,11 @@ 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);
free (p);

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

@ -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

@ -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);
}
}