merged in mainline
This commit is contained in:
commit
c45d352721
200 changed files with 11651 additions and 3374 deletions
|
@ -460,7 +460,8 @@ grub_guess_root_device (const char *dir)
|
|||
|
||||
return os_dev;
|
||||
}
|
||||
int
|
||||
|
||||
static int
|
||||
grub_util_is_dmraid (const char *os_dev)
|
||||
{
|
||||
if (! strncmp (os_dev, "/dev/mapper/nvidia_", 19))
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include <grub_emu_init.h>
|
||||
|
||||
#define ENABLE_RELOCATABLE 0
|
||||
#include "progname.h"
|
||||
|
||||
/* Used for going back to the main function. */
|
||||
|
@ -51,7 +52,7 @@ static char *prefix = NULL;
|
|||
grub_addr_t
|
||||
grub_arch_modules_addr (void)
|
||||
{
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
|
@ -106,10 +107,6 @@ grub_machine_fini (void)
|
|||
grub_console_fini ();
|
||||
}
|
||||
|
||||
void
|
||||
read_command_list (void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static struct option options[] =
|
||||
|
@ -149,6 +146,11 @@ usage (int status)
|
|||
}
|
||||
|
||||
|
||||
void grub_hostfs_init (void);
|
||||
void grub_hostfs_fini (void);
|
||||
void grub_host_init (void);
|
||||
void grub_host_fini (void);
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
|
@ -160,8 +162,6 @@ main (int argc, char *argv[])
|
|||
|
||||
set_program_name (argv[0]);
|
||||
|
||||
grub_util_init_nls ();
|
||||
|
||||
while ((opt = getopt_long (argc, argv, "r:d:m:vH:hV", options, 0)) != -1)
|
||||
switch (opt)
|
||||
{
|
||||
|
@ -209,6 +209,8 @@ main (int argc, char *argv[])
|
|||
|
||||
signal (SIGINT, SIG_IGN);
|
||||
grub_console_init ();
|
||||
grub_host_init ();
|
||||
grub_hostfs_init ();
|
||||
|
||||
/* XXX: This is a bit unportable. */
|
||||
grub_util_biosdisk_init (dev_map);
|
||||
|
@ -241,6 +243,8 @@ main (int argc, char *argv[])
|
|||
grub_main ();
|
||||
|
||||
grub_fini_all ();
|
||||
grub_hostfs_fini ();
|
||||
grub_host_fini ();
|
||||
|
||||
grub_machine_fini ();
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ platform=@platform@
|
|||
host_os=@host_os@
|
||||
font=@datadir@/@PACKAGE_TARNAME@/ascii.pf2
|
||||
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
|
||||
localedir=@datadir@/locale
|
||||
|
||||
grub_setup=${sbindir}/`echo grub-setup | sed ${transform}`
|
||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] || [ "${target_cpu}-${platform}" = "mips-yeeloong" ] ; then
|
||||
|
@ -296,9 +297,9 @@ 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/
|
||||
for dir in ${localedir}/*; do
|
||||
if test -f "$dir/LC_MESSAGES/grub.mo"; then
|
||||
cp -f "$dir/LC_MESSAGES/grub.mo" "${grubdir}/locale/${dir##*/}.mo"
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
@ -224,7 +224,11 @@ export GRUB_DEFAULT \
|
|||
GRUB_DISABLE_LINUX_UUID \
|
||||
GRUB_DISABLE_LINUX_RECOVERY \
|
||||
GRUB_GFXMODE \
|
||||
GRUB_DISABLE_OS_PROBER
|
||||
GRUB_THEME \
|
||||
GRUB_GFXPAYLOAD_LINUX \
|
||||
GRUB_DISABLE_OS_PROBER \
|
||||
GRUB_INIT_TUNE \
|
||||
GRUB_SAVEDEFAULT
|
||||
|
||||
if test "x${grub_cfg}" != "x"; then
|
||||
rm -f ${grub_cfg}.new
|
||||
|
|
|
@ -96,7 +96,7 @@ convert_system_path_to_grub_path ()
|
|||
|
||||
save_default_entry ()
|
||||
{
|
||||
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then
|
||||
if [ "x${GRUB_SAVEDEFAULT}" = "xtrue" ] ; then
|
||||
cat << EOF
|
||||
savedefault
|
||||
EOF
|
||||
|
@ -120,7 +120,7 @@ prepare_grub_to_access_device ()
|
|||
|
||||
# If there's a filesystem UUID that GRUB is capable of identifying, use it;
|
||||
# otherwise set root as per value in device.map.
|
||||
echo "set root=`${grub_probe} --device ${device} --target=drive`"
|
||||
echo "set root='`${grub_probe} --device ${device} --target=drive`'"
|
||||
if fs_uuid="`${grub_probe} --device ${device} --target=fs_uuid 2> /dev/null`" ; then
|
||||
echo "search --no-floppy --fs-uuid --set ${fs_uuid}"
|
||||
fi
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <grub/machine/kernel.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/elf.h>
|
||||
#include <grub/aout.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/kernel.h>
|
||||
#include <grub/disk.h>
|
||||
|
@ -41,6 +42,8 @@
|
|||
|
||||
#include "progname.h"
|
||||
|
||||
#define ALIGN_ADDR(x) (ALIGN_UP((x), GRUB_TARGET_SIZEOF_VOID_P))
|
||||
|
||||
#ifdef ENABLE_LZMA
|
||||
#include <grub/lib/LzmaEnc.h>
|
||||
|
||||
|
@ -129,20 +132,20 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
|
||||
if (font_path)
|
||||
{
|
||||
font_size = ALIGN_UP(grub_util_get_image_size (font_path), 4);
|
||||
font_size = ALIGN_ADDR (grub_util_get_image_size (font_path));
|
||||
total_module_size += font_size + sizeof (struct grub_module_header);
|
||||
}
|
||||
|
||||
if (config_path)
|
||||
{
|
||||
config_size_pure = grub_util_get_image_size (config_path) + 1;
|
||||
config_size = ALIGN_UP(config_size_pure, 4);
|
||||
config_size = ALIGN_ADDR (config_size_pure);
|
||||
grub_util_info ("the size of config file is 0x%x", config_size);
|
||||
total_module_size += config_size + sizeof (struct grub_module_header);
|
||||
}
|
||||
|
||||
for (p = path_list; p; p = p->next)
|
||||
total_module_size += (grub_util_get_image_size (p->name)
|
||||
total_module_size += (ALIGN_ADDR (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);
|
||||
|
@ -157,9 +160,9 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
/* Fill in the grub_module_info structure. */
|
||||
modinfo = (struct grub_module_info *) (kernel_img + kernel_size);
|
||||
memset (modinfo, 0, sizeof (struct grub_module_info));
|
||||
modinfo->magic = GRUB_MODULE_MAGIC;
|
||||
modinfo->offset = sizeof (struct grub_module_info);
|
||||
modinfo->size = total_module_size;
|
||||
modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC);
|
||||
modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info));
|
||||
modinfo->size = grub_host_to_target_addr (total_module_size);
|
||||
|
||||
offset = kernel_size + sizeof (struct grub_module_info);
|
||||
for (p = path_list; p; p = p->next)
|
||||
|
@ -168,11 +171,11 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
size_t mod_size, orig_size;
|
||||
|
||||
orig_size = grub_util_get_image_size (p->name);
|
||||
mod_size = ALIGN_UP(orig_size, 4);
|
||||
mod_size = ALIGN_ADDR (orig_size);
|
||||
|
||||
header = (struct grub_module_header *) (kernel_img + offset);
|
||||
memset (header, 0, sizeof (struct grub_module_header));
|
||||
header->type = OBJ_TYPE_ELF;
|
||||
header->type = grub_host_to_target32 (OBJ_TYPE_ELF);
|
||||
header->size = grub_host_to_target32 (mod_size + sizeof (*header));
|
||||
offset += sizeof (*header);
|
||||
memset (kernel_img + offset + orig_size, 0, mod_size - orig_size);
|
||||
|
@ -187,7 +190,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
|
||||
header = (struct grub_module_header *) (kernel_img + offset);
|
||||
memset (header, 0, sizeof (struct grub_module_header));
|
||||
header->type = OBJ_TYPE_MEMDISK;
|
||||
header->type = grub_host_to_target32 (OBJ_TYPE_MEMDISK);
|
||||
header->size = grub_host_to_target32 (memdisk_size + sizeof (*header));
|
||||
offset += sizeof (*header);
|
||||
|
||||
|
@ -201,7 +204,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
|
||||
header = (struct grub_module_header *) (kernel_img + offset);
|
||||
memset (header, 0, sizeof (struct grub_module_header));
|
||||
header->type = OBJ_TYPE_FONT;
|
||||
header->type = grub_host_to_target32 (OBJ_TYPE_FONT);
|
||||
header->size = grub_host_to_target32 (font_size + sizeof (*header));
|
||||
offset += sizeof (*header);
|
||||
|
||||
|
@ -215,7 +218,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
|
||||
header = (struct grub_module_header *) (kernel_img + offset);
|
||||
memset (header, 0, sizeof (struct grub_module_header));
|
||||
header->type = OBJ_TYPE_CONFIG;
|
||||
header->type = grub_host_to_target32 (OBJ_TYPE_CONFIG);
|
||||
header->size = grub_host_to_target32 (config_size + sizeof (*header));
|
||||
offset += sizeof (*header);
|
||||
|
||||
|
@ -230,6 +233,36 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
|
||||
grub_util_info ("the core size is 0x%x", core_size);
|
||||
|
||||
#ifdef GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
|
||||
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE))
|
||||
= grub_host_to_target32 (total_module_size);
|
||||
#endif
|
||||
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE))
|
||||
= grub_host_to_target32 (kernel_size);
|
||||
#ifdef GRUB_KERNEL_MACHINE_COMPRESSED_SIZE
|
||||
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE))
|
||||
= grub_host_to_target32 (core_size - GRUB_KERNEL_MACHINE_RAW_SIZE);
|
||||
#endif
|
||||
|
||||
#if defined(GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) && defined(GRUB_KERNEL_MACHINE_INSTALL_BSD_PART)
|
||||
/* If we included a drive in our prefix, let GRUB know it doesn't have to
|
||||
prepend the drive told by BIOS. */
|
||||
if (prefix[0] == '(')
|
||||
{
|
||||
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART))
|
||||
= grub_host_to_target32 (-2);
|
||||
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART))
|
||||
= grub_host_to_target32 (-2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
if (GRUB_KERNEL_MACHINE_LINK_ADDR + core_size > GRUB_MEMORY_MACHINE_UPPER)
|
||||
grub_util_error (_("core image is too big (%p > %p)"),
|
||||
GRUB_KERNEL_MACHINE_LINK_ADDR + core_size,
|
||||
GRUB_MEMORY_MACHINE_UPPER);
|
||||
#endif
|
||||
|
||||
#if defined(GRUB_MACHINE_PCBIOS)
|
||||
{
|
||||
unsigned num;
|
||||
|
@ -298,39 +331,52 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
free (boot_img);
|
||||
free (boot_path);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
|
||||
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE))
|
||||
= grub_host_to_target32 (total_module_size);
|
||||
#endif
|
||||
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE))
|
||||
= grub_host_to_target32 (kernel_size);
|
||||
#ifdef GRUB_KERNEL_MACHINE_COMPRESSED_SIZE
|
||||
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE))
|
||||
= grub_host_to_target32 (core_size - GRUB_KERNEL_MACHINE_RAW_SIZE);
|
||||
#endif
|
||||
|
||||
#if defined(GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) && defined(GRUB_KERNEL_MACHINE_INSTALL_BSD_PART)
|
||||
/* If we included a drive in our prefix, let GRUB know it doesn't have to
|
||||
prepend the drive told by BIOS. */
|
||||
if (prefix[0] == '(')
|
||||
#elif defined (GRUB_MACHINE_SPARC64)
|
||||
if (format == GRUB_PLATFORM_IMAGE_AOUT)
|
||||
{
|
||||
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART))
|
||||
= grub_host_to_target32 (-2);
|
||||
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART))
|
||||
= grub_host_to_target32 (-2);
|
||||
void *aout_img;
|
||||
size_t aout_size;
|
||||
struct grub_aout32_header *aout_head;
|
||||
|
||||
aout_size = core_size + sizeof (*aout_head);
|
||||
aout_img = xmalloc (aout_size);
|
||||
aout_head = aout_img;
|
||||
aout_head->a_midmag = grub_host_to_target32 ((AOUT_MID_SUN << 16)
|
||||
| AOUT32_OMAGIC);
|
||||
aout_head->a_text = grub_host_to_target32 (core_size);
|
||||
aout_head->a_entry
|
||||
= grub_host_to_target32 (GRUB_BOOT_MACHINE_IMAGE_ADDRESS);
|
||||
memcpy (aout_img + sizeof (*aout_head), core_img, core_size);
|
||||
|
||||
free (core_img);
|
||||
core_img = aout_img;
|
||||
core_size = aout_size;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
unsigned int num;
|
||||
char *boot_path, *boot_img;
|
||||
size_t boot_size;
|
||||
|
||||
#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)"),
|
||||
GRUB_KERNEL_MACHINE_LINK_ADDR + core_size,
|
||||
GRUB_MEMORY_MACHINE_UPPER);
|
||||
#endif
|
||||
num = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
|
||||
num <<= GRUB_DISK_SECTOR_BITS;
|
||||
|
||||
#if defined(GRUB_MACHINE_MIPS)
|
||||
boot_path = grub_util_get_path (dir, "diskboot.img");
|
||||
boot_size = grub_util_get_image_size (boot_path);
|
||||
if (boot_size != GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error ("diskboot.img is not one sector size");
|
||||
|
||||
boot_img = grub_util_read_image (boot_path);
|
||||
|
||||
*((grub_uint32_t *) (boot_img + GRUB_DISK_SECTOR_SIZE
|
||||
- GRUB_BOOT_MACHINE_LIST_SIZE + 8))
|
||||
= grub_host_to_target32 (num);
|
||||
|
||||
grub_util_write_image (boot_img, boot_size, out);
|
||||
free (boot_img);
|
||||
free (boot_path);
|
||||
}
|
||||
#elif defined(GRUB_MACHINE_MIPS)
|
||||
if (format == GRUB_PLATFORM_IMAGE_ELF)
|
||||
{
|
||||
char *elf_img;
|
||||
|
@ -339,7 +385,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
Elf32_Phdr *phdr;
|
||||
grub_uint32_t target_addr;
|
||||
|
||||
program_size = ALIGN_UP (core_size, 4);
|
||||
program_size = ALIGN_ADDR (core_size);
|
||||
|
||||
elf_img = xmalloc (program_size + sizeof (*ehdr) + sizeof (*phdr));
|
||||
memset (elf_img, 0, program_size + sizeof (*ehdr) + sizeof (*phdr));
|
||||
|
@ -444,10 +490,8 @@ Make a bootable image of GRUB.\n\
|
|||
-o, --output=FILE output a generated image to FILE [default=stdout]\n"
|
||||
#ifdef GRUB_PLATFORM_IMAGE_DEFAULT
|
||||
"\
|
||||
-O, --format=FORMAT generate an image in format [default="
|
||||
GRUB_PLATFORM_IMAGE_DEFAULT_FORMAT "]\n \
|
||||
available formats: "
|
||||
GRUB_PLATFORM_IMAGE_FORMATS "\n"
|
||||
-O, --format=FORMAT generate an image in format [default=%s]\n\
|
||||
available formats: %s\n"
|
||||
#endif
|
||||
"\
|
||||
-h, --help display this message and exit\n\
|
||||
|
@ -455,7 +499,12 @@ Make a bootable image of GRUB.\n\
|
|||
-v, --verbose print verbose messages\n\
|
||||
\n\
|
||||
Report bugs to <%s>.\n\
|
||||
"), program_name, GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
|
||||
"),
|
||||
program_name, GRUB_LIBDIR, DEFAULT_DIRECTORY,
|
||||
#ifdef GRUB_PLATFORM_IMAGE_DEFAULT
|
||||
GRUB_PLATFORM_IMAGE_DEFAULT_FORMAT, GRUB_PLATFORM_IMAGE_FORMATS,
|
||||
#endif
|
||||
PACKAGE_BUGREPORT);
|
||||
|
||||
exit (status);
|
||||
}
|
||||
|
@ -474,6 +523,8 @@ main (int argc, char *argv[])
|
|||
grub_platform_image_format_t format = GRUB_PLATFORM_IMAGE_DEFAULT;
|
||||
#endif
|
||||
|
||||
set_program_name (argv[0]);
|
||||
|
||||
grub_util_init_nls ();
|
||||
|
||||
while (1)
|
||||
|
@ -503,6 +554,11 @@ main (int argc, char *argv[])
|
|||
if (strcmp (optarg, "elf") == 0)
|
||||
format = GRUB_PLATFORM_IMAGE_ELF;
|
||||
else
|
||||
#endif
|
||||
#ifdef GRUB_PLATFORM_IMAGE_AOUT
|
||||
if (strcmp (optarg, "aout") == 0)
|
||||
format = GRUB_PLATFORM_IMAGE_AOUT;
|
||||
else
|
||||
#endif
|
||||
usage (1);
|
||||
break;
|
||||
|
|
|
@ -103,7 +103,15 @@ if [ "x${output_image}" = x ] ; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
iso9660_dir=`mktemp -d`
|
||||
if test "x$TMP" != x; then
|
||||
MKTEMP_TEMPLATE="$TMP/grub-mkrescue.XXXXXXXXXX"
|
||||
elif test "x$TEMP" != x; then
|
||||
MKTEMP_TEMPLATE="$TEMP/grub-mkrescue.XXXXXXXXXX"
|
||||
else
|
||||
MKTEMP_TEMPLATE="/tmp/grub-mkrescue.XXXXXXXXXX"
|
||||
fi
|
||||
|
||||
iso9660_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
|
||||
mkdir -p ${iso9660_dir}/boot/grub
|
||||
|
||||
process_input_dir ()
|
||||
|
@ -150,11 +158,11 @@ fi
|
|||
# build coreboot core.img
|
||||
if test -e "${coreboot_dir}" ; then
|
||||
echo "Enabling coreboot support ..."
|
||||
memdisk_img=`mktemp`
|
||||
memdisk_dir=`mktemp -d`
|
||||
memdisk_img=`mktemp "$MKTEMP_TEMPLATE"`
|
||||
memdisk_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
|
||||
mkdir -p ${memdisk_dir}/boot/grub
|
||||
# obtain date-based UUID
|
||||
iso_uuid=$(date +%Y-%m-%d-%H-%M-%S-00)
|
||||
iso_uuid=$(date -u +%Y-%m-%d-%H-%M-%S-00)
|
||||
|
||||
modules="$(cat ${coreboot_dir}/partmap.lst) ${modules}"
|
||||
cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg
|
||||
|
@ -179,12 +187,12 @@ fi
|
|||
# build BIOS core.img
|
||||
if test -e "${pc_dir}" ; then
|
||||
echo "Enabling BIOS support ..."
|
||||
core_img=`mktemp`
|
||||
core_img=`mktemp "$MKTEMP_TEMPLATE"`
|
||||
grub-mkimage -d ${pc_dir}/ -o ${core_img} --prefix=/boot/grub/i386-pc \
|
||||
iso9660 biosdisk
|
||||
cat ${pc_dir}/cdboot.img ${core_img} > ${iso9660_dir}/boot/grub/i386-pc/eltorito.img
|
||||
|
||||
embed_img=`mktemp`
|
||||
embed_img=`mktemp "$MKTEMP_TEMPLATE"`
|
||||
cat ${pc_dir}/boot.img ${core_img} > ${embed_img}
|
||||
|
||||
rm -f ${core_img}
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "progname.h"
|
||||
|
||||
static struct option options[] = {
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"version", no_argument, 0, 'V'},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* grub-script-check.c - check grub script file for syntax errors */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
* Copyright (C) 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
|
||||
|
|
|
@ -103,6 +103,18 @@ if loadfont `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then
|
|||
# understand terminal_output
|
||||
terminal gfxterm
|
||||
fi
|
||||
EOF
|
||||
if [ x$GRUB_THEME != x ] && [ -f $GRUB_THEME ] \
|
||||
&& is_path_readable_by_grub $GRUB_THEME; then
|
||||
echo "Found theme: $GRUB_THEME" >&2
|
||||
prepare_grub_to_access_device `${grub_probe} --target=device $GRUB_THEME` | sed -e "s/^/ /"
|
||||
cat << EOF
|
||||
insmod gfxmenu
|
||||
set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
|
||||
set menuviewer=gfxmenu
|
||||
EOF
|
||||
fi
|
||||
cat << EOF
|
||||
fi
|
||||
EOF
|
||||
;;
|
||||
|
@ -146,3 +158,11 @@ else
|
|||
set timeout=${GRUB_TIMEOUT}
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Play an initial tune
|
||||
if [ "x${GRUB_INIT_TUNE}" != "x" ] ; then
|
||||
cat << EOF
|
||||
insmod play
|
||||
play ${GRUB_INIT_TUNE}
|
||||
EOF
|
||||
fi
|
||||
|
|
|
@ -21,10 +21,13 @@ exec_prefix=@exec_prefix@
|
|||
libdir=@libdir@
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
|
||||
CLASS="--class gnu --class os"
|
||||
|
||||
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
|
||||
OS=GNU
|
||||
else
|
||||
OS="${GRUB_DISTRIBUTOR} GNU/Hurd"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]') ${CLASS}"
|
||||
fi
|
||||
|
||||
at_least_one=false
|
||||
|
@ -69,7 +72,7 @@ if ${all_of_them} && test -e /lib/ld.so.1 ; then : ; else
|
|||
fi
|
||||
|
||||
cat << EOF
|
||||
menuentry "${OS}" {
|
||||
menuentry "${OS}" ${CLASS} {
|
||||
EOF
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
|
||||
cat << EOF
|
||||
|
|
|
@ -23,11 +23,19 @@ libdir=@libdir@
|
|||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
|
||||
export TEXTDOMAIN=@PACKAGE@
|
||||
export TEXTDOMAINDIR=@localedir@
|
||||
export TEXTDOMAINDIR=@LOCALEDIR@
|
||||
|
||||
CLASS="--class os"
|
||||
|
||||
case "${GRUB_DISTRIBUTOR}" in
|
||||
Debian) OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD" ;;
|
||||
*) OS="FreeBSD" ;;
|
||||
Debian)
|
||||
OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]') --class gnu-kfreebsd --class gnu ${CLASS}"
|
||||
;;
|
||||
*)
|
||||
OS="FreeBSD"
|
||||
CLASS="--class freebsd --class bsd ${CLASS}"
|
||||
;;
|
||||
esac
|
||||
|
||||
kfreebsd_entry ()
|
||||
|
@ -37,7 +45,7 @@ kfreebsd_entry ()
|
|||
recovery="$3" # not used yet
|
||||
args="$4" # not used yet
|
||||
title="$(gettext "%s, with kFreeBSD %s")"
|
||||
printf "menuentry \"${title}\" {\n" "${os}" "${version}"
|
||||
printf "menuentry \"${title}\" ${CLASS} {\n" "${os}" "${version}"
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
if [ -z "${prepare_boot_cache}" ]; then
|
||||
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
|
||||
|
|
|
@ -23,12 +23,15 @@ libdir=@libdir@
|
|||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
|
||||
export TEXTDOMAIN=@PACKAGE@
|
||||
export TEXTDOMAINDIR=@localedir@
|
||||
export TEXTDOMAINDIR=@LOCALEDIR@
|
||||
|
||||
CLASS="--class gnu-linux --class gnu --class os"
|
||||
|
||||
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
|
||||
OS=GNU/Linux
|
||||
else
|
||||
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]') ${CLASS}"
|
||||
fi
|
||||
|
||||
# loop-AES arranges things so that /dev/loop/X can be our root device, but
|
||||
|
@ -57,14 +60,21 @@ linux_entry ()
|
|||
else
|
||||
title="$(gettext "%s, with Linux %s")"
|
||||
fi
|
||||
printf "menuentry \"${title}\" {\n" "${os}" "${version}"
|
||||
printf "menuentry \"${title}\" ${CLASS} {\n" "${os}" "${version}"
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
|
||||
# Use ELILO's generic "efifb" when it's known to be available.
|
||||
# FIXME: We need an interface to select vesafb in case efifb can't be used.
|
||||
if grep -qx "CONFIG_FB_EFI=y" /boot/config-${version} 2> /dev/null ; then
|
||||
cat << EOF
|
||||
if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then
|
||||
if grep -qx "CONFIG_FB_EFI=y" /boot/config-${version} 2> /dev/null \
|
||||
&& grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" /boot/config-${version} 2> /dev/null; then
|
||||
cat << EOF
|
||||
set gfxpayload=keep
|
||||
EOF
|
||||
fi
|
||||
else
|
||||
cat << EOF
|
||||
set gfxpayload=$GRUB_GFXPAYLOAD_LINUX
|
||||
EOF
|
||||
fi
|
||||
|
||||
|
|
128
util/hostdisk.c
128
util/hostdisk.c
|
@ -26,6 +26,7 @@
|
|||
#include <grub/util/hostdisk.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/list.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -103,6 +104,13 @@ struct
|
|||
char *device;
|
||||
} map[256];
|
||||
|
||||
struct grub_util_biosdisk_data
|
||||
{
|
||||
char *dev;
|
||||
int access_mode;
|
||||
int fd;
|
||||
};
|
||||
|
||||
#ifdef __linux__
|
||||
/* Check if we have devfs support. */
|
||||
static int
|
||||
|
@ -137,7 +145,7 @@ find_grub_drive (const char *name)
|
|||
}
|
||||
|
||||
static int
|
||||
find_free_slot ()
|
||||
find_free_slot (void)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
|
@ -165,14 +173,19 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
{
|
||||
int drive;
|
||||
struct stat st;
|
||||
struct grub_util_biosdisk_data *data;
|
||||
|
||||
drive = find_grub_drive (name);
|
||||
if (drive < 0)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
||||
"no mapping exists for `%s'", name);
|
||||
|
||||
disk->has_partitions = 1;
|
||||
disk->id = drive;
|
||||
disk->data = data = xmalloc (sizeof (struct grub_util_biosdisk_data));
|
||||
data->dev = NULL;
|
||||
data->access_mode = 0;
|
||||
data->fd = -1;
|
||||
|
||||
/* Get the size. */
|
||||
#if defined(__MINGW32__)
|
||||
|
@ -198,7 +211,7 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
|
||||
fd = open (map[drive].device, O_RDONLY);
|
||||
if (fd == -1)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' while attempting to get disk size", map[drive].device);
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "cannot open `%s' while attempting to get disk size", map[drive].device);
|
||||
|
||||
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
|
||||
if (fstat (fd, &st) < 0 || ! S_ISCHR (st.st_mode))
|
||||
|
@ -244,7 +257,7 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
# warning "No special routine to get the size of a block device is implemented for your OS. This is not possibly fatal."
|
||||
#endif
|
||||
if (stat (map[drive].device, &st) < 0)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "cannot stat `%s'", map[drive].device);
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "cannot stat `%s'", map[drive].device);
|
||||
|
||||
disk->total_sectors = st.st_size >> GRUB_DISK_SECTOR_BITS;
|
||||
|
||||
|
@ -254,6 +267,17 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
}
|
||||
|
||||
#ifdef __linux__
|
||||
/* Cache of partition start sectors for each disk. */
|
||||
struct linux_partition_cache
|
||||
{
|
||||
struct linux_partition_cache *next;
|
||||
char *dev;
|
||||
unsigned long start;
|
||||
int partno;
|
||||
};
|
||||
|
||||
struct linux_partition_cache *linux_partition_cache_list;
|
||||
|
||||
static int
|
||||
linux_find_partition (char *dev, unsigned long sector)
|
||||
{
|
||||
|
@ -262,6 +286,7 @@ linux_find_partition (char *dev, unsigned long sector)
|
|||
char *p;
|
||||
int i;
|
||||
char real_dev[PATH_MAX];
|
||||
struct linux_partition_cache *cache;
|
||||
|
||||
strcpy(real_dev, dev);
|
||||
|
||||
|
@ -281,6 +306,16 @@ linux_find_partition (char *dev, unsigned long sector)
|
|||
format = "%d";
|
||||
}
|
||||
|
||||
for (cache = linux_partition_cache_list; cache; cache = cache->next)
|
||||
{
|
||||
if (strcmp (cache->dev, dev) == 0 && cache->start == sector)
|
||||
{
|
||||
sprintf (p, format, cache->partno);
|
||||
strcpy (dev, real_dev);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 1; i < 10000; i++)
|
||||
{
|
||||
int fd;
|
||||
|
@ -301,6 +336,15 @@ linux_find_partition (char *dev, unsigned long sector)
|
|||
|
||||
if (hdg.start == sector)
|
||||
{
|
||||
struct linux_partition_cache *new_cache_item;
|
||||
|
||||
new_cache_item = xmalloc (sizeof *new_cache_item);
|
||||
new_cache_item->dev = xstrdup (dev);
|
||||
new_cache_item->start = hdg.start;
|
||||
new_cache_item->partno = i;
|
||||
grub_list_push (GRUB_AS_LIST_P (&linux_partition_cache_list),
|
||||
GRUB_AS_LIST (new_cache_item));
|
||||
|
||||
strcpy (dev, real_dev);
|
||||
return 1;
|
||||
}
|
||||
|
@ -314,6 +358,7 @@ static int
|
|||
open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
|
||||
{
|
||||
int fd;
|
||||
struct grub_util_biosdisk_data *data = disk->data;
|
||||
|
||||
#ifdef O_LARGEFILE
|
||||
flags |= O_LARGEFILE;
|
||||
|
@ -340,18 +385,35 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
|
|||
&& strncmp (map[disk->id].device, "/dev/", 5) == 0)
|
||||
is_partition = linux_find_partition (dev, disk->partition->start);
|
||||
|
||||
/* Open the partition. */
|
||||
grub_dprintf ("hostdisk", "opening the device `%s' in open_device()\n", dev);
|
||||
fd = open (dev, flags);
|
||||
if (fd < 0)
|
||||
if (data->dev && strcmp (data->dev, dev) == 0 &&
|
||||
data->access_mode == (flags & O_ACCMODE))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s'", dev);
|
||||
return -1;
|
||||
grub_dprintf ("hostdisk", "reusing open device `%s'\n", dev);
|
||||
fd = data->fd;
|
||||
}
|
||||
else
|
||||
{
|
||||
free (data->dev);
|
||||
if (data->fd != -1)
|
||||
close (data->fd);
|
||||
|
||||
/* Flush the buffer cache to the physical disk.
|
||||
XXX: This also empties the buffer cache. */
|
||||
ioctl (fd, BLKFLSBUF, 0);
|
||||
/* Open the partition. */
|
||||
grub_dprintf ("hostdisk", "opening the device `%s' in open_device()\n", dev);
|
||||
fd = open (dev, flags);
|
||||
if (fd < 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s'", dev);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Flush the buffer cache to the physical disk.
|
||||
XXX: This also empties the buffer cache. */
|
||||
ioctl (fd, BLKFLSBUF, 0);
|
||||
|
||||
data->dev = xstrdup (dev);
|
||||
data->access_mode = (flags & O_ACCMODE);
|
||||
data->fd = fd;
|
||||
}
|
||||
|
||||
if (is_partition)
|
||||
sector -= disk->partition->start;
|
||||
|
@ -375,7 +437,26 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
|
|||
}
|
||||
#endif
|
||||
|
||||
fd = open (map[disk->id].device, flags);
|
||||
if (data->dev && strcmp (data->dev, map[disk->id].device) == 0 &&
|
||||
data->access_mode == (flags & O_ACCMODE))
|
||||
{
|
||||
grub_dprintf ("hostdisk", "reusing open device `%s'\n", data->dev);
|
||||
fd = data->fd;
|
||||
}
|
||||
else
|
||||
{
|
||||
free (data->dev);
|
||||
if (data->fd != -1)
|
||||
close (data->fd);
|
||||
|
||||
fd = open (map[disk->id].device, flags);
|
||||
if (fd >= 0)
|
||||
{
|
||||
data->dev = xstrdup (map[disk->id].device);
|
||||
data->access_mode = (flags & O_ACCMODE);
|
||||
data->fd = fd;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
if (! (sysctl_oldflags & 0x10)
|
||||
|
@ -535,7 +616,6 @@ grub_util_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
!= (ssize_t) (size << GRUB_DISK_SECTOR_BITS))
|
||||
grub_error (GRUB_ERR_READ_ERROR, "cannot read from `%s'", map[disk->id].device);
|
||||
|
||||
close (fd);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
@ -570,17 +650,27 @@ grub_util_biosdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
!= (ssize_t) (size << GRUB_DISK_SECTOR_BITS))
|
||||
grub_error (GRUB_ERR_WRITE_ERROR, "cannot write to `%s'", map[disk->id].device);
|
||||
|
||||
close (fd);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static void
|
||||
grub_util_biosdisk_close (struct grub_disk *disk)
|
||||
{
|
||||
struct grub_util_biosdisk_data *data = disk->data;
|
||||
|
||||
free (data->dev);
|
||||
if (data->fd != -1)
|
||||
close (data->fd);
|
||||
free (data);
|
||||
}
|
||||
|
||||
static struct grub_disk_dev grub_util_biosdisk_dev =
|
||||
{
|
||||
.name = "biosdisk",
|
||||
.id = GRUB_DISK_DEVICE_BIOSDISK_ID,
|
||||
.iterate = grub_util_biosdisk_iterate,
|
||||
.open = grub_util_biosdisk_open,
|
||||
.close = 0,
|
||||
.close = grub_util_biosdisk_close,
|
||||
.read = grub_util_biosdisk_read,
|
||||
.write = grub_util_biosdisk_write,
|
||||
.next = 0
|
||||
|
@ -981,10 +1071,10 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
struct hd_geometry hdg;
|
||||
int dos_part = -1;
|
||||
int bsd_part = -1;
|
||||
auto int find_partition (grub_disk_t disk,
|
||||
auto int find_partition (grub_disk_t dsk,
|
||||
const grub_partition_t partition);
|
||||
|
||||
int find_partition (grub_disk_t disk __attribute__ ((unused)),
|
||||
int find_partition (grub_disk_t dsk __attribute__ ((unused)),
|
||||
const grub_partition_t partition)
|
||||
{
|
||||
struct grub_msdos_partition *pcdata = NULL;
|
||||
|
|
|
@ -31,6 +31,7 @@ target_cpu=@target_cpu@
|
|||
platform=@platform@
|
||||
host_os=@host_os@
|
||||
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
|
||||
localedir=@datadir@/locale
|
||||
|
||||
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
|
||||
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
|
||||
|
@ -200,6 +201,14 @@ for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do
|
|||
cp -f $file ${grubdir} || exit 1
|
||||
done
|
||||
|
||||
# Copy gettext files
|
||||
mkdir -p ${grubdir}/locale/
|
||||
for dir in ${localedir}/*; do
|
||||
if test -f "$dir/LC_MESSAGES/grub.mo"; then
|
||||
cp -f "$dir/LC_MESSAGES/grub.mo" "${grubdir}/locale/${dir##*/}.mo"
|
||||
fi
|
||||
done
|
||||
|
||||
if ! test -f ${grubdir}/grubenv; then
|
||||
$grub_editenv ${grubdir}/grubenv create
|
||||
fi
|
||||
|
|
|
@ -418,7 +418,7 @@ unable_to_embed:
|
|||
|
||||
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."));
|
||||
"their use is discouraged."));
|
||||
if (! force)
|
||||
grub_util_error (_("if you really want blocklists, use --force"));
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ mdblocksizes = {"_gcry_digest_spec_crc32" : 64,
|
|||
"_gcry_digest_spec_whirlpool" : 64}
|
||||
|
||||
cryptolist = open (os.path.join (cipher_dir_out, "crypto.lst"), "w")
|
||||
conf.write ("MAINTAINER_CLEANFILES += $(srcdir)/conf/gcry.rmk $(srcdir)/lib/libgcrypt-grub/cipher/ChangeLog $(srcdir)/lib/libgcrypt-grub/cipher/cipher.h $(srcdir)/lib/libgcrypt-grub/cipher/crypto.lst $(srcdir)/lib/libgcrypt-grub/cipher/g10lib.h $(srcdir)/lib/libgcrypt-grub/cipher/memory.h $(srcdir)/lib/libgcrypt-grub/cipher/types.h\n");
|
||||
|
||||
# rijndael is the only cipher using aliases. So no need for mangling, just
|
||||
# hardcode it
|
||||
|
@ -87,6 +88,7 @@ for cipher_file in cipher_files:
|
|||
continue
|
||||
nch = False
|
||||
if re.match (".*\.[ch]$", cipher_file):
|
||||
conf.write ("MAINTAINER_CLEANFILES += $(srcdir)/lib/libgcrypt-grub/cipher/" + cipher_file + "\n");
|
||||
isc = re.match (".*\.c$", cipher_file)
|
||||
f = open (infile, "r")
|
||||
fw = open (outfile, "w")
|
||||
|
|
15
util/misc.c
15
util/misc.c
|
@ -43,6 +43,7 @@
|
|||
#include <grub/time.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
#define ENABLE_RELOCATABLE 0
|
||||
#include "progname.h"
|
||||
|
||||
/* Include malloc.h, only if memalign is available. It is known that
|
||||
|
@ -103,6 +104,7 @@ grub_util_error (const char *fmt, ...)
|
|||
exit (1);
|
||||
}
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
int
|
||||
grub_err_printf (const char *fmt, ...)
|
||||
{
|
||||
|
@ -115,6 +117,7 @@ grub_err_printf (const char *fmt, ...)
|
|||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
void *
|
||||
xmalloc (size_t size)
|
||||
|
@ -142,13 +145,13 @@ char *
|
|||
xstrdup (const char *str)
|
||||
{
|
||||
size_t len;
|
||||
char *dup;
|
||||
char *newstr;
|
||||
|
||||
len = strlen (str);
|
||||
dup = (char *) xmalloc (len + 1);
|
||||
memcpy (dup, str, len + 1);
|
||||
newstr = (char *) xmalloc (len + 1);
|
||||
memcpy (newstr, str, len + 1);
|
||||
|
||||
return dup;
|
||||
return newstr;
|
||||
}
|
||||
|
||||
char *
|
||||
|
@ -371,11 +374,13 @@ grub_millisleep (grub_uint32_t ms)
|
|||
|
||||
#endif
|
||||
|
||||
#if !(defined (__i386__) || defined (__x86_64__))
|
||||
void
|
||||
grub_arch_sync_caches (void *address __attribute__ ((unused)),
|
||||
grub_size_t len __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VASPRINTF
|
||||
|
||||
|
@ -595,6 +600,7 @@ make_system_path_relative_to_its_root (const char *path)
|
|||
return buf3;
|
||||
}
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
void
|
||||
grub_util_init_nls (void)
|
||||
{
|
||||
|
@ -604,3 +610,4 @@ grub_util_init_nls (void)
|
|||
textdomain (PACKAGE);
|
||||
#endif /* ENABLE_NLS */
|
||||
}
|
||||
#endif
|
||||
|
|
237
util/sdl.c
Normal file
237
util/sdl.c
Normal file
|
@ -0,0 +1,237 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define grub_video_render_target grub_video_fbrender_target
|
||||
|
||||
#include <grub/err.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/video_fb.h>
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
static SDL_Surface *window = 0;
|
||||
static struct grub_video_render_target *sdl_render_target;
|
||||
static struct grub_video_mode_info mode_info;
|
||||
|
||||
static grub_err_t
|
||||
grub_video_sdl_set_palette (unsigned int start, unsigned int count,
|
||||
struct grub_video_palette_data *palette_data);
|
||||
|
||||
static grub_err_t
|
||||
grub_video_sdl_init (void)
|
||||
{
|
||||
window = 0;
|
||||
|
||||
if (SDL_Init (SDL_INIT_VIDEO) < 0)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "Couldn't init SDL: %s",
|
||||
SDL_GetError ());
|
||||
|
||||
grub_memset (&mode_info, 0, sizeof (mode_info));
|
||||
|
||||
return grub_video_fb_init ();
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_sdl_fini (void)
|
||||
{
|
||||
SDL_Quit ();
|
||||
window = 0;
|
||||
|
||||
grub_memset (&mode_info, 0, sizeof (mode_info));
|
||||
|
||||
return grub_video_fb_fini ();
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
get_mask_size (grub_uint32_t mask)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; mask > 1U << i; i++);
|
||||
return i;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_sdl_setup (unsigned int width, unsigned int height,
|
||||
unsigned int mode_type, unsigned int mode_mask)
|
||||
{
|
||||
int depth;
|
||||
int flags = 0;
|
||||
grub_err_t err;
|
||||
|
||||
/* Decode depth from mode_type. If it is zero, then autodetect. */
|
||||
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
||||
>> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
|
||||
|
||||
if (depth == 0)
|
||||
depth = 32;
|
||||
|
||||
if (width == 0 && height == 0)
|
||||
{
|
||||
width = 800;
|
||||
height = 600;
|
||||
}
|
||||
|
||||
if ((mode_type & GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED)
|
||||
|| !(mode_mask & GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED))
|
||||
flags |= SDL_DOUBLEBUF;
|
||||
|
||||
window = SDL_SetVideoMode (width, height, depth, flags | SDL_HWSURFACE);
|
||||
if (! window)
|
||||
window = SDL_SetVideoMode (width, height, depth, flags | SDL_SWSURFACE);
|
||||
if (! window)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "Couldn't open window: %s",
|
||||
SDL_GetError ());
|
||||
|
||||
grub_memset (&sdl_render_target, 0, sizeof (sdl_render_target));
|
||||
|
||||
mode_info.width = window->w;
|
||||
mode_info.height = window->h;
|
||||
mode_info.mode_type = 0;
|
||||
if (window->flags & SDL_DOUBLEBUF)
|
||||
mode_info.mode_type
|
||||
|= GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED;
|
||||
if (window->format->palette)
|
||||
mode_info.mode_type |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
|
||||
else
|
||||
mode_info.mode_type |= GRUB_VIDEO_MODE_TYPE_RGB;
|
||||
|
||||
mode_info.bpp = window->format->BitsPerPixel;
|
||||
mode_info.bytes_per_pixel = window->format->BytesPerPixel;
|
||||
mode_info.pitch = window->pitch;
|
||||
|
||||
/* In index color mode, number of colors. In RGB mode this is 256. */
|
||||
if (window->format->palette)
|
||||
mode_info.number_of_colors
|
||||
= 1 << window->format->BitsPerPixel;
|
||||
else
|
||||
mode_info.number_of_colors = 256;
|
||||
|
||||
if (! window->format->palette)
|
||||
{
|
||||
mode_info.red_mask_size
|
||||
= get_mask_size (window->format->Rmask >> window->format->Rshift);
|
||||
mode_info.red_field_pos = window->format->Rshift;
|
||||
mode_info.green_mask_size
|
||||
= get_mask_size (window->format->Gmask >> window->format->Gshift);
|
||||
mode_info.green_field_pos = window->format->Gshift;
|
||||
mode_info.blue_mask_size
|
||||
= get_mask_size (window->format->Bmask >> window->format->Bshift);
|
||||
mode_info.blue_field_pos = window->format->Bshift;
|
||||
mode_info.reserved_mask_size
|
||||
= get_mask_size (window->format->Amask >> window->format->Ashift);
|
||||
mode_info.reserved_field_pos = window->format->Ashift;
|
||||
mode_info.blit_format
|
||||
= grub_video_get_blit_format (&mode_info);
|
||||
}
|
||||
|
||||
err = grub_video_fb_create_render_target_from_pointer (&sdl_render_target,
|
||||
&mode_info,
|
||||
window->pixels);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* Copy default palette to initialize emulated palette. */
|
||||
grub_video_sdl_set_palette (0, (sizeof (grub_video_fbstd_colors)
|
||||
/ sizeof (grub_video_fbstd_colors[0])),
|
||||
grub_video_fbstd_colors);
|
||||
|
||||
/* Reset render target to SDL one. */
|
||||
return grub_video_fb_set_active_render_target (sdl_render_target);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_sdl_set_palette (unsigned int start, unsigned int count,
|
||||
struct grub_video_palette_data *palette_data)
|
||||
{
|
||||
unsigned i;
|
||||
if (window->format->palette)
|
||||
{
|
||||
SDL_Color *tmp = grub_malloc (count * sizeof (tmp[0]));
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
tmp[i].r = palette_data[i].r;
|
||||
tmp[i].g = palette_data[i].g;
|
||||
tmp[i].b = palette_data[i].b;
|
||||
tmp[i].unused = palette_data[i].a;
|
||||
}
|
||||
SDL_SetColors (window, tmp, start, count);
|
||||
grub_free (tmp);
|
||||
}
|
||||
|
||||
return grub_video_fb_set_palette (start, count, palette_data);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_sdl_swap_buffers (void)
|
||||
{
|
||||
if (SDL_Flip (window) < 0)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "couldn't swap buffers: %s",
|
||||
SDL_GetError ());
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_sdl_set_active_render_target (struct grub_video_render_target *target)
|
||||
{
|
||||
if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY)
|
||||
return grub_video_fb_set_active_render_target (sdl_render_target);
|
||||
|
||||
return grub_video_fb_set_active_render_target (target);
|
||||
}
|
||||
|
||||
static struct grub_video_adapter grub_video_sdl_adapter =
|
||||
{
|
||||
.name = "SDL Video Driver",
|
||||
|
||||
.init = grub_video_sdl_init,
|
||||
.fini = grub_video_sdl_fini,
|
||||
.setup = grub_video_sdl_setup,
|
||||
.get_info = grub_video_fb_get_info,
|
||||
.set_palette = grub_video_sdl_set_palette,
|
||||
.get_palette = grub_video_fb_get_palette,
|
||||
.set_viewport = grub_video_fb_set_viewport,
|
||||
.get_viewport = grub_video_fb_get_viewport,
|
||||
.map_color = grub_video_fb_map_color,
|
||||
.map_rgb = grub_video_fb_map_rgb,
|
||||
.map_rgba = grub_video_fb_map_rgba,
|
||||
.unmap_color = grub_video_fb_unmap_color,
|
||||
.fill_rect = grub_video_fb_fill_rect,
|
||||
.blit_bitmap = grub_video_fb_blit_bitmap,
|
||||
.blit_render_target = grub_video_fb_blit_render_target,
|
||||
.scroll = grub_video_fb_scroll,
|
||||
.swap_buffers = grub_video_sdl_swap_buffers,
|
||||
.create_render_target = grub_video_fb_create_render_target,
|
||||
.delete_render_target = grub_video_fb_delete_render_target,
|
||||
.set_active_render_target = grub_video_sdl_set_active_render_target,
|
||||
.get_active_render_target = grub_video_fb_get_active_render_target,
|
||||
|
||||
.next = 0
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT(sdl)
|
||||
{
|
||||
grub_video_register (&grub_video_sdl_adapter);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(sdl)
|
||||
{
|
||||
grub_video_unregister (&grub_video_sdl_adapter);
|
||||
}
|
|
@ -1,300 +0,0 @@
|
|||
/* grub-mkimage.c - make a bootable image */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <grub/types.h>
|
||||
#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>
|
||||
#include <grub/misc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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)
|
||||
{
|
||||
/* No compression support yet. */
|
||||
grub_util_info ("kernel_img=%p, kernel_size=0x%x", kernel_img, kernel_size);
|
||||
*core_img = xmalloc (kernel_size);
|
||||
memcpy (*core_img, kernel_img, kernel_size);
|
||||
*core_size = kernel_size;
|
||||
}
|
||||
|
||||
static void
|
||||
generate_image (const char *dir, const char *prefix, FILE *out, char *mods[], char *memdisk_path)
|
||||
{
|
||||
size_t kernel_size, total_module_size, memdisk_size, core_size, boot_size, offset;
|
||||
char *kernel_path, *kernel_img, *core_img, *boot_path, *boot_img;
|
||||
struct grub_util_path_list *path_list, *p;
|
||||
struct grub_module_info *modinfo;
|
||||
grub_addr_t module_addr;
|
||||
unsigned int num;
|
||||
|
||||
path_list = grub_util_resolve_dependencies (dir, "moddep.lst", mods);
|
||||
|
||||
kernel_path = grub_util_get_path (dir, "kernel.img");
|
||||
kernel_size = grub_util_get_image_size (kernel_path);
|
||||
|
||||
total_module_size = sizeof (struct grub_module_info);
|
||||
for (p = path_list; p; p = p->next)
|
||||
total_module_size += (grub_util_get_image_size (p->name)
|
||||
+ sizeof (struct grub_module_header));
|
||||
|
||||
memdisk_size = 0;
|
||||
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);
|
||||
total_module_size += memdisk_size + sizeof (struct grub_module_header);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if ((GRUB_KERNEL_MACHINE_PREFIX + strlen (prefix) + 1)
|
||||
> GRUB_KERNEL_MACHINE_DATA_END)
|
||||
grub_util_error ("prefix too long");
|
||||
strcpy (kernel_img + GRUB_KERNEL_MACHINE_PREFIX, prefix);
|
||||
|
||||
/* Fill in the grub_module_info structure. */
|
||||
modinfo = (struct grub_module_info *) (kernel_img + kernel_size);
|
||||
modinfo->magic = GRUB_MODULE_MAGIC;
|
||||
modinfo->offset = sizeof (struct grub_module_info);
|
||||
modinfo->size = total_module_size;
|
||||
|
||||
offset = kernel_size + sizeof (struct grub_module_info);
|
||||
for (p = path_list; p; p = p->next)
|
||||
{
|
||||
struct grub_module_header *header;
|
||||
size_t mod_size;
|
||||
|
||||
mod_size = grub_util_get_image_size (p->name);
|
||||
|
||||
header = (struct grub_module_header *) (kernel_img + offset);
|
||||
header->type = OBJ_TYPE_ELF;
|
||||
header->size = grub_host_to_target32 (mod_size + sizeof (*header));
|
||||
offset += sizeof (*header);
|
||||
|
||||
grub_util_load_image (p->name, kernel_img + offset);
|
||||
offset += mod_size;
|
||||
}
|
||||
|
||||
if (memdisk_path)
|
||||
{
|
||||
struct grub_module_header *header;
|
||||
|
||||
header = (struct grub_module_header *) (kernel_img + offset);
|
||||
header->type = OBJ_TYPE_MEMDISK;
|
||||
header->size = grub_host_to_target32 (memdisk_size + sizeof (*header));
|
||||
offset += sizeof (*header);
|
||||
|
||||
grub_util_load_image (memdisk_path, kernel_img + offset);
|
||||
offset += memdisk_size;
|
||||
}
|
||||
|
||||
compress_kernel (kernel_img, kernel_size + total_module_size,
|
||||
&core_img, &core_size);
|
||||
|
||||
grub_util_info ("the core size is 0x%x", core_size);
|
||||
|
||||
num = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
|
||||
num <<= GRUB_DISK_SECTOR_BITS;
|
||||
|
||||
boot_path = grub_util_get_path (dir, "diskboot.img");
|
||||
boot_size = grub_util_get_image_size (boot_path);
|
||||
if (boot_size != GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error ("diskboot.img is not one sector size");
|
||||
|
||||
boot_img = grub_util_read_image (boot_path);
|
||||
|
||||
/* sparc is a big endian architecture. */
|
||||
*((grub_uint32_t *) (boot_img + GRUB_DISK_SECTOR_SIZE
|
||||
- GRUB_BOOT_MACHINE_LIST_SIZE + 8))
|
||||
= grub_cpu_to_be32 (num);
|
||||
|
||||
grub_util_write_image (boot_img, boot_size, out);
|
||||
free (boot_img);
|
||||
free (boot_path);
|
||||
|
||||
module_addr = (path_list
|
||||
? (GRUB_BOOT_MACHINE_IMAGE_ADDRESS + kernel_size)
|
||||
: 0);
|
||||
|
||||
grub_util_info ("the first module address is 0x%x", module_addr);
|
||||
|
||||
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE))
|
||||
= grub_cpu_to_be32 (total_module_size);
|
||||
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE))
|
||||
= grub_cpu_to_be32 (kernel_size);
|
||||
|
||||
/* No compression support yet. */
|
||||
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE))
|
||||
= grub_cpu_to_be32 (0);
|
||||
|
||||
grub_util_write_image (core_img, core_size, out);
|
||||
free (kernel_img);
|
||||
free (core_img);
|
||||
free (kernel_path);
|
||||
|
||||
while (path_list)
|
||||
{
|
||||
struct grub_util_path_list *next = path_list->next;
|
||||
free ((void *) path_list->name);
|
||||
free (path_list);
|
||||
path_list = next;
|
||||
}
|
||||
}
|
||||
|
||||
static struct option options[] =
|
||||
{
|
||||
{"directory", required_argument, 0, 'd'},
|
||||
{"prefix", required_argument, 0, 'p'},
|
||||
{"memdisk", required_argument, 0, 'm'},
|
||||
{"output", required_argument, 0, 'o'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"version", no_argument, 0, 'V'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static void
|
||||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: %s [OPTION]... [MODULES]\n\
|
||||
\n\
|
||||
Make a bootable image of GRUB.\n\
|
||||
\n\
|
||||
-d, --directory=DIR use images and modules under DIR [default=%s]\n\
|
||||
-p, --prefix=DIR set grub_prefix directory [default=%s]\n\
|
||||
-m, --memdisk=FILE embed FILE as a memdisk image\n\
|
||||
-o, --output=FILE output a generated image to FILE [default=stdout]\n\
|
||||
-h, --help display this message and exit\n\
|
||||
-V, --version print version information and exit\n\
|
||||
-v, --verbose print verbose messages\n\
|
||||
\n\
|
||||
Report bugs to <%s>.\n\
|
||||
", program_name, GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
|
||||
|
||||
exit (status);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
char *output = NULL;
|
||||
char *dir = NULL;
|
||||
char *prefix = NULL;
|
||||
char *memdisk = NULL;
|
||||
FILE *fp = stdout;
|
||||
|
||||
set_program_name (argv[0]);
|
||||
|
||||
grub_util_init_nls ();
|
||||
|
||||
while (1)
|
||||
{
|
||||
int c = getopt_long (argc, argv, "d:p:m:o:hVv", options, 0);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
else
|
||||
switch (c)
|
||||
{
|
||||
case 'o':
|
||||
if (output)
|
||||
free (output);
|
||||
output = xstrdup (optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
if (dir)
|
||||
free (dir);
|
||||
dir = xstrdup (optarg);
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
if (memdisk)
|
||||
free (memdisk);
|
||||
memdisk = xstrdup (optarg);
|
||||
|
||||
if (prefix)
|
||||
free (prefix);
|
||||
prefix = xstrdup ("(memdisk)/boot/grub");
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
usage (0);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
if (prefix)
|
||||
free (prefix);
|
||||
prefix = xstrdup (optarg);
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
printf ("grub-mkimage (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
|
||||
return 0;
|
||||
|
||||
case 'v':
|
||||
verbosity++;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (output)
|
||||
{
|
||||
fp = fopen (output, "wb");
|
||||
if (! fp)
|
||||
grub_util_error ("cannot open %s", output);
|
||||
}
|
||||
|
||||
generate_image (dir ? : GRUB_LIBDIR,
|
||||
prefix ? : DEFAULT_DIRECTORY, fp,
|
||||
argv + optind, memdisk);
|
||||
|
||||
fclose (fp);
|
||||
|
||||
if (dir)
|
||||
free (dir);
|
||||
|
||||
return 0;
|
||||
}
|
46
util/time.c
Normal file
46
util/time.c
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/datetime.h>
|
||||
#include <time.h>
|
||||
|
||||
grub_err_t
|
||||
grub_get_datetime (struct grub_datetime *datetime)
|
||||
{
|
||||
struct tm *mytm;
|
||||
time_t mytime;
|
||||
|
||||
mytime = time (&mytime);
|
||||
mytm = gmtime (&mytime);
|
||||
|
||||
datetime->year = mytm->tm_year + 1900;
|
||||
datetime->month = mytm->tm_mon + 1;
|
||||
datetime->day = mytm->tm_mday;
|
||||
datetime->hour = mytm->tm_hour;
|
||||
datetime->minute = mytm->tm_min;
|
||||
datetime->second = mytm->tm_sec;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_set_datetime (struct grub_datetime *datetime __attribute__ ((unused)))
|
||||
{
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"no clock setting routine available");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue