View | Details | Raw Unified
Collapse All | Expand All

(-) grub-0.96.orig/INSTALL (+3 lines)
 Lines 207-212    Link Here 
`--disable-reiserfs'
`--disable-reiserfs'
     Omit the ReiserFS support in Stage 2.
     Omit the ReiserFS support in Stage 2.
`--disable-reiser4'
     Omit the Reiser4 support in Stage 2.
`--disable-vstafs'
`--disable-vstafs'
     Omit the VSTa filesystem support in Stage 2.
     Omit the VSTa filesystem support in Stage 2.
(-) grub-0.96.orig/config.h.in (+7 lines)
 Lines 27-35    Link Here 
/* Define to 1 if you have the <inttypes.h> header file. */
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `aal-minimal' library (-laal-minimal). */
#undef HAVE_LIBAAL_MINIMAL
/* Define if you have a curses library */
/* Define if you have a curses library */
#undef HAVE_LIBCURSES
#undef HAVE_LIBCURSES
/* Define to 1 if you have the `reiser4-minimal' library (-lreiser4-minimal).
   */
#undef HAVE_LIBREISER4_MINIMAL
/* Define to 1 if you have the <memory.h> header file. */
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
#undef HAVE_MEMORY_H
(-) grub-0.96.orig/configure.ac (+71 lines)
 Lines 263-268    Link Here 
  FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_REISERFS=1"
  FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_REISERFS=1"
fi
fi
dnl Checking for reiser4
REISER4_LIBS=""
REISER4_CFLAGS=""
OLD_LIBS=$LIBS
OLD_CFLAGS=$CFLAGS
LIBS=""
CFLAGS=""
AC_ARG_ENABLE(reiser4,
  [  --disable-reiser4       disable Reiser4 support in Stage 2])
if test x"$enable_reiser4" != xno; then
  AC_CHECK_LIB(aal-minimal, aal_mem_init, , 
    AC_MSG_WARN(
Reiser4 support is disabled due to inability find libaal-minimal with 
memory manager support turned on.)
    enable_reiser4=no
  )
fi
  
if test x"$enable_reiser4" != xno; then
  AC_CHECK_HEADER(aal/libaal.h, ,
  AC_MSG_WARN(
Libaal header files are not found. Reiser4 support is disabled
  )
  enable_reiser4=no)
fi
  
if test x"$enable_reiser4" != xno; then
  AC_CHECK_LIB(reiser4-minimal, reiser4_fs_open, , 
  AC_MSG_WARN(
Reiser4 support is disabled due to inability find valid libreiser4-minimal.)
    enable_reiser4=no, 
    -laal-minimal
  )
fi
if test x"$enable_reiser4" != xno; then
  AC_CHECK_HEADER(reiser4/libreiser4.h, ,
  AC_MSG_WARN(
Reiser4 header files are not found. Reiser4 support is disabled.
  )
  enable_reiser4=no)
fi
if test x"$enable_reiser4" != xno; then
  REISER4_CFLAGS="$REISER4_CFLAGS -DFSYS_REISER4=1"
  REISER4_LIBS=$LIBS
fi
if test x"$enable_reiser4" != xno; then
  AC_CHECK_LIB(reiser4-minimal, __sym40_plug_init, 
    REISER4_CFLAGS="$REISER4_CFLAGS -DENABLE_SYMLINKS=1",
AC_MSG_WARN(Reiser4 symlinks support is disabled.), 
    -laal-minimal
  )
fi
LIBS=$OLD_LIBS
CFLAGS=$OLD_CFLAGS
if test x"$enable_reiser4" != xno; then
  enable_reiser4_support=yes
  FSYS_CFLAGS="$FSYS_CFLAGS $REISER4_CFLAGS"
fi
AC_SUBST(REISER4_LIBS)
AC_SUBST(REISER4_CFLAGS)
AM_CONDITIONAL(ENABLE_REISER4_SUPPORT, test x"$enable_reiser4" != xno)
AC_ARG_ENABLE(vstafs,
AC_ARG_ENABLE(vstafs,
  [  --disable-vstafs        disable VSTa FS support in Stage 2])
  [  --disable-vstafs        disable VSTa FS support in Stage 2])
(-) grub-0.96.orig/docs/grub.texi (-1 / +2 lines)
 Lines 283-289    Link Here 
Support multiple filesystem types transparently, plus a useful explicit
Support multiple filesystem types transparently, plus a useful explicit
blocklist notation. The currently supported filesystem types are
blocklist notation. The currently supported filesystem types are
@dfn{BSD FFS}, @dfn{DOS FAT16 and FAT32}, @dfn{Minix fs}, @dfn{Linux
@dfn{BSD FFS}, @dfn{DOS FAT16 and FAT32}, @dfn{Minix fs}, @dfn{Linux
ext2fs}, @dfn{ReiserFS}, @dfn{JFS}, @dfn{XFS}, and @dfn{VSTa
ext2fs}, @dfn{ReiserFS}, @dfn{ReiserFS}, @dfn{JFS}, @dfn{XFS}, and @dfn{VSTa
fs}. @xref{Filesystem}, for more information.
fs}. @xref{Filesystem}, for more information.
@item Support automatic decompression
@item Support automatic decompression
 Lines 1776-1781    Link Here 
@itemx jfs_stage1_5
@itemx jfs_stage1_5
@itemx minix_stage1_5
@itemx minix_stage1_5
@itemx reiserfs_stage1_5
@itemx reiserfs_stage1_5
@itemx reiser4_stage1_5
@itemx vstafs_stage1_5
@itemx vstafs_stage1_5
@itemx xfs_stage1_5
@itemx xfs_stage1_5
(-) grub-0.96.orig/grub/Makefile.am (-1 / +1 lines)
 Lines 16-19    Link Here 
AM_CFLAGS = $(GRUB_CFLAGS)
AM_CFLAGS = $(GRUB_CFLAGS)
grub_SOURCES = main.c asmstub.c
grub_SOURCES = main.c asmstub.c
grub_LDADD = ../stage2/libgrub.a  ../lib/libcommon.a $(GRUB_LIBS)
grub_LDADD = ../stage2/libgrub.a  ../lib/libcommon.a $(GRUB_LIBS) $(REISER4_LIBS)
(-) grub-0.96.orig/grub/Makefile.am.orig (+19 lines)
Line 0    Link Here 
sbin_PROGRAMS = grub
if SERIAL_SPEED_SIMULATION
SERIAL_FLAGS = -DSUPPORT_SERIAL=1 -DSIMULATE_SLOWNESS_OF_SERIAL=1
else
SERIAL_FLAGS = -DSUPPORT_SERIAL=1 
endif
AM_CPPFLAGS = -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
	-DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
	-DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \
	-DUSE_MD5_PASSWORDS=1 -DSUPPORT_HERCULES=1 \
	$(SERIAL_FLAGS) -I$(top_srcdir)/stage2 \
	-I$(top_srcdir)/stage1 -I$(top_srcdir)/lib
AM_CFLAGS = $(GRUB_CFLAGS)
grub_SOURCES = main.c asmstub.c
grub_LDADD = ../stage2/libgrub.a  ../lib/libcommon.a $(GRUB_LIBS)
(-) grub-0.96.orig/stage2/Makefile.am (-14 / +36 lines)
 Lines 13-29    Link Here 
# For <stage1.h>.
# For <stage1.h>.
INCLUDES = -I$(top_srcdir)/stage1
INCLUDES = -I$(top_srcdir)/stage1
if ENABLE_REISER4_SUPPORT
REISER4_STAGE1_5 = reiser4_stage1_5
REISER4_STAGE1_5_EXEC = reiser4_stage1_5.exec
else
REISER4_STAGE1_5 =
REISER4_STAGE1_5_EXEC =
endif
# The library for /sbin/grub.
# The library for /sbin/grub.
noinst_LIBRARIES = libgrub.a
noinst_LIBRARIES = libgrub.a
libgrub_a_SOURCES = boot.c builtins.c char_io.c cmdline.c common.c \
libgrub_a_SOURCES = boot.c builtins.c char_io.c cmdline.c common.c \
	disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \
	disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \
	fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \
	fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_reiser4.c fsys_ufs2.c \
	fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \
	fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \
	terminfo.c tparm.c graphics.c
	terminfo.c tparm.c graphics.c
libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
	-DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
	-DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
	-DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
	-DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
	-DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \
	$(REISER4_CFLAGS) -DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \
	-DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1
	-DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1
# Stage 2 and Stage 1.5's.
# Stage 2 and Stage 1.5's.
 Lines 34-57    Link Here 
if DISKLESS_SUPPORT
if DISKLESS_SUPPORT
pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \
pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \
	ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \
	ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \
	reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5 \
	reiserfs_stage1_5 $(REISER4_STAGE1_5) ufs2_stage1_5 \
	nbgrub pxegrub
	vstafs_stage1_5 xfs_stage1_5 nbgrub pxegrub
noinst_DATA = pre_stage2 start start_eltorito nbloader pxeloader diskless
noinst_DATA = pre_stage2 start start_eltorito nbloader pxeloader diskless
noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \
noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \
	e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \
	e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \
	iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \
	iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \
	reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \
	reiserfs_stage1_5.exec $(REISER4_STAGE1_5_EXEC) ufs2_stage1_5.exec \
	xfs_stage1_5.exec nbloader.exec pxeloader.exec diskless.exec
	vstafs_stage1_5.exec xfs_stage1_5.exec nbloader.exec pxeloader.exec \
	diskless.exec
else
else
pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \
pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \
	ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \
	ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \
	reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5
	reiserfs_stage1_5 $(REISER4_STAGE1_5) ufs2_stage1_5 \
	vstafs_stage1_5 xfs_stage1_5
noinst_DATA = pre_stage2 start start_eltorito
noinst_DATA = pre_stage2 start start_eltorito
noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \
noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \
	e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \
	e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \
	iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \
	iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \
	reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \
	reiserfs_stage1_5.exec $(REISER4_STAGE1_5_EXEC) ufs2_stage1_5.exec \
	xfs_stage1_5.exec
	vstafs_stage1_5.exec xfs_stage1_5.exec
endif
endif
MOSTLYCLEANFILES = $(noinst_PROGRAMS)
MOSTLYCLEANFILES = $(noinst_PROGRAMS)
 Lines 85-91    Link Here 
GRAPHICS_FLAGS =
GRAPHICS_FLAGS =
endif
endif
STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin \
	$(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS)
	$(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS)
STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
 Lines 95-109    Link Here 
pre_stage2_exec_SOURCES = asm.S bios.c boot.c builtins.c char_io.c \
pre_stage2_exec_SOURCES = asm.S bios.c boot.c builtins.c char_io.c \
	cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \
	cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \
	fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \
	fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \
	fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \
	fsys_reiserfs.c fsys_reiser4.c fsys_ufs2.c fsys_vstafs.c \
	hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c \
	fsys_xfs.c gunzip.c hercules.c md5.c serial.c smp-imps.c \
	graphics.c
	stage2.c terminfo.c tparm.c graphics.c
pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
if NETBOOT_SUPPORT
if NETBOOT_SUPPORT
pre_stage2_exec_LDADD = ../netboot/libdrivers.a
pre_stage2_exec_LDADD = ../netboot/libdrivers.a $(REISER4_LIBS)
else
pre_stage2_exec_LDADD = $(REISER4_LIBS)
endif
endif
if DISKLESS_SUPPORT
if DISKLESS_SUPPORT
 Lines 197-202    Link Here 
	-DNO_BLOCK_FILES=1
	-DNO_BLOCK_FILES=1
reiserfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
reiserfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For reiser4_stage1_5 target.
reiser4_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
	disk_io.c stage1_5.c fsys_reiser4.c bios.c
reiser4_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) $(REISER4_CFLAGS) \
	-DNO_BLOCK_FILES=1
reiser4_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) $(REISER4_CFLAGS) \
	-DNO_BLOCK_FILES=1
reiser4_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
reiser4_stage1_5_exec_LDADD = $(REISER4_LIBS)
# For vstafs_stage1_5 target.
# For vstafs_stage1_5 target.
vstafs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
vstafs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
	disk_io.c stage1_5.c fsys_vstafs.c bios.c
	disk_io.c stage1_5.c fsys_vstafs.c bios.c
(-) grub-0.96.orig/stage2/Makefile.am.orig (+279 lines)
Line 0    Link Here 
# For test target.
TESTS = size_test
noinst_SCRIPTS = $(TESTS)
# For dist target.
noinst_HEADERS = apic.h defs.h dir.h disk_inode.h disk_inode_ffs.h \
        fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \
	imgact_aout.h iso9660.h jfs.h mb_header.h mb_info.h md5.h \
	nbi.h pc_slice.h serial.h shared.h smp-imps.h term.h \
	terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h graphics.h
EXTRA_DIST = setjmp.S apm.S $(noinst_SCRIPTS)
# For <stage1.h>.
INCLUDES = -I$(top_srcdir)/stage1
# The library for /sbin/grub.
noinst_LIBRARIES = libgrub.a
libgrub_a_SOURCES = boot.c builtins.c char_io.c cmdline.c common.c \
	disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \
	fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \
	fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \
	terminfo.c tparm.c graphics.c
libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
	-DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
	-DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
	-DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \
	-DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1
# Stage 2 and Stage 1.5's.
pkglibdir = $(libdir)/$(PACKAGE)/$(host_cpu)-$(host_vendor)
EXTRA_PROGRAMS = nbloader.exec pxeloader.exec diskless.exec
if DISKLESS_SUPPORT
pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \
	ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \
	reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5 \
	nbgrub pxegrub
noinst_DATA = pre_stage2 start start_eltorito nbloader pxeloader diskless
noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \
	e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \
	iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \
	reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \
	xfs_stage1_5.exec nbloader.exec pxeloader.exec diskless.exec
else
pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \
	ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \
	reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5
noinst_DATA = pre_stage2 start start_eltorito
noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \
	e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \
	iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \
	reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \
	xfs_stage1_5.exec
endif
MOSTLYCLEANFILES = $(noinst_PROGRAMS)
PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8200
START_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000
NBLOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,0
PXELOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00
START_ELTORITO_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00
if NETBOOT_SUPPORT
NETBOOT_FLAGS = -I$(top_srcdir)/netboot -DSUPPORT_NETBOOT=1
else
NETBOOT_FLAGS =
endif
if SERIAL_SUPPORT
SERIAL_FLAGS = -DSUPPORT_SERIAL=1
else
SERIAL_FLAGS =
endif
if HERCULES_SUPPORT
HERCULES_FLAGS = -DSUPPORT_HERCULES=1
else
HERCULES_FLAGS =
endif
if GRAPHICS_SUPPORT
GRAPHICS_FLAGS = -DSUPPORT_GRAPHICS=1
else
GRAPHICS_FLAGS =
endif
STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
	$(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS)
STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1
# For stage2 target.
pre_stage2_exec_SOURCES = asm.S bios.c boot.c builtins.c char_io.c \
	cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \
	fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \
	fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \
	hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c \
	graphics.c
pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
if NETBOOT_SUPPORT
pre_stage2_exec_LDADD = ../netboot/libdrivers.a
endif
if DISKLESS_SUPPORT
BUILT_SOURCES = stage2_size.h diskless_size.h
else
BUILT_SOURCES = stage2_size.h
endif
CLEANFILES = $(pkglib_DATA) $(noinst_DATA) $(BUILT_SOURCES)
stage2_size.h: pre_stage2
	-rm -f stage2_size.h
	set dummy `ls -l pre_stage2`; \
	echo "#define STAGE2_SIZE $$6" > stage2_size.h
start_exec_SOURCES = start.S
start_exec_CCASFLAGS = $(STAGE2_COMPILE)
start_exec_LDFLAGS = $(START_LINK)
# XXX: automake doesn't provide a way to specify dependencies for object
# files explicitly, so we must write this by a general Makefile scheme.
# If automake change the naming scheme for per-executable objects, this
# will be broken.
start_exec-start.$(OBJEXT): stage2_size.h
stage2: pre_stage2 start
	-rm -f stage2
	cat start pre_stage2 > stage2
start_eltorito_exec_SOURCES = start_eltorito.S
start_eltorito_exec_CCASFLAGS = $(STAGE2_COMPILE)
start_eltorito_exec_LDFLAGS = $(START_ELTORITO_LINK)
start_eltorito_exec-start.$(OBJEXT): stage2_size.h
stage2_eltorito: pre_stage2 start_eltorito
	-rm -f stage2_eltorito
	cat start_eltorito pre_stage2 > stage2_eltorito
# For e2fs_stage1_5 target.
e2fs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
	stage1_5.c fsys_ext2fs.c bios.c
e2fs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_EXT2FS=1 \
	-DNO_BLOCK_FILES=1
e2fs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_EXT2FS=1 \
	-DNO_BLOCK_FILES=1
e2fs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For fat_stage1_5 target.
fat_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
	stage1_5.c fsys_fat.c bios.c
fat_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_FAT=1 \
	-DNO_BLOCK_FILES=1
fat_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_FAT=1 \
	-DNO_BLOCK_FILES=1
fat_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For ffs_stage1_5 target.
ffs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
	stage1_5.c fsys_ffs.c bios.c
ffs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_FFS=1 \
	-DNO_BLOCK_FILES=1
ffs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_FFS=1 \
	-DNO_BLOCK_FILES=1
ffs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For ufs2_stage1_5 target.
ufs2_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
	stage1_5.c fsys_ufs2.c bios.c
ufs2_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_UFS2=1 \
	-DNO_BLOCK_FILES=1
ufs2_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_UFS2=1 \
	-DNO_BLOCK_FILES=1
ufs2_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For minix_stage1_5 target.
minix_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
	stage1_5.c fsys_minix.c bios.c
minix_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_MINIX=1 \
	-DNO_BLOCK_FILES=1
minix_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_MINIX=1 \
	-DNO_BLOCK_FILES=1
minix_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For reiserfs_stage1_5 target.
reiserfs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
	disk_io.c stage1_5.c fsys_reiserfs.c bios.c
reiserfs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_REISERFS=1 \
	-DNO_BLOCK_FILES=1
reiserfs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_REISERFS=1 \
	-DNO_BLOCK_FILES=1
reiserfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For vstafs_stage1_5 target.
vstafs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
	disk_io.c stage1_5.c fsys_vstafs.c bios.c
vstafs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_VSTAFS=1 \
	-DNO_BLOCK_FILES=1
vstafs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_VSTAFS=1 \
	-DNO_BLOCK_FILES=1
vstafs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For jfs_stage1_5 target.
jfs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
	disk_io.c stage1_5.c fsys_jfs.c bios.c
jfs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_JFS=1 \
	-DNO_BLOCK_FILES=1
jfs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_JFS=1 \
	-DNO_BLOCK_FILES=1
jfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For xfs_stage1_5 target.
xfs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
	disk_io.c stage1_5.c fsys_xfs.c bios.c
xfs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_XFS=1 \
	-DNO_BLOCK_FILES=1
xfs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_XFS=1 \
	-DNO_BLOCK_FILES=1
xfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For iso9660_stage1_5 target.
iso9660_stage1_5_exec_SOURCES = start_eltorito.S asm.S common.c char_io.c \
	disk_io.c stage1_5.c fsys_iso9660.c bios.c
iso9660_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_ISO9660=1 \
	-DNO_BLOCK_FILES=1
iso9660_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_ISO9660=1 \
	-DNO_BLOCK_FILES=1
iso9660_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For diskless target.
diskless_exec_SOURCES = $(pre_stage2_exec_SOURCES)
diskless_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) \
	-DSUPPORT_DISKLESS=1
diskless_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) \
	-DSUPPORT_DISKLESS=1
diskless_exec_LDFLAGS = $(PRE_STAGE2_LINK)
diskless_exec_LDADD = ../netboot/libdrivers.a
diskless_size.h: diskless
	-rm -f $@
	set dummy `ls -l $^`; \
	echo "#define DISKLESS_SIZE $$6" > $@
# For nbloader target.
nbloader_exec_SOURCES = nbloader.S
nbloader_exec_CCASFLAGS = $(STAGE2_COMPILE)
nbloader_exec_LDFLAGS = $(NBLOADER_LINK)
# XXX: See the comment for start_exec-start.o.
nbloader_exec-nbloader.$(OBJEXT): diskless_size.h
# For nbgrub target.
nbgrub: nbloader diskless
	-rm -f $@
	cat $^ > $@
# For pxeloader target.
pxeloader_exec_SOURCES = pxeloader.S
pxeloader_exec_CCASFLAGS = $(STAGE2_COMPILE)
pxeloader_exec_LDFLAGS = $(PXELOADER_LINK)
# XXX: See the comment for start_exec-start.o.
pxeloader_exec-pxeloader.$(OBJEXT): diskless_size.h
# For pxegrub target.
pxegrub: pxeloader diskless
	-rm -f $@
	cat $^ > $@
# General rule for making a raw binary.
SUFFIXES = .exec
.exec:
	$(OBJCOPY) -O binary $< $@
(-) grub-0.96.orig/stage2/builtins.c (+1 lines)
 Lines 4067-4072    Link Here 
    {"jfs",      "/jfs_stage1_5"},
    {"jfs",      "/jfs_stage1_5"},
    {"minix",    "/minix_stage1_5"},
    {"minix",    "/minix_stage1_5"},
    {"reiserfs", "/reiserfs_stage1_5"},
    {"reiserfs", "/reiserfs_stage1_5"},
    {"reiser4",  "/reiser4_stage1_5"},
    {"vstafs",   "/vstafs_stage1_5"},
    {"vstafs",   "/vstafs_stage1_5"},
    {"xfs",      "/xfs_stage1_5"}
    {"xfs",      "/xfs_stage1_5"}
  };
  };
(-) grub-0.96.orig/stage2/builtins.c.orig (-182 / +512 lines)
 Lines 59-65    Link Here 
/* The default entry.  */
/* The default entry.  */
int default_entry = 0;
int default_entry = 0;
/* The fallback entry.  */
/* The fallback entry.  */
int fallback_entry = -1;
int fallback_entryno;
int fallback_entries[MAX_FALLBACK_ENTRIES];
/* The number of current entry.  */
/* The number of current entry.  */
int current_entryno;
int current_entryno;
/* The address for Multiboot command-line buffer.  */
/* The address for Multiboot command-line buffer.  */
 Lines 97-103    Link Here 
{
{
  default_entry = 0;
  default_entry = 0;
  password = 0;
  password = 0;
  fallback_entry = -1;
  fallback_entryno = -1;
  fallback_entries[0] = -1;
  grub_timeout = -1;
  grub_timeout = -1;
}
}
 Lines 129-189    Link Here 
}
}


/* blocklist_read_helper nee disk_read_blocklist_func was a nested
 * function, to which pointers were taken and exposed globally.  Even
 * in the GNU-C nested functions extension, they have local linkage,
 * and aren't guaranteed to be accessable *at all* outside of their 
 * containing scope.
 *
 * Above and beyond all of that, the variables within blocklist_func_context
 * are originally local variables, with local (not even static) linkage,
 * from within blocklist_func.  These were each referenced by
 * disk_read_blocklist_func, which is only called from other functions
 * through a globally scoped pointer.
 * 
 * The documentation in GCC actually uses the words "all hell will break
 * loose" to describe this scenario.
 *
 * Also, "start_sector" was also used uninitialized, but gcc doesn't warn
 * about it (possibly because of the scoping madness?)
 */
   
static struct {
       int start_sector;
       int num_sectors;
       int num_entries;
       int last_length;
} blocklist_func_context = {
       .start_sector = 0,
       .num_sectors = 0,
       .num_entries = 0,
       .last_length = 0
};
/* Collect contiguous blocks into one entry as many as possible,
   and print the blocklist notation on the screen.  */
static void
blocklist_read_helper (int sector, int offset, int length)
{
  int *start_sector = &blocklist_func_context.start_sector;
  int *num_sectors = &blocklist_func_context.num_sectors;
  int *num_entries = &blocklist_func_context.num_entries;
  int *last_length = &blocklist_func_context.last_length;
  if (*num_sectors > 0)
  {
    if (*start_sector + *num_sectors == sector
      && offset == 0 && *last_length == SECTOR_SIZE)
    {
      *num_sectors++;
      *last_length = length;
      return;
    }
    else
    {
      if (*last_length == SECTOR_SIZE)
        grub_printf ("%s%d+%d", *num_entries ? "," : "",
          *start_sector - part_start, *num_sectors);
      else if (*num_sectors > 1)
        grub_printf ("%s%d+%d,%d[0-%d]", *num_entries ? "," : "",
          *start_sector - part_start, *num_sectors-1,
          *start_sector + *num_sectors-1 - part_start, 
          *last_length);
      else
        grub_printf ("%s%d[0-%d]", *num_entries ? "," : "",
          *start_sector - part_start, *last_length);
      *num_entries++;
      *num_sectors = 0;
    }
  }
  if (offset > 0)
  {
    grub_printf("%s%d[%d-%d]", *num_entries ? "," : "",
          sector-part_start, offset, offset+length);
    *num_entries++;
  }
  else
  {
    *start_sector = sector;
    *num_sectors = 1;
    *last_length = length;
  }
}
/* blocklist */
/* blocklist */
static int
static int
blocklist_func (char *arg, int flags)
blocklist_func (char *arg, int flags)
{
{
  char *dummy = (char *) RAW_ADDR (0x100000);
  char *dummy = (char *) RAW_ADDR (0x100000);
  int start_sector;
  int num_sectors = 0;
  int num_entries = 0;
  int last_length = 0;
  /* Collect contiguous blocks into one entry as many as possible,
     and print the blocklist notation on the screen.  */
  static void disk_read_blocklist_func (int sector, int offset, int length)
    {
      if (num_sectors > 0)
	{
	  if (start_sector + num_sectors == sector
	      && offset == 0 && last_length == SECTOR_SIZE)
	    {
	      num_sectors++;
	      last_length = length;
	      return;
	    }
	  else
	    {
	      if (last_length == SECTOR_SIZE)
		grub_printf ("%s%d+%d", num_entries ? "," : "",
			     start_sector - part_start, num_sectors);
	      else if (num_sectors > 1)
		grub_printf ("%s%d+%d,%d[0-%d]", num_entries ? "," : "",
			     start_sector - part_start, num_sectors-1,
			     start_sector + num_sectors-1 - part_start, 
			     last_length);
	      else
		grub_printf ("%s%d[0-%d]", num_entries ? "," : "",
			     start_sector - part_start, last_length);
	      num_entries++;
	      num_sectors = 0;
	    }
	}
      if (offset > 0)
	{
	  grub_printf("%s%d[%d-%d]", num_entries ? "," : "",
		      sector-part_start, offset, offset+length);
	  num_entries++;
	}
      else
	{
	  start_sector = sector;
	  num_sectors = 1;
	  last_length = length;
	}
    }
  int *start_sector = &blocklist_func_context.start_sector;
  int *num_sectors = &blocklist_func_context.num_sectors;
  int *num_entries = &blocklist_func_context.num_entries;
  
  /* Open the file.  */
  /* Open the file.  */
  if (! grub_open (arg))
  if (! grub_open (arg))
    return 1;
    return 1;
 Lines 202-216    Link Here 
  grub_printf (")");
  grub_printf (")");
  /* Read in the whole file to DUMMY.  */
  /* Read in the whole file to DUMMY.  */
  disk_read_hook = disk_read_blocklist_func;
  disk_read_hook = blocklist_read_helper;
  if (! grub_read (dummy, -1))
  if (! grub_read (dummy, -1))
    goto fail;
    goto fail;
  /* The last entry may not be printed yet.  Don't check if it is a
  /* The last entry may not be printed yet.  Don't check if it is a
   * full sector, since it doesn't matter if we read too much. */
   * full sector, since it doesn't matter if we read too much. */
  if (num_sectors > 0)
  if (*num_sectors > 0)
    grub_printf ("%s%d+%d", num_entries ? "," : "",
	grub_printf ("%s%d+%d", *num_entries ? "," : "",
		 start_sector - part_start, num_sectors);
                *start_sector - part_start, *num_sectors);
  grub_printf ("\n");
  grub_printf ("\n");
  
  
 Lines 587-594    Link Here 
    "white"
    "white"
  };
  };
  auto int color_number (char *str);
  
  /* Convert the color name STR into the magical number.  */
  /* Convert the color name STR into the magical number.  */
  static int color_number (char *str)
  auto int color_number (char *str)
    {
    {
      char *ptr;
      char *ptr;
      int i;
      int i;
 Lines 846-851    Link Here 
};
};
#endif /* SUPPORT_NETBOOT */
#endif /* SUPPORT_NETBOOT */
static int terminal_func (char *arg, int flags);
#ifdef SUPPORT_GRAPHICS

static int splashimage_func(char *arg, int flags) {
    char splashimage[64];
    int i;
    
    /* filename can only be 64 characters due to our buffer size */
    if (strlen(arg) > 63)
	return 1;
    if (flags == BUILTIN_CMDLINE) {
	if (!grub_open(arg))
	    return 1;
	grub_close();
    }
    strcpy(splashimage, arg);
    /* get rid of TERM_NEED_INIT from the graphics terminal. */
    for (i = 0; term_table[i].name; i++) {
	if (grub_strcmp (term_table[i].name, "graphics") == 0) {
	    term_table[i].flags &= ~TERM_NEED_INIT;
	    break;
	}
    }
    
    graphics_set_splash(splashimage);
    if (flags == BUILTIN_CMDLINE && graphics_inited) {
	graphics_end();
	graphics_init();
	graphics_cls();
    }
    /* FIXME: should we be explicitly switching the terminal as a 
     * side effect here? */
    terminal_func("graphics", flags);
    return 0;
}
static struct builtin builtin_splashimage =
{
  "splashimage",
  splashimage_func,
  BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
  "splashimage FILE",
  "Load FILE as the background image when in graphics mode."
};

/* foreground */
static int
foreground_func(char *arg, int flags)
{
    if (grub_strlen(arg) == 6) {
	int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
	int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
	int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
	foreground = (r << 16) | (g << 8) | b;
	if (graphics_inited)
	    graphics_set_palette(15, r, g, b);
	return (0);
    }
    return (1);
}
static struct builtin builtin_foreground =
{
  "foreground",
  foreground_func,
  BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
  "foreground RRGGBB",
  "Sets the foreground color when in graphics mode."
  "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
};

/* background */
static int
background_func(char *arg, int flags)
{
    if (grub_strlen(arg) == 6) {
	int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
	int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
	int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
	background = (r << 16) | (g << 8) | b;
	if (graphics_inited)
	    graphics_set_palette(0, r, g, b);
	return (0);
    }
    return (1);
}
static struct builtin builtin_background =
{
  "background",
  background_func,
  BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
  "background RRGGBB",
  "Sets the background color when in graphics mode."
  "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
};
#endif /* SUPPORT_GRAPHICS */

/* clear */
static int 
clear_func() 
{
  if (current_term->cls)
    current_term->cls();
  return 0;
}
static struct builtin builtin_clear =
{
  "clear",
  clear_func,
  BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
  "clear",
  "Clear the screen"
};


/* displayapm */
/* displayapm */
static int
static int
 Lines 1143-1151    Link Here 
static int
static int
fallback_func (char *arg, int flags)
fallback_func (char *arg, int flags)
{
{
  if (! safe_parse_maxint (&arg, &fallback_entry))
  int i = 0;
    return 1;
  while (*arg)
    {
      int entry;
      int j;
      
      if (! safe_parse_maxint (&arg, &entry))
	return 1;
      /* Remove duplications to prevent infinite looping.  */
      for (j = 0; j < i; j++)
	if (entry == fallback_entries[j])
	  break;
      if (j != i)
	continue;
      
      fallback_entries[i++] = entry;
      if (i == MAX_FALLBACK_ENTRIES)
	break;
      
      arg = skip_to (0, arg);
    }
  if (i < MAX_FALLBACK_ENTRIES)
    fallback_entries[i] = -1;
  fallback_entryno = (i == 0) ? -1 : 0;
  
  return 0;
  return 0;
}
}
 Lines 1155-1161    Link Here 
  fallback_func,
  fallback_func,
  BUILTIN_MENU,
  BUILTIN_MENU,
#if 0
#if 0
  "fallback NUM",
  "fallback NUM...",
  "Go into unattended boot mode: if the default boot entry has any"
  "Go into unattended boot mode: if the default boot entry has any"
  " errors, instead of waiting for the user to do anything, it"
  " errors, instead of waiting for the user to do anything, it"
  " immediately starts over using the NUM entry (same numbering as the"
  " immediately starts over using the NUM entry (same numbering as the"
 Lines 1708-1713    Link Here 


/* install */
/* install */
static struct {
       int saved_sector;
       int installaddr;
       int installlist;
       char *stage2_first_buffer;
} install_func_context = {
       .saved_sector = 0,
       .installaddr = 0,
       .installlist = 0,
       .stage2_first_buffer = NULL,
};
/* Save the first sector of Stage2 in STAGE2_SECT.  */
/* Formerly disk_read_savesect_func with local scope inside install_func */
static void
install_savesect_helper(int sector, int offset, int length)
{
  if (debug)
    printf ("[%d]", sector);
  /* ReiserFS has files which sometimes contain data not aligned
     on sector boundaries.  Returning an error is better than
     silently failing. */
  if (offset != 0 || length != SECTOR_SIZE)
    errnum = ERR_UNALIGNED;
  install_func_context.saved_sector = sector;
}
/* Write SECTOR to INSTALLLIST, and update INSTALLADDR and  INSTALLSECT.  */
/* Formerly disk_read_blocklist_func with local scope inside install_func */
static void
install_blocklist_helper (int sector, int offset, int length)
{
  int *installaddr = &install_func_context.installaddr;
  int *installlist = &install_func_context.installlist;
  char **stage2_first_buffer = &install_func_context.stage2_first_buffer;
  /* Was the last sector full? */
  static int last_length = SECTOR_SIZE;
  if (debug)
    printf("[%d]", sector);
  if (offset != 0 || last_length != SECTOR_SIZE)
    {
      /* We found a non-sector-aligned data block. */
      errnum = ERR_UNALIGNED;
      return;
    }
  last_length = length;
  if (*((unsigned long *) (*installlist - 4))
      + *((unsigned short *) *installlist) != sector
      || *installlist == (int) *stage2_first_buffer + SECTOR_SIZE + 4)
    {
      *installlist -= 8;
      if (*((unsigned long *) (*installlist - 8)))
        errnum = ERR_WONT_FIT;
      else
        {
          *((unsigned short *) (*installlist + 2)) = (*installaddr >> 4);
          *((unsigned long *) (*installlist - 4)) = sector;
        }
    }
  *((unsigned short *) *installlist) += 1;
  *installaddr += 512;
}
static int
static int
install_func (char *arg, int flags)
install_func (char *arg, int flags)
{
{
 Lines 1715-1734    Link Here 
  char *stage1_buffer = (char *) RAW_ADDR (0x100000);
  char *stage1_buffer = (char *) RAW_ADDR (0x100000);
  char *stage2_buffer = stage1_buffer + SECTOR_SIZE;
  char *stage2_buffer = stage1_buffer + SECTOR_SIZE;
  char *old_sect = stage2_buffer + SECTOR_SIZE;
  char *old_sect = stage2_buffer + SECTOR_SIZE;
  char *stage2_first_buffer = old_sect + SECTOR_SIZE;
  /* stage2_first_buffer used to be defined as:
  char *stage2_second_buffer = stage2_first_buffer + SECTOR_SIZE;
   * char *stage2_first_buffer = old_sect + SECTOR_SIZE;  */
  char **stage2_first_buffer = &install_func_context.stage2_first_buffer;
  /* and stage2_second_buffer was:
   * char *stage2_second_buffer = stage2_first_buffer + SECTOR_SIZE; */
  char *stage2_second_buffer = old_sect + SECTOR_SIZE + SECTOR_SIZE;
  /* XXX: Probably SECTOR_SIZE is reasonable.  */
  /* XXX: Probably SECTOR_SIZE is reasonable.  */
  char *config_filename = stage2_second_buffer + SECTOR_SIZE;
  char *config_filename = stage2_second_buffer + SECTOR_SIZE;
  char *dummy = config_filename + SECTOR_SIZE;
  char *dummy = config_filename + SECTOR_SIZE;
  int new_drive = 0xFF;
  int new_drive = GRUB_INVALID_DRIVE;
  int dest_drive, dest_partition, dest_sector;
  int dest_drive, dest_partition, dest_sector;
  int src_drive, src_partition, src_part_start;
  int src_drive, src_partition, src_part_start;
  int i;
  int i;
  struct geometry dest_geom, src_geom;
  struct geometry dest_geom, src_geom;
  int saved_sector;
  int *saved_sector = &install_func_context.saved_sector;
  int stage2_first_sector, stage2_second_sector;
  int stage2_first_sector, stage2_second_sector;
  char *ptr;
  char *ptr;
  int installaddr, installlist;
  int *installaddr = &install_func_context.installaddr;
  int *installlist = &install_func_context.installlist;
  /* Point to the location of the name of a configuration file in Stage 2.  */
  /* Point to the location of the name of a configuration file in Stage 2.  */
  char *config_file_location;
  char *config_file_location;
  /* If FILE is a Stage 1.5?  */
  /* If FILE is a Stage 1.5?  */
 Lines 1737-1800    Link Here 
  int is_open = 0;
  int is_open = 0;
  /* If LBA is forced?  */
  /* If LBA is forced?  */
  int is_force_lba = 0;
  int is_force_lba = 0;
  /* Was the last sector full? */
  int last_length = SECTOR_SIZE;
  
#ifdef GRUB_UTIL
#ifdef GRUB_UTIL
  /* If the Stage 2 is in a partition mounted by an OS, this will store
  /* If the Stage 2 is in a partition mounted by an OS, this will store
     the filename under the OS.  */
     the filename under the OS.  */
  char *stage2_os_file = 0;
  char *stage2_os_file = 0;
#endif /* GRUB_UTIL */
#endif /* GRUB_UTIL */
  
  /* Save the first sector of Stage2 in STAGE2_SECT.  */
  static void disk_read_savesect_func (int sector, int offset, int length)
    {
      if (debug)
	printf ("[%d]", sector);
      /* ReiserFS has files which sometimes contain data not aligned
         on sector boundaries.  Returning an error is better than
         silently failing. */
      if (offset != 0 || length != SECTOR_SIZE)
	errnum = ERR_UNALIGNED;
      saved_sector = sector;
  *stage2_first_buffer = old_sect + SECTOR_SIZE;
    }
  /* Write SECTOR to INSTALLLIST, and update INSTALLADDR and
     INSTALLSECT.  */
  static void disk_read_blocklist_func (int sector, int offset, int length)
    {
      if (debug)
	printf("[%d]", sector);
      if (offset != 0 || last_length != SECTOR_SIZE)
	{
	  /* We found a non-sector-aligned data block. */
	  errnum = ERR_UNALIGNED;
	  return;
	}
      last_length = length;
      if (*((unsigned long *) (installlist - 4))
	  + *((unsigned short *) installlist) != sector
	  || installlist == (int) stage2_first_buffer + SECTOR_SIZE + 4)
	{
	  installlist -= 8;
	  if (*((unsigned long *) (installlist - 8)))
	    errnum = ERR_WONT_FIT;
	  else
	    {
	      *((unsigned short *) (installlist + 2)) = (installaddr >> 4);
	      *((unsigned long *) (installlist - 4)) = sector;
	    }
	}
      *((unsigned short *) installlist) += 1;
      installaddr += 512;
    }
  /* First, check the GNU-style long option.  */
  /* First, check the GNU-style long option.  */
  while (1)
  while (1)
 Lines 1827-1836    Link Here 
  addr = skip_to (0, file);
  addr = skip_to (0, file);
  /* Get the installation address.  */
  /* Get the installation address.  */
  if (! safe_parse_maxint (&addr, &installaddr))
  if (! safe_parse_maxint (&addr, installaddr))
    {
    {
      /* ADDR is not specified.  */
      /* ADDR is not specified.  */
      installaddr = 0;
      *installaddr = 0;
      ptr = addr;
      ptr = addr;
      errnum = 0;
      errnum = 0;
    }
    }
 Lines 1924-1940    Link Here 
    = (dest_drive & BIOS_FLAG_FIXED_DISK);
    = (dest_drive & BIOS_FLAG_FIXED_DISK);
  
  
  /* Read the first sector of Stage 2.  */
  /* Read the first sector of Stage 2.  */
  disk_read_hook = disk_read_savesect_func;
  disk_read_hook = install_savesect_helper;
  if (grub_read (stage2_first_buffer, SECTOR_SIZE) != SECTOR_SIZE)
  if (grub_read (*stage2_first_buffer, SECTOR_SIZE) != SECTOR_SIZE)
    goto fail;
    goto fail;
  stage2_first_sector = saved_sector;
  stage2_first_sector = *saved_sector;
  
  
  /* Read the second sector of Stage 2.  */
  /* Read the second sector of Stage 2.  */
  if (grub_read (stage2_second_buffer, SECTOR_SIZE) != SECTOR_SIZE)
  if (grub_read (stage2_second_buffer, SECTOR_SIZE) != SECTOR_SIZE)
    goto fail;
    goto fail;
  stage2_second_sector = saved_sector;
  stage2_second_sector = *saved_sector;
  
  
  /* Check for the version of Stage 2.  */
  /* Check for the version of Stage 2.  */
  if (*((short *) (stage2_second_buffer + STAGE2_VER_MAJ_OFFS))
  if (*((short *) (stage2_second_buffer + STAGE2_VER_MAJ_OFFS))
 Lines 1950-1976    Link Here 
  /* If INSTALLADDR is not specified explicitly in the command-line,
  /* If INSTALLADDR is not specified explicitly in the command-line,
     determine it by the Stage 2 id.  */
     determine it by the Stage 2 id.  */
  if (! installaddr)
  if (! *installaddr)
    {
    {
      if (! is_stage1_5)
      if (! is_stage1_5)
	/* Stage 2.  */
	/* Stage 2.  */
	installaddr = 0x8000;
	*installaddr = 0x8000;
      else
      else
	/* Stage 1.5.  */
	/* Stage 1.5.  */
	installaddr = 0x2000;
	*installaddr = 0x2000;
    }
    }
  *((unsigned long *) (stage1_buffer + STAGE1_STAGE2_SECTOR))
  *((unsigned long *) (stage1_buffer + STAGE1_STAGE2_SECTOR))
    = stage2_first_sector;
    = stage2_first_sector;
  *((unsigned short *) (stage1_buffer + STAGE1_STAGE2_ADDRESS))
  *((unsigned short *) (stage1_buffer + STAGE1_STAGE2_ADDRESS))
    = installaddr;
    = *installaddr;
  *((unsigned short *) (stage1_buffer + STAGE1_STAGE2_SEGMENT))
  *((unsigned short *) (stage1_buffer + STAGE1_STAGE2_SEGMENT))
    = installaddr >> 4;
    = *installaddr >> 4;
  i = (int) stage2_first_buffer + SECTOR_SIZE - 4;
  i = (int) *stage2_first_buffer + SECTOR_SIZE - 4;
  while (*((unsigned long *) i))
  while (*((unsigned long *) i))
    {
    {
      if (i < (int) stage2_first_buffer
      if (i < (int) *stage2_first_buffer
	  || (*((int *) (i - 4)) & 0x80000000)
	  || (*((int *) (i - 4)) & 0x80000000)
	  || *((unsigned short *) i) >= 0xA00
	  || *((unsigned short *) i) >= 0xA00
	  || *((short *) (i + 2)) == 0)
	  || *((short *) (i + 2)) == 0)
 Lines 1984-1996    Link Here 
      i -= 8;
      i -= 8;
    }
    }
  installlist = (int) stage2_first_buffer + SECTOR_SIZE + 4;
  *installlist = (int) *stage2_first_buffer + SECTOR_SIZE + 4;
  installaddr += SECTOR_SIZE;
  *installaddr += SECTOR_SIZE;
  
  
  /* Read the whole of Stage2 except for the first sector.  */
  /* Read the whole of Stage2 except for the first sector.  */
  grub_seek (SECTOR_SIZE);
  grub_seek (SECTOR_SIZE);
  disk_read_hook = disk_read_blocklist_func;
  disk_read_hook = install_blocklist_helper;
  if (! grub_read (dummy, -1))
  if (! grub_read (dummy, -1))
    goto fail;
    goto fail;
  
  
 Lines 2051-2057    Link Here 
	      /* If the drive where the Stage 2 resides is the same as
	      /* If the drive where the Stage 2 resides is the same as
		 the one where the Stage 1.5 resides, do not embed the
		 the one where the Stage 1.5 resides, do not embed the
		 drive number.  */
		 drive number.  */
	      current_drive = 0xFF;
	      current_drive = GRUB_INVALID_DRIVE;
	    }
	    }
	  device = (current_drive << 24) | current_partition;
	  device = (current_drive << 24) | current_partition;
 Lines 2073-2079    Link Here 
	  /* Skip the first sector.  */
	  /* Skip the first sector.  */
	  grub_seek (SECTOR_SIZE);
	  grub_seek (SECTOR_SIZE);
	  
	  
	  disk_read_hook = disk_read_savesect_func;
	  disk_read_hook = install_savesect_helper;
	  if (grub_read (stage2_buffer, SECTOR_SIZE) != SECTOR_SIZE)
	  if (grub_read (stage2_buffer, SECTOR_SIZE) != SECTOR_SIZE)
	    goto fail;
	    goto fail;
	  
	  
 Lines 2143-2149    Link Here 
	  else
	  else
#endif /* GRUB_UTIL */
#endif /* GRUB_UTIL */
	    {
	    {
	      if (! devwrite (saved_sector - part_start, 1, stage2_buffer))
	      if (! devwrite (*saved_sector - part_start, 1, stage2_buffer))
		goto fail;
		goto fail;
	    }
	    }
	}
	}
 Lines 2165-2171    Link Here 
	  goto fail;
	  goto fail;
	}
	}
      if (fwrite (stage2_first_buffer, 1, SECTOR_SIZE, fp) != SECTOR_SIZE)
      if (fwrite (*stage2_first_buffer, 1, SECTOR_SIZE, fp) != SECTOR_SIZE)
	{
	{
	  fclose (fp);
	  fclose (fp);
	  errnum = ERR_WRITE;
	  errnum = ERR_WRITE;
 Lines 2192-2198    Link Here 
	goto fail;
	goto fail;
      if (! devwrite (stage2_first_sector - src_part_start, 1,
      if (! devwrite (stage2_first_sector - src_part_start, 1,
		      stage2_first_buffer))
		      *stage2_first_buffer))
	goto fail;
	goto fail;
      if (! devwrite (stage2_second_sector - src_part_start, 1,
      if (! devwrite (stage2_second_sector - src_part_start, 1,
 Lines 3185-3192    Link Here 
savedefault_func (char *arg, int flags)
savedefault_func (char *arg, int flags)
{
{
#if !defined(SUPPORT_DISKLESS) && !defined(GRUB_UTIL)
#if !defined(SUPPORT_DISKLESS) && !defined(GRUB_UTIL)
  char buffer[512];
  unsigned long tmp_drive = saved_drive;
  int *entryno_ptr;
  unsigned long tmp_partition = saved_partition;
  char *default_file = (char *) DEFAULT_FILE_BUF;
  char buf[10];
  char sect[SECTOR_SIZE];
  int entryno;
  int sector_count = 0;
  int saved_sectors[2];
  int saved_offsets[2];
  int saved_lengths[2];
  /* Save sector information about at most two sectors.  */
  auto void disk_read_savesect_func (int sector, int offset, int length);
  void disk_read_savesect_func (int sector, int offset, int length)
    {
      if (sector_count < 2)
	{
	  saved_sectors[sector_count] = sector;
	  saved_offsets[sector_count] = offset;
	  saved_lengths[sector_count] = length;
	}
      sector_count++;
    }
  
  
  /* This command is only useful when you boot an entry from the menu
  /* This command is only useful when you boot an entry from the menu
     interface.  */
     interface.  */
 Lines 3195-3240    Link Here 
      errnum = ERR_UNRECOGNIZED;
      errnum = ERR_UNRECOGNIZED;
      return 1;
      return 1;
    }
    }
  
  /* Get the geometry of the boot drive (i.e. the disk which contains
     this stage2).  */
  if (get_diskinfo (boot_drive, &buf_geom))
    {
      errnum = ERR_NO_DISK;
      return 1;
    }
  /* Load the second sector of this stage2.  */
  /* Determine a saved entry number.  */
  if (! rawread (boot_drive, install_second_sector, 0, SECTOR_SIZE, buffer))
  if (*arg)
    {
    {
      return 1;
      if (grub_memcmp (arg, "fallback", sizeof ("fallback") - 1) == 0)
    }
	{
	  int i;
	  int index = 0;
	  
	  for (i = 0; i < MAX_FALLBACK_ENTRIES; i++)
	    {
	      if (fallback_entries[i] < 0)
		break;
	      if (fallback_entries[i] == current_entryno)
		{
		  index = i + 1;
		  break;
		}
	    }
	  
	  if (index >= MAX_FALLBACK_ENTRIES || fallback_entries[index] < 0)
	    {
	      /* This is the last.  */
	      errnum = ERR_BAD_ARGUMENT;
	      return 1;
	    }
  /* Sanity check.  */
	  entryno = fallback_entries[index];
  if (buffer[STAGE2_STAGE2_ID] != STAGE2_ID_STAGE2
	}
      || *((short *) (buffer + STAGE2_VER_MAJ_OFFS)) != COMPAT_VERSION)
      else if (! safe_parse_maxint (&arg, &entryno))
    {
	return 1;
      errnum = ERR_BAD_VERSION;
      return 1;
    }
    }
  
  else
  entryno_ptr = (int *) (buffer + STAGE2_SAVED_ENTRYNO);
    entryno = current_entryno;
  /* Check if the saved entry number differs from current entry number.  */
  /* Open the default file.  */
  if (*entryno_ptr != current_entryno)
  saved_drive = boot_drive;
    {
  saved_partition = install_partition;
      /* Overwrite the saved entry number.  */
  if (grub_open (default_file))
      *entryno_ptr = current_entryno;
    {
      int len;
      
      disk_read_hook = disk_read_savesect_func;
      len = grub_read (buf, sizeof (buf));
      disk_read_hook = 0;
      grub_close ();
      
      
      /* Save the image in the disk.  */
      if (len != sizeof (buf))
      if (! rawwrite (boot_drive, install_second_sector, buffer))
	{
	return 1;
	  /* This is too small. Do not modify the file manually, please!  */
	  errnum = ERR_READ;
	  goto fail;
	}
      if (sector_count > 2)
	{
	  /* Is this possible?! Too fragmented!  */
	  errnum = ERR_FSYS_CORRUPT;
	  goto fail;
	}
      
      
      /* Set up a string to be written.  */
      grub_memset (buf, '\n', sizeof (buf));
      grub_sprintf (buf, "%d", entryno);
      
      if (saved_lengths[0] < sizeof (buf))
	{
	  /* The file is anchored to another file and the first few bytes
	     are spanned in two sectors. Uggh...  */
	  if (! rawread (current_drive, saved_sectors[0], 0, SECTOR_SIZE,
			 sect))
	    goto fail;
	  grub_memmove (sect + saved_offsets[0], buf, saved_lengths[0]);
	  if (! rawwrite (current_drive, saved_sectors[0], sect))
	    goto fail;
	  if (! rawread (current_drive, saved_sectors[1], 0, SECTOR_SIZE,
			 sect))
	    goto fail;
	  grub_memmove (sect + saved_offsets[1],
			buf + saved_lengths[0],
			sizeof (buf) - saved_lengths[0]);
	  if (! rawwrite (current_drive, saved_sectors[1], sect))
	    goto fail;
	}
      else
	{
	  /* This is a simple case. It fits into a single sector.  */
	  if (! rawread (current_drive, saved_sectors[0], 0, SECTOR_SIZE,
			 sect))
	    goto fail;
	  grub_memmove (sect + saved_offsets[0], buf, sizeof (buf));
	  if (! rawwrite (current_drive, saved_sectors[0], sect))
	    goto fail;
	}
      /* Clear the cache.  */
      /* Clear the cache.  */
      buf_track = -1;
      buf_track = -1;
    }
    }
  return 0;
 fail:
  saved_drive = tmp_drive;
  saved_partition = tmp_partition;
  return errnum;
#else /* ! SUPPORT_DISKLESS && ! GRUB_UTIL */
#else /* ! SUPPORT_DISKLESS && ! GRUB_UTIL */
  errnum = ERR_UNRECOGNIZED;
  errnum = ERR_UNRECOGNIZED;
  return 1;
  return 1;
 Lines 3246-3253    Link Here 
  "savedefault",
  "savedefault",
  savedefault_func,
  savedefault_func,
  BUILTIN_CMDLINE,
  BUILTIN_CMDLINE,
  "savedefault",
  "savedefault [NUM | `fallback']",
  "Save the current entry as the default boot entry."
  "Save the current entry as the default boot entry if no argument is"
  " specified. If a number is specified, this number is saved. If"
  " `fallback' is used, next fallback entry is saved."
};
};


 Lines 3495-3501    Link Here 
  int to_code, from_code;
  int to_code, from_code;
  int map_in_interrupt = 0;
  int map_in_interrupt = 0;
  
  
  static int find_key_code (char *key)
  auto int find_key_code (char *key);
  auto int find_ascii_code (char *key);
  
  auto int find_key_code (char *key)
    {
    {
      int i;
      int i;
 Lines 3512-3518    Link Here 
      return 0;
      return 0;
    }
    }
  
  
  static int find_ascii_code (char *key)
  auto int find_ascii_code (char *key)
    {
    {
      int i;
      int i;
      
      
 Lines 3747-3753    Link Here 
  {
  {
    {"ext2fs",   "/e2fs_stage1_5"},
    {"ext2fs",   "/e2fs_stage1_5"},
    {"fat",      "/fat_stage1_5"},
    {"fat",      "/fat_stage1_5"},
    {"ufs2",     "/ufs2_stage1_5"},
    {"ffs",      "/ffs_stage1_5"},
    {"ffs",      "/ffs_stage1_5"},
    {"iso9660",  "/iso9660_stage1_5"},
    {"jfs",      "/jfs_stage1_5"},
    {"jfs",      "/jfs_stage1_5"},
    {"minix",    "/minix_stage1_5"},
    {"minix",    "/minix_stage1_5"},
    {"reiserfs", "/reiserfs_stage1_5"},
    {"reiserfs", "/reiserfs_stage1_5"},
 Lines 3956-3962    Link Here 
};
};


#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
/* terminal */
/* terminal */
static int
static int
terminal_func (char *arg, int flags)
terminal_func (char *arg, int flags)
 Lines 4115-4131    Link Here 
 end:
 end:
  current_term = term_table + default_term;
  current_term = term_table + default_term;
  current_term->flags = term_flags;
  current_term->flags = term_flags;
  
  if (lines)
  if (lines)
    max_lines = lines;
    max_lines = lines;
  else
  else
    /* 24 would be a good default value.  */
    max_lines = current_term->max_lines;
    max_lines = 24;
  
  /* If the interface is currently the command-line,
  /* If the interface is currently the command-line,
     restart it to repaint the screen.  */
     restart it to repaint the screen.  */
  if (current_term != prev_term && (flags & BUILTIN_CMDLINE))
  if ((current_term != prev_term) && (flags & BUILTIN_CMDLINE)){
    if (prev_term->shutdown)
      prev_term->shutdown();
    if (current_term->startup)
      current_term->startup();
    grub_longjmp (restart_cmdline_env, 0);
    grub_longjmp (restart_cmdline_env, 0);
  }
  
  
  return 0;
  return 0;
}
}
 Lines 4135-4141    Link Here 
  "terminal",
  "terminal",
  terminal_func,
  terminal_func,
  BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
  BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
  "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules]",
  "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules] [graphics]",
  "Select a terminal. When multiple terminals are specified, wait until"
  "Select a terminal. When multiple terminals are specified, wait until"
  " you push any key to continue. If both console and serial are specified,"
  " you push any key to continue. If both console and serial are specified,"
  " the terminal to which you input a key first will be selected. If no"
  " the terminal to which you input a key first will be selected. If no"
 Lines 4147-4153    Link Here 
  " seconds. The option --lines specifies the maximum number of lines."
  " seconds. The option --lines specifies the maximum number of lines."
  " The option --silent is used to suppress messages."
  " The option --silent is used to suppress messages."
};
};
#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */


#ifdef SUPPORT_SERIAL
#ifdef SUPPORT_SERIAL
 Lines 4666-4671    Link Here 
/* The table of builtin commands. Sorted in dictionary order.  */
/* The table of builtin commands. Sorted in dictionary order.  */
struct builtin *builtin_table[] =
struct builtin *builtin_table[] =
{
{
#ifdef SUPPORT_GRAPHICS
  &builtin_background,
#endif
  &builtin_blocklist,
  &builtin_blocklist,
  &builtin_boot,
  &builtin_boot,
#ifdef SUPPORT_NETBOOT
#ifdef SUPPORT_NETBOOT
 Lines 4673-4678    Link Here 
#endif /* SUPPORT_NETBOOT */
#endif /* SUPPORT_NETBOOT */
  &builtin_cat,
  &builtin_cat,
  &builtin_chainloader,
  &builtin_chainloader,
  &builtin_clear,
  &builtin_cmp,
  &builtin_cmp,
  &builtin_color,
  &builtin_color,
  &builtin_configfile,
  &builtin_configfile,
 Lines 4692-4697    Link Here 
  &builtin_embed,
  &builtin_embed,
  &builtin_fallback,
  &builtin_fallback,
  &builtin_find,
  &builtin_find,
#ifdef SUPPORT_GRAPHICS
  &builtin_foreground,
#endif
  &builtin_fstest,
  &builtin_fstest,
  &builtin_geometry,
  &builtin_geometry,
  &builtin_halt,
  &builtin_halt,
 Lines 4735-4743    Link Here 
#endif /* SUPPORT_SERIAL */
#endif /* SUPPORT_SERIAL */
  &builtin_setkey,
  &builtin_setkey,
  &builtin_setup,
  &builtin_setup,
#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
#ifdef SUPPORT_GRAPHICS
  &builtin_splashimage,
#endif /* SUPPORT_GRAPHICS */
#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
  &builtin_terminal,
  &builtin_terminal,
#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
#ifdef SUPPORT_SERIAL
#ifdef SUPPORT_SERIAL
  &builtin_terminfo,
  &builtin_terminfo,
#endif /* SUPPORT_SERIAL */
#endif /* SUPPORT_SERIAL */
(-) grub-0.96.orig/stage2/disk_io.c (+3 lines)
 Lines 63-68    Link Here 
# ifdef FSYS_REISERFS
# ifdef FSYS_REISERFS
  {"reiserfs", reiserfs_mount, reiserfs_read, reiserfs_dir, 0, reiserfs_embed},
  {"reiserfs", reiserfs_mount, reiserfs_read, reiserfs_dir, 0, reiserfs_embed},
# endif
# endif
# ifdef FSYS_REISER4
  {"reiser4", reiser4_mount, reiser4_read, reiser4_dir, 0, reiser4_embed},
# endif
# ifdef FSYS_VSTAFS
# ifdef FSYS_VSTAFS
  {"vstafs", vstafs_mount, vstafs_read, vstafs_dir, 0, 0},
  {"vstafs", vstafs_mount, vstafs_read, vstafs_dir, 0, 0},
# endif
# endif
(-) grub-0.96.orig/stage2/filesys.h (-2 / +12 lines)
 Lines 77-82    Link Here 
#define FSYS_REISERFS_NUM 0
#define FSYS_REISERFS_NUM 0
#endif
#endif
#ifdef FSYS_REISER4
#define FSYS_REISER4_NUM 1
int reiser4_mount (void);
int reiser4_read (char *buf, int len);
int reiser4_dir (char *dirname);
int reiser4_embed (int *start_sector, int needed_sectors);
#else
#define FSYS_REISER4_NUM 0
#endif
#ifdef FSYS_VSTAFS
#ifdef FSYS_VSTAFS
#define FSYS_VSTAFS_NUM 1
#define FSYS_VSTAFS_NUM 1
int vstafs_mount (void);
int vstafs_mount (void);
 Lines 127-134    Link Here 
#ifndef NUM_FSYS
#ifndef NUM_FSYS
#define NUM_FSYS	\
#define NUM_FSYS	\
  (FSYS_FFS_NUM + FSYS_FAT_NUM + FSYS_EXT2FS_NUM + FSYS_MINIX_NUM	\
  (FSYS_FFS_NUM + FSYS_FAT_NUM + FSYS_EXT2FS_NUM + FSYS_MINIX_NUM	\
   + FSYS_REISERFS_NUM + FSYS_VSTAFS_NUM + FSYS_JFS_NUM + FSYS_XFS_NUM	\
   + FSYS_REISERFS_NUM + FSYS_REISER4_NUM + FSYS_VSTAFS_NUM + FSYS_JFS_NUM \
   + FSYS_TFTP_NUM + FSYS_ISO9660_NUM + FSYS_UFS2_NUM)
   + FSYS_XFS_NUM + FSYS_TFTP_NUM + FSYS_ISO9660_NUM + FSYS_UFS2_NUM)
#endif
#endif
/* defines for the block filesystem info area */
/* defines for the block filesystem info area */
(-) grub-0.96.orig/stage2/fsys_reiser4.c (+260 lines)
Line 0    Link Here 
/* 
 *  fsys_reiser4.c -- reiser4 filesystem support.
 *  Copyright (C) 2000, 2001   Free Software Foundation, Inc.
 *  
 *  GRUB  --  GRand Unified Bootloader
 *
 *  This program 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 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef FSYS_REISER4
#include "shared.h"
#include "filesys.h"
#define ENABLE_MINIMAL
#include <reiser4/libreiser4.h>
static reiser4_fs_t *fs = NULL;
static aal_device_t *dev = NULL;
static reiser4_object_t *object = NULL;
/* Read callback of grub specific device. It uses devread() for reading passed
   @count of device blocks starting from @blk to passed @buff. */
static errno_t grub_dev_read(aal_device_t *device,
			     void *buff, blk_t blk,
			     count_t count)
{
	unsigned int size;
	unsigned int factor;
	unsigned int sector;
	/* Calculating actual sector and size in bytes to be read from
	   device. */
	factor = device->blksize / SECTOR_SIZE;
	sector = (unsigned int)blk << aal_log2(factor);
	size = (unsigned int)count * (SECTOR_SIZE * factor);
	
	/* Reading from the current device */
        if (!devread(sector, 0, size, buff))
    	        return -EIO;
		
	return 0;
}
/* Length callback of grub device */
static count_t grub_dev_len(aal_device_t *device) {
	unsigned int factor;
	/* Getting partition length in device blocks */
	factor = device->blksize / SECTOR_SIZE;
	return (part_length >> aal_log2(factor));
}
/*
  Initializing grub device abstraction instance. It will use devread and friends
  for providing needed functionality.
*/
struct aal_device_ops grub_dev_ops = {
	.read   = grub_dev_read,
	.len    = grub_dev_len
};
/* Initializes reiser4 */
static int reiser4_init(void) {
	extern aal_hash_table_t *plugins;
	
	plugins = NULL;
	/* Initializing memory manager */
	aal_mem_init((void *)FSYS_BUF, FSYS_BUFLEN);
	/* Initializing device abstraction on current device GRUB uses. */
	if (!(dev = aal_device_open(&grub_dev_ops, NULL,
				    SECTOR_SIZE, 0)))
	{
		return 0;
	}
	/* Initializing libreiser4 (plugins, etc) */
	return !libreiser4_init();
}
#define MEMORY_WATERMARK 8192
/* Memory pressure detect function. */
static int mpressure_detect(reiser4_tree_t *tree) {
	return (aal_mem_free() <= MEMORY_WATERMARK);
}
/* Reiser4 mount() routine */
int reiser4_mount(void) {
	
	/* Initialize all reiser4 related stuff first */
	if (!reiser4_init())
		return 0;
	
	/* Open filesystem on @dev. */
	if (!(fs = reiser4_fs_open(dev)))
		return 0;
	fs->tree->mpc_func = mpressure_detect;
	
	object = NULL;
	return 1;
}
/* Reiser4 read() handler */
int reiser4_read(char *buf, int len) {
	int64_t read;
	if (object == NULL)
		return 0;
	/* Seet at current position denoted by @filepos */
	if (objplug(object)->o.object_ops->seek) {
		plug_call(objplug(object)->o.object_ops,
			  seek, object->ent, filepos);
	}
	
	/* Reading current file data starting from @filepos */
	disk_read_func = disk_read_hook;
	read = objplug(object)->o.object_ops->read ?
		plug_call(objplug(object)->o.object_ops, read, 
			  object->ent, buf, len) : -EINVAL;
	disk_read_func = NULL;
	if (read < 0) {
		errnum = ERR_FSYS_CORRUPT;
		return 0;
	}
    	filepos += read;
	return read;
}
/* Reiser4 file open() routine */
int reiser4_dir(char *dirname) {
	char *ch;
	
	if (fs == NULL)
		return 0;
	if (object != NULL) {
		plug_call(objplug(object)->o.object_ops, 
			  close, object->ent);
		aal_free(object);
		object = NULL;
	}
	/* Cutting out string after first space character */
    	if ((ch = aal_strchr(dirname, ' ')))
		*ch = '\0';
		
	/* This function is also called for getting directory list for
	   maintaining the bash-like completion. */
#ifndef STAGE1_5
	if (print_possibilities) {
		char entry[256];
		entry_hint_t entry_hint;
		
		/* Getting last part of name (jsut after last '/') */
		if (*(dirname + aal_strlen(dirname) - 1) != '/') {
		
			if (!(ch = aal_strrchr(dirname, '/'))) {
				errnum = ERR_BAD_FILETYPE;
				return 0;
			}
			aal_strncpy(entry, ch + 1, sizeof(entry));
			*(ch + 1) = '\0';
		} else {
			aal_memset(entry, 0, sizeof(entry));
		}
		/* Open obejct by @dirname */
		if (!(object = reiser4_semantic_open(fs->tree, dirname, 
						     NULL, 1))) 
		{
			errnum = ERR_FILE_NOT_FOUND;
			return 0;
		}
		/* Checking if it is a directory object */
		if (object->ent->opset.plug[OPSET_OBJ]->id.group != DIR_OBJECT)
		{
			/* If not, cutting out last '/' character */
    			if ((ch = aal_strrchr(dirname, '/')))
				*ch = '\0';
			/* Close current object */
			plug_call(objplug(object)->o.object_ops, 
				  close, object->ent);
			aal_free(object);
			return 0;
		}
		
		/* Reading the opened directory to build the completion list. */
		if (objplug(object)->o.object_ops->readdir) {
			while (plug_call(objplug(object)->o.object_ops, readdir,
					 object->ent, &entry_hint) > 0) 
			{
				if (substring(entry, entry_hint.name) <= 0) {
					if (print_possibilities > 0)
						print_possibilities = 
							-print_possibilities;
				
					print_a_completion(entry_hint.name);
				}
			}
		}
	} else {
#endif
		/* This is the case when resier4_dir() is called for open the
		   file @dirname, not for building completion list. */
		if (!(object = reiser4_semantic_open(fs->tree, dirname,
						     NULL, 1))) 
		{
			errnum = ERR_FILE_NOT_FOUND;
			return 0;
		}
		
		if (object->ent->opset.plug[OPSET_OBJ]->id.group != REG_OBJECT)
		{
			errnum = ERR_BAD_FILETYPE;
			return 0;
		}
		
		/* Initializing GRUB global variables @filepos and @filemax. */
		filepos = 0;
		filemax = reiser4_object_size(object);
	
		return 1;
#ifndef STAGE1_5
	}
	return 1;
#endif
	errnum = ERR_FILE_NOT_FOUND;
	return 0;
}
/* Returns how many sectors may be used for embeding reiser4_stage1_5 in teh
   case of installing GRUB to partition instead of MBR. */
int reiser4_embed (int *start_sector, int needed_sectors) {
	*start_sector = 1;
	return needed_sectors <= ((REISER4_MASTER_OFFSET >> SECTOR_BITS) - 1);
}
#endif /* FSYS_REISER4 */
(-) grub-0.96.orig/stage2/shared.h (-5 / +8 lines)
 Lines 207-217    Link Here 
#define STAGE2_ID_FAT_STAGE1_5		3
#define STAGE2_ID_FAT_STAGE1_5		3
#define STAGE2_ID_MINIX_STAGE1_5	4
#define STAGE2_ID_MINIX_STAGE1_5	4
#define STAGE2_ID_REISERFS_STAGE1_5	5
#define STAGE2_ID_REISERFS_STAGE1_5	5
#define STAGE2_ID_VSTAFS_STAGE1_5	6
#define STAGE2_ID_REISER4_STAGE1_5	6
#define STAGE2_ID_JFS_STAGE1_5		7
#define STAGE2_ID_VSTAFS_STAGE1_5	7
#define STAGE2_ID_XFS_STAGE1_5		8
#define STAGE2_ID_JFS_STAGE1_5		8
#define STAGE2_ID_ISO9660_STAGE1_5	9
#define STAGE2_ID_XFS_STAGE1_5		9
#define STAGE2_ID_UFS2_STAGE1_5		10
#define STAGE2_ID_ISO9660_STAGE1_5	10
#define STAGE2_ID_UFS2_STAGE1_5		11
#ifndef STAGE1_5
#ifndef STAGE1_5
# define STAGE2_ID	STAGE2_ID_STAGE2
# define STAGE2_ID	STAGE2_ID_STAGE2
 Lines 226-231    Link Here 
#  define STAGE2_ID	STAGE2_ID_MINIX_STAGE1_5
#  define STAGE2_ID	STAGE2_ID_MINIX_STAGE1_5
# elif defined(FSYS_REISERFS)
# elif defined(FSYS_REISERFS)
#  define STAGE2_ID	STAGE2_ID_REISERFS_STAGE1_5
#  define STAGE2_ID	STAGE2_ID_REISERFS_STAGE1_5
# elif defined(FSYS_REISER4)
#  define STAGE2_ID	STAGE2_ID_REISER4_STAGE1_5
# elif defined(FSYS_VSTAFS)
# elif defined(FSYS_VSTAFS)
#  define STAGE2_ID	STAGE2_ID_VSTAFS_STAGE1_5
#  define STAGE2_ID	STAGE2_ID_VSTAFS_STAGE1_5
# elif defined(FSYS_JFS)
# elif defined(FSYS_JFS)