diff -Nur grub-0.95.20040823.clean/grub/Makefile.am grub-0.95.20040823.patched/grub/Makefile.am --- grub-0.95.20040823.clean/grub/Makefile.am 2004-08-24 02:21:31.000000000 +0300 +++ grub-0.95.20040823.patched/grub/Makefile.am 2005-01-23 16:43:56.529095704 +0200 @@ -13,7 +13,7 @@ $(SERIAL_FLAGS) -I$(top_srcdir)/stage2 \ -I$(top_srcdir)/stage1 -I$(top_srcdir)/lib -AM_CFLAGS = $(GRUB_CFLAGS) -fwritable-strings +AM_CFLAGS = $(GRUB_CFLAGS) grub_SOURCES = main.c asmstub.c grub_LDADD = ../stage2/libgrub.a ../lib/libcommon.a $(GRUB_LIBS) diff -Nur grub-0.95.20040823.clean/grub/Makefile.in grub-0.95.20040823.patched/grub/Makefile.in --- grub-0.95.20040823.clean/grub/Makefile.in 2004-08-24 02:21:31.000000000 +0300 +++ grub-0.95.20040823.patched/grub/Makefile.in 2005-01-23 16:43:56.530095552 +0200 @@ -185,7 +185,7 @@ $(SERIAL_FLAGS) -I$(top_srcdir)/stage2 \ -I$(top_srcdir)/stage1 -I$(top_srcdir)/lib -AM_CFLAGS = $(GRUB_CFLAGS) -fwritable-strings +AM_CFLAGS = $(GRUB_CFLAGS) grub_SOURCES = main.c asmstub.c grub_LDADD = ../stage2/libgrub.a ../lib/libcommon.a $(GRUB_LIBS) all: all-am diff -Nur grub-0.95.20040823.clean/lib/device.c grub-0.95.20040823.patched/lib/device.c --- grub-0.95.20040823.clean/lib/device.c 2004-08-24 02:21:30.000000000 +0300 +++ grub-0.95.20040823.patched/lib/device.c 2005-01-23 16:24:39.960920792 +0200 @@ -828,9 +828,11 @@ is_disk_device (char **map, int drive) { struct stat st; + int retval; assert (map[drive] != 0); - assert (stat (map[drive], &st) == 0); + retval = stat (map[drive], &st); + assert (retval == 0); /* For now, disk devices under Linux are all block devices. */ return S_ISBLK (st.st_mode); } diff -Nur grub-0.95.20040823.clean/stage2/boot.c grub-0.95.20040823.patched/stage2/boot.c --- grub-0.95.20040823.clean/stage2/boot.c 2004-08-24 02:21:32.000000000 +0300 +++ grub-0.95.20040823.patched/stage2/boot.c 2005-01-23 16:36:16.113089576 +0200 @@ -824,8 +824,11 @@ moveto = (mbi.mem_upper + 0x400) << 10; moveto = (moveto - len) & 0xfffff000; - max_addr = (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0203 - ? lh->initrd_addr_max : LINUX_INITRD_MAX_ADDRESS); + max_addr = LINUX_INITRD_MAX_ADDRESS; + if (lh->header == LINUX_MAGIC_SIGNATURE && + lh->version >= 0x0203 && + lh->initrd_addr_max < max_addr) + max_addr = lh->initrd_addr_max; if (moveto + len >= max_addr) moveto = (max_addr - len) & 0xfffff000; diff -Nur grub-0.95.20040823.clean/stage2/builtins.c grub-0.95.20040823.patched/stage2/builtins.c --- grub-0.95.20040823.clean/stage2/builtins.c 2004-08-24 02:21:32.000000000 +0300 +++ grub-0.95.20040823.patched/stage2/builtins.c 2005-01-23 16:27:29.962076688 +0200 @@ -1835,9 +1835,23 @@ #ifdef GRUB_UTIL else if (grub_memcmp ("--stage2=", arg, sizeof ("--stage2=") - 1) == 0) { + int fd; stage2_os_file = arg + sizeof ("--stage2=") - 1; arg = skip_to (0, arg); nul_terminate (stage2_os_file); + +#if defined(__linux__) && defined (FSYS_REISERFS) + if ((fd=open(stage2_os_file, O_RDONLY)) >= 0) + { + struct statfs buf; + /* see if the file sits on a reiserfs, + and try do defragment it if so. */ + fstatfs(fd, &buf); + if (buf.f_type == REISERFS_SUPER_MAGIC) + ioctl (fd, REISERFS_IOC_UNPACK, 1); + } +#endif /* __linux__ && FSYS_REISERFS */ + } #endif /* GRUB_UTIL */ else diff -Nur grub-0.95.20040823.clean/stage2/filesys.h grub-0.95.20040823.patched/stage2/filesys.h --- grub-0.95.20040823.clean/stage2/filesys.h 2004-08-24 02:21:32.000000000 +0300 +++ grub-0.95.20040823.patched/stage2/filesys.h 2005-01-23 16:27:29.959077144 +0200 @@ -73,6 +73,16 @@ int reiserfs_read (char *buf, int len); int reiserfs_dir (char *dirname); int reiserfs_embed (int *start_sector, int needed_sectors); +#if defined(__linux__) && defined (GRUB_UTIL) +#include +#include +#include +#include +#include +/* from */ +#define REISERFS_SUPER_MAGIC 0x52654973 +#define REISERFS_IOC_UNPACK _IOW(0xCD,1,long) +#endif #else #define FSYS_REISERFS_NUM 0 #endif diff -Nur grub-0.95.20040823.clean/stage2/Makefile.am grub-0.95.20040823.patched/stage2/Makefile.am --- grub-0.95.20040823.clean/stage2/Makefile.am 2004-08-24 02:21:32.000000000 +0300 +++ grub-0.95.20040823.patched/stage2/Makefile.am 2005-01-23 16:43:56.530095552 +0200 @@ -24,8 +24,7 @@ -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 \ - -fwritable-strings + -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1 # Stage 2 and Stage 1.5's. pkglibdir = $(libdir)/$(PACKAGE)/$(host_cpu)-$(host_vendor) diff -Nur grub-0.95.20040823.clean/stage2/Makefile.in grub-0.95.20040823.patched/stage2/Makefile.in --- grub-0.95.20040823.clean/stage2/Makefile.in 2004-08-24 02:21:32.000000000 +0300 +++ grub-0.95.20040823.patched/stage2/Makefile.in 2005-01-23 16:43:56.537094488 +0200 @@ -579,8 +579,7 @@ -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 \ - -fwritable-strings + -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1 @DISKLESS_SUPPORT_FALSE@pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \ @DISKLESS_SUPPORT_FALSE@ ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \ diff -Nur grub-0.95.20040823.clean/util/mbchk.c grub-0.95.20040823.patched/util/mbchk.c --- grub-0.95.20040823.clean/util/mbchk.c 2004-08-24 02:21:31.000000000 +0300 +++ grub-0.95.20040823.patched/util/mbchk.c 2005-01-23 16:18:41.843362936 +0200 @@ -59,7 +59,9 @@ int i; char buf[8192]; - if (fread (buf, 1, 8192, fp) < 0) + fread (buf, 1, 8192, fp); + + if (ferror(fp)) { fprintf (stderr, "%s: Read error.\n", filename); return 0;