merged with mainline
This commit is contained in:
commit
8f33d5549f
163 changed files with 22923 additions and 4101 deletions
|
@ -264,10 +264,17 @@ find_root_device (const char *dir, dev_t dev)
|
|||
/* Found! */
|
||||
char *res;
|
||||
char *cwd;
|
||||
#if defined(__NetBSD__)
|
||||
/* Convert this block device to its character (raw) device. */
|
||||
const char *template = "%s/r%s";
|
||||
#else
|
||||
/* Keep the device name as it is. */
|
||||
const char *template = "%s/%s";
|
||||
#endif
|
||||
|
||||
cwd = xgetcwd ();
|
||||
res = xmalloc (strlen (cwd) + strlen (ent->d_name) + 2);
|
||||
sprintf (res, "%s/%s", cwd, ent->d_name);
|
||||
res = xmalloc (strlen (cwd) + strlen (ent->d_name) + 3);
|
||||
sprintf (res, template, cwd, ent->d_name);
|
||||
strip_extra_slashes (res);
|
||||
free (cwd);
|
||||
|
||||
|
|
|
@ -38,8 +38,6 @@
|
|||
#include <grub/partition.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
#include <grub_emu_init.h>
|
||||
|
||||
#define ENABLE_RELOCATABLE 0
|
||||
#include "progname.h"
|
||||
|
||||
|
@ -55,6 +53,7 @@ grub_arch_modules_addr (void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if GRUB_NO_MODULES
|
||||
grub_err_t
|
||||
grub_arch_dl_check_header (void *ehdr)
|
||||
{
|
||||
|
@ -71,6 +70,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
|||
|
||||
return GRUB_ERR_BAD_MODULE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
grub_reboot (void)
|
||||
|
@ -150,6 +150,10 @@ void grub_hostfs_init (void);
|
|||
void grub_hostfs_fini (void);
|
||||
void grub_host_init (void);
|
||||
void grub_host_fini (void);
|
||||
#if GRUB_NO_MODULES
|
||||
void grub_init_all (void);
|
||||
void grub_fini_all (void);
|
||||
#endif
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
|
@ -215,7 +219,9 @@ main (int argc, char *argv[])
|
|||
/* XXX: This is a bit unportable. */
|
||||
grub_util_biosdisk_init (dev_map);
|
||||
|
||||
#if GRUB_NO_MODULES
|
||||
grub_init_all ();
|
||||
#endif
|
||||
|
||||
/* Make sure that there is a root device. */
|
||||
if (! root_dev)
|
||||
|
@ -233,7 +239,10 @@ main (int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
dir = grub_get_prefix (dir);
|
||||
if (strcmp (root_dev, "host") == 0)
|
||||
dir = xstrdup (dir);
|
||||
else
|
||||
dir = grub_get_prefix (dir);
|
||||
prefix = xmalloc (strlen (root_dev) + 2 + strlen (dir) + 1);
|
||||
sprintf (prefix, "(%s)%s", root_dev, dir);
|
||||
free (dir);
|
||||
|
@ -242,7 +251,9 @@ main (int argc, char *argv[])
|
|||
if (setjmp (main_env) == 0)
|
||||
grub_main ();
|
||||
|
||||
#if GRUB_NO_MODULES
|
||||
grub_fini_all ();
|
||||
#endif
|
||||
grub_hostfs_fini ();
|
||||
grub_host_fini ();
|
||||
|
||||
|
|
|
@ -252,8 +252,7 @@ else
|
|||
fi
|
||||
|
||||
# Create the GRUB directory if it is not present.
|
||||
test -d "$bootdir" || mkdir "$bootdir" || exit 1
|
||||
test -d "$grubdir" || mkdir "$grubdir" || exit 1
|
||||
mkdir -p "$grubdir" || exit 1
|
||||
|
||||
# If --recheck is specified, remove the device map, if present.
|
||||
if test $recheck = yes; then
|
||||
|
@ -304,7 +303,7 @@ for dir in ${localedir}/*; do
|
|||
done
|
||||
|
||||
# Write device to a variable so we don't have to traverse /dev every time.
|
||||
grub_device=`$grub_probe --target=device ${grubdir}`
|
||||
grub_device=`$grub_probe --target=device ${grubdir}` || exit 1
|
||||
|
||||
if ! test -f ${grubdir}/grubenv; then
|
||||
$grub_editenv ${grubdir}/grubenv create
|
||||
|
@ -321,7 +320,10 @@ fi
|
|||
# Then the partition map module. In order to support partition-less media,
|
||||
# this command is allowed to fail (--target=fs already grants us that the
|
||||
# filesystem will be accessible).
|
||||
partmap_module=`$grub_probe --target=partmap --device ${grub_device} 2> /dev/null`
|
||||
partmap_module=
|
||||
for x in `$grub_probe --target=partmap --device ${grub_device} 2> /dev/null`; do
|
||||
partmap_module="$partmap_module part_$x";
|
||||
done
|
||||
|
||||
# Device abstraction module, if any (lvm, raid).
|
||||
devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}`
|
||||
|
@ -343,11 +345,11 @@ if [ "x${devabstraction_module}" = "x" ] ; then
|
|||
if echo "${install_device}" | grep -qx "(.*)" ; then
|
||||
install_drive="${install_device}"
|
||||
else
|
||||
install_drive="`$grub_probe --target=drive --device ${install_device}`"
|
||||
install_drive="`$grub_probe --target=drive --device ${install_device}`" || exit 1
|
||||
fi
|
||||
install_drive="`echo ${install_drive} | sed -e s/,[0-9]*[a-z]*//g`"
|
||||
fi
|
||||
grub_drive="`$grub_probe --target=drive --device ${grub_device}`"
|
||||
grub_drive="`$grub_probe --target=drive --device ${grub_device}`" || exit 1
|
||||
|
||||
# Strip partition number
|
||||
grub_drive="`echo ${grub_drive} | sed -e s/,[0-9]*[a-z]*//g`"
|
||||
|
@ -374,7 +376,7 @@ if [ "x${devabstraction_module}" = "x" ] ; then
|
|||
modules="$modules search_fs_uuid"
|
||||
fi
|
||||
else
|
||||
prefix_drive=`$grub_probe --target=drive --device ${grub_device}`
|
||||
prefix_drive=`$grub_probe --target=drive --device ${grub_device}` || exit 1
|
||||
fi
|
||||
|
||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
|
||||
|
|
|
@ -144,60 +144,73 @@ if [ "x${GRUB_TERMINAL}" != "x" ] ; then
|
|||
GRUB_TERMINAL_OUTPUT="${GRUB_TERMINAL}"
|
||||
fi
|
||||
|
||||
case x${GRUB_TERMINAL_OUTPUT} in
|
||||
x | xgfxterm)
|
||||
# If this platform supports gfxterm, try to use it.
|
||||
if test -e ${grub_prefix}/gfxterm.mod ; then
|
||||
# FIXME: this should do something smarter than just loading first
|
||||
# video backend.
|
||||
GRUB_VIDEO_BACKEND=$(head -n 1 ${grub_prefix}/video.lst || true)
|
||||
if [ -n "${GRUB_VIDEO_BACKEND}" ] ; then
|
||||
GRUB_TERMINAL_OUTPUT=gfxterm
|
||||
elif [ "${GRUB_TERMINAL_OUTPUT}" = "gfxterm" ] ; then
|
||||
echo "No suitable backend could be found for gfxterm." >&2 ; exit 1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
xconsole | xserial | xofconsole) ;;
|
||||
*) echo "Invalid output terminal \"${GRUB_TERMINAL_OUTPUT}\"" >&2 ; exit 1 ;;
|
||||
esac
|
||||
termoutdefault=0
|
||||
if [ "x${GRUB_TERMINAL_OUTPUT}" == x ]; then
|
||||
GRUB_TERMINAL_OUTPUT=gfxterm;
|
||||
termoutdefault=1;
|
||||
fi
|
||||
|
||||
# check for terminals that require fonts
|
||||
case ${GRUB_TERMINAL_OUTPUT} in
|
||||
gfxterm)
|
||||
if [ -n "$GRUB_FONT" ] ; then
|
||||
if is_path_readable_by_grub ${GRUB_FONT} > /dev/null ; then
|
||||
GRUB_FONT_PATH=${GRUB_FONT}
|
||||
else
|
||||
echo "No such font or not readable by grub: ${GRUB_FONT}" >&2
|
||||
exit 1
|
||||
for x in ${GRUB_TERMINAL_OUTPUT}; do
|
||||
if [ x${x} == xgfxterm ]; then
|
||||
# If this platform supports gfxterm, try to use it.
|
||||
if ! test -e ${grub_prefix}/gfxterm.mod ; then
|
||||
if [ "x$termoutdefault" != "x1" ]; then
|
||||
echo "gfxterm isn't available on your platform" >&2 ; exit 1
|
||||
fi
|
||||
GRUB_TERMINAL_OUTPUT=
|
||||
break;
|
||||
fi
|
||||
# FIXME: this should do something smarter than just loading first
|
||||
# video backend.
|
||||
GRUB_VIDEO_BACKEND=$(head -n 1 ${grub_prefix}/video.lst || true)
|
||||
if [ -z "${GRUB_VIDEO_BACKEND}" ] ; then
|
||||
if [ "x$termoutdefault" != "x1" ]; then
|
||||
echo "No suitable backend could be found for gfxterm." >&2 ; exit 1
|
||||
fi
|
||||
GRUB_TERMINAL_OUTPUT=
|
||||
fi
|
||||
if [ -n "$GRUB_FONT" ] ; then
|
||||
if is_path_readable_by_grub ${GRUB_FONT} > /dev/null ; then
|
||||
GRUB_FONT_PATH=${GRUB_FONT}
|
||||
else
|
||||
echo "No such font or not readable by grub: ${GRUB_FONT}" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
for dir in ${pkgdatadir} /boot/grub /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
|
||||
GRUB_FONT_PATH=${path}
|
||||
else
|
||||
continue
|
||||
fi
|
||||
if [ "${basename}" = "ascii" ] ; then
|
||||
# make sure all our children behave in conformance with ascii..
|
||||
export LANG=C
|
||||
fi
|
||||
break 2
|
||||
done
|
||||
done
|
||||
fi
|
||||
if [ -z "${GRUB_FONT_PATH}" ] ; then
|
||||
if [ "x$termoutdefault" != "x1" ]; then
|
||||
echo "No font for gfxterm found." >&2 ; exit 1
|
||||
fi
|
||||
GRUB_TERMINAL_OUTPUT=
|
||||
fi
|
||||
else
|
||||
for dir in ${pkgdatadir} /boot/grub /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
|
||||
GRUB_FONT_PATH=${path}
|
||||
else
|
||||
continue
|
||||
fi
|
||||
if [ "${basename}" = "ascii" ] ; then
|
||||
# make sure all our children behave in conformance with ascii..
|
||||
export LANG=C
|
||||
fi
|
||||
break 2
|
||||
done
|
||||
done
|
||||
fi
|
||||
if [ -z "${GRUB_FONT_PATH}" ] ; then
|
||||
# fallback to the native terminal for this platform
|
||||
unset GRUB_TERMINAL_OUTPUT
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# make sure all our children behave in conformance with ascii..
|
||||
export LANG=C
|
||||
esac
|
||||
done
|
||||
|
||||
for x in ${GRUB_TERMINAL_OUTPUT}; do
|
||||
case "x${x}" in
|
||||
xgfxterm) ;;
|
||||
xconsole | xserial | xofconsole)
|
||||
# make sure all our children behave in conformance with ascii..
|
||||
export LANG=C;;
|
||||
*) echo "Invalid output terminal \"${GRUB_TERMINAL_OUTPUT}\"" >&2 ; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# These are defined in this script, export them here so that user can
|
||||
# override them.
|
||||
|
@ -224,6 +237,7 @@ export GRUB_DEFAULT \
|
|||
GRUB_DISABLE_LINUX_UUID \
|
||||
GRUB_DISABLE_LINUX_RECOVERY \
|
||||
GRUB_GFXMODE \
|
||||
GRUB_BACKGROUND \
|
||||
GRUB_THEME \
|
||||
GRUB_GFXPAYLOAD_LINUX \
|
||||
GRUB_DISABLE_OS_PROBER \
|
||||
|
|
|
@ -173,7 +173,7 @@ EOF
|
|||
echo "insmod $i"
|
||||
done ; \
|
||||
echo "source /boot/grub/grub.cfg") \
|
||||
> ${iso9660_dir}/boot/grub/i386-pc/grub.cfg
|
||||
> ${iso9660_dir}/boot/grub/i386-coreboot/grub.cfg
|
||||
|
||||
tar -C ${memdisk_dir} -cf ${memdisk_img} boot
|
||||
rm -rf ${memdisk_dir}
|
||||
|
@ -204,7 +204,7 @@ if test -e "${pc_dir}" ; then
|
|||
echo "source /boot/grub/grub.cfg") \
|
||||
> ${iso9660_dir}/boot/grub/i386-pc/grub.cfg
|
||||
|
||||
grub_mkisofs_arguments="${grub_mkisofs_arguments} -b boot/grub/i386-pc/eltorito.img -boot-info-table \
|
||||
grub_mkisofs_arguments="${grub_mkisofs_arguments} -b boot/grub/i386-pc/eltorito.img -no-emul-boot -boot-info-table \
|
||||
--embedded-boot ${embed_img}"
|
||||
fi
|
||||
|
||||
|
|
|
@ -82,13 +82,16 @@ grub_refresh (void)
|
|||
static void
|
||||
probe_partmap (grub_disk_t disk)
|
||||
{
|
||||
grub_partition_t part;
|
||||
|
||||
if (disk->partition == NULL)
|
||||
{
|
||||
grub_util_info ("no partition map found for %s", disk->name);
|
||||
return;
|
||||
}
|
||||
|
||||
printf ("%s\n", disk->partition->partmap->name);
|
||||
for (part = disk->partition; part; part = part->parent)
|
||||
printf ("%s\n", part->partmap->name);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -116,7 +119,7 @@ probe (const char *path, char *device_name)
|
|||
|
||||
if (path == NULL)
|
||||
{
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
|
||||
if (! grub_util_check_char_device (device_name))
|
||||
grub_util_error ("%s is not a character device", device_name);
|
||||
#else
|
||||
|
|
|
@ -81,6 +81,18 @@ grub_script_execute_cmdif (struct grub_script_cmd *cmd __attribute__ ((unused)))
|
|||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_script_execute_cmdfor (struct grub_script_cmd *cmd __attribute__ ((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_script_execute_cmdwhile (struct grub_script_cmd *cmd __attribute__ ((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_script_execute_menuentry (struct grub_script_cmd *cmd __attribute__ ((unused)))
|
||||
{
|
||||
|
@ -118,7 +130,7 @@ Checks GRUB script configuration file for syntax errors.\n\
|
|||
\n\
|
||||
-h, --help display this message and exit\n\
|
||||
-V, --version print version information and exit\n\
|
||||
-v, --verbose print script being processed\n\
|
||||
-v, --verbose print the script as it is being processed\n\
|
||||
\n\
|
||||
Report bugs to <%s>.\n\
|
||||
", program_name,
|
||||
|
|
|
@ -59,19 +59,92 @@ function savedefault {
|
|||
}
|
||||
EOF
|
||||
|
||||
case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in
|
||||
serial:* | *:serial)
|
||||
serial=0;
|
||||
gfxterm=0;
|
||||
for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
|
||||
if [ xserial = "x$x" ]; then
|
||||
serial=1;
|
||||
fi
|
||||
if [ xgfxterm = "x$x" ]; then
|
||||
gfxterm=1;
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "x$serial" = x1 ]; then
|
||||
if ! test -e ${grub_prefix}/serial.mod ; then
|
||||
echo "Serial terminal not available on this platform." >&2 ; exit 1
|
||||
echo "Serial terminal not available on this platform." >&2 ; exit 1
|
||||
fi
|
||||
|
||||
if [ "x${GRUB_SERIAL_COMMAND}" = "x" ] ; then
|
||||
grub_warn "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used."
|
||||
GRUB_SERIAL_COMMAND=serial
|
||||
grub_warn "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used."
|
||||
GRUB_SERIAL_COMMAND=serial
|
||||
fi
|
||||
echo "${GRUB_SERIAL_COMMAND}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ "x$gfxterm" = x1 ]; then
|
||||
# Make the font accessible
|
||||
prepare_grub_to_access_device `${grub_probe} --target=device "${GRUB_FONT_PATH}"`
|
||||
|
||||
cat << EOF
|
||||
if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT_PATH}"` ; then
|
||||
set gfxmode=${GRUB_GFXMODE}
|
||||
insmod gfxterm
|
||||
insmod ${GRUB_VIDEO_BACKEND}
|
||||
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
|
||||
EOF
|
||||
themedir="`dirname "$GRUB_THEME"`"
|
||||
for x in "$themedir"/*.pf2 "$themedir"/f/*.pf2; do
|
||||
if [ -f "$x" ]; then
|
||||
cat << EOF
|
||||
loadfont (\$root)`make_system_path_relative_to_its_root $x`
|
||||
EOF
|
||||
fi
|
||||
done
|
||||
if [ x"`echo "$themedir"/*.jpg`" != x"$themedir/*.jpg" ] || [ x"`echo "$themedir"/*.jpeg`" != x"$themedir/*.jpeg" ]; then
|
||||
cat << EOF
|
||||
insmod jpeg
|
||||
EOF
|
||||
fi
|
||||
if [ x"`echo "$themedir"/*.png`" != x"$themedir/*.png" ]; then
|
||||
cat << EOF
|
||||
insmod png
|
||||
EOF
|
||||
fi
|
||||
if [ x"`echo "$themedir"/*.tga`" != x"$themedir/*.tga" ]; then
|
||||
cat << EOF
|
||||
insmod tga
|
||||
EOF
|
||||
fi
|
||||
|
||||
cat << EOF
|
||||
set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
|
||||
EOF
|
||||
elif [ "x$GRUB_BACKGROUND" != x ] && [ -f "$GRUB_BACKGROUND" ] \
|
||||
&& is_path_readable_by_grub "$GRUB_BACKGROUND"; then
|
||||
echo "Found background: $GRUB_BACKGROUND" >&2
|
||||
case "$GRUB_BACKGROUND" in
|
||||
*.png) reader=png ;;
|
||||
*.tga) reader=tga ;;
|
||||
*.jpg|*.jpeg) reader=jpeg ;;
|
||||
*) echo "Unsupported image format" >&2; exit 1 ;;
|
||||
esac
|
||||
prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_BACKGROUND"` | sed -e "s/^/ /"
|
||||
cat << EOF
|
||||
insmod $reader
|
||||
background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"`
|
||||
EOF
|
||||
fi
|
||||
cat << EOF
|
||||
fi
|
||||
EOF
|
||||
fi
|
||||
|
||||
case x${GRUB_TERMINAL_INPUT} in
|
||||
x)
|
||||
|
@ -89,35 +162,6 @@ EOF
|
|||
esac
|
||||
|
||||
case x${GRUB_TERMINAL_OUTPUT} in
|
||||
xgfxterm)
|
||||
# Make the font accessible
|
||||
prepare_grub_to_access_device `${grub_probe} --target=device ${GRUB_FONT_PATH}`
|
||||
|
||||
cat << EOF
|
||||
if loadfont `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then
|
||||
set gfxmode=${GRUB_GFXMODE}
|
||||
insmod gfxterm
|
||||
insmod ${GRUB_VIDEO_BACKEND}
|
||||
if terminal_output gfxterm ; then true ; else
|
||||
# For backward compatibility with versions of terminal.mod that don't
|
||||
# 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
|
||||
;;
|
||||
x)
|
||||
# Just use the native terminal
|
||||
;;
|
||||
|
|
|
@ -27,7 +27,7 @@ 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}"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
|
||||
fi
|
||||
|
||||
at_least_one=false
|
||||
|
|
|
@ -30,7 +30,7 @@ CLASS="--class os"
|
|||
case "${GRUB_DISTRIBUTOR}" in
|
||||
Debian)
|
||||
OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]') --class gnu-kfreebsd --class gnu ${CLASS}"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) --class gnu-kfreebsd --class gnu ${CLASS}"
|
||||
;;
|
||||
*)
|
||||
OS="FreeBSD"
|
||||
|
|
|
@ -31,7 +31,7 @@ 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}"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
|
||||
fi
|
||||
|
||||
# loop-AES arranges things so that /dev/loop/X can be our root device, but
|
||||
|
|
195
util/hostdisk.c
195
util/hostdisk.c
|
@ -98,6 +98,18 @@ struct hd_geometry
|
|||
# include <sys/disk.h>
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
# include <sys/ioctl.h>
|
||||
# include <sys/disklabel.h> /* struct disklabel */
|
||||
# ifdef HAVE_GETRAWPARTITION
|
||||
# include <util.h> /* getrawpartition */
|
||||
# endif /* HAVE_GETRAWPARTITION */
|
||||
# include <sys/fdio.h>
|
||||
# ifndef RAW_FLOPPY_MAJOR
|
||||
# define RAW_FLOPPY_MAJOR 9
|
||||
# endif /* ! RAW_FLOPPY_MAJOR */
|
||||
#endif /* defined(__NetBSD__) */
|
||||
|
||||
struct
|
||||
{
|
||||
char *drive;
|
||||
|
@ -129,6 +141,31 @@ have_devfs (void)
|
|||
}
|
||||
#endif /* __linux__ */
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
/* Adjust device driver parameters. This function should be called just
|
||||
after successfully opening the device. For now, it simply prevents the
|
||||
floppy driver from retrying operations on failure, as otherwise the
|
||||
driver takes a while to abort when there is no floppy in the drive. */
|
||||
static void
|
||||
configure_device_driver (int fd)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (fstat (fd, &st) < 0 || ! S_ISCHR (st.st_mode))
|
||||
return;
|
||||
if (major(st.st_rdev) == RAW_FLOPPY_MAJOR)
|
||||
{
|
||||
int floppy_opts;
|
||||
|
||||
if (ioctl (fd, FDIOCGETOPTS, &floppy_opts) == -1)
|
||||
return;
|
||||
floppy_opts |= FDOPT_NORETRY;
|
||||
if (ioctl (fd, FDIOCSETOPTS, &floppy_opts) == -1)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif /* defined(__NetBSD__) */
|
||||
|
||||
static int
|
||||
find_grub_drive (const char *name)
|
||||
{
|
||||
|
@ -204,16 +241,20 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
return GRUB_ERR_NONE;
|
||||
}
|
||||
#elif defined(__linux__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \
|
||||
defined(__FreeBSD_kernel__) || defined(__APPLE__)
|
||||
defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__)
|
||||
{
|
||||
# if defined(__NetBSD__)
|
||||
struct disklabel label;
|
||||
# else
|
||||
unsigned long long nr;
|
||||
# endif
|
||||
int fd;
|
||||
|
||||
fd = open (map[drive].device, O_RDONLY);
|
||||
if (fd == -1)
|
||||
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 defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__)
|
||||
if (fstat (fd, &st) < 0 || ! S_ISCHR (st.st_mode))
|
||||
# else
|
||||
if (fstat (fd, &st) < 0 || ! S_ISBLK (st.st_mode))
|
||||
|
@ -227,6 +268,9 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
if (ioctl (fd, DIOCGMEDIASIZE, &nr))
|
||||
# elif defined(__APPLE__)
|
||||
if (ioctl (fd, DKIOCGETBLOCKCOUNT, &nr))
|
||||
# elif defined(__NetBSD__)
|
||||
configure_device_driver (fd);
|
||||
if (ioctl (fd, DIOCGDINFO, &label) == -1)
|
||||
# else
|
||||
if (ioctl (fd, BLKGETSIZE64, &nr))
|
||||
# endif
|
||||
|
@ -237,14 +281,16 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
|
||||
close (fd);
|
||||
|
||||
#if defined (__APPLE__)
|
||||
# if defined (__APPLE__)
|
||||
disk->total_sectors = nr;
|
||||
#else
|
||||
# elif defined(__NetBSD__)
|
||||
disk->total_sectors = label.d_secperunit;
|
||||
# else
|
||||
disk->total_sectors = nr / 512;
|
||||
|
||||
if (nr % 512)
|
||||
grub_util_error ("unaligned device size");
|
||||
#endif
|
||||
# endif
|
||||
|
||||
grub_util_info ("the size of %s is %llu", name, disk->total_sectors);
|
||||
|
||||
|
@ -379,11 +425,14 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
|
|||
{
|
||||
int is_partition = 0;
|
||||
char dev[PATH_MAX];
|
||||
grub_disk_addr_t part_start = 0;
|
||||
|
||||
part_start = grub_partition_get_start (disk->partition);
|
||||
|
||||
strcpy (dev, map[disk->id].device);
|
||||
if (disk->partition && sector >= disk->partition->start
|
||||
if (disk->partition && sector >= part_start
|
||||
&& strncmp (map[disk->id].device, "/dev/", 5) == 0)
|
||||
is_partition = linux_find_partition (dev, disk->partition->start);
|
||||
is_partition = linux_find_partition (dev, part_start);
|
||||
|
||||
if (data->dev && strcmp (data->dev, dev) == 0 &&
|
||||
data->access_mode == (flags & O_ACCMODE))
|
||||
|
@ -416,7 +465,7 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
|
|||
}
|
||||
|
||||
if (is_partition)
|
||||
sector -= disk->partition->start;
|
||||
sector -= part_start;
|
||||
}
|
||||
#else /* ! __linux__ */
|
||||
#if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
|
@ -480,6 +529,10 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
|
|||
}
|
||||
#endif /* ! __linux__ */
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
configure_device_driver (fd);
|
||||
#endif /* defined(__NetBSD__) */
|
||||
|
||||
#if defined(__linux__) && (!defined(__GLIBC__) || \
|
||||
((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
|
||||
/* Maybe libc doesn't have large file support. */
|
||||
|
@ -808,7 +861,7 @@ make_device_name (int drive, int dos_part, int bsd_part)
|
|||
dos_part_str = xasprintf (",%d", dos_part + 1);
|
||||
|
||||
if (bsd_part >= 0)
|
||||
bsd_part_str = xasprintf (",%c", dos_part + 'a');
|
||||
bsd_part_str = xasprintf (",%c", bsd_part + 'a');
|
||||
|
||||
ret = xasprintf ("%s%s%s", map[drive].drive,
|
||||
dos_part_str ? : "",
|
||||
|
@ -978,6 +1031,27 @@ convert_system_partition_to_system_disk (const char *os_dev)
|
|||
}
|
||||
return path;
|
||||
|
||||
#elif defined(__NetBSD__)
|
||||
/* NetBSD uses "/dev/r[wsc]d[0-9]+[a-z]". */
|
||||
char *path = xstrdup (os_dev);
|
||||
if (strncmp ("/dev/rwd", path, 8) == 0 ||
|
||||
strncmp ("/dev/rsd", path, 8) == 0 ||
|
||||
strncmp ("/dev/rcd", path, 8) == 0)
|
||||
{
|
||||
char *q;
|
||||
q = path + strlen(path) - 1; /* last character */
|
||||
if (grub_isalpha(*q) && grub_isdigit(*(q-1)))
|
||||
{
|
||||
int rawpart = -1;
|
||||
# ifdef HAVE_GETRAWPARTITION
|
||||
rawpart = getrawpartition();
|
||||
# endif /* HAVE_GETRAWPARTITION */
|
||||
if (rawpart >= 0)
|
||||
*q = 'a' + rawpart;
|
||||
}
|
||||
}
|
||||
return path;
|
||||
|
||||
#else
|
||||
# warning "The function `convert_system_partition_to_system_disk' might not work on your OS correctly."
|
||||
return xstrdup (os_dev);
|
||||
|
@ -996,6 +1070,26 @@ device_is_wholedisk (const char *os_dev)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
/* Try to determine whether a given device name corresponds to a whole disk.
|
||||
This function should give in most cases a definite answer, but it may
|
||||
actually give an approximate one in the following sense: if the return
|
||||
value is 0 then the device name does not correspond to a whole disk. */
|
||||
static int
|
||||
device_is_wholedisk (const char *os_dev)
|
||||
{
|
||||
int len = strlen (os_dev);
|
||||
int rawpart = -1;
|
||||
|
||||
# ifdef HAVE_GETRAWPARTITION
|
||||
rawpart = getrawpartition();
|
||||
# endif /* HAVE_GETRAWPARTITION */
|
||||
if (rawpart < 0)
|
||||
return 1;
|
||||
return (os_dev[len - 1] == ('a' + rawpart));
|
||||
}
|
||||
#endif /* defined(__NetBSD__) */
|
||||
|
||||
static int
|
||||
find_system_device (const char *os_dev)
|
||||
{
|
||||
|
@ -1039,7 +1133,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
drive = find_system_device (os_dev);
|
||||
if (drive < 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
||||
"no mapping exists for `%s'", os_dev);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1048,14 +1142,14 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
== 0)
|
||||
return make_device_name (drive, -1, -1);
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__)
|
||||
if (! S_ISCHR (st.st_mode))
|
||||
#else
|
||||
if (! S_ISBLK (st.st_mode))
|
||||
#endif
|
||||
return make_device_name (drive, -1, -1);
|
||||
|
||||
#if defined(__linux__) || defined(__CYGWIN__)
|
||||
#if defined(__linux__) || defined(__CYGWIN__) || defined(__NetBSD__)
|
||||
/* Linux counts partitions uniformly, whether a BSD partition or a DOS
|
||||
partition, so mapping them to GRUB devices is not trivial.
|
||||
Here, get the start sector of a partition by HDIO_GETGEO, and
|
||||
|
@ -1063,12 +1157,22 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
|
||||
Cygwin /dev/sdXN emulation uses Windows partition mapping. It
|
||||
does not count the extended partition and missing primary
|
||||
partitions. Use same method as on Linux here. */
|
||||
partitions. Use same method as on Linux here.
|
||||
|
||||
For NetBSD, proceed as for Linux, except that the start sector is
|
||||
obtained from the disk label. */
|
||||
{
|
||||
char *name;
|
||||
grub_disk_t disk;
|
||||
int fd;
|
||||
# if !defined(__NetBSD__)
|
||||
struct hd_geometry hdg;
|
||||
typeof (hdg.start) p_offset;
|
||||
# else /* defined(__NetBSD__) */
|
||||
struct disklabel label;
|
||||
int index;
|
||||
u_int32_t p_offset;
|
||||
# endif /* !defined(__NetBSD__) */
|
||||
int dos_part = -1;
|
||||
int bsd_part = -1;
|
||||
auto int find_partition (grub_disk_t dsk,
|
||||
|
@ -1077,39 +1181,25 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
int find_partition (grub_disk_t dsk __attribute__ ((unused)),
|
||||
const grub_partition_t partition)
|
||||
{
|
||||
struct grub_msdos_partition *pcdata = NULL;
|
||||
grub_disk_addr_t part_start = 0;
|
||||
grub_util_info ("Partition %d starts from %lu",
|
||||
partition->number, partition->start);
|
||||
|
||||
if (strcmp (partition->partmap->name, "part_msdos") == 0)
|
||||
pcdata = partition->data;
|
||||
part_start = grub_partition_get_start (partition);
|
||||
|
||||
if (pcdata)
|
||||
if (p_offset == part_start)
|
||||
{
|
||||
if (pcdata->bsd_part < 0)
|
||||
grub_util_info ("DOS partition %d starts from %lu",
|
||||
pcdata->dos_part, partition->start);
|
||||
else
|
||||
grub_util_info ("BSD partition %d,%c starts from %lu",
|
||||
pcdata->dos_part, pcdata->bsd_part + 'a',
|
||||
partition->start);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_util_info ("Partition %d starts from %lu",
|
||||
partition->index, partition->start);
|
||||
}
|
||||
|
||||
if (hdg.start == partition->start)
|
||||
{
|
||||
if (pcdata)
|
||||
if (partition->parent)
|
||||
{
|
||||
dos_part = pcdata->dos_part;
|
||||
bsd_part = pcdata->bsd_part;
|
||||
dos_part = partition->parent->number;
|
||||
bsd_part = partition->number;
|
||||
}
|
||||
else
|
||||
{
|
||||
dos_part = partition->index;
|
||||
dos_part = partition->number;
|
||||
bsd_part = -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1118,8 +1208,15 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
|
||||
name = make_device_name (drive, -1, -1);
|
||||
|
||||
# if !defined(__NetBSD__)
|
||||
if (MAJOR (st.st_rdev) == FLOPPY_MAJOR)
|
||||
return name;
|
||||
# else /* defined(__NetBSD__) */
|
||||
/* Since os_dev and convert_system_partition_to_system_disk (os_dev) are
|
||||
* different, we know that os_dev is of the form /dev/r[wsc]d[0-9]+[a-z]
|
||||
* and in particular it cannot be a floppy device. */
|
||||
index = os_dev[strlen(os_dev) - 1] - 'a';
|
||||
# endif /* !defined(__NetBSD__) */
|
||||
|
||||
fd = open (os_dev, O_RDONLY);
|
||||
if (fd == -1)
|
||||
|
@ -1129,10 +1226,15 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
# if !defined(__NetBSD__)
|
||||
if (ioctl (fd, HDIO_GETGEO, &hdg))
|
||||
# else /* defined(__NetBSD__) */
|
||||
configure_device_driver (fd);
|
||||
if (ioctl (fd, DIOCGDINFO, &label) == -1)
|
||||
# endif /* !defined(__NetBSD__) */
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"cannot get geometry of `%s'", os_dev);
|
||||
"cannot get disk geometry of `%s'", os_dev);
|
||||
close (fd);
|
||||
free (name);
|
||||
return 0;
|
||||
|
@ -1140,9 +1242,22 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
|
||||
close (fd);
|
||||
|
||||
grub_util_info ("%s starts from %lu", os_dev, hdg.start);
|
||||
# if !defined(__NetBSD__)
|
||||
p_offset = hdg.start;
|
||||
# else /* defined(__NetBSD__) */
|
||||
if (index >= label.d_npartitions)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"no disk label entry for `%s'", os_dev);
|
||||
free (name);
|
||||
return 0;
|
||||
}
|
||||
p_offset = label.d_partitions[index].p_offset;
|
||||
# endif /* !defined(__NetBSD__) */
|
||||
|
||||
if (hdg.start == 0 && device_is_wholedisk (os_dev))
|
||||
grub_util_info ("%s starts from %lu", os_dev, p_offset);
|
||||
|
||||
if (p_offset == 0 && device_is_wholedisk (os_dev))
|
||||
return name;
|
||||
|
||||
grub_util_info ("opening the device %s", name);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if [ x$1 == x ]; then
|
||||
if [ "x$1" = "x" ]; then
|
||||
echo "Filename required".
|
||||
fi
|
||||
|
||||
|
|
|
@ -165,8 +165,7 @@ else
|
|||
fi
|
||||
|
||||
# Create the GRUB directory if it is not present.
|
||||
test -d "$bootdir" || mkdir "$bootdir" || exit 1
|
||||
test -d "$grubdir" || mkdir "$grubdir" || exit 1
|
||||
mkdir -p "$grubdir" || exit 1
|
||||
|
||||
# If --recheck is specified, remove the device map, if present.
|
||||
if test $recheck = yes; then
|
||||
|
@ -223,7 +222,10 @@ fi
|
|||
# Then the partition map module. In order to support partition-less media,
|
||||
# this command is allowed to fail (--target=fs already grants us that the
|
||||
# filesystem will be accessible).
|
||||
partmap_module=`$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null`
|
||||
partmap_module=
|
||||
for x in `$grub_probe --target=partmap --device ${grub_device} 2> /dev/null`; do
|
||||
partmap_module="$partmap_module part_$x";
|
||||
done
|
||||
|
||||
# Device abstraction module, if any (lvm, raid).
|
||||
devabstraction_module=`$grub_probe --target=abstraction --device-map=${device_map} ${grubdir}`
|
||||
|
|
|
@ -116,15 +116,10 @@ setup (const char *dir,
|
|||
int NESTED_FUNC_ATTR find_usable_region_msdos (grub_disk_t disk __attribute__ ((unused)),
|
||||
const grub_partition_t p)
|
||||
{
|
||||
struct grub_msdos_partition *pcdata = p->data;
|
||||
|
||||
/* There's always an embed region, and it starts right after the MBR. */
|
||||
embed_region.start = 1;
|
||||
|
||||
/* For its end offset, include as many dummy partitions as we can. */
|
||||
if (! grub_msdos_partition_is_empty (pcdata->dos_type)
|
||||
&& ! grub_msdos_partition_is_bsd (pcdata->dos_type)
|
||||
&& embed_region.end > p->start)
|
||||
if (embed_region.end > p->start)
|
||||
embed_region.end = p->start;
|
||||
|
||||
return 0;
|
||||
|
@ -135,17 +130,21 @@ setup (const char *dir,
|
|||
int NESTED_FUNC_ATTR find_usable_region_gpt (grub_disk_t disk __attribute__ ((unused)),
|
||||
const grub_partition_t p)
|
||||
{
|
||||
struct grub_gpt_partentry *gptdata = p->data;
|
||||
struct grub_gpt_partentry gptdata;
|
||||
|
||||
disk->partition = p->parent;
|
||||
if (grub_disk_read (disk, p->offset, p->index,
|
||||
sizeof (gptdata), &gptdata))
|
||||
return 0;
|
||||
|
||||
/* If there's an embed region, it is in a dedicated partition. */
|
||||
if (! memcmp (&gptdata->type, &grub_gpt_partition_type_bios_boot, 16))
|
||||
if (! memcmp (&gptdata.type, &grub_gpt_partition_type_bios_boot, 16))
|
||||
{
|
||||
embed_region.start = p->start;
|
||||
embed_region.end = p->start + p->len;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -289,22 +288,19 @@ setup (const char *dir,
|
|||
/* Embed information about the installed location. */
|
||||
if (root_dev->disk->partition)
|
||||
{
|
||||
if (strcmp (root_dev->disk->partition->partmap->name,
|
||||
"part_msdos") == 0)
|
||||
{
|
||||
struct grub_msdos_partition *pcdata =
|
||||
root_dev->disk->partition->data;
|
||||
dos_part = pcdata->dos_part;
|
||||
bsd_part = pcdata->bsd_part;
|
||||
}
|
||||
else if (strcmp (root_dev->disk->partition->partmap->name,
|
||||
"part_gpt") == 0)
|
||||
{
|
||||
dos_part = root_dev->disk->partition->index;
|
||||
bsd_part = -1;
|
||||
}
|
||||
if (root_dev->disk->partition->parent)
|
||||
{
|
||||
if (root_dev->disk->partition->parent->parent)
|
||||
grub_util_error ("Installing on doubly nested partitions is "
|
||||
"not supported");
|
||||
dos_part = root_dev->disk->partition->parent->number;
|
||||
bsd_part = root_dev->disk->partition->number;
|
||||
}
|
||||
else
|
||||
grub_util_error (_("no DOS-style partitions found"));
|
||||
{
|
||||
dos_part = root_dev->disk->partition->number;
|
||||
bsd_part = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
dos_part = bsd_part = -1;
|
||||
|
@ -337,6 +333,8 @@ setup (const char *dir,
|
|||
int NESTED_FUNC_ATTR identify_partmap (grub_disk_t disk __attribute__ ((unused)),
|
||||
const grub_partition_t p)
|
||||
{
|
||||
if (p->parent)
|
||||
return 0;
|
||||
dest_partmap = p->partmap->name;
|
||||
return 1;
|
||||
}
|
||||
|
@ -349,16 +347,16 @@ setup (const char *dir,
|
|||
goto unable_to_embed;
|
||||
}
|
||||
|
||||
if (strcmp (dest_partmap, "part_msdos") == 0)
|
||||
if (strcmp (dest_partmap, "msdos") == 0)
|
||||
grub_partition_iterate (dest_dev->disk, find_usable_region_msdos);
|
||||
else if (strcmp (dest_partmap, "part_gpt") == 0)
|
||||
else if (strcmp (dest_partmap, "gpt") == 0)
|
||||
grub_partition_iterate (dest_dev->disk, find_usable_region_gpt);
|
||||
else
|
||||
grub_util_error (_("No DOS-style partitions found"));
|
||||
|
||||
if (embed_region.end == embed_region.start)
|
||||
{
|
||||
if (! strcmp (dest_partmap, "part_msdos"))
|
||||
if (! strcmp (dest_partmap, "msdos"))
|
||||
grub_util_warn (_("This msdos-style partition label has no post-MBR gap; embedding won't be possible!"));
|
||||
else
|
||||
grub_util_warn (_("This GPT partition label has no BIOS Boot Partition; embedding won't be possible!"));
|
||||
|
|
|
@ -161,8 +161,7 @@ fi
|
|||
# XXX warn on firmware-unreadable filesystems?
|
||||
|
||||
# Create the GRUB directory if it is not present.
|
||||
test -d "$bootdir" || mkdir "$bootdir" || exit 1
|
||||
test -d "$grubdir" || mkdir "$grubdir" || exit 1
|
||||
mkdir -p "$grubdir" || exit 1
|
||||
|
||||
# Create the device map file if it is not present.
|
||||
if test -f "$device_map"; then
|
||||
|
@ -199,7 +198,10 @@ fi
|
|||
# Then the partition map module. In order to support partition-less media,
|
||||
# this command is allowed to fail (--target=fs already grants us that the
|
||||
# filesystem will be accessible).
|
||||
partmap_module=`$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null`
|
||||
partmap_module=
|
||||
for x in `$grub_probe --target=partmap --device ${grub_device} 2> /dev/null`; do
|
||||
partmap_module="$partmap_module part_$x";
|
||||
done
|
||||
|
||||
# Device abstraction module, if any (lvm, raid).
|
||||
devabstraction_module=`$grub_probe --target=abstraction --device-map=${device_map} ${grubdir}`
|
||||
|
|
59
util/misc.c
59
util/misc.c
|
@ -35,6 +35,7 @@
|
|||
#endif
|
||||
|
||||
#include <grub/kernel.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/cache.h>
|
||||
#include <grub/util/misc.h>
|
||||
|
@ -262,56 +263,6 @@ grub_util_write_image (const char *img, size_t size, FILE *out)
|
|||
grub_util_error ("write failed");
|
||||
}
|
||||
|
||||
void *
|
||||
grub_malloc (grub_size_t size)
|
||||
{
|
||||
return xmalloc (size);
|
||||
}
|
||||
|
||||
void *
|
||||
grub_zalloc (grub_size_t size)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
ret = xmalloc (size);
|
||||
memset (ret, 0, size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
grub_free (void *ptr)
|
||||
{
|
||||
free (ptr);
|
||||
}
|
||||
|
||||
void *
|
||||
grub_realloc (void *ptr, grub_size_t size)
|
||||
{
|
||||
return xrealloc (ptr, size);
|
||||
}
|
||||
|
||||
void *
|
||||
grub_memalign (grub_size_t align, grub_size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
#if defined(HAVE_POSIX_MEMALIGN)
|
||||
if (posix_memalign (&p, align, size) != 0)
|
||||
p = 0;
|
||||
#elif defined(HAVE_MEMALIGN)
|
||||
p = memalign (align, size);
|
||||
#else
|
||||
(void) align;
|
||||
(void) size;
|
||||
grub_util_error ("grub_memalign is not supported");
|
||||
#endif
|
||||
|
||||
if (! p)
|
||||
grub_util_error ("out of memory");
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Some functions that we don't use. */
|
||||
void
|
||||
grub_mm_init_region (void *addr __attribute__ ((unused)),
|
||||
|
@ -319,10 +270,12 @@ grub_mm_init_region (void *addr __attribute__ ((unused)),
|
|||
{
|
||||
}
|
||||
|
||||
#if GRUB_NO_MODULES
|
||||
void
|
||||
grub_register_exported_symbols (void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
grub_exit (void)
|
||||
|
@ -374,7 +327,7 @@ grub_millisleep (grub_uint32_t ms)
|
|||
|
||||
#endif
|
||||
|
||||
#if !(defined (__i386__) || defined (__x86_64__))
|
||||
#if !(defined (__i386__) || defined (__x86_64__)) && GRUB_NO_MODULES
|
||||
void
|
||||
grub_arch_sync_caches (void *address __attribute__ ((unused)),
|
||||
grub_size_t len __attribute__ ((unused)))
|
||||
|
@ -604,10 +557,10 @@ make_system_path_relative_to_its_root (const char *path)
|
|||
void
|
||||
grub_util_init_nls (void)
|
||||
{
|
||||
#if ENABLE_NLS
|
||||
#if (defined(ENABLE_NLS) && ENABLE_NLS)
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
#endif /* ENABLE_NLS */
|
||||
#endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -640,11 +640,11 @@ int FDECL2(main, int, argc, char **, argv){
|
|||
char *log_file = 0;
|
||||
|
||||
set_program_name (argv[0]);
|
||||
#if ENABLE_NLS
|
||||
#if (defined(ENABLE_NLS) && ENABLE_NLS)
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
#endif /* ENABLE_NLS */
|
||||
#endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */
|
||||
|
||||
if (argc < 2)
|
||||
usage();
|
||||
|
|
|
@ -30,12 +30,12 @@
|
|||
#include <prototyp.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if ENABLE_NLS
|
||||
#if (defined(ENABLE_NLS) && ENABLE_NLS)
|
||||
|
||||
# include <locale.h>
|
||||
# include <libintl.h>
|
||||
|
||||
#else /* ! ENABLE_NLS */
|
||||
#else /* ! (defined(ENABLE_NLS) && ENABLE_NLS) */
|
||||
|
||||
/* Disabled NLS.
|
||||
The casts to 'const char *' serve the purpose of producing warnings
|
||||
|
@ -43,7 +43,7 @@
|
|||
On pre-ANSI systems without 'const', the config.h file is supposed to
|
||||
contain "#define const". */
|
||||
# define gettext(Msgid) ((const char *) (Msgid))
|
||||
#endif /* ENABLE_NLS */
|
||||
#endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */
|
||||
|
||||
#define _(str) gettext(str)
|
||||
#define N_(str) str
|
||||
|
|
85
util/mm.c
Normal file
85
util/mm.c
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/mm.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void *
|
||||
grub_malloc (grub_size_t size)
|
||||
{
|
||||
void *ret;
|
||||
ret = malloc (size);
|
||||
if (!ret)
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *
|
||||
grub_zalloc (grub_size_t size)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
ret = grub_malloc (size);
|
||||
if (!ret)
|
||||
return NULL;
|
||||
memset (ret, 0, size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
grub_free (void *ptr)
|
||||
{
|
||||
free (ptr);
|
||||
}
|
||||
|
||||
void *
|
||||
grub_realloc (void *ptr, grub_size_t size)
|
||||
{
|
||||
void *ret;
|
||||
ret = realloc (ptr, size);
|
||||
if (!ret)
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *
|
||||
grub_memalign (grub_size_t align, grub_size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
#if defined(HAVE_POSIX_MEMALIGN)
|
||||
if (align < sizeof (void *))
|
||||
align = sizeof (void *);
|
||||
if (posix_memalign (&p, align, size) != 0)
|
||||
p = 0;
|
||||
#elif defined(HAVE_MEMALIGN)
|
||||
p = memalign (align, size);
|
||||
#else
|
||||
(void) align;
|
||||
(void) size;
|
||||
grub_util_error ("grub_memalign is not supported");
|
||||
#endif
|
||||
|
||||
if (!p)
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
|
||||
|
||||
return p;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue