clear the bss at the startup and fix some netboot bugs.

This commit is contained in:
okuji 1999-10-22 17:32:23 +00:00
parent f4c8bacd5a
commit 1f6d422a9a
23 changed files with 2406 additions and 125 deletions

View file

@ -1,3 +1,58 @@
1999-10-23 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
From Michael Hohmuth <hohmuth@innocent.com>:
* acconfig.h (HAVE_USCORE_USCORE_BSS_START_SYMBOL): Added the
`undef' entry.
(HAVE_EDATA_SYMBOL): Likewise.
(HAVE_USCORE_EDATA_SYMBOL): Likewise.
* acinclude.m4 (grub_CHECK_USCORE_USCORE_BSS_START_SYMBOL): New
function.
(grub_CHECK_EDATA_SYMBOL): Likewise.
(grub_CHECK_USCORE_EDATA_SYMBOL): Likewise.
* configure.in: Check for __bss, edata and _edata.
* netboot/Makefile.am (DRIVERS): Deleted ns8390.c and ns8390.h.
(libdrivers_a_LIBADD): New variable.
($(libdrivers_a_LIBADD)): New target.
(nepci_o_CFLAGS): New variable.
(ne_o_CFLAGS): Likewise.
(wd_o_CFLAGS): Likewise.
(t503_o_CFLAGS): Likewise.
* netboot/fsys_tftp.c (tftp_close): New function.
* stage2/boot.c (load_image): Call grub_close before return.
(load_initrd): Likewise.
(load_module): Likewise.
* stage2/builtins.c (cat_func): Likewise.
(chainloader_func): Likewise.
(configfile_func): Likewise.
(embed_func): Likewise.
(find_func): Likewise.
(install_func): Set IS_OPEN to the value returned by grub_open.
If IS_OPEN is non-zero, call grub_close before return.
(setup_func): Call grub_close after grub_open.
(testload): Call grub_close before return.
* stage2/disk_io.c (fsys_table): Add the `close' member into
each of the entries. For TFTP, tftp_close is added, and for the
rest, NULL is added.
(grub_read): "|" -> "||".
(grub_close): New function.
* stage2/filesys.h [FSYS_TFTP] (tftp_close): Declared.
(struct fsys_entry): Added close_func.
* stage2/shared.h (grub_close): Declared.
* stage2/stage1_5.c (cmain): Call grub_close after grub_open.
* stage2/stage2.c (cmain): Clear ERRNUM after calling
find_command to just ignore the error code.
Call grub_close after loading the configuration file.
* stage2/asm.S (main): Clean out the bss.
1999-10-23 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
* docs/new-grub.texi: Updated.
* docs/user-ref.texi: Likewise.
* docs/tutorial.texi: Likewise.
* docs/prog-ref.texi: Likewise.
* docs/appendices.texi: Likewise.
1999-10-22 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
* docs/prog-ref.texi: New file.

1
THANKS
View file

@ -22,6 +22,7 @@ John Tobey <spam@john-edwin-tobey.org>
Klaus Reichl <klaus.reichl@alcatel.at>
Kunihiro Ishiguro <kunihiro@zebra.org>
Mark Lundeberg <aa026@pgfn.bc.ca>
Michael Hohmuth <hohmuth@innocent.com>
Miles Bader <miles@gnu.org>
OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
Pavel Roskin <pavel_roskin@geocities.com>

View file

@ -10,6 +10,15 @@
/* Defined if _start is defined. */
#undef HAVE_USCORE_START_SYMBOL
/* Defined if __bss_start is defined. */
#undef HAVE_USCORE_USCORE_BSS_START_SYMBOL
/* Defined if edata is defined. */
#undef HAVE_EDATA_SYMBOL
/* Defined if _edata is defined. */
#undef HAVE_USCORE_EDATA_SYMBOL
/* Defined if end is defined. */
#undef HAVE_END_SYMBOL

View file

@ -1,3 +1,15 @@
dnl aclocal.m4 generated automatically by aclocal 1.4a
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
dnl PARTICULAR PURPOSE.
dnl grub_ASM_USCORE checks if C symbols get an underscore after
dnl compiling to assembler.
dnl Written by Pavel Roskin. Based on grub_ASM_EXT_C written by
@ -189,6 +201,63 @@ fi
AC_MSG_RESULT([$grub_cv_check_uscore_start_symbol])
])
dnl
dnl grub_CHECK_USCORE_USCORE_BSS_START_SYMBOL checks if __bss_start is
dnl automatically defined by the compiler.
dnl Written by Michael Hohmoth.
AC_DEFUN(grub_CHECK_USCORE_USCORE_BSS_START_SYMBOL,
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if __bss_start is defined by the compiler])
AC_CACHE_VAL(grub_cv_check_uscore_uscore_bss_start_symbol,
[AC_TRY_LINK([], [asm ("incl __bss_start")],
grub_cv_check_uscore_uscore_bss_start_symbol=yes,
grub_cv_check_uscore_uscore_bss_start_symbol=no)])
if test "x$grub_cv_check_uscore_uscore_bss_start_symbol" = xyes; then
AC_DEFINE([HAVE_USCORE_USCORE_BSS_START_SYMBOL])
fi
AC_MSG_RESULT([$grub_cv_check_uscore_uscore_bss_start_symbol])
])
dnl
dnl grub_CHECK_EDATA_SYMBOL checks if edata is automatically defined by the
dnl compiler.
dnl Written by Michael Hohmuth.
AC_DEFUN(grub_CHECK_EDATA_SYMBOL,
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if edata is defined by the compiler])
AC_CACHE_VAL(grub_cv_check_edata_symbol,
[AC_TRY_LINK([], [asm ("incl edata")],
grub_cv_check_edata_symbol=yes,
grub_cv_check_edata_symbol=no)])
if test "x$grub_cv_check_edata_symbol" = xyes; then
AC_DEFINE([HAVE_EDATA_SYMBOL])
fi
AC_MSG_RESULT([$grub_cv_check_edata_symbol])
])
dnl
dnl grub_CHECK_USCORE_EDATA_SYMBOL checks if _edata is automatically
dnl defined by the compiler.
dnl Written by Michael Hohmuth.
AC_DEFUN(grub_CHECK_USCORE_EDATA_SYMBOL,
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if _edata is defined by the compiler])
AC_CACHE_VAL(grub_cv_check_uscore_edata_symbol,
[AC_TRY_LINK([], [asm ("incl _edata")],
grub_cv_check_uscore_edata_symbol=yes,
grub_cv_check_uscore_edata_symbol=no)])
if test "x$grub_cv_check_uscore_edata_symbol" = xyes; then
AC_DEFINE([HAVE_USCORE_EDATA_SYMBOL])
fi
AC_MSG_RESULT([$grub_cv_check_uscore_edata_symbol])
])
dnl
dnl grub_CHECK_END_SYMBOL checks if end is automatically defined by the
dnl compiler.
@ -226,3 +295,174 @@ fi
AC_MSG_RESULT([$grub_cv_check_uscore_end_symbol])
])
# Do all the work for Automake. This macro actually does too much --
# some checks are only needed if your package does certain things.
# But this isn't really a big deal.
# serial 1
dnl Usage:
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
AC_DEFUN(AM_INIT_AUTOMAKE,
[AC_REQUIRE([AC_PROG_INSTALL])
dnl We require 2.13 because we rely on SHELL being computed by configure.
AC_PREREQ([2.13])
PACKAGE=[$1]
AC_SUBST(PACKAGE)
VERSION=[$2]
AC_SUBST(VERSION)
dnl test to see if srcdir already configured
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
ifelse([$3],,
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
AC_REQUIRE([AM_SANITY_CHECK])
AC_REQUIRE([AC_ARG_PROGRAM])
dnl FIXME This is truly gross.
missing_dir=`cd $ac_aux_dir && pwd`
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
dnl Set install_sh for make dist
install_sh="$missing_dir/install-sh"
test -f "$install_sh" || install_sh="$missing_dir/install.sh"
AC_SUBST(install_sh)
dnl We check for tar when the user configures the end package.
dnl This is sad, since we only need this for "dist". However,
dnl there's no other good way to do it. We prefer GNU tar if
dnl we can find it. If we can't find a tar, it doesn't really matter.
AC_CHECK_PROGS(AMTAR, gnutar gtar tar)
dnl We need awk for the "check" target. The system "awk" is bad on
dnl some platforms.
AC_REQUIRE([AC_PROG_AWK])
AMTARFLAGS=
if test -n "$AMTAR"; then
if $SHELL -c "$AMTAR --version" > /dev/null 2>&1; then
dnl We have GNU tar.
AMTARFLAGS=o
fi
fi
AC_SUBST(AMTARFLAGS)
AC_REQUIRE([AC_PROG_MAKE_SET])])
#
# Check to make sure that the build environment is sane.
#
AC_DEFUN(AM_SANITY_CHECK,
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftestfile
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
if test "[$]*" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftestfile`
fi
if test "[$]*" != "X $srcdir/configure conftestfile" \
&& test "[$]*" != "X conftestfile $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "[$]2" = conftestfile
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
rm -f conftest*
AC_MSG_RESULT(yes)])
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
dnl The program must properly implement --version.
AC_DEFUN(AM_MISSING_PROG,
[AC_MSG_CHECKING(for working $2)
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if ($2 --version) < /dev/null > /dev/null 2>&1; then
$1=$2
AC_MSG_RESULT(found)
else
$1="$3/missing $2"
AC_MSG_RESULT(missing)
fi
AC_SUBST($1)])
# Like AC_CONFIG_HEADER, but automatically create stamp file.
AC_DEFUN(AM_CONFIG_HEADER,
[AC_PREREQ([2.12])
AC_CONFIG_HEADER([$1])
dnl When config.status generates a header, we must update the stamp-h file.
dnl This file resides in the same directory as the config header
dnl that is generated. We must strip everything past the first ":",
dnl and everything past the last "/".
AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
<<am_indx=1
for am_file in <<$1>>; do
case " <<$>>CONFIG_HEADERS " in
*" <<$>>am_file "*<<)>>
echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
;;
esac
am_indx=`expr "<<$>>am_indx" + 1`
done<<>>dnl>>)
changequote([,]))])
# Add --enable-maintainer-mode option to configure.
# From Jim Meyering
# serial 1
AC_DEFUN(AM_MAINTAINER_MODE,
[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
dnl maintainer-mode is disabled by default
AC_ARG_ENABLE(maintainer-mode,
[ --enable-maintainer-mode enable make rules and dependencies not useful
(and sometimes confusing) to the casual installer],
USE_MAINTAINER_MODE=$enableval,
USE_MAINTAINER_MODE=no)
AC_MSG_RESULT($USE_MAINTAINER_MODE)
AM_CONDITIONAL(MAINTAINER_MODE, test $USE_MAINTAINER_MODE = yes)
MAINT=$MAINTAINER_MODE_TRUE
AC_SUBST(MAINT)dnl
]
)
# Define a conditional.
AC_DEFUN(AM_CONDITIONAL,
[AC_SUBST($1_TRUE)
AC_SUBST($1_FALSE)
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi])

70
aclocal.m4 vendored
View file

@ -10,6 +10,18 @@ dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
dnl PARTICULAR PURPOSE.
dnl aclocal.m4 generated automatically by aclocal 1.4a
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
dnl PARTICULAR PURPOSE.
dnl grub_ASM_USCORE checks if C symbols get an underscore after
dnl compiling to assembler.
dnl Written by Pavel Roskin. Based on grub_ASM_EXT_C written by
@ -201,6 +213,63 @@ fi
AC_MSG_RESULT([$grub_cv_check_uscore_start_symbol])
])
dnl
dnl grub_CHECK_USCORE_USCORE_BSS_START_SYMBOL checks if __bss_start is
dnl automatically defined by the compiler.
dnl Written by Michael Hohmoth.
AC_DEFUN(grub_CHECK_USCORE_USCORE_BSS_START_SYMBOL,
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if __bss_start is defined by the compiler])
AC_CACHE_VAL(grub_cv_check_uscore_uscore_bss_start_symbol,
[AC_TRY_LINK([], [asm ("incl __bss_start")],
grub_cv_check_uscore_uscore_bss_start_symbol=yes,
grub_cv_check_uscore_uscore_bss_start_symbol=no)])
if test "x$grub_cv_check_uscore_uscore_bss_start_symbol" = xyes; then
AC_DEFINE([HAVE_USCORE_USCORE_BSS_START_SYMBOL])
fi
AC_MSG_RESULT([$grub_cv_check_uscore_uscore_bss_start_symbol])
])
dnl
dnl grub_CHECK_EDATA_SYMBOL checks if edata is automatically defined by the
dnl compiler.
dnl Written by Michael Hohmuth.
AC_DEFUN(grub_CHECK_EDATA_SYMBOL,
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if edata is defined by the compiler])
AC_CACHE_VAL(grub_cv_check_edata_symbol,
[AC_TRY_LINK([], [asm ("incl edata")],
grub_cv_check_edata_symbol=yes,
grub_cv_check_edata_symbol=no)])
if test "x$grub_cv_check_edata_symbol" = xyes; then
AC_DEFINE([HAVE_EDATA_SYMBOL])
fi
AC_MSG_RESULT([$grub_cv_check_edata_symbol])
])
dnl
dnl grub_CHECK_USCORE_EDATA_SYMBOL checks if _edata is automatically
dnl defined by the compiler.
dnl Written by Michael Hohmuth.
AC_DEFUN(grub_CHECK_USCORE_EDATA_SYMBOL,
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if _edata is defined by the compiler])
AC_CACHE_VAL(grub_cv_check_uscore_edata_symbol,
[AC_TRY_LINK([], [asm ("incl _edata")],
grub_cv_check_uscore_edata_symbol=yes,
grub_cv_check_uscore_edata_symbol=no)])
if test "x$grub_cv_check_uscore_edata_symbol" = xyes; then
AC_DEFINE([HAVE_USCORE_EDATA_SYMBOL])
fi
AC_MSG_RESULT([$grub_cv_check_uscore_edata_symbol])
])
dnl
dnl grub_CHECK_END_SYMBOL checks if end is automatically defined by the
dnl compiler.
@ -409,3 +478,4 @@ else
$1_FALSE=
fi])

166
configure vendored
View file

@ -1776,9 +1776,9 @@ if test "x$grub_cv_check_start_symbol" != "xyes" \
fi
echo $ac_n "checking if end is defined by the compiler""... $ac_c" 1>&6
echo "configure:1781: checking if end is defined by the compiler" >&5
if eval "test \"\${grub_cv_check_end_symbol+set}\" = set"; then
echo $ac_n "checking if __bss_start is defined by the compiler""... $ac_c" 1>&6
echo "configure:1781: checking if __bss_start is defined by the compiler" >&5
if eval "test \"\${grub_cv_check_uscore_uscore_bss_start_symbol+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
@ -1786,10 +1786,124 @@ else
#include "confdefs.h"
int main() {
asm ("incl end")
asm ("incl __bss_start")
; return 0; }
EOF
if { (eval echo configure:1793: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
grub_cv_check_uscore_uscore_bss_start_symbol=yes
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
grub_cv_check_uscore_uscore_bss_start_symbol=no
fi
rm -f conftest*
fi
if test "x$grub_cv_check_uscore_uscore_bss_start_symbol" = xyes; then
cat >> confdefs.h <<\EOF
#define HAVE_USCORE_USCORE_BSS_START_SYMBOL 1
EOF
fi
echo "$ac_t""$grub_cv_check_uscore_uscore_bss_start_symbol" 1>&6
echo $ac_n "checking if _edata is defined by the compiler""... $ac_c" 1>&6
echo "configure:1817: checking if _edata is defined by the compiler" >&5
if eval "test \"\${grub_cv_check_uscore_edata_symbol+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1822 "configure"
#include "confdefs.h"
int main() {
asm ("incl _edata")
; return 0; }
EOF
if { (eval echo configure:1829: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
grub_cv_check_uscore_edata_symbol=yes
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
grub_cv_check_uscore_edata_symbol=no
fi
rm -f conftest*
fi
if test "x$grub_cv_check_uscore_edata_symbol" = xyes; then
cat >> confdefs.h <<\EOF
#define HAVE_USCORE_EDATA_SYMBOL 1
EOF
fi
echo "$ac_t""$grub_cv_check_uscore_edata_symbol" 1>&6
echo $ac_n "checking if edata is defined by the compiler""... $ac_c" 1>&6
echo "configure:1853: checking if edata is defined by the compiler" >&5
if eval "test \"\${grub_cv_check_edata_symbol+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1858 "configure"
#include "confdefs.h"
int main() {
asm ("incl edata")
; return 0; }
EOF
if { (eval echo configure:1865: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
grub_cv_check_edata_symbol=yes
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
grub_cv_check_edata_symbol=no
fi
rm -f conftest*
fi
if test "x$grub_cv_check_edata_symbol" = xyes; then
cat >> confdefs.h <<\EOF
#define HAVE_EDATA_SYMBOL 1
EOF
fi
echo "$ac_t""$grub_cv_check_edata_symbol" 1>&6
if test "x$grub_cv_check_uscore_uscore_bss_start_symbol" != "xyes" \
-a "x$grub_cv_check_uscore_edata_symbol" != "xyes" \
-a "x$grub_cv_check_edata_symbol" != "xyes"; then
{ echo "configure: error: None of __bss_start, _edata, edata defined" 1>&2; exit 1; }
fi
echo $ac_n "checking if end is defined by the compiler""... $ac_c" 1>&6
echo "configure:1895: checking if end is defined by the compiler" >&5
if eval "test \"\${grub_cv_check_end_symbol+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1900 "configure"
#include "confdefs.h"
int main() {
asm ("incl end")
; return 0; }
EOF
if { (eval echo configure:1907: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
grub_cv_check_end_symbol=yes
else
@ -1813,19 +1927,19 @@ echo "$ac_t""$grub_cv_check_end_symbol" 1>&6
echo $ac_n "checking if _end is defined by the compiler""... $ac_c" 1>&6
echo "configure:1817: checking if _end is defined by the compiler" >&5
echo "configure:1931: checking if _end is defined by the compiler" >&5
if eval "test \"\${grub_cv_check_uscore_end_symbol+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1822 "configure"
#line 1936 "configure"
#include "confdefs.h"
int main() {
asm ("incl _end")
; return 0; }
EOF
if { (eval echo configure:1829: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1943: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
grub_cv_check_uscore_end_symbol=yes
else
@ -1863,7 +1977,7 @@ fi
# Get the filename or the whole disk and open it.
# Known to work on NetBSD.
echo $ac_n "checking for opendisk in -lutil""... $ac_c" 1>&6
echo "configure:1867: checking for opendisk in -lutil" >&5
echo "configure:1981: checking for opendisk in -lutil" >&5
ac_lib_var=`echo util'_'opendisk | sed 'y%./+-:%__p__%'`
if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -1871,7 +1985,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lutil $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1875 "configure"
#line 1989 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -1882,7 +1996,7 @@ int main() {
opendisk()
; return 0; }
EOF
if { (eval echo configure:1886: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2000: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -1910,7 +2024,7 @@ fi
# Unless the user specify --without-curses, check for curses.
if test "x$with_curses" != "xno"; then
echo $ac_n "checking for wgetch in -lncurses""... $ac_c" 1>&6
echo "configure:1914: checking for wgetch in -lncurses" >&5
echo "configure:2028: checking for wgetch in -lncurses" >&5
ac_lib_var=`echo ncurses'_'wgetch | sed 'y%./+-:%__p__%'`
if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -1918,7 +2032,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lncurses $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1922 "configure"
#line 2036 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -1929,7 +2043,7 @@ int main() {
wgetch()
; return 0; }
EOF
if { (eval echo configure:1933: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2047: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -1952,7 +2066,7 @@ EOF
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for wgetch in -lcurses""... $ac_c" 1>&6
echo "configure:1956: checking for wgetch in -lcurses" >&5
echo "configure:2070: checking for wgetch in -lcurses" >&5
ac_lib_var=`echo curses'_'wgetch | sed 'y%./+-:%__p__%'`
if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -1960,7 +2074,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lcurses $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1964 "configure"
#line 2078 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -1971,7 +2085,7 @@ int main() {
wgetch()
; return 0; }
EOF
if { (eval echo configure:1975: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2089: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -2003,7 +2117,7 @@ fi
# Check for headers.
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:2007: checking how to run the C preprocessor" >&5
echo "configure:2121: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@ -2018,13 +2132,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
#line 2022 "configure"
#line 2136 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2028: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2142: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -2035,13 +2149,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
#line 2039 "configure"
#line 2153 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2045: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2159: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -2052,13 +2166,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
#line 2056 "configure"
#line 2170 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2062: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2176: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -2086,17 +2200,17 @@ for ac_hdr in string.h strings.h ncurses/curses.h ncurses.h curses.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:2090: checking for $ac_hdr" >&5
echo "configure:2204: checking for $ac_hdr" >&5
if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2095 "configure"
#line 2209 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2100: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2214: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*

View file

@ -121,6 +121,15 @@ if test "x$grub_cv_check_start_symbol" != "xyes" \
AC_MSG_ERROR([Neither start nor _start is defined])
fi
grub_CHECK_USCORE_USCORE_BSS_START_SYMBOL
grub_CHECK_USCORE_EDATA_SYMBOL
grub_CHECK_EDATA_SYMBOL
if test "x$grub_cv_check_uscore_uscore_bss_start_symbol" != "xyes" \
-a "x$grub_cv_check_uscore_edata_symbol" != "xyes" \
-a "x$grub_cv_check_edata_symbol" != "xyes"; then
AC_MSG_ERROR([None of __bss_start, _edata, edata defined])
fi
grub_CHECK_END_SYMBOL
grub_CHECK_USCORE_END_SYMBOL
if test "x$grub_cv_check_end_symbol" != "xyes" \

View file

@ -49,7 +49,9 @@ $ mke2fs /dev/fd0
Mount it on somewhere, say, @file{/mnt}.
@item
Copy the GRUB images to @file{/mnt/boot/grub}.
Copy the GRUB images to @file{/mnt/boot/grub}. Only @file{stage1},
@file{stage2} and @file{menu.lst} are necessary. You may not copy
@dfn{stage1.5}s.
@item
Run the following command:
@ -115,7 +117,7 @@ Multiboot-compliant, the world would be an utopia@dots{}
@node Obtaining and Building GRUB
@appendix Obtaining and Building GRUB
@appendix How to obtain and build GRUB
@quotation
@strong{Caution:} GRUB requires binutils-2.9.1.0.23 or later because the

View file

@ -97,38 +97,39 @@ edition documents version @value{VERSION}.
@menu
Part I: The Tutorial Manual
* Overview::
* Device Syntax::
* Installation::
* Boot::
* Configuration::
* Overview:: Starting to use GRUB
* Device Syntax:: How to specify a device
* Installation:: How to install GRUB on your drive
* Boot:: How to boot your operating systems
* Configuration:: Writing your configuration file
Part II: The User Reference Manual
* Introduction::
* Filesystem::
* Interface::
* Command::
* Troubleshooting::
* Invoking the grub shell::
* Invoking mbchk::
* Introduction:: Capturing the spirit of GRUB
* Filesystem:: Filesystem syntax and semantics
* Interface:: The menu and the command-line
* Command:: The list of available builtin commands
* Troubleshooting:: Error messages produced by GRUB
* Invoking the grub shell:: How to use the grub shell
* Invoking mbchk:: How to use the Multiboot checker
Part III: The Programmer Reference Manual
* Memory map::
* Embedded data::
* Filesystem interface::
* Bootstrap tricks::
* Memory detection::
* Low-level disk I/O::
* MBR::
* Partition table::
* Hacking:: Implementation details
* Memory map:: The memory map of various components
* Embedded data:: Embedded variables in GRUB
* Filesystem interface:: The generic interface for the fs code
* Bootstrap tricks:: The bootstrap mechanism used in GRUB
* Memory detection:: How to detect all installed @sc{ram}
* Low-level disk I/O:: INT 13H disk I/O interrupts
* MBR:: The structure of Master Boot Record
* Partition table:: The format of partition table
Appendices and Indices
* FAQ::
* Obtaining and Building GRUB::
* Reporting bugs::
* FAQ:: Frequently asked questions
* Obtaining and Building GRUB:: How to obtain and build GRUB
* Reporting bugs:: Where you should send a bug report
* Index::
@end menu

File diff suppressed because it is too large Load diff

View file

@ -276,6 +276,9 @@ command. An example is to set @samp{vga} to @samp{ext}:
grub> kernel /vmlinuz root=/dev/hda1 vga=ext
@end example
See the documentation in the Linux source tree, for the complete
information on the available options.
If you use initrd, execute the command @command{initrd} after
@command{kernel}:

View file

@ -1,7 +1,9 @@
@node Introduction
@chapter Introduction
This chapter documents the history and the features of GRUB.
This part documents the user-visible aspect of GRUB. If you are looking
for the information on the internals, see the Programmer Reference
Manual (@pxref{Hacking}).
@menu
* History:: From maggot to house fly.

View file

@ -11,10 +11,25 @@ endif
noinst_LIBRARIES = $(LIBDRIVERS)
DRIVERS = 3c509.c 3c509.h 3c59x.c cs89x0.c cs89x0.h eepro100.c \
lance.c ns8390.c ns8390.h
lance.c
libdrivers_a_SOURCES = byteorder.h config.c netboot_config.h \
fsys_tftp.c if.h io.h ip.c ip.h netboot.h netdevice.h nic.h \
pci.c pci.h $(DRIVERS)
libdrivers_a_CFLAGS = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
-DFSYS_TFTP $(NET_CFLAGS) $(NET_EXTRAFLAGS)
libdrivers_a_LIBADD = nepci.o ne.o wd.o t503.o
$(libdrivers_a_LIBADD): ns8390.c ns8390.h
$(libdrivers_a_LIBADD): %.o: ns8390.c
$(COMPILE) $($(basename $@)_o_CFLAGS) -o $@ -c $<
nepci_o_CFLAGS = $(filter-out -DINCLUDE_T503=1 -DINCLUDE_NE=1 \
-DINCLUDE_WD=1, $(libdrivers_a_CFLAGS))
ne_o_CFLAGS = $(filter-out -DINCLUDE_T503=1 -DINCLUDE_NEPCI=1 \
-DINCLUDE_WD=1, $(libdrivers_a_CFLAGS))
wd_o_CFLAGS = $(filter-out -DINCLUDE_T503=1 -DINCLUDE_NE=1 \
-DINCLUDE_NEPCI=1, $(libdrivers_a_CFLAGS))
t503_o_CFLAGS = $(filter-out -DINCLUDE_NE=1 -DINCLUDE_NEPCI=1 \
-DINCLUDE_WD=1, $(libdrivers_a_CFLAGS))

View file

@ -91,7 +91,7 @@ INCLUDES = -I$(top_srcdir)/stage1
noinst_LIBRARIES = $(LIBDRIVERS)
DRIVERS = 3c509.c 3c509.h 3c59x.c cs89x0.c cs89x0.h eepro100.c \
lance.c ns8390.c ns8390.h
lance.c
libdrivers_a_SOURCES = byteorder.h config.c netboot_config.h \
@ -101,6 +101,21 @@ libdrivers_a_SOURCES = byteorder.h config.c netboot_config.h \
libdrivers_a_CFLAGS = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
-DFSYS_TFTP $(NET_CFLAGS) $(NET_EXTRAFLAGS)
libdrivers_a_LIBADD = nepci.o ne.o wd.o t503.o
nepci_o_CFLAGS = $(filter-out -DINCLUDE_T503=1 -DINCLUDE_NE=1 \
-DINCLUDE_WD=1, $(libdrivers_a_CFLAGS))
ne_o_CFLAGS = $(filter-out -DINCLUDE_T503=1 -DINCLUDE_NEPCI=1 \
-DINCLUDE_WD=1, $(libdrivers_a_CFLAGS))
wd_o_CFLAGS = $(filter-out -DINCLUDE_T503=1 -DINCLUDE_NE=1 \
-DINCLUDE_NEPCI=1, $(libdrivers_a_CFLAGS))
t503_o_CFLAGS = $(filter-out -DINCLUDE_NE=1 -DINCLUDE_NEPCI=1 \
-DINCLUDE_WD=1, $(libdrivers_a_CFLAGS))
subdir = netboot
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
@ -113,11 +128,11 @@ CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
libdrivers_a_AR = $(AR) cru
libdrivers_a_LIBADD =
libdrivers_a_DEPENDENCIES = nepci.o ne.o wd.o t503.o
am_libdrivers_a_OBJECTS = libdrivers_a-config.o \
libdrivers_a-fsys_tftp.o libdrivers_a-ip.o libdrivers_a-pci.o \
libdrivers_a-3c509.o libdrivers_a-3c59x.o libdrivers_a-cs89x0.o \
libdrivers_a-eepro100.o libdrivers_a-lance.o libdrivers_a-ns8390.o
libdrivers_a-eepro100.o libdrivers_a-lance.o
libdrivers_a_OBJECTS = $(am_libdrivers_a_OBJECTS)
AR = ar
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@ -132,8 +147,7 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
GZIP_ENV = --best
DEP_FILES = .deps/3c509.P .deps/3c59x.P .deps/config.P .deps/cs89x0.P \
.deps/eepro100.P .deps/fsys_tftp.P .deps/ip.P .deps/lance.P \
.deps/ns8390.P .deps/pci.P
.deps/eepro100.P .deps/fsys_tftp.P .deps/ip.P .deps/lance.P .deps/pci.P
SOURCES = $(libdrivers_a_SOURCES)
OBJECTS = $(am_libdrivers_a_OBJECTS)
@ -175,7 +189,6 @@ libdrivers_a-3c59x.o: 3c59x.c
libdrivers_a-cs89x0.o: cs89x0.c
libdrivers_a-eepro100.o: eepro100.c
libdrivers_a-lance.o: lance.c
libdrivers_a-ns8390.o: ns8390.c
libdrivers.a: $(libdrivers_a_OBJECTS) $(libdrivers_a_DEPENDENCIES)
-rm -f libdrivers.a
@ -438,25 +451,6 @@ libdrivers_a-lance.lo: lance.c
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*D)/$(*F).P; \
rm -f .deps/$(*D)/$(*F).pp
libdrivers_a-ns8390.o: ns8390.c
@echo '$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o $@ $<'; \
$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -Wp,-MD,.deps/$(*D)/$(*F).pp -c -o $@ $<
@-cp .deps/$(*D)/$(*F).pp .deps/$(*D)/$(*F).P; \
tr ' ' '\012' < .deps/$(*D)/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*D)/$(*F).P; \
rm .deps/$(*D)/$(*F).pp
libdrivers_a-ns8390.lo: ns8390.c
@echo '$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o $@ $<'; \
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -Wp,-MD,.deps/$(*D)/$(*F).pp -c -o $@ $<
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
< .deps/$(*D)/$(*F).pp > .deps/$(*D)/$(*F).P; \
tr ' ' '\012' < .deps/$(*D)/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*D)/$(*F).P; \
rm -f .deps/$(*D)/$(*F).pp
info-am:
info: info-am
dvi-am:
@ -530,6 +524,10 @@ installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
$(libdrivers_a_LIBADD): ns8390.c ns8390.h
$(libdrivers_a_LIBADD): %.o: ns8390.c
$(COMPILE) $($(basename $@)_o_CFLAGS) -o $@ -c $<
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View file

@ -146,13 +146,11 @@ int tftp_dir(char *dirname)
return 1;
}
#if 0
void tftp_close(void)
{
buf_read = 0;
buf_fill(1); /* abort. */
buf_fill (1); /* abort. */
}
#endif
static int buf_fill(int abort)
{

View file

@ -117,6 +117,37 @@ codestart:
/* The ".code32" directive takes GAS out of 16-bit mode. */
.code32
/* clean out the bss */
/* set %edi to the bss starting address */
#if defined(HAVE_USCORE_USCORE_BSS_START_SYMBOL)
movl $__bss_start, %edi
#elif defined(HAVE_USCORE_EDATA_SYMBOL)
movl $_edata, %edi
#elif defined(HAVE_EDATA_SYMBOL)
movl $edata, %edi
#endif
/* set %ecx to the bss end */
#if defined(HAVE_END_SYMBOL)
movl $end, %ecx
#elif defined(HAVE_USCORE_END_SYMBOL)
movl $_end, %ecx
#endif
/* compute the bss length */
subl %edi, %ecx
/* zero %al */
xorb %al, %al
/* set the direction */
cld
/* clean out */
rep
stosb
/*
* Call the start of main body of C code, which does some
* of it's own initialization before transferring to "cmain".

View file

@ -64,6 +64,8 @@ load_image (char *kernel, char *arg)
if (!(len = grub_read (buffer, MULTIBOOT_SEARCH)) || len < 32)
{
grub_close ();
if (!errnum)
errnum = ERR_EXEC_FORMAT;
@ -77,6 +79,7 @@ load_image (char *kernel, char *arg)
flags = ((struct multiboot_header *) (buffer + i))->flags;
if (flags & MULTIBOOT_UNSUPPORTED)
{
grub_close ();
errnum = ERR_BOOT_FEATURES;
return KERNEL_TYPE_NONE;
}
@ -198,9 +201,10 @@ load_image (char *kernel, char *arg)
{
int big_linux = buffer[LINUX_SETUP_LOAD_FLAGS] & LINUX_FLAG_BIG_KERNEL;
buffer[LINUX_SETUP_LOADER] = 0x70;
if (!big_linux && text_len > LINUX_KERNEL_MAXLEN)
if (! big_linux && text_len > LINUX_KERNEL_MAXLEN)
{
printf (" linux 'zImage' kernel too big, try 'make bzImage'\n");
grub_close ();
errnum = ERR_WONT_FIT;
return KERNEL_TYPE_NONE;
}
@ -232,9 +236,12 @@ load_image (char *kernel, char *arg)
else if (safe_parse_maxint (&value, &vid_mode))
;
else
/* ERRNUM is already set inside the function
safe_parse_maxint. */
return KERNEL_TYPE_NONE;
{
/* ERRNUM is already set inside the function
safe_parse_maxint. */
return KERNEL_TYPE_NONE;
grub_close ();
}
/* Set the vid mode to VID_MODE. Note that this can work
because i386 architecture is little-endian. */
@ -276,8 +283,12 @@ load_image (char *kernel, char *arg)
filepos = data_len + SECTOR_SIZE;
cur_addr = LINUX_STAGING_AREA + text_len;
if (grub_read ((char *) LINUX_STAGING_AREA, text_len) >= (text_len - 16))
return (big_linux ? KERNEL_TYPE_BIG_LINUX : KERNEL_TYPE_LINUX);
if (grub_read ((char *) LINUX_STAGING_AREA, text_len)
>= (text_len - 16))
{
grub_close ();
return big_linux ? KERNEL_TYPE_BIG_LINUX : KERNEL_TYPE_LINUX;
}
else if (!errnum)
errnum = ERR_EXEC_FORMAT;
}
@ -289,7 +300,10 @@ load_image (char *kernel, char *arg)
/* return if error */
if (errnum)
return KERNEL_TYPE_NONE;
{
grub_close ();
return KERNEL_TYPE_NONE;
}
/* fill the multiboot info structure */
mbi.cmdline = (int) arg;
@ -472,6 +486,7 @@ load_image (char *kernel, char *arg)
type = KERNEL_TYPE_NONE;
}
grub_close ();
return type;
}
@ -483,9 +498,16 @@ load_module (char *module, char *arg)
/* if we are supposed to load on 4K boundaries */
cur_addr = (cur_addr + 0xFFF) & 0xFFFFF000;
if (!grub_open (module) || !(len = grub_read ((char *) cur_addr, -1)))
if (!grub_open (module))
return 0;
len = grub_read ((char *) cur_addr, -1);
if (! len)
{
grub_close ();
return 0;
}
printf (" [Multiboot-module @ 0x%x, 0x%x bytes]\n", cur_addr, len);
/* these two simply need to be set if any modules are loaded at all */
@ -501,6 +523,7 @@ load_module (char *module, char *arg)
/* increment number of modules included */
mbi.mods_count++;
grub_close ();
return 1;
}
@ -510,9 +533,16 @@ load_initrd (char *initrd)
int len;
unsigned long *ramdisk, moveto;
if (! grub_open (initrd) || ! (len = grub_read ((char *) cur_addr, -1)))
if (! grub_open (initrd))
return 0;
len = grub_read ((char *) cur_addr, -1);
if (! len)
{
grub_close ();
return 0;
}
moveto = ((mbi.mem_upper + 0x400) * 0x400 - len) & 0xfffff000;
memmove ((void *) RAW_ADDR (moveto), (void *) cur_addr, len);
@ -522,6 +552,7 @@ load_initrd (char *initrd)
ramdisk[0] = RAW_ADDR (moveto);
ramdisk[1] = len;
grub_close ();
return 1;
}

View file

@ -165,6 +165,7 @@ cat_func (char *arg, int flags)
while (grub_read (&c, 1))
grub_putchar (c);
grub_close ();
return 0;
}
@ -182,18 +183,25 @@ static struct builtin builtin_cat =
static int
chainloader_func (char *arg, int flags)
{
if (grub_open (arg)
&& grub_read ((char *) BOOTSEC_LOCATION, SECTOR_SIZE) == SECTOR_SIZE
if (! grub_open (arg))
{
kernel_type = KERNEL_TYPE_NONE;
return 1;
}
if (grub_read ((char *) BOOTSEC_LOCATION, SECTOR_SIZE) == SECTOR_SIZE
&& (*((unsigned short *) (BOOTSEC_LOCATION + BOOTSEC_SIG_OFFSET))
== BOOTSEC_SIGNATURE))
kernel_type = KERNEL_TYPE_CHAINLOADER;
else if (! errnum)
{
grub_close ();
errnum = ERR_EXEC_FORMAT;
kernel_type = KERNEL_TYPE_NONE;
return 1;
}
grub_close ();
return 0;
}
@ -351,6 +359,8 @@ configfile_func (char *arg, int flags)
if (! grub_open (arg))
return 1;
grub_close ();
/* Copy ARG to CONFIG_FILE. */
while ((*new_config++ = *arg++) != 0)
;
@ -546,6 +556,8 @@ embed_func (char *arg, int flags)
/* Read the whole of the Stage 1.5. */
len = grub_read (stage1_5_buffer, -1);
grub_close ();
if (errnum)
return 1;
@ -702,7 +714,10 @@ find_func (char *arg, int flags)
saved_drive = current_drive;
saved_partition = current_partition;
if (grub_open (filename))
grub_printf (" (fd%d)\n", drive);
{
grub_close ();
grub_printf (" (fd%d)\n", drive);
}
}
/* Hard disks. */
@ -728,8 +743,11 @@ find_func (char *arg, int flags)
saved_drive = current_drive;
saved_partition = current_partition;
if (grub_open (filename))
grub_printf (" (hd%d,%d,%c)",
drive - 0x80, slice, part + 'a');
{
grub_close ();
grub_printf (" (hd%d,%d,%c)",
drive - 0x80, slice, part + 'a');
}
}
}
else
@ -737,7 +755,10 @@ find_func (char *arg, int flags)
saved_drive = current_drive;
saved_partition = current_partition;
if (grub_open (filename))
grub_printf (" (hd%d,%d)", drive - 0x80, slice);
{
grub_close ();
grub_printf (" (hd%d,%d)", drive - 0x80, slice);
}
}
}
}
@ -1098,6 +1119,8 @@ install_func (char *arg, int flags)
char *config_file_location;
/* If FILE is a Stage 1.5? */
int is_stage1_5 = 0;
/* Must call grub_close? */
int is_open = 0;
/* Save the first sector of Stage2 in STAGE2_SECT. */
static void disk_read_savesect_func (int sector)
@ -1161,7 +1184,8 @@ install_func (char *arg, int flags)
#endif
/* Read Stage 1. */
if (! grub_open (stage1_file)
is_open = grub_open (stage1_file);
if (! is_open
|| ! grub_read (stage1_buffer, SECTOR_SIZE) == SECTOR_SIZE)
goto fail;
@ -1206,8 +1230,11 @@ install_func (char *arg, int flags)
goto fail;
}
grub_close ();
/* Open Stage 2. */
if (! grub_open (file))
is_open = grub_open (file);
if (! is_open)
goto fail;
if (! new_drive)
@ -1371,7 +1398,9 @@ install_func (char *arg, int flags)
}
fail:
if (is_open)
grub_close ();
disk_read_hook = 0;
#ifndef NO_DECOMPRESSION
@ -1864,9 +1893,14 @@ setup_func (char *arg, int flags)
/* Check for stage1 and stage2. We hardcode the filenames, so
if the user installed GRUB in a uncommon directory, this never
succeed. */
if (! grub_open (stage1) || ! grub_open (stage2))
if (! grub_open (stage1))
goto fail;
grub_close ();
if (! grub_open (stage2))
goto fail;
grub_close ();
/* If the drive where stage2 resides is a hard disk, try to use a
Stage 1.5. */
if (image_drive & 0x80)
@ -1882,6 +1916,7 @@ setup_func (char *arg, int flags)
/* OK, check if the Stage 1.5 exists. */
if (grub_open (stage1_5_map[i].name))
{
grub_close ();
grub_strcpy (config_file, stage2);
grub_strcpy (stage2, stage1_5_map[i].name);
@ -2038,6 +2073,7 @@ testload_func (char *arg, int flags)
grub_printf ("Max is 0x10ac0: i=0x%x, filepos=0x%x\n", i, filepos);
disk_read_hook = 0;
grub_close ();
return 0;
}

View file

@ -42,23 +42,23 @@ struct fsys_entry fsys_table[NUM_FSYS + 1] =
{
/* TFTP should come first because others don't handle net device. */
# ifdef FSYS_TFTP
{"tftp", tftp_mount, tftp_read, tftp_dir},
{"tftp", tftp_mount, tftp_read, tftp_dir, tftp_close},
# endif
# ifdef FSYS_FAT
{"fat", fat_mount, 0, fat_dir},
{"fat", fat_mount, 0, fat_dir, 0},
# endif
# ifdef FSYS_EXT2FS
{"ext2fs", ext2fs_mount, ext2fs_read, ext2fs_dir},
{"ext2fs", ext2fs_mount, ext2fs_read, ext2fs_dir, 0},
# endif
# ifdef FSYS_MINIX
{"minix", minix_mount, minix_read, minix_dir},
{"minix", minix_mount, minix_read, minix_dir, 0},
# endif
/* XX FFS should come last as it's superblock is commonly crossing tracks
on floppies from track 1 to 2, while others only use 1. */
# ifdef FSYS_FFS
{"ffs", ffs_mount, ffs_read, ffs_dir},
{"ffs", ffs_mount, ffs_read, ffs_dir, 0},
# endif
{0, 0, 0, 0}
{0, 0, 0, 0, 0}
};
@ -1391,11 +1391,11 @@ int
grub_read (char *buf, int len)
{
/* Make sure "filepos" is a sane value */
if ((filepos < 0) | (filepos > filemax))
if ((filepos < 0) || (filepos > filemax))
filepos = filemax;
/* Make sure "len" is a sane value */
if ((len < 0) | (len > (filemax - filepos)))
if ((len < 0) || (len > (filemax - filepos)))
len = filemax - filepos;
/* if target file position is past the end of
@ -1513,3 +1513,18 @@ dir (char *dirname)
return (*(fsys_table[fsys_type].dir_func)) (dirname);
}
#endif /* STAGE1_5 */
void
grub_close (void)
{
if (fsys_type == NUM_FSYS)
{
errnum = ERR_FSYS_MOUNT;
return;
}
if (fsys_table[fsys_type].close_func == 0)
return;
(*(fsys_table[fsys_type].close_func)) ();
}

View file

@ -65,6 +65,7 @@ int minix_dir (char *dirname);
int tftp_mount (void);
int tftp_read (char *buf, int len);
int tftp_dir (char *dirname);
void tftp_close (void);
#else
#define FSYS_TFTP_NUM 0
#endif
@ -90,12 +91,13 @@ int tftp_dir (char *dirname);
/* this next part is pretty ugly, but it keeps it in one place! */
struct fsys_entry
{
char *name;
int (*mount_func) (void);
int (*read_func) (char *buf, int len);
int (*dir_func) (char *dirname);
};
{
char *name;
int (*mount_func) (void);
int (*read_func) (char *buf, int len);
int (*dir_func) (char *dirname);
void (*close_func) (void);
};
#ifdef STAGE1_5
# define print_possibilities 0

View file

@ -680,6 +680,9 @@ int grub_open (char *filename);
GRUB_OPEN. If LEN is -1, read all the remaining data in the file */
int grub_read (char *buf, int len);
/* Close a file. */
void grub_close (void);
/* List the contents of the directory that was opened with GRUB_OPEN,
printing all completions. */
int dir (char *dirname);

View file

@ -1,4 +1,3 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
@ -29,8 +28,13 @@ cmain (void)
* Here load the true second-stage boot-loader.
*/
if (grub_open (config_file) && grub_read ((char *) 0x8000, -1))
chain_stage2 (0, 0x8200);
if (grub_open (config_file))
{
grub_close ();
if (grub_read ((char *) 0x8000, -1))
chain_stage2 (0, 0x8200);
}
/*
* If not, then print error message and die.

View file

@ -608,6 +608,7 @@ cmain (void)
/* Get the pointer to the builtin structure. */
builtin = find_command (cmdline);
errnum = 0;
if (! builtin)
/* Unknown command. Just skip now. */
continue;
@ -680,6 +681,8 @@ cmain (void)
config_entries[config_len++] = 0;
grub_memmove (config_entries + config_len, menu_entries, menu_len);
menu_entries = config_entries + config_len;
grub_close ();
}
if (! num_entries)