merge trunk

This commit is contained in:
Colin Watson 2010-12-23 12:20:48 +00:00
commit 6d46121efb
21 changed files with 271 additions and 91 deletions

104
ChangeLog
View file

@ -1,3 +1,107 @@
2010-12-23 Jordan Uggla <jordan.uggla@gmail.com>
* tests/util/grub-shell.in: Suppress "ACPI shutdown failed" error to
keep unit tests from failing when they shouldn't.
2010-12-21 Colin Watson <cjwatson@ubuntu.com>
* include/grub/offsets.h (GRUB_KERNEL_I386_PC_RAW_SIZE): The
previous patch increased the size of the RS code by 20 bytes (at
least with gcc-4.4), so increase this by 20 bytes to match.
(GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART): Likewise.
2010-12-21 Colin Watson <cjwatson@ubuntu.com>
* grub-core/lib/reed_solomon.c (gauss_solve): Fix size of standalone
scratch area. Make sure to initialise chosen in standalone mode as
well as non-standalone.
Reported by: Robert Hooker and Andy Whitcroft.
Tested by: Andy Whitcroft.
2010-12-21 Colin Watson <cjwatson@ubuntu.com>
* grub-core/commands/echo.c (grub_cmd_echo): Make UTF-8-clean by
constructing a new unescaped string and passing it to grub_xputs in
one go, rather than passing characters to grub_printf one at a time.
2010-12-21 Colin Watson <cjwatson@ubuntu.com>
* grub-core/fs/udf.c (read_string): Pacify GCC warning by
initialising utf16.
2010-12-21 Colin Watson <cjwatson@ubuntu.com>
* util/grub-mkconfig_lib.in (gettext_quoted): Add clarifying
comment. Add an extra layer of quotation, requiring the output of
this function to be used in a printf format string.
(gettext_printf): New function.
* util/grub.d/10_hurd.in: Use gettext_printf where appropriate.
Extract translatable strings from here-documents and use a temporary
variable instead, so that xgettext can find them.
* util/grub.d/10_kfreebsd.in: Likewise.
* util/grub.d/10_linux.in: Likewise.
* util/grub.d/20_linux_xen.in: Likewise.
* po/grub.d.sed: New file.
* po/Makefile.in.in ($(DOMAIN).pot-update): Extract gettext_printf
arguments. Set c-format flags on all strings extracted from
util/grub.d/ (xgettext refuses to include these itself for strings
it extracted from a shell file, but these really are c-format).
2010-12-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_add_module):
Avoid next pointing to nowhere.
2010-12-19 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/affs.c (grub_affs_mount): Read data->bblock.rootblock
rather than assuming than rootblock is exactly in the middle.
(grub_affs_label): Likewise.
2010-12-19 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/affs.c (grub_affs_fs) [GRUB_UTIL]: Explicitly set
reserved_first_sector to 0.
* grub-core/fs/cpio.c (grub_cpio_fs) [GRUB_UTIL]: Likewise.
* grub-core/fs/sfs.c (grub_sfs_fs) [GRUB_UTIL]: Likewise.
* grub-core/fs/xfs.c (grub_xfs_fs) [GRUB_UTIL]: Likewise.
2010-12-19 Vladimir Serbinenko <phcoder@gmail.com>
Fix handling of UTF-16 UDF labels.
* grub-core/fs/udf.c (grub_udf_iterate_dir): Move string-parsing part
(read_string): .. here.
(grub_udf_label): Use read_string.
2010-12-19 BVK Chaitanya <bvk.groups@gmail.com>
* grub-core/normal/menu_entry.c (run): Execute commands from menu
editor under argument scope.
Reported by: Jordan Uggla
2010-12-18 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkfont.c (main): Handle errors from FT_Set_Pixel_Sizes.
2010-12-18 Colin Watson <cjwatson@ubuntu.com>
* grub-core/normal/term.c (print_more): Make \r or \n scroll one
line, and other keys scroll an entire page (previous handling was
for \r and \n to scroll a page and other keys to scroll two lines).
2010-12-18 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi):
Set ptrdest to correct get_physical_target_address rather than
incorrect get_virtual_current_address.
2010-12-18 kashyap garimella <garimella.kashyap@gmail.com>
* grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_load): Use
correct cat to grub_uint8_t * rather than grub_uint32_t *.
2010-12-10 Colin Watson <cjwatson@ubuntu.com>
* .bzrignore: Ignore grub-core/rs_decoder.S.

View file

@ -44,8 +44,14 @@ grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args)
for (i = 0; i < argc; i++)
{
char *arg = *args;
/* Unescaping results in a string no longer than the original. */
char *unescaped = grub_malloc (grub_strlen (arg) + 1);
char *p = unescaped;
args++;
if (!unescaped)
return grub_errno;
while (*arg)
{
/* In case `-e' is used, parse backslashes. */
@ -58,11 +64,11 @@ grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args)
switch (*arg)
{
case '\\':
grub_printf ("\\");
*p++ = '\\';
break;
case 'a':
grub_printf ("\a");
*p++ = '\a';
break;
case 'c':
@ -70,23 +76,23 @@ grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args)
break;
case 'f':
grub_printf ("\f");
*p++ = '\f';
break;
case 'n':
grub_printf ("\n");
*p++ = '\n';
break;
case 'r':
grub_printf ("\r");
*p++ = '\r';
break;
case 't':
grub_printf ("\t");
*p++ = '\t';
break;
case 'v':
grub_printf ("\v");
*p++ = '\v';
break;
}
arg++;
@ -95,10 +101,14 @@ grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args)
/* This was not an escaped character, or escaping is not
enabled. */
grub_printf ("%c", *arg);
*p++ = *arg;
arg++;
}
*p = '\0';
grub_xputs (unescaped);
grub_free (unescaped);
/* If another argument follows, insert a space. */
if (i != argc - 1)
grub_printf (" " );

View file

@ -208,7 +208,7 @@ grub_affs_mount (grub_disk_t disk)
rblock = (struct grub_affs_rblock *) rootblock;
/* Read the rootblock. */
grub_disk_read (disk, (disk->total_sectors >> 1) + blocksize, 0,
grub_disk_read (disk, grub_be_to_cpu32 (data->bblock.rootblock), 0,
GRUB_DISK_SECTOR_SIZE * 16, rootblock);
if (grub_errno)
goto fail;
@ -240,7 +240,7 @@ grub_affs_mount (grub_disk_t disk)
data->disk = disk;
data->htsize = grub_be_to_cpu32 (rblock->htsize);
data->diropen.data = data;
data->diropen.block = (disk->total_sectors >> 1);
data->diropen.block = grub_be_to_cpu32 (data->bblock.rootblock);
grub_free (rootblock);
@ -507,7 +507,7 @@ grub_affs_label (grub_device_t device, char **label)
{
/* The rootblock maps quite well on a file header block, it's
something we can use here. */
grub_disk_read (data->disk, disk->total_sectors >> 1,
grub_disk_read (data->disk, grub_be_to_cpu32 (data->bblock.rootblock),
data->blocksize * (GRUB_DISK_SECTOR_SIZE
- GRUB_AFFS_FILE_LOCATION),
sizeof (file), &file);
@ -535,6 +535,9 @@ static struct grub_fs grub_affs_fs =
.read = grub_affs_read,
.close = grub_affs_close,
.label = grub_affs_label,
#ifdef GRUB_UTIL
.reserved_first_sector = 0,
#endif
.next = 0
};

View file

@ -354,6 +354,9 @@ static struct grub_fs grub_cpio_fs = {
.open = grub_cpio_open,
.read = grub_cpio_read,
.close = grub_cpio_close,
#ifdef GRUB_UTIL
.reserved_first_sector = 0,
#endif
};
#ifdef MODE_USTAR

View file

@ -579,6 +579,9 @@ static struct grub_fs grub_sfs_fs =
.read = grub_sfs_read,
.close = grub_sfs_close,
.label = grub_sfs_label,
#ifdef GRUB_UTIL
.reserved_first_sector = 0,
#endif
.next = 0
};

View file

@ -788,6 +788,43 @@ fail:
return 0;
}
static char *
read_string (grub_uint8_t *raw, grub_size_t sz)
{
grub_uint16_t *utf16 = NULL;
char *ret;
grub_size_t utf16len = 0;
if (raw[0] != 8 && raw[0] != 16)
return NULL;
if (raw[0] == 8)
{
unsigned i;
utf16len = sz - 1;
utf16 = grub_malloc (utf16len * sizeof (utf16[0]));
if (!utf16)
return NULL;
for (i = 0; i < utf16len; i++)
utf16[i] = raw[i + 1];
}
if (raw[0] == 16)
{
unsigned i;
utf16len = (sz - 1) / 2;
utf16 = grub_malloc (utf16len * sizeof (utf16[0]));
if (!utf16)
return NULL;
for (i = 0; i < utf16len; i++)
utf16[i] = (raw[2 * i + 1] << 8) | raw[2*i + 2];
}
ret = grub_malloc (utf16len * 3 + 1);
if (ret)
*grub_utf16_to_utf8 ((grub_uint8_t *) ret, utf16, utf16len) = '\0';
grub_free (utf16);
return ret;
}
static int
grub_udf_iterate_dir (grub_fshelp_node_t dir,
int NESTED_FUNC_ATTR
@ -841,10 +878,8 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir,
else
{
enum grub_fshelp_filetype type;
char *filename;
grub_uint8_t raw[dirent.file_ident_length];
grub_uint16_t utf16[dirent.file_ident_length - 1];
grub_uint8_t filename[dirent.file_ident_length * 2];
grub_size_t utf16len = 0;
type = ((dirent.characteristics & GRUB_UDF_FID_CHAR_DIRECTORY) ?
(GRUB_FSHELP_DIR) : (GRUB_FSHELP_REG));
@ -855,27 +890,16 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir,
!= dirent.file_ident_length)
return 0;
if (raw[0] == 8)
{
unsigned i;
utf16len = dirent.file_ident_length - 1;
for (i = 0; i < utf16len; i++)
utf16[i] = raw[i + 1];
}
if (raw[0] == 16)
{
unsigned i;
utf16len = (dirent.file_ident_length - 1) / 2;
for (i = 0; i < utf16len; i++)
utf16[i] = (raw[2 * i + 1] << 8) | raw[2*i + 2];
}
if (raw[0] == 8 || raw[0] == 16)
{
*grub_utf16_to_utf8 (filename, utf16, utf16len) = '\0';
filename = read_string (raw, dirent.file_ident_length);
if (!filename)
grub_print_error ();
if (hook ((char *) filename, type, child))
return 1;
if (filename && hook (filename, type, child))
{
grub_free (filename);
return 1;
}
grub_free (filename);
}
}
@ -1004,7 +1028,7 @@ grub_udf_label (grub_device_t device, char **label)
if (data)
{
*label = grub_strdup ((char *) &data->lvd.ident[1]);
*label = read_string (data->lvd.ident, sizeof (data->lvd.ident));
grub_free (data);
}
else

View file

@ -808,6 +808,9 @@ static struct grub_fs grub_xfs_fs =
.close = grub_xfs_close,
.label = grub_xfs_label,
.uuid = grub_xfs_uuid,
#ifdef GRUB_UTIL
.reserved_first_sector = 0,
#endif
.next = 0
};

View file

@ -18,6 +18,8 @@
#ifdef TEST
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define xmalloc malloc
#define grub_memset memset
#define grub_memcpy memcpy
@ -25,8 +27,6 @@
#ifndef STANDALONE
#ifdef TEST
#include <string.h>
#include <stdlib.h>
typedef unsigned int grub_size_t;
typedef unsigned char grub_uint8_t;
typedef unsigned short grub_uint16_t;
@ -45,6 +45,7 @@ typedef unsigned char grub_uint8_t;
typedef unsigned short grub_uint16_t;
#else
#include <grub/types.h>
#include <grub/misc.h>
#endif
void
grub_reed_solomon_recover (void *ptr_, grub_size_t s, grub_size_t rs);
@ -207,11 +208,12 @@ gauss_solve (gf_single_t *eq, int n, int m, gf_single_t *sol)
#ifndef STANDALONE
chosen = xmalloc (n * sizeof (int));
grub_memset (chosen, -1, n * sizeof (int));
#else
chosen = (void *) scratch;
scratch += n;
scratch += n * sizeof (int);
#endif
for (i = 0; i < n; i++)
chosen[i] = -1;
for (i = 0; i < m; i++)
sol[i] = 0;
gauss_eliminate (eq, n, m, chosen);
@ -228,7 +230,7 @@ gauss_solve (gf_single_t *eq, int n, int m, gf_single_t *sol)
#ifndef STANDALONE
free (chosen);
#else
scratch -= n;
scratch -= n * sizeof (int);
#endif
}

View file

@ -141,7 +141,7 @@ grub_multiboot_load (grub_file_t file)
}
if (header->bss_end_addr)
grub_memset ((grub_uint32_t *) source + load_size, 0,
grub_memset ((grub_uint8_t *) source + load_size, 0,
header->bss_end_addr - header->load_addr - load_size);
grub_multiboot_payload_eip = header->entry_addr;
@ -441,7 +441,7 @@ grub_multiboot_make_mbi (grub_uint32_t *target)
if (err)
return err;
ptrorig = get_virtual_current_address (ch);
ptrdest = (grub_addr_t) get_virtual_current_address (ch);
ptrdest = get_physical_target_address (ch);
*target = ptrdest;
@ -641,6 +641,7 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
return grub_errno;
newmod->start = start;
newmod->size = size;
newmod->next = 0;
for (i = 0; i < argc; i++)
len += grub_strlen (argv[i]) + 1;

View file

@ -1163,37 +1163,35 @@ clear_completions_all (struct screen *screen)
static int
run (struct screen *screen)
{
int currline = 0;
char *nextline;
char *script;
int errs_before;
grub_menu_t menu;
char *dummy[1] = { NULL };
auto grub_err_t editor_getline (char **line, int cont);
grub_err_t editor_getline (char **line, int cont __attribute__ ((unused)))
{
struct line *linep = screen->lines + currline;
char *p;
auto char * editor_getsource (void);
char * editor_getsource (void)
{
int i;
int size = 0;
char *source;
if (currline > screen->num_lines)
{
*line = 0;
return 0;
}
for (i = 0; i < screen->num_lines; i++)
size += screen->lines[i].len + 1;
/* Trim down space characters. */
for (p = linep->buf + linep->len - 1;
p >= linep->buf && grub_isspace (*p);
p--)
;
*++p = '\0';
source = grub_malloc (size + 1);
if (! source)
return NULL;
linep->len = p - linep->buf;
for (p = linep->buf; grub_isspace (*p); p++)
;
*line = grub_strdup (p);
currline++;
return 0;
}
size = 0;
for (i = 0; i < screen->num_lines; i++)
{
grub_strcpy (source + size, screen->lines[i].buf);
size += screen->lines[i].len;
source[size++] = '\n';
}
source[size] = '\0';
return source;
}
grub_cls ();
grub_printf (" ");
@ -1212,12 +1210,11 @@ run (struct screen *screen)
}
/* Execute the script, line for line. */
while (currline < screen->num_lines)
{
editor_getline (&nextline, 0);
if (grub_normal_parse_line (nextline, editor_getline))
break;
}
script = editor_getsource ();
if (! script)
return 0;
grub_script_execute_sourcecode (script, 0, dummy);
grub_free (script);
if (errs_before != grub_err_printed_errors)
grub_wait_after_message ();

View file

@ -91,16 +91,16 @@ print_more (void)
grub_term_restore_pos (pos);
grub_free (pos);
/* Scroll one lines or an entire page, depending on the key. */
/* Scroll one line or an entire page, depending on the key. */
if (key == '\r' || key =='\n')
grub_normal_reset_more ();
else
{
static struct term_state *state;
for (state = term_states; state; state = state->next)
state->num_lines -= 2;
state->num_lines--;
}
else
grub_normal_reset_more ();
}
void

View file

@ -38,9 +38,9 @@
#define GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY 0x1c
/* The size of the first region which won't be compressed. */
#define GRUB_KERNEL_I386_PC_RAW_SIZE 0xc90
#define GRUB_KERNEL_I386_PC_RAW_SIZE 0xca4
#define GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART 0x6f8
#define GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART 0x70c
/* The offset of GRUB_PREFIX. */
#define GRUB_KERNEL_I386_PC_PREFIX GRUB_KERNEL_I386_PC_RAW_SIZE

View file

@ -173,7 +173,8 @@ $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in $(srcdir)/POTFILES-shell
--files-from=$(srcdir)/POTFILES-shell.in \
--copyright-holder='$(COPYRIGHT_HOLDER)' \
--msgid-bugs-address="$$msgid_bugs_address" \
--join-existing --language=Shell --keyword=gettext_quoted \
--join-existing --language=Shell \
--keyword=gettext_quoted --keyword=gettext_printf \
;; \
*) \
$(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
@ -183,10 +184,13 @@ $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in $(srcdir)/POTFILES-shell
--package-name="$${package_gnu}@PACKAGE@" \
--package-version='@VERSION@' \
--msgid-bugs-address="$$msgid_bugs_address" \
--join-existing --language=Shell --keyword=gettext_quoted \
--join-existing --language=Shell \
--keyword=gettext_quoted --keyword=gettext_printf \
;; \
esac
test ! -f $(DOMAIN).po || { \
sed -f grub.d.sed < $(DOMAIN).po > $(DOMAIN).1po && \
mv $(DOMAIN).1po $(DOMAIN).po; \
if test -f $(srcdir)/$(DOMAIN).pot; then \
sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \

2
po/grub.d.sed Normal file
View file

@ -0,0 +1,2 @@
/^#: util\/grub\.d\//a\
#, c-format

View file

@ -132,6 +132,8 @@ done
cat <<EOF >>${cfgfile}
source /boot/grub/testcase.cfg
# Stop serial output to suppress "ACPI shutdown failed" error.
terminal_output console
halt
EOF

View file

@ -187,8 +187,20 @@ version_find_latest ()
echo "$a"
}
# One layer of quotation is eaten by "", the second by sed, and the third by
# printf; so this turns ' into \'. Note that you must use the output of
# this function in a printf format string.
gettext_quoted () {
$gettext "$@" | sed "s/'/'\\\\''/g"
$gettext "$@" | sed "s/'/'\\\\\\\\''/g"
}
# Run the first argument through gettext_quoted, and then pass that and all
# remaining arguments to printf. This is a useful abbreviation and tends to
# be easier to type.
gettext_printf () {
local format="$1"
shift
printf "$(gettext_quoted "$format")" "$@"
}
uses_abstraction () {

View file

@ -1170,7 +1170,8 @@ main (int argc, char *argv[])
font_info.style = ft_face->style_flags;
font_info.size = size;
FT_Set_Pixel_Sizes (ft_face, size, size);
if (FT_Set_Pixel_Sizes (ft_face, size, size))
grub_util_error ("can't set %dx%d font size", size, size);
add_font (&font_info, ft_face, file_format != PF2);
FT_Done_Face (ft_face);
}

View file

@ -81,14 +81,16 @@ do
menuentry "${OS} ${KERNEL}" ${CLASS} {
EOF
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
message="$(gettext_printf "Loading GNU Mach ...")"
cat << EOF
echo '$(gettext_quoted "Loading GNU Mach ...")'
echo '$message'
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/"
message="$(gettext_printf "Loading the Hurd ...")"
cat << EOF
echo '$(gettext_quoted "Loading the Hurd ...")'
echo '$message'
module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
--multiboot-command-line='\${kernel-command-line}' \\
--host-priv-port='\${host-port}' \\
@ -103,13 +105,15 @@ EOF
menuentry "${OS} ${KERNEL} (recovery mode)" ${CLASS} {
EOF
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
message="$(gettext_printf "Loading GNU Mach ...")"
cat << EOF
echo '$(gettext_quoted "Loading GNU Mach ...")'
echo '$message'
multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} -s
EOF
prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
message="$(gettext_printf "Loading the Hurd ...")"
cat << EOF
echo '$(gettext_quoted "Loading the Hurd ...")'
echo '$message'
module /hurd/${hurd_fs}.static ${hurd_fs} \\
--multiboot-command-line='\${kernel-command-line}' \\
--host-priv-port='\${host-port}' \\

View file

@ -84,8 +84,9 @@ kfreebsd_entry ()
fi
printf '%s\n' "${prepare_boot_cache}"
message="$(gettext_printf "Loading kernel of FreeBSD %s ..." ${version})"
cat << EOF
echo '$(printf "$(gettext_quoted "Loading kernel of FreeBSD %s ...")" ${version})'
echo '$message'
kfreebsd ${rel_dirname}/${basename} ${args}
EOF

View file

@ -94,13 +94,15 @@ EOF
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
fi
printf '%s\n' "${prepare_boot_cache}"
message="$(gettext_printf "Loading Linux %s ..." ${version})"
cat << EOF
echo '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})'
echo '$message'
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
EOF
if test -n "${initrd}" ; then
message="$(gettext_printf "Loading initial ramdisk ...")"
cat << EOF
echo '$(gettext_quoted "Loading initial ramdisk ...")'
echo '$message'
initrd ${rel_dirname}/${initrd}
EOF
fi

View file

@ -73,14 +73,16 @@ linux_entry ()
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
fi
printf '%s\n' "${prepare_boot_cache}"
message="$(gettext_printf "Loading Linux %s ..." ${version})"
cat << EOF
echo '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})'
echo '$message'
multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args}
module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
EOF
if test -n "${initrd}" ; then
message="$(gettext_printf "Loading initial ramdisk ...")"
cat << EOF
echo '$(gettext_quoted "Loading initial ramdisk ...")'
echo '$message'
module ${rel_dirname}/${initrd}
EOF
fi