Merge mainline into install

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-09-11 17:28:46 +02:00
commit 76e61597b4
25 changed files with 728 additions and 57 deletions

112
ChangeLog
View file

@ -1,3 +1,115 @@
2010-09-11 Vladimir Serbinenko <phcoder@gmail.com>
2010-09-11 Colin Watson <cjwatson@ubuntu.com>
* util/grub-install.in (grub_partition): New variable.
Set prefix_drive on EFI and PC to (,$grub_partition) as last resort.
* util/i386/pc/grub-setup.c (setup): Don't touch prefix.
Fixes a bug reported by Yves Blusseau.
2010-09-11 Vladimir Serbinenko <phcoder@gmail.com>
Fix emu on mipsel.
* conf/Makefile.common (CFLAGS_PLATFORM): Add -mflush-func
=grub_cpu_flush_cache on all mips and not only yeeloong.
* configure.ac (COND_mips): New conditional.
* grub-core/Makefile.am (KERNEL_HEADER_FILES): Add libgcc on all
platforms.
* grub-core/kern/emu/cache.S (__mips__): Use _flush_cache.
* grub-core/kern/emu/full.c (grub_arch_dl_init_linker)
[GRUB_LINKER_HAVE_INIT]: New function.
(grub_emu_post_init): Likewise.
* grub-core/kern/emu/lite.c (grub_emu_post_init): Likewise.
* grub-core/kern/emu/main.c: Use grub_emu_post_init.
* include/grub/cache.h (_mips): Include mips/cache.h.
* include/grub/disk.h [GRUB_UTIL || GRUB_MACHINE_EMU]: Add missing
LVM and RAID prototypes.
* include/grub/emu/misc.h (grub_emu_post_init): New proto.
* include/grub/mips/time.h (grub_cpu_idle) [GRUB_MACHINE_EMU]: New
function.
2010-09-10 Colin Watson <cjwatson@ubuntu.com>
* util/grub-install.in: Don't try to verify core.img until after
running grub-mkimage to create it.
2010-09-10 Robert Millan <rmh@gnu.org>
* util/grub.d/10_hurd.in: Add misc readability checks.
* util/grub.d/10_kfreebsd.in: Likewise.
* util/grub.d/10_linux.in: Likewise.
2010-09-10 Colin Watson <cjwatson@ubuntu.com>
* util/grub-install.in: ${imgext} won't be defined here until the
install branch is merged. For the meantime, only verify core.img on
i386-pc and sparc64-ieee1275 platforms.
2010-09-10 Robert Millan <rmh@gnu.org>
Solaris support in grub_find_zpool_from_dir(). Thanks
Seth Goldberg for referring to getextmntent() facility.
* configure.ac: Check for getextmntent(), `sys/mnttab.h' and
`sys/mkdev.h'.
* grub-core/kern/emu/misc.c [HAVE_SYS_MNTTAB_H]: Include
`<sys/mnttab.h>'.
[HAVE_SYS_MKDEV_H]: Include `<sys/mkdev.h>'.
[HAVE_GETEXTMNTENT] (grub_find_zpool_from_dir): Add getextmntent()
method for finding zpool name.
2010-09-10 Colin Watson <cjwatson@ubuntu.com>
grub-fstest needs the host and hostfs modules while other utilities
actively require those modules to be absent, so grub-fstest needs
its own initialisation and finalisation code.
* Makefile.am (grub_fstest.pp): New target.
(grub_fstest_init.lst): Likewise.
(grub_fstest_init.c): Likewise.
* Makefile.util.def (grub-fstest): Add grub_fstest_init.c.
2010-09-10 Robert Millan <rmh@gnu.org>
* configure.ac: Check for `struct statfs.f_fstypename' and
`struct statfs.f_mntfromname'.
* grub-core/kern/emu/misc.c (grub_find_zpool_from_dir): Conditionalize
kFreeBSD-specific code.
2010-09-10 Robert Millan <rmh@gnu.org>
* util/grub.d/10_kfreebsd.in: Fix ${kfreebsd_device} initialization
on ZFS. Now non-main filesystems are supported as / too.
2010-09-09 Colin Watson <cjwatson@ubuntu.com>
* Makefile.util.def (libgrub.a): Move grub-core/kern/emu/hostfs.c
and grub-core/disk/host.c to ...
(grub-fstest): ... here. Having the host disk implementation
present confuses grub-probe and other utility programs.
* util/grub-mkconfig.in: Only verify readability of grub.cfg.new
when writing to a file, not when writing to stdout.
2010-09-09 BVK Chaitanya <bvk.groups@gmail.com>
* tests/partmap_test.in: New test for partitions.
* Makefile.util.def: Rules for new test.
2010-09-09 Robert Millan <rmh@gnu.org>
* util/grub-probe.c (probe): Fix a pair of unhandled error
conditions.
2010-09-09 Robert Millan <rmh@gnu.org>
Basic Btrfs support (detection and UUID).
* grub-core/fs/btrfs.c: New file.
* Makefile.util.def (library): Register btrfs.c.
* grub-core/Makefile.core.def: Likewise.
2010-09-08 Robert Millan <rmh@gnu.org> 2010-09-08 Robert Millan <rmh@gnu.org>
* util/grub-mkconfig_lib.in (is_path_readable_by_grub): Improve * util/grub-mkconfig_lib.in (is_path_readable_by_grub): Improve

View file

@ -44,6 +44,20 @@ libgrub_a_init.c: libgrub_a_init.lst $(top_srcdir)/geninit.sh
sh $(top_srcdir)/geninit.sh `cat $<` > $@ || (rm -f $@; exit 1) sh $(top_srcdir)/geninit.sh `cat $<` > $@ || (rm -f $@; exit 1)
CLEANFILES += libgrub_a_init.c CLEANFILES += libgrub_a_init.c
# For grub-fstest
grub_fstest.pp: $(grub_fstest_SOURCES)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_fstest_CPPFLAGS) $(CPPFLAGS) \
-D'GRUB_MOD_INIT(x)=@MARKER@x@' $^ > $@ || (rm -f $@; exit 1)
CLEANFILES += grub_fstest.pp
grub_fstest_init.lst: libgrub.pp grub_fstest.pp
cat $^ | grep '@MARKER@' | sed 's/@MARKER@\(.*\)@/\1/g' | sort -u > $@ || (rm -f $@; exit 1)
CLEANFILES += grub_fstest_init.lst
grub_fstest_init.c: grub_fstest_init.lst $(top_srcdir)/geninit.sh
sh $(top_srcdir)/geninit.sh `cat $<` > $@ || (rm -f $@; exit 1)
CLEANFILES += grub_fstest_init.c
if COND_GRUB_MKFONT if COND_GRUB_MKFONT
if COND_HAVE_FONT_SOURCE if COND_HAVE_FONT_SOURCE
grubdata_DATA = unicode.pf2 ascii.pf2 ascii.h widthspec.h grubdata_DATA = unicode.pf2 ascii.pf2 ascii.h widthspec.h

View file

@ -23,7 +23,6 @@ library = {
common = grub-core/kern/misc.c; common = grub-core/kern/misc.c;
common = grub-core/kern/emu/mm.c; common = grub-core/kern/emu/mm.c;
common = grub-core/kern/emu/misc.c; common = grub-core/kern/emu/misc.c;
common = grub-core/kern/emu/hostfs.c;
common = grub-core/kern/emu/getroot.c; common = grub-core/kern/emu/getroot.c;
common = grub-core/kern/emu/hostdisk.c; common = grub-core/kern/emu/hostdisk.c;
@ -31,7 +30,6 @@ library = {
common = grub-core/commands/extcmd.c; common = grub-core/commands/extcmd.c;
common = grub-core/commands/ls.c; common = grub-core/commands/ls.c;
common = grub-core/disk/dmraid_nvidia.c; common = grub-core/disk/dmraid_nvidia.c;
common = grub-core/disk/host.c;
common = grub-core/disk/loopback.c; common = grub-core/disk/loopback.c;
common = grub-core/disk/lvm.c; common = grub-core/disk/lvm.c;
common = grub-core/disk/mdraid_linux.c; common = grub-core/disk/mdraid_linux.c;
@ -43,6 +41,7 @@ library = {
common = grub-core/fs/afs.c; common = grub-core/fs/afs.c;
common = grub-core/fs/befs_be.c; common = grub-core/fs/befs_be.c;
common = grub-core/fs/befs.c; common = grub-core/fs/befs.c;
common = grub-core/fs/btrfs.c;
common = grub-core/fs/cpio.c; common = grub-core/fs/cpio.c;
common = grub-core/fs/ext2.c; common = grub-core/fs/ext2.c;
common = grub-core/fs/fat.c; common = grub-core/fs/fat.c;
@ -180,7 +179,10 @@ program = {
program = { program = {
name = grub-fstest; name = grub-fstest;
mansection = 1; mansection = 1;
common_nodist = grub_fstest_init.c;
common = util/grub-fstest.c; common = util/grub-fstest.c;
common = grub-core/kern/emu/hostfs.c;
common = grub-core/disk/host.c;
ldadd = libgrub.a; ldadd = libgrub.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER)'; ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
@ -527,6 +529,12 @@ script = {
common = tests/grub_script_not.in; common = tests/grub_script_not.in;
}; };
script = {
testcase;
name = partmap_test;
common = tests/partmap_test.in;
};
program = { program = {
testcase; testcase;
name = example_unit_test; name = example_unit_test;

View file

@ -1,8 +1,10 @@
# -*- makefile -*- # -*- makefile -*-
CFLAGS_PLATFORM=
# Platform specific options # Platform specific options
if COND_i386_pc if COND_i386_pc
CFLAGS_PLATFORM = -mrtd -mregparm=3 CFLAGS_PLATFORM += -mrtd -mregparm=3
endif endif
if COND_i386_efi if COND_i386_efi
LDFLAGS_PLATFORM = -melf_i386 LDFLAGS_PLATFORM = -melf_i386
@ -11,21 +13,24 @@ if COND_x86_64_efi
LDFLAGS_PLATFORM = -melf_x86_64 LDFLAGS_PLATFORM = -melf_x86_64
endif endif
if COND_i386_qemu if COND_i386_qemu
CFLAGS_PLATFORM = -mrtd -mregparm=3 CFLAGS_PLATFORM += -mrtd -mregparm=3
endif endif
if COND_i386_coreboot if COND_i386_coreboot
CFLAGS_PLATFORM = -mrtd -mregparm=3 CFLAGS_PLATFORM += -mrtd -mregparm=3
endif endif
if COND_i386_ieee1275 if COND_i386_ieee1275
CFLAGS_PLATFORM = -mrtd -mregparm=3 CFLAGS_PLATFORM += -mrtd -mregparm=3
endif endif
if COND_mips_yeeloong if COND_mips_yeeloong
CFLAGS_PLATFORM = -march=mips3 -mexplicit-relocs -mflush-func=grub_cpu_flush_cache CFLAGS_PLATFORM += -march=mips3 -mexplicit-relocs
CPPFLAGS_PLATFORM = -DUSE_ASCII_FAILBACK CPPFLAGS_PLATFORM = -DUSE_ASCII_FAILBACK
CCASFLAGS_PLATFORM = -march=mips3 CCASFLAGS_PLATFORM = -march=mips3
endif endif
if COND_mips
CFLAGS_PLATFORM += -mflush-func=grub_cpu_flush_cache
endif
if COND_sparc64_ieee1275 if COND_sparc64_ieee1275
CFLAGS_PLATFORM = -mno-app-regs CFLAGS_PLATFORM += -mno-app-regs
LDFLAGS_PLATFORM = -melf64_sparc -mno-relax LDFLAGS_PLATFORM = -melf64_sparc -mno-relax
endif endif

View file

@ -277,8 +277,16 @@ else
fi fi
# Check for functions and headers. # Check for functions and headers.
AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf) AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf getextmntent)
AC_CHECK_HEADERS(libzfs.h libnvpair.h sys/param.h sys/mount.h) AC_CHECK_HEADERS(libzfs.h libnvpair.h sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h)
AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
#include <sys/param.h>
#include <sys/mount.h>])
AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
#include <sys/param.h>
#include <sys/mount.h>])
# For opendisk() and getrawpartition() on NetBSD. # For opendisk() and getrawpartition() on NetBSD.
# Used in util/deviceiter.c and in util/hostdisk.c. # Used in util/deviceiter.c and in util/hostdisk.c.
@ -892,6 +900,7 @@ AM_CONDITIONAL([COND_mips_yeeloong], [test x$target_cpu = xmips -a x$platform =
AM_CONDITIONAL([COND_mips_qemu_mips], [test x$target_cpu = xmips -a x$platform = xqemu_mips]) AM_CONDITIONAL([COND_mips_qemu_mips], [test x$target_cpu = xmips -a x$platform = xqemu_mips])
AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275]) AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275]) AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips])
AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd]) AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux]) AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])

View file

@ -74,6 +74,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
if COND_i386_pc if COND_i386_pc
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
@ -132,7 +133,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bitmap_scale.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bitmap_scale.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cs5536.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cs5536.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pci.h KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pci.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/serial.h KERNEL_HEADER_FILES += $(top_builddir)/include/grub/serial.h
@ -140,11 +140,9 @@ endif
if COND_powerpc_ieee1275 if COND_powerpc_ieee1275
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
endif endif
if COND_sparc64_ieee1275 if COND_sparc64_ieee1275
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sparc64/ieee1275/ieee1275.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sparc64/ieee1275/ieee1275.h
endif endif

View file

@ -835,6 +835,11 @@ module = {
common = fs/befs_be.c; common = fs/befs_be.c;
}; };
module = {
name = btrfs;
common = fs/btrfs.c;
};
module = { module = {
name = cpio; name = cpio;
common = fs/cpio.c; common = fs/cpio.c;

132
grub-core/fs/btrfs.c Normal file
View file

@ -0,0 +1,132 @@
/* btrfs.c - B-tree file system. */
/*
* 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/err.h>
#include <grub/file.h>
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/disk.h>
#include <grub/dl.h>
#include <grub/types.h>
#define BTRFS_SIGNATURE "_BHRfS_M"
struct btrfs_superblock
{
grub_uint8_t dummy1[32];
grub_uint16_t uuid[8];
grub_uint8_t dummy2[16];
grub_uint8_t signature[sizeof (BTRFS_SIGNATURE) - 1];
} __attribute__ ((packed));
struct grub_btrfs_data
{
struct btrfs_superblock sblock;
};
static struct grub_btrfs_data *
grub_btrfs_mount (grub_disk_t disk)
{
struct grub_btrfs_data *data = grub_malloc (sizeof (*data));
if (! data)
return NULL;
if (grub_disk_read (disk, 128, 0, sizeof (data->sblock),
&data->sblock) != GRUB_ERR_NONE)
goto fail;
if (grub_strncmp ((char *) data->sblock.signature, BTRFS_SIGNATURE, sizeof (BTRFS_SIGNATURE) - 1))
{
grub_error (GRUB_ERR_BAD_FS, "not a Btrfs filesystem");
goto fail;
}
return data;
fail:
grub_free (data);
return NULL;
}
static grub_err_t
grub_btrfs_open (struct grub_file *file __attribute__ ((unused)),
const char *name __attribute__ ((unused)))
{
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "only detection is supported for Btrfs");
}
static grub_err_t
grub_btrfs_dir (grub_device_t device,
const char *path __attribute__ ((unused)),
int (*hook) (const char *filename,
const struct grub_dirhook_info *info)
__attribute__ ((unused)))
{
struct grub_btrfs_data *data = grub_btrfs_mount (device->disk);
if (grub_errno)
return grub_errno;
grub_free (data);
return GRUB_ERR_NONE;
}
static grub_err_t
grub_btrfs_uuid (grub_device_t device, char **uuid)
{
struct grub_btrfs_data *data;
*uuid = NULL;
data = grub_btrfs_mount (device->disk);
if (! data)
return grub_errno;
*uuid = grub_xasprintf ("%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
grub_be_to_cpu16 (data->sblock.uuid[0]),
grub_be_to_cpu16 (data->sblock.uuid[1]),
grub_be_to_cpu16 (data->sblock.uuid[2]),
grub_be_to_cpu16 (data->sblock.uuid[3]),
grub_be_to_cpu16 (data->sblock.uuid[4]),
grub_be_to_cpu16 (data->sblock.uuid[5]),
grub_be_to_cpu16 (data->sblock.uuid[6]),
grub_be_to_cpu16 (data->sblock.uuid[7]));
grub_free (data);
return grub_errno;
}
static struct grub_fs grub_btrfs_fs =
{
.name = "btrfs",
.dir = grub_btrfs_dir,
.open = grub_btrfs_open,
.uuid = grub_btrfs_uuid,
};
GRUB_MOD_INIT(btrfs)
{
grub_fs_register (&grub_btrfs_fs);
}
GRUB_MOD_FINI(btrfs)
{
grub_fs_unregister (&grub_btrfs_fs);
}

View file

@ -7,7 +7,20 @@
#elif defined(__sparc__) #elif defined(__sparc__)
#include "../sparc64/cache.S" #include "../sparc64/cache.S"
#elif defined(__mips__) #elif defined(__mips__)
#include "../mips/cache.S" /* On MIPS we must go through standard functions. */
#include <grub/symbol.h>
FUNCTION (grub_cpu_flush_cache)
FUNCTION (grub_arch_sync_caches)
.set nomacro
.set noreorder
lui $t0, %hi(_flush_cache)
addui $t0, $t0, %lo(_flush_cache)
move $a3, $zero
jr $t0
nop
.set reorder
.set macro
#elif defined(__powerpc__) #elif defined(__powerpc__)
#include "../powerpc/cache.S" #include "../powerpc/cache.S"
#else #else

View file

@ -22,6 +22,7 @@
#include <grub/kernel.h> #include <grub/kernel.h>
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/emu/misc.h> #include <grub/emu/misc.h>
#include <grub/disk.h>
void void
grub_register_exported_symbols (void) grub_register_exported_symbols (void)
@ -48,3 +49,21 @@ grub_emu_init (void)
{ {
grub_no_autoload = 1; grub_no_autoload = 1;
} }
#ifdef GRUB_LINKER_HAVE_INIT
void
grub_arch_dl_init_linker (void)
{
}
#endif
void
grub_emu_post_init (void)
{
grub_lvm_fini ();
grub_mdraid_fini ();
grub_raid_fini ();
grub_raid_init ();
grub_mdraid_init ();
grub_lvm_init ();
}

View file

@ -38,3 +38,8 @@ grub_emu_init (void)
{ {
return; return;
} }
void
grub_emu_post_init (void)
{
}

View file

@ -197,12 +197,7 @@ main (int argc, char *argv[])
grub_init_all (); grub_init_all ();
grub_lvm_fini (); grub_emu_post_init ();
grub_mdraid_fini ();
grub_raid_fini ();
grub_raid_init ();
grub_mdraid_init ();
grub_lvm_init ();
/* Make sure that there is a root device. */ /* Make sure that there is a root device. */
if (! root_dev) if (! root_dev)

View file

@ -61,6 +61,15 @@
# include <sys/mount.h> # include <sys/mount.h>
#endif #endif
#ifdef HAVE_SYS_MNTTAB_H
# include <stdio.h> /* Needed by sys/mnttab.h. */
# include <sys/mnttab.h>
#endif
#ifdef HAVE_SYS_MKDEV_H
# include <sys/mkdev.h> /* makedev */
#endif
int verbosity; int verbosity;
void void
@ -282,18 +291,52 @@ grub_get_libzfs_handle (void)
void void
grub_find_zpool_from_dir (const char *dir, char **poolname, char **poolfs) grub_find_zpool_from_dir (const char *dir, char **poolname, char **poolfs)
{ {
struct statfs mnt;
char *slash; char *slash;
*poolname = *poolfs = NULL; *poolname = *poolfs = NULL;
if (statfs (dir, &mnt) != 0) #if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) && defined(HAVE_STRUCT_STATFS_F_MNTFROMNAME)
return; /* FreeBSD and GNU/kFreeBSD. */
{
struct statfs mnt;
if (strcmp (mnt.f_fstypename, "zfs") != 0) if (statfs (dir, &mnt) != 0)
return; return;
*poolname = xstrdup (mnt.f_mntfromname); if (strcmp (mnt.f_fstypename, "zfs") != 0)
return;
*poolname = xstrdup (mnt.f_mntfromname);
}
#elif defined(HAVE_GETEXTMNTENT)
/* Solaris. */
{
struct stat st;
struct extmnttab mnt;
if (stat (dir, &st) != 0)
return;
FILE *mnttab = fopen ("/etc/mnttab", "r");
if (! mnttab)
return;
while (getextmntent (mnttab, &mnt, sizeof (mnt)) == 0)
{
if (makedev (mnt.mnt_major, mnt.mnt_minor) == st.st_dev
&& !strcmp (mnt.mnt_fstype, "zfs"))
{
*poolname = xstrdup (mnt.mnt_special);
break;
}
}
fclose (mnttab);
}
#endif
if (! *poolname)
return;
slash = strchr (*poolname, '/'); slash = strchr (*poolname, '/');
if (slash) if (slash)

View file

@ -23,6 +23,10 @@
#include <grub/symbol.h> #include <grub/symbol.h>
#include <grub/types.h> #include <grub/types.h>
#ifdef _mips
#include <grub/mips/cache.h>
#endif
#if defined (__i386__) || defined (__x86_64__) #if defined (__i386__) || defined (__x86_64__)
static inline void static inline void
grub_arch_sync_caches (void *address __attribute__ ((unused)), grub_arch_sync_caches (void *address __attribute__ ((unused)),

View file

@ -177,4 +177,13 @@ struct grub_disk_ata_pass_through_parms
extern grub_err_t (* EXPORT_VAR(grub_disk_ata_pass_through)) (grub_disk_t, extern grub_err_t (* EXPORT_VAR(grub_disk_ata_pass_through)) (grub_disk_t,
struct grub_disk_ata_pass_through_parms *); struct grub_disk_ata_pass_through_parms *);
#if defined (GRUB_UTIL) || defined (GRUB_MACHINE_EMU)
void grub_lvm_init (void);
void grub_mdraid_init (void);
void grub_raid_init (void);
void grub_lvm_fini (void);
void grub_mdraid_fini (void);
void grub_raid_fini (void);
#endif
#endif /* ! GRUB_DISK_HEADER */ #endif /* ! GRUB_DISK_HEADER */

View file

@ -45,6 +45,7 @@ extern const char *program_name;
void grub_emu_init (void); void grub_emu_init (void);
void grub_init_all (void); void grub_init_all (void);
void grub_fini_all (void); void grub_fini_all (void);
void grub_emu_post_init (void);
void grub_find_zpool_from_dir (const char *dir, void grub_find_zpool_from_dir (const char *dir,
char **poolname, char **poolfs); char **poolname, char **poolfs);

View file

@ -0,0 +1,6 @@
#ifdef GRUB_MACHINE_EMU
static inline void
grub_cpu_idle(void)
{
}
#endif

274
tests/partmap_test.in Normal file
View file

@ -0,0 +1,274 @@
#! /bin/sh -e
#
# 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/>.
parted=/sbin/parted
grubshell=@builddir@/grub-shell
create_disk_image () {
name=$1
size=$2
qemu-img create ${name} ${size} >/dev/null
}
check_output () {
outfile=$1
shift
for disk in $@; do
if ! grep "($disk)" ${outfile} >/dev/null
then
echo "($disk): disk/partiton not found"
exit 1
fi
done
}
list_parts () {
mod=$1;
shift;
imgfile=$1
shift
outfile=$1
shift
echo ls | ${grubshell} --boot=cd --qemu-opts="-hda ${imgfile}" \
--modules=$mod | tr -d "\n\r" > ${outfile}
cat ${outfile}
echo
}
imgfile=`mktemp`
outfile=`mktemp`
#
# MSDOS partition types
#
echo "Checking MSDOS partition types..."
# 0 primary
create_disk_image ${imgfile} 64M
${parted} -a none -s ${imgfile} mklabel msdos
list_parts part_msdos ${imgfile} ${outfile}
check_output ${outfile} hd0
# 1 primary
create_disk_image ${imgfile} 64M
${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M
list_parts part_msdos ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,msdos1
# 2 primary
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M
list_parts part_msdos ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,msdos1 hd0,msdos2
# 3 primary
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart primary 20M 30M
list_parts part_msdos ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,msdos1 hd0,msdos2 hd0,msdos3
# 4 primary
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M
list_parts part_msdos ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,msdos1 hd0,msdos2 hd0,msdos3 hd0,msdos4
# 1 primary, 1 extended
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100%
list_parts part_msdos ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,msdos1
# 1 primary, 1 extended, 1 logical
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100% mkpart logical 20M 30M
list_parts part_msdos ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,msdos1 hd0,msdos5
# 1 primary, 1 extended, 2 logical
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100% mkpart logical 20M 30M mkpart logical 30M 40M
list_parts part_msdos ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,msdos1 hd0,msdos5 hd0,msdos6
# 1 primary, 1 extended, 3 logical
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100% mkpart logical 20M 30M mkpart logical 30M 40M mkpart logical 40M 50M
list_parts part_msdos ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,msdos1 hd0,msdos5 hd0,msdos6 hd0,msdos7
# 1 primary, 1 extended, 4 logical
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100% mkpart logical 20M 30M mkpart logical 30M 40M mkpart logical 40M 50M mkpart logical 50M 60M
list_parts part_msdos ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,msdos1 hd0,msdos5 hd0,msdos6 hd0,msdos7 hd0,msdos8
#
# GPT partition types
#
echo "Checking GPT partition types..."
# 0 parts
create_disk_image ${imgfile} 64M
${parted} -a none -s ${imgfile} mklabel gpt
list_parts part_gpt ${imgfile} ${outfile}
check_output ${outfile} hd0
# 1 parts
create_disk_image ${imgfile} 64M
${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M
list_parts part_gpt ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,gpt1
# 2 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M
list_parts part_gpt ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2
# 3 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M mkpart 3 20M 30M
list_parts part_gpt ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2 hd0,gpt3
# 4 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M mkpart 4 20M 30M mkpart 5 30M 40M
list_parts part_gpt ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2 hd0,gpt3 hd0,gpt4
# 5 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M mkpart 3 20M 30M mkpart 4 30M 40M mkpart 5 40M 50M
list_parts part_gpt ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2 hd0,gpt3 hd0,gpt4 hd0,gpt5
# 6 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M mkpart 3 20M 30M mkpart 4 30M 40M mkpart 5 40M 50M mkpart 6 50M 60M
list_parts part_gpt ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2 hd0,gpt3 hd0,gpt4 hd0,gpt5 hd0,gpt6
#
# SUN partition types
#
# It seems partition #3 is reserved for whole disk by parted.
#
echo "Checking SUN partition types..."
# 0 parts
create_disk_image ${imgfile} 64M
${parted} -a none -s ${imgfile} mklabel sun
list_parts part_sun ${imgfile} ${outfile}
check_output ${outfile} hd0
# 1 parts
create_disk_image ${imgfile} 64M
${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M
list_parts part_sun ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,sun1
# 2 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M mkpart 10M 20M
list_parts part_sun ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,sun1 hd0,sun2
# 3 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M
list_parts part_sun ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,sun1 hd0,sun2 hd0,sun4
# 4 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M mkpart 30M 40M
list_parts part_sun ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,sun1 hd0,sun2 hd0,sun4 hd0,sun5
# 5 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M mkpart 30M 40M mkpart 40M 50M
list_parts part_sun ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,sun1 hd0,sun2 hd0,sun4 hd0,sun5 hd0,sun6
# 6 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M mkpart 30M 40M mkpart 40M 50M mkpart 50M 60M
list_parts part_sun ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,sun1 hd0,sun2 hd0,sun4 hd0,sun5 hd0,sun6 hd0,sun7
#
# Apple partition types
#
# Partition table itself is part of some partition, so there is always
# a partition by default. But I don't understand why GRUB displays
# two partitions by default :-(
#
echo "Checking APPLE partition types..."
# 0 parts
create_disk_image ${imgfile} 64M
${parted} -a none -s ${imgfile} mklabel mac
list_parts part_apple ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,apple1 hd0,apple2
# 1 parts
create_disk_image ${imgfile} 64M
${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M
list_parts part_apple ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple3
# 2 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M mkpart b 10M 20M
list_parts part_apple ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple3 hd0,apple4
# 3 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M
list_parts part_apple ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple4 hd0,apple5
# 4 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M mkpart d 30M 40M
list_parts part_apple ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple4 hd0,apple5 hd0,apple6
# 5 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M mkpart d 30M 40M mkpart e 40M 50M
list_parts part_apple ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple4 hd0,apple5 hd0,apple6 hd0,apple7
# 6 parts
create_disk_image ${imgfile} 128M
${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M mkpart d 30M 40M mkpart e 40M 50M mkpart f 50M 60M
list_parts part_apple ${imgfile} ${outfile}
check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple4 hd0,apple5 hd0,apple6 hd0,apple7 hd0,apple8

View file

@ -527,9 +527,8 @@ if [ "x${devabstraction_module}" = "x" ] ; then
echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg
config_opt="-c ${grubdir}/load.cfg " config_opt="-c ${grubdir}/load.cfg "
modules="$modules search_fs_uuid" modules="$modules search_fs_uuid"
elif [ "x$platform" = xefi ]; then elif [ "x$platform" = xefi ] || [ "x$platform" = xpc ]; then
# No grub-setup, so we need to hardcode the partition number in the # we need to hardcode the partition number in the core image's prefix.
# core image's prefix.
prefix_drive="(,$grub_partition)" prefix_drive="(,$grub_partition)"
fi fi
else else
@ -562,7 +561,7 @@ elif [ "${target_cpu}-${platform}" = "i386-efi" ] || [ "${target_cpu}-${platform
fi fi
# Verify readability of a few critical files # Verify readability of a few critical files
for file in grubenv core.${imgext} normal.mod ; do for file in grubenv normal.mod core.${imgext} ; do
if is_path_readable_by_grub ${grubdir}/${file} ${grub_device} ${relative_grubdir}/${file} ; then : ; else if is_path_readable_by_grub ${grubdir}/${file} ${grub_device} ${relative_grubdir}/${file} ; then : ; else
echo "GRUB is unable to read ${grubdir}/${file}" >&2 echo "GRUB is unable to read ${grubdir}/${file}" >&2
exit 1 exit 1

View file

@ -304,9 +304,11 @@ for i in ${grub_mkconfig_dir}/* ; do
done done
# Verify readability of ${grub_cfg}.new # Verify readability of ${grub_cfg}.new
if is_path_readable_by_grub ${grub_cfg}.new ; then : ; else if test "x${grub_cfg}" != "x"; then
echo "GRUB is unable to read ${grubdir}/${file}" >&2 if is_path_readable_by_grub ${grub_cfg}.new ; then : ; else
exit 1 echo "GRUB is unable to read ${grubdir}/${file}" >&2
exit 1
fi
fi fi
if test "x${grub_cfg}" != "x" ; then if test "x${grub_cfg}" != "x" ; then

View file

@ -234,7 +234,8 @@ probe (const char *path, char *device_name)
if (! fs->uuid) if (! fs->uuid)
grub_util_error ("%s does not support UUIDs", fs->name); grub_util_error ("%s does not support UUIDs", fs->name);
fs->uuid (dev, &uuid); if (fs->uuid (dev, &uuid) != GRUB_ERR_NONE)
grub_util_error ("%s", grub_errmsg);
printf ("%s\n", uuid); printf ("%s\n", uuid);
} }
@ -244,7 +245,8 @@ probe (const char *path, char *device_name)
if (! fs->label) if (! fs->label)
grub_util_error ("%s does not support labels", fs->name); grub_util_error ("%s does not support labels", fs->name);
fs->label (dev, &label); if (fs->label (dev, &label) != GRUB_ERR_NONE)
grub_util_error ("%s", grub_errmsg);
printf ("%s\n", label); printf ("%s\n", label);
} }

View file

@ -41,6 +41,14 @@ for i in /boot/gnumach* ; do
basename=`basename $i` basename=`basename $i`
dirname=`dirname $i` dirname=`dirname $i`
rel_dirname=`make_system_path_relative_to_its_root $dirname` rel_dirname=`make_system_path_relative_to_its_root $dirname`
if ! is_path_readable_by_grub ${dirname}/${basename} \
${GRUB_DEVICE_BOOT} \
${rel_dirname}/${basename} ; then
echo "${dirname}/${basename} is not readable by GRUB" >&2
exit 1
fi
echo "Found GNU Mach: $i" >&2 echo "Found GNU Mach: $i" >&2
kernels="${kernels} ${rel_dirname}/${basename}" kernels="${kernels} ${rel_dirname}/${basename}"
at_least_one=true at_least_one=true

View file

@ -44,7 +44,7 @@ load_kfreebsd_module ()
mod="$1" mod="$1"
allow_fail="$2" allow_fail="$2"
if ! test -e "${module_dir}/${mod}.ko" ; then if ! is_path_readable_by_grub "${module_dir}/${mod}.ko" ; then
if [ "${allow_fail}" = "true" ] ; then if [ "${allow_fail}" = "true" ] ; then
# Return silently # Return silently
return return
@ -77,6 +77,13 @@ kfreebsd_entry ()
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
fi fi
if ! is_path_readable_by_grub ${dirname}/${basename} \
${GRUB_DEVICE_BOOT} \
${rel_dirname}/${basename} ; then
echo "${dirname}/${basename} is not readable by GRUB" >&2
exit 1
fi
printf '%s\n' "${prepare_boot_cache}" printf '%s\n' "${prepare_boot_cache}"
cat << EOF cat << EOF
echo '$(printf "$(gettext_quoted "Loading kernel of FreeBSD %s ...")" ${version})' echo '$(printf "$(gettext_quoted "Loading kernel of FreeBSD %s ...")" ${version})'
@ -95,7 +102,13 @@ EOF
zfs) zfs)
load_kfreebsd_module opensolaris false load_kfreebsd_module opensolaris false
ls "${dirname}/zfs/zpool.cache" > /dev/null if ! is_path_readable_by_grub ${dirname}/zfs/zpool.cache \
${GRUB_DEVICE_BOOT} \
${rel_dirname}/zfs/zpool.cache ; then
echo "${dirname}/zfs/zpool.cache is not readable by GRUB" >&2
exit 1
fi
printf '%s\n' "${prepare_boot_cache}" printf '%s\n' "${prepare_boot_cache}"
cat << EOF cat << EOF
kfreebsd_module ${rel_dirname}/zfs/zpool.cache type=/boot/zfs/zpool.cache kfreebsd_module ${rel_dirname}/zfs/zpool.cache type=/boot/zfs/zpool.cache
@ -138,7 +151,12 @@ while [ "x$list" != "x" ] ; do
esac esac
case ${GRUB_FS} in case ${GRUB_FS} in
zfs) kfreebsd_device=$(grub-probe -t fs_label --device ${GRUB_DEVICE}) ;; zfs)
# zpool name
kfreebsd_device=$(grub-probe -t fs_label --device ${GRUB_DEVICE})
# filesystem name (empty string for the main filesystem)
kfreebsd_device="${kfreebsd_device}$(grub-mkrelpath / | sed -e "s,/*@$,,")"
;;
*) kfreebsd_device=${GRUB_DEVICE} ;; *) kfreebsd_device=${GRUB_DEVICE} ;;
esac esac

View file

@ -83,6 +83,15 @@ EOF
EOF EOF
fi fi
for i in ${basename} ${initrd} ; do
if ! is_path_readable_by_grub ${dirname}/${i} \
${GRUB_DEVICE_BOOT} \
${rel_dirname}/${i} ; then
echo "${dirname}/${i} is not readable by GRUB" >&2
exit 1
fi
done
if [ -z "${prepare_boot_cache}" ]; then if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
fi fi

View file

@ -81,8 +81,6 @@ setup (const char *dir,
struct grub_boot_blocklist *first_block, *block; struct grub_boot_blocklist *first_block, *block;
grub_int32_t *install_dos_part, *install_bsd_part; grub_int32_t *install_dos_part, *install_bsd_part;
grub_int32_t dos_part, bsd_part; grub_int32_t dos_part, bsd_part;
char *install_prefix;
char *prefix = NULL;
char *tmp_img; char *tmp_img;
int i; int i;
grub_disk_addr_t first_sector; grub_disk_addr_t first_sector;
@ -214,8 +212,6 @@ setup (const char *dir,
+ GRUB_KERNEL_MACHINE_INSTALL_DOS_PART); + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART);
install_bsd_part = (grub_int32_t *) (core_img + GRUB_DISK_SECTOR_SIZE install_bsd_part = (grub_int32_t *) (core_img + GRUB_DISK_SECTOR_SIZE
+ GRUB_KERNEL_MACHINE_INSTALL_BSD_PART); + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART);
install_prefix = (char *) (core_img + GRUB_DISK_SECTOR_SIZE +
GRUB_KERNEL_MACHINE_PREFIX);
/* Open the root device and the destination device. */ /* Open the root device and the destination device. */
root_dev = grub_device_open (root); root_dev = grub_device_open (root);
@ -291,16 +287,6 @@ setup (const char *dir,
dos_part = root_dev->disk->partition->number; dos_part = root_dev->disk->partition->number;
bsd_part = -1; bsd_part = -1;
} }
if (install_prefix[0] != '(')
{
char *root_part_name;
root_part_name =
grub_partition_get_name (root_dev->disk->partition);
prefix = xasprintf ("(,%s)%s", root_part_name, install_prefix);
free (root_part_name);
}
} }
else else
dos_part = bsd_part = -1; dos_part = bsd_part = -1;
@ -389,8 +375,6 @@ setup (const char *dir,
*install_dos_part = grub_cpu_to_le32 (dos_part); *install_dos_part = grub_cpu_to_le32 (dos_part);
*install_bsd_part = grub_cpu_to_le32 (bsd_part); *install_bsd_part = grub_cpu_to_le32 (bsd_part);
if (prefix)
strcpy (install_prefix, prefix);
/* The first blocklist contains the whole sectors. */ /* The first blocklist contains the whole sectors. */
first_block->start = grub_cpu_to_le64 (embed_region.start + 1); first_block->start = grub_cpu_to_le64 (embed_region.start + 1);
@ -553,8 +537,6 @@ unable_to_embed:
*install_dos_part = grub_cpu_to_le32 (dos_part); *install_dos_part = grub_cpu_to_le32 (dos_part);
*install_bsd_part = grub_cpu_to_le32 (bsd_part); *install_bsd_part = grub_cpu_to_le32 (bsd_part);
if (prefix)
strcpy (install_prefix, prefix);
/* Write the first two sectors of the core image onto the disk. */ /* Write the first two sectors of the core image onto the disk. */
grub_util_info ("opening the core image `%s'", core_path); grub_util_info ("opening the core image `%s'", core_path);
@ -574,7 +556,6 @@ unable_to_embed:
/* Sync is a Good Thing. */ /* Sync is a Good Thing. */
sync (); sync ();
free (prefix);
free (core_path); free (core_path);
free (core_img); free (core_img);
free (boot_img); free (boot_img);