Merge mainline into install

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-09-11 16:38:37 +02:00
commit 038272a5c5
13 changed files with 203 additions and 159 deletions

View file

@ -7,6 +7,42 @@
* util/grub-mkconfig.in: Use is_path_readable_by_grub() to
verify readability of grub.cfg.new.
2010-09-08 Vladimir Serbinenko <phcoder@gmail.com>
Split minix.mod into minix.mod and minix2.mod.
* Makefile.util.def (libgrub.a): Add grub-core/fs/minix2.c.
* grub-core/Makefile.core.def (minix2): New module.
* grub-core/fs/minix.c: Use definitions instead of runtime version
checking.
* grub-core/fs/minix2.c: New file.
2010-09-08 Yves Blusseau <blusseau@zetam.org>
Add new --boot-directory option to replace --root-directory
* util/grub-install.in: Add new --boot-directory option
* util/grub-reboot.in: Likewise.
* util/grub-set-default.in: Likewise.
2010-09-08 Yves Blusseau <blusseau@zetam.org>
* util/grub-mkconfig.in: Use new variable.
2010-09-08 Yves Blusseau <blusseau@zetam.org>
* configure.ac: Define some useful variables.
2010-09-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/ieee1275/cmain.c (grub_ieee1275_find_options): Set
GRUB_IEEE1275_FLAG_HAS_CURSORONOFF when appropriate.
* grub-core/term/ieee1275/ofconsole.c (grub_ofconsole_setcursor):
Use terminfo and don't use cursor-on/cursor-off unless it's known
to work.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): New element
GRUB_IEEE1275_FLAG_HAS_CURSORONOFF.
2010-09-08 Colin Watson <cjwatson@ubuntu.com>
* grub-core/kern/efi/init.c (grub_efi_set_prefix): If the prefix

View file

@ -52,6 +52,7 @@ library = {
common = grub-core/fs/iso9660.c;
common = grub-core/fs/jfs.c;
common = grub-core/fs/minix.c;
common = grub-core/fs/minix2.c;
common = grub-core/fs/nilfs2.c;
common = grub-core/fs/ntfs.c;
common = grub-core/fs/ntfscomp.c;

View file

@ -176,6 +176,19 @@ AC_SUBST(host_kernel)
AC_SUBST(target_cpu)
AC_SUBST(platform)
# Define default variables
case "$host_os" in
netbsd* | openbsd*)
# Because /boot is used for the boot block in NetBSD and OpenBSD,
bootdirname='' ;;
*) bootdirname='boot' ;;
esac
bootdirname=`echo "$bootdirname" | sed "$program_transform_name"`
AC_SUBST(bootdirname)
grubdirname=`echo "$PACKAGE" | sed "$program_transform_name"`
AC_SUBST(grubdirname)
#
# Checks for build programs.
#

View file

@ -880,6 +880,11 @@ module = {
common = fs/minix.c;
};
module = {
name = minix2;
common = fs/minix2.c;
};
module = {
name = nilfs2;
common = fs/nilfs2.c;

View file

@ -25,10 +25,13 @@
#include <grub/dl.h>
#include <grub/types.h>
#ifdef MODE_MINIX2
#define GRUB_MINIX_MAGIC 0x2468
#define GRUB_MINIX_MAGIC_30 0x2478
#else
#define GRUB_MINIX_MAGIC 0x137F
#define GRUB_MINIX2_MAGIC 0x2468
#define GRUB_MINIX_MAGIC_30 0x138F
#define GRUB_MINIX2_MAGIC_30 0x2478
#endif
#define GRUB_MINIX_BSIZE 1024U
#define GRUB_MINIX_LOG2_BSIZE 1
#define GRUB_MINIX_ROOT_INODE 1
@ -38,20 +41,25 @@
#define GRUB_MINIX_IFDIR 0040000U
#define GRUB_MINIX_IFLNK 0120000U
#define GRUB_MINIX_INODE(data,field) (data->version == 1 ? \
data->inode. field : data->inode2. field)
#define GRUB_MINIX_INODE_ENDIAN(data,field,bits1,bits2) (data->version == 1 ? \
grub_le_to_cpu##bits1 (data->inode.field) : \
grub_le_to_cpu##bits2 (data->inode2.field))
#define GRUB_MINIX_INODE_SIZE(data) GRUB_MINIX_INODE_ENDIAN (data,size,16,32)
#define GRUB_MINIX_INODE_MODE(data) GRUB_MINIX_INODE_ENDIAN (data,mode,16,16)
#define GRUB_MINIX_INODE_DIR_ZONES(data,blk) GRUB_MINIX_INODE_ENDIAN \
(data,dir_zones[blk],16,32)
#define GRUB_MINIX_INODE_INDIR_ZONE(data) \
GRUB_MINIX_INODE_ENDIAN (data,indir_zone,16,32)
#define GRUB_MINIX_INODE_DINDIR_ZONE(data) \
GRUB_MINIX_INODE_ENDIAN (data,double_indir_zone,16,32)
#define GRUB_MINIX_INODE_BLKSZ(data) (data->version == 1 ? 2 : 4)
#ifdef MODE_MINIX2
typedef grub_uint32_t grub_minix_uintn_t;
#define grub_minix_le_to_cpu_n grub_le_to_cpu32
#else
typedef grub_uint16_t grub_minix_uintn_t;
#define grub_minix_le_to_cpu_n grub_le_to_cpu16
#endif
#define GRUB_MINIX_INODE_BLKSZ(data) sizeof (grub_minix_uintn_t)
#define GRUB_MINIX_INODE_SIZE(data) (grub_minix_le_to_cpu_n (data->inode.size))
#define GRUB_MINIX_INODE_MODE(data) (grub_le_to_cpu16 (data->inode.mode))
#define GRUB_MINIX_INODE_DIR_ZONES(data,blk) (grub_minix_le_to_cpu_n \
(data->inode.dir_zones[blk]))
#define GRUB_MINIX_INODE_INDIR_ZONE(data) (grub_minix_le_to_cpu_n \
(data->inode.indir_zone))
#define GRUB_MINIX_INODE_DINDIR_ZONE(data) (grub_minix_le_to_cpu_n \
(data->inode.double_indir_zone))
#define GRUB_MINIX_LOG2_ZONESZ (GRUB_MINIX_LOG2_BSIZE \
+ grub_le_to_cpu16 (sblock->log2_zone_size))
#define GRUB_MINIX_ZONESZ (GRUB_MINIX_BSIZE \
@ -69,6 +77,7 @@ struct grub_minix_sblock
grub_uint16_t magic;
};
#ifndef MODE_MINIX2
struct grub_minix_inode
{
grub_uint16_t mode;
@ -82,7 +91,9 @@ struct grub_minix_inode
grub_uint16_t double_indir_zone;
};
struct grub_minix2_inode
#else
struct grub_minix_inode
{
grub_uint16_t mode;
grub_uint16_t nlinks;
@ -99,16 +110,16 @@ struct grub_minix2_inode
};
#endif
/* Information about a "mounted" minix filesystem. */
struct grub_minix_data
{
struct grub_minix_sblock sblock;
struct grub_minix_inode inode;
struct grub_minix2_inode inode2;
int ino;
int linknest;
grub_disk_t disk;
int version;
int filename_size;
};
@ -128,24 +139,12 @@ grub_minix_get_file_block (struct grub_minix_data *data, unsigned int blk)
/* Read the block pointer in ZONE, on the offset NUM. */
int grub_get_indir (int zone, int num)
{
if (data->version == 1)
{
grub_uint16_t indir16;
grub_minix_uintn_t indirn;
grub_disk_read (data->disk,
zone << GRUB_MINIX_LOG2_ZONESZ,
sizeof (grub_uint16_t) * num,
sizeof (grub_uint16_t), (char *) &indir16);
return grub_le_to_cpu16 (indir16);
}
else
{
grub_uint32_t indir32;
grub_disk_read (data->disk,
zone << GRUB_MINIX_LOG2_ZONESZ,
sizeof (grub_uint32_t) * num,
sizeof (grub_uint32_t), (char *) &indir32);
return grub_le_to_cpu32 (indir32);
}
sizeof (grub_minix_uintn_t) * num,
sizeof (grub_minix_uintn_t), (char *) &indirn);
return grub_minix_le_to_cpu_n (indirn);
}
/* Direct block. */
@ -259,8 +258,6 @@ grub_minix_read_inode (struct grub_minix_data *data, int ino)
+ grub_le_to_cpu16 (sblock->zone_bmap_size))
<< GRUB_MINIX_LOG2_BSIZE);
if (data->version == 1)
{
block += ino / (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix_inode));
int offs = (ino % (GRUB_DISK_SECTOR_SIZE
/ sizeof (struct grub_minix_inode))
@ -268,18 +265,6 @@ grub_minix_read_inode (struct grub_minix_data *data, int ino)
grub_disk_read (data->disk, block, offs,
sizeof (struct grub_minix_inode), &data->inode);
}
else
{
block += ino / (GRUB_DISK_SECTOR_SIZE
/ sizeof (struct grub_minix2_inode));
int offs = (ino
% (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix2_inode))
* sizeof (struct grub_minix2_inode));
grub_disk_read (data->disk, block, offs,
sizeof (struct grub_minix2_inode),&data->inode2);
}
return GRUB_ERR_NONE;
}
@ -424,25 +409,9 @@ grub_minix_mount (grub_disk_t disk)
goto fail;
if (grub_le_to_cpu16 (data->sblock.magic) == GRUB_MINIX_MAGIC)
{
data->version = 1;
data->filename_size = 14;
}
else if (grub_le_to_cpu16 (data->sblock.magic) == GRUB_MINIX2_MAGIC)
{
data->version = 2;
data->filename_size = 14;
}
else if (grub_le_to_cpu16 (data->sblock.magic) == GRUB_MINIX_MAGIC_30)
{
data->version = 1;
data->filename_size = 30;
}
else if (grub_le_to_cpu16 (data->sblock.magic) == GRUB_MINIX2_MAGIC_30)
{
data->version = 2;
data->filename_size = 30;
}
else
goto fail;
@ -453,7 +422,11 @@ grub_minix_mount (grub_disk_t disk)
fail:
grub_free (data);
#ifdef MODE_MINIX2
grub_error (GRUB_ERR_BAD_FS, "not a minix2 filesystem");
#else
grub_error (GRUB_ERR_BAD_FS, "not a minix filesystem");
#endif
return 0;
}
@ -583,32 +556,36 @@ grub_minix_close (grub_file_t file)
}
static grub_err_t
grub_minix_label (grub_device_t device __attribute ((unused)),
char **label __attribute ((unused)))
{
return GRUB_ERR_NONE;
}
static struct grub_fs grub_minix_fs =
{
#ifdef MODE_MINIX2
.name = "minix2",
#else
.name = "minix",
#endif
.dir = grub_minix_dir,
.open = grub_minix_open,
.read = grub_minix_read,
.close = grub_minix_close,
.label = grub_minix_label,
.next = 0
};
#ifdef MODE_MINIX2
GRUB_MOD_INIT(minix2)
#else
GRUB_MOD_INIT(minix)
#endif
{
grub_fs_register (&grub_minix_fs);
my_mod = mod;
}
#ifdef MODE_MINIX2
GRUB_MOD_FINI(minix2)
#else
GRUB_MOD_FINI(minix)
#endif
{
grub_fs_unregister (&grub_minix_fs);
}

2
grub-core/fs/minix2.c Normal file
View file

@ -0,0 +1,2 @@
#define MODE_MINIX2 1
#include "minix.c"

View file

@ -138,12 +138,17 @@ grub_ieee1275_find_options (void)
*/
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_OFDISK_SDCARD_ONLY);
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_HAS_CURSORONOFF);
}
if (is_qemu)
{
/* OpenFirmware hangs on qemu if one requests any memory below 1.5 MiB. */
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM);
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_HAS_CURSORONOFF);
}
if (! grub_ieee1275_finddevice ("/rom/boot-rom", &bootrom))
{
rc = grub_ieee1275_get_property (bootrom, "model", tmp, sizeof (tmp), 0);

View file

@ -117,9 +117,14 @@ grub_ofconsole_getwh (struct grub_term_output *term __attribute__ ((unused)))
}
static void
grub_ofconsole_setcursor (struct grub_term_output *term __attribute__ ((unused)),
grub_ofconsole_setcursor (struct grub_term_output *term,
int on)
{
grub_terminfo_setcursor (term, on);
if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_HAS_CURSORONOFF))
return;
/* Understood by the Open Firmware flavour in OLPC. */
if (on)
grub_ieee1275_interpret ("cursor-on", 0);

View file

@ -103,6 +103,9 @@ enum grub_ieee1275_flag
/* OpenFirmware hangs on qemu if one requests any memory below 1.5 MiB. */
GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM,
/* OLPC / XO firmware has the cursor ON/OFF routines. */
GRUB_IEEE1275_FLAG_HAS_CURSORONOFF,
};
extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag);

View file

@ -43,7 +43,8 @@ grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
grub_mkrelpath=${bindir}/`echo grub-mkrelpath | sed ${transform}`
rootdir=
grub_prefix=`echo /boot/grub | sed ${transform}`
bootdir=
grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
modules=
install_device=
@ -97,8 +98,8 @@ Install GRUB on your drive.
-h, --help print this message and exit
-v, --version print the version information and exit
--modules=MODULES pre-load specified modules MODULES
--root-directory=DIR install GRUB images under the directory DIR
instead of the root directory
--boot-directory=DIR install GRUB images under the directory DIR/@grubdirname@
instead of the $grubdir directory
--grub-setup=FILE use FILE as grub-setup
--grub-mkimage=FILE use FILE as grub-mkimage
--grub-mkrelpath=FILE use FILE as grub-mkrelpath
@ -128,11 +129,8 @@ fi
INSTALL_DEVICE can be a GRUB device name or a system device filename.
$self copies GRUB images into /boot/grub (or /grub on NetBSD and
OpenBSD), and uses grub-setup to install grub into the boot sector.
If the --root-directory option is used, then $self will copy
images into the operating system installation rooted at that directory.
$self copies GRUB images into $grubdir, and uses grub-setup
to install grub into the boot sector.
Report bugs to <bug-grub@gnu.org>.
EOF
@ -174,11 +172,17 @@ do
--font=*)
;;
# Accept for compatibility
--root-directory)
rootdir=`argument $option "$@"`; shift;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
--boot-directory)
bootdir=`argument $option "$@"`; shift;;
--boot-directory=*)
bootdir=`echo "$option" | sed 's/--boot-directory=//'` ;;
--grub-setup)
grub_setup=`argument $option "$@"`; shift;;
--grub-setup=*)
@ -271,23 +275,18 @@ if test $debug = yes; then
efi_quiet=-q
fi
# Initialize these directories here, since ROOTDIR was initialized.
case "$host_os" in
netbsd* | openbsd*)
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
# instead of /boot/grub.
grub_prefix=`echo /grub | sed ${transform}`
bootdir=${rootdir}
;;
*)
# Use /boot/grub by default.
bootdir=${rootdir}/boot
;;
esac
if [ -z "$bootdir" ]; then
# Default bootdir if bootdir not initialized.
bootdir=/@bootdirname@
grubdir=${bootdir}/`echo grub | sed ${transform}`
if [ -n "$rootdir" ] ; then
# Initialize bootdir if rootdir was initialized.
bootdir=${rootdir}/@bootdirname@
fi
fi
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
device_map=${grubdir}/device.map
grub_probe="${grub_probe} --device-map=${device_map}"
# Check if GRUB is installed.

View file

@ -38,6 +38,8 @@ self=`basename $0`
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
GRUB_PREFIX=`echo '/@bootdirname@/@grubdirname@' | sed "s,//*,/,g"`
# Usage: usage
# Print the usage.
usage () {
@ -93,18 +95,6 @@ done
. ${libdir}/grub/grub-mkconfig_lib
case "$host_os" in
netbsd* | openbsd*)
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
# instead of /boot/grub.
GRUB_PREFIX=`echo /grub | sed ${transform}`
;;
*)
# Use /boot/grub by default.
GRUB_PREFIX=`echo /boot/grub | sed ${transform}`
;;
esac
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
@ -200,7 +190,7 @@ for x in ${GRUB_TERMINAL_OUTPUT}; do
exit 1
fi
else
for dir in ${pkgdatadir} /boot/grub /usr/share/grub ; do
for dir in ${pkgdatadir} ${GRUB_PREFIX} /usr/share/grub ; do
for basename in unicode unifont ascii; do
path="${dir}/${basename}.pf2"
if is_path_readable_by_grub ${path} > /dev/null ; then

View file

@ -29,6 +29,8 @@ self=`basename $0`
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir=
bootdir=
grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
# Usage: usage
# Print the usage.
@ -39,8 +41,8 @@ Set the default boot entry for GRUB, for the next boot only.
-h, --help print this message and exit
-v, --version print the version information and exit
--root-directory=DIR expect GRUB images under the directory DIR
instead of the root directory
--boot-directory=DIR expect GRUB images under the directory DIR/@grubdirname@
instead of the $grubdir directory
ENTRY is a number or a menu item title.
@ -73,11 +75,17 @@ do
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
# Accept for compatibility
--root-directory)
rootdir=`argument $option "$@"`; shift ;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
--boot-directory)
bootdir=`argument $option "$@"`; shift;;
--boot-directory=*)
bootdir=`echo "$option" | sed 's/--boot-directory=//'` ;;
-*)
echo "Unrecognized option \`$option'" 1>&2
usage
@ -99,21 +107,17 @@ if test "x$entry" = x; then
exit 1
fi
# Initialize these directories here, since ROOTDIR was initialized.
case "$host_os" in
netbsd* | openbsd*)
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
# instead of /boot/grub.
grub_prefix=`echo /grub | sed ${transform}`
bootdir=${rootdir}
;;
*)
# Use /boot/grub by default.
bootdir=${rootdir}/boot
;;
esac
if [ -z "$bootdir" ]; then
# Default bootdir if bootdir not initialized.
bootdir=/@bootdirname@
grubdir=${bootdir}/`echo grub | sed ${transform}`
if [ -n "$rootdir" ] ; then
# Initialize bootdir if rootdir was initialized.
bootdir=${rootdir}/@bootdirname@
fi
fi
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'`
if [ "$prev_saved_entry" ]; then

View file

@ -29,6 +29,8 @@ self=`basename $0`
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir=
bootdir=
grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
# Usage: usage
# Print the usage.
@ -39,8 +41,8 @@ Set the default boot entry for GRUB.
-h, --help print this message and exit
-v, --version print the version information and exit
--root-directory=DIR expect GRUB images under the directory DIR
instead of the root directory
--boot-directory=DIR expect GRUB images under the directory DIR/@grubdirname@
instead of the $grubdir directory
ENTRY is a number or a menu item title.
@ -73,11 +75,17 @@ do
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
# Accept for compatibility
--root-directory)
rootdir=`argument $option "$@"`; shift ;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
--boot-directory)
bootdir=`argument $option "$@"`; shift;;
--boot-directory=*)
bootdir=`echo "$option" | sed 's/--boot-directory=//'` ;;
-*)
echo "Unrecognized option \`$option'" 1>&2
usage
@ -99,21 +107,17 @@ if test "x$entry" = x; then
exit 1
fi
# Initialize these directories here, since ROOTDIR was initialized.
case "$host_os" in
netbsd* | openbsd*)
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
# instead of /boot/grub.
grub_prefix=`echo /grub | sed ${transform}`
bootdir=${rootdir}
;;
*)
# Use /boot/grub by default.
bootdir=${rootdir}/boot
;;
esac
if [ -z "$bootdir" ]; then
# Default bootdir if bootdir not initialized.
bootdir=/@bootdirname@
grubdir=${bootdir}/`echo grub | sed ${transform}`
if [ -n "$rootdir" ] ; then
# Initialize bootdir if rootdir was initialized.
bootdir=${rootdir}/@bootdirname@
fi
fi
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
$grub_editenv ${grubdir}/grubenv unset prev_saved_entry
$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"