1 Submitted By: Jim Gifford <jim@linuxfromscratch.org>
3 Initial Package Version: 0.97
4 Upstream Status: Unknown
5 Origin: Fedora and Mandriva
6 Description: This patch fixes issues with disk geometry not being
7 detected properly. Part of this patch also fixes
8 gcc 4 compile errors, which are a part of the issue.
10 diff -Naur grub-0.97.orig/configure grub-0.97/configure
11 --- grub-0.97.orig/configure 2005-05-07 19:48:12.000000000 -0700
12 +++ grub-0.97/configure 2006-05-28 20:29:36.025466751 -0700
14 echo "$as_me:$LINENO: result: $size_flag" >&5
15 echo "${ECHO_T}$size_flag" >&6
16 if test "x$size_flag" = xyes; then
18 + STAGE2_CFLAGS="-Os -fno-strict-aliasing"
20 - STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops"
21 + STAGE2_CFLAGS="-O2 -fno-strict-aliasing -fno-strength-reduce -fno-unroll-loops"
23 # OpenBSD has a GCC extension for protecting applications from
24 # stack smashing attacks, but GRUB doesn't want this feature.
25 diff -Naur grub-0.97.orig/configure.ac grub-0.97/configure.ac
26 --- grub-0.97.orig/configure.ac 2005-05-07 19:36:03.000000000 -0700
27 +++ grub-0.97/configure.ac 2006-05-28 20:28:41.538819726 -0700
31 if test "x$size_flag" = xyes; then
33 + STAGE2_CFLAGS="-Os -fno-strict-aliasing"
35 - STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops"
36 + STAGE2_CFLAGS="-O2 -fno-strict-aliasing -fno-strength-reduce -fno-unroll-loops"
38 # OpenBSD has a GCC extension for protecting applications from
39 # stack smashing attacks, but GRUB doesn't want this feature.
40 diff -Naur grub-0.97.orig/lib/device.c grub-0.97/lib/device.c
41 --- grub-0.97.orig/lib/device.c 2005-03-27 15:14:25.000000000 -0800
42 +++ grub-0.97/lib/device.c 2006-05-28 20:34:03.546804777 -0700
47 +#if defined(__linux__)
48 +/* The 2.6 kernel has removed all of the geometry handling for IDE drives
49 + * that did fixups for LBA, etc. This means that the geometry we get
50 + * with the ioctl has a good chance of being wrong. So, we get to
51 + * also know about partition tables and try to read what the geometry
52 + * is there. *grumble* Very closely based on code from cfdisk
54 +static void get_kernel_geometry(int fd, long long *cyl, int *heads, int *sectors) {
55 + struct hd_geometry hdg;
57 + if (ioctl (fd, HDIO_GETGEO, &hdg))
60 + *cyl = hdg.cylinders;
62 + *sectors = hdg.sectors;
66 + unsigned char boot_ind; /* 0x80 - active */
67 + unsigned char head; /* starting head */
68 + unsigned char sector; /* starting sector */
69 + unsigned char cyl; /* starting cylinder */
70 + unsigned char sys_ind; /* What partition type */
71 + unsigned char end_head; /* end head */
72 + unsigned char end_sector; /* end sector */
73 + unsigned char end_cyl; /* end cylinder */
74 + unsigned char start4[4]; /* starting sector counting from 0 */
75 + unsigned char size4[4]; /* nr of sectors in partition */
81 + unsigned char align[ALIGNMENT];
82 + unsigned char b[SECTOR_SIZE];
85 + unsigned char align[ALIGNMENT];
86 + unsigned char buffer[0x1BE];
87 + struct partition part[4];
88 + unsigned char magicflag[2];
92 +#define PART_TABLE_FLAG0 0x55
93 +#define PART_TABLE_FLAG1 0xAA
96 +get_partition_table_geometry(partition_table *bufp, long long *cyl, int *heads,
98 + struct partition *p;
103 + if (bufp->p.magicflag[0] != PART_TABLE_FLAG0 ||
104 + bufp->p.magicflag[1] != PART_TABLE_FLAG1) {
105 + /* Matthew Wilcox: slightly friendlier version of
106 + fatal(_("Bad signature on partition table"), 3);
108 + fprintf(stderr, "Unknown partition table signature\n");
113 + for (i=0; i<4; i++) {
114 + p = &(bufp->p.part[i]);
115 + if (p->sys_ind != 0) {
116 + h = p->end_head + 1;
117 + s = (p->end_sector & 077);
122 + } else if (hh != h || ss != s)
127 + if (!first && !bad) {
133 +static long long my_lseek (unsigned int fd, long long offset,
134 + unsigned int origin)
136 +#if defined(__linux__) && (!defined(__GLIBC__) || \
137 + ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
138 + /* Maybe libc doesn't have large file support. */
139 + loff_t offset, result;
140 + static int _llseek (uint filedes, ulong hi, ulong lo,
141 + loff_t *res, uint wh);
142 + _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
143 + loff_t *, res, uint, wh);
145 + if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET) < 0)
146 + return (long long) -1;
149 + return lseek(fd, offset, SEEK_SET);
153 +static void get_linux_geometry (int fd, struct geometry *geom) {
154 + long long kern_cyl = 0; int kern_head = 0, kern_sectors = 0;
155 + long long pt_cyl = 0; int pt_head = 0, pt_sectors = 0;
156 + partition_table bufp;
157 + char *buff, *buf_unaligned;
159 + buf_unaligned = malloc(sizeof(partition_table) + 4095);
160 + buff = (char *) (((unsigned long)buf_unaligned + 4096 - 1) &
163 + get_kernel_geometry(fd, &kern_cyl, &kern_head, &kern_sectors);
165 + if (my_lseek (fd, 0*SECTOR_SIZE, SEEK_SET) < 0) {
166 + fprintf(stderr, "Unable to seek");
169 + if (read(fd, buff, SECTOR_SIZE) == SECTOR_SIZE) {
170 + memcpy(bufp.c.b, buff, SECTOR_SIZE);
171 + get_partition_table_geometry(&bufp, &pt_cyl, &pt_head, &pt_sectors);
173 + fprintf(stderr, "Unable to read partition table: %s\n", strerror(errno));
176 + if (pt_head && pt_sectors) {
179 + geom->heads = pt_head;
180 + geom->sectors = pt_sectors;
181 + cyl_size = pt_head * pt_sectors;
182 + geom->cylinders = geom->total_sectors/cyl_size;
184 + geom->heads = kern_head;
185 + geom->sectors = kern_sectors;
186 + geom->cylinders = kern_cyl;
193 /* Get the geometry of a drive DRIVE. */
195 get_drive_geometry (struct geometry *geom, char **map, int drive)
196 @@ -151,21 +297,16 @@
197 #if defined(__linux__)
200 - struct hd_geometry hdg;
203 - if (ioctl (fd, HDIO_GETGEO, &hdg))
206 if (ioctl (fd, BLKGETSIZE, &nr))
209 /* Got the geometry, so save it. */
210 - geom->cylinders = hdg.cylinders;
211 - geom->heads = hdg.heads;
212 - geom->sectors = hdg.sectors;
213 geom->total_sectors = nr;
215 + get_linux_geometry(fd, geom);
216 + if (!geom->heads && !geom->cylinders && !geom->sectors)
223 char dev[PATH_MAX]; /* XXX */
225 + off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
227 if ((partition & 0x00FF00) != 0x00FF00)
229 @@ -870,35 +1012,13 @@
230 errnum = ERR_NO_PART;
234 -#if defined(__linux__) && (!defined(__GLIBC__) || \
235 - ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
236 - /* Maybe libc doesn't have large file support. */
238 - loff_t offset, result;
239 - static int _llseek (uint filedes, ulong hi, ulong lo,
240 - loff_t *res, uint wh);
241 - _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
242 - loff_t *, res, uint, wh);
244 - offset = (loff_t) sector * (loff_t) SECTOR_SIZE;
245 - if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
247 - errnum = ERR_DEV_VALUES;
253 - off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
255 - if (lseek (fd, offset, SEEK_SET) != offset)
257 - errnum = ERR_DEV_VALUES;
262 + if (my_lseek(fd, offset, SEEK_SET) != offset)
264 + errnum = ERR_DEV_VALUES;
268 if (write (fd, buf, size * SECTOR_SIZE) != (size * SECTOR_SIZE))
270 diff -Naur grub-0.97.orig/stage2/Makefile.am grub-0.97/stage2/Makefile.am
271 --- grub-0.97.orig/stage2/Makefile.am 2005-02-02 12:37:35.000000000 -0800
272 +++ grub-0.97/stage2/Makefile.am 2006-05-28 20:28:41.590818435 -0700
274 -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
275 -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
276 -DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \
277 - -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1
278 + -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1 \
279 + -fno-strict-aliasing
281 # Stage 2 and Stage 1.5's.
282 pkglibdir = $(libdir)/$(PACKAGE)/$(host_cpu)-$(host_vendor)
283 diff -Naur grub-0.97.orig/stage2/boot.c grub-0.97/stage2/boot.c
284 --- grub-0.97.orig/stage2/boot.c 2004-03-30 03:44:08.000000000 -0800
285 +++ grub-0.97/stage2/boot.c 2006-05-28 20:33:30.123638792 -0700
288 /* presuming that MULTIBOOT_SEARCH is large enough to encompass an
290 - unsigned char buffer[MULTIBOOT_SEARCH];
291 + char buffer[MULTIBOOT_SEARCH];
293 /* sets the header pointer to point to the beginning of the
296 /* ELF loading supported if multiboot, FreeBSD and NetBSD. */
297 if ((type == KERNEL_TYPE_MULTIBOOT
298 || pu.elf->e_ident[EI_OSABI] == ELFOSABI_FREEBSD
299 - || grub_strcmp (pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0
300 + || grub_strcmp ((char *) pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0
301 || suggested_type == KERNEL_TYPE_NETBSD)
302 && len > sizeof (Elf32_Ehdr)
303 && BOOTABLE_I386_ELF ((*((Elf32_Ehdr *) buffer))))
305 moveto = (mbi.mem_upper + 0x400) << 10;
307 moveto = (moveto - len) & 0xfffff000;
309 max_addr = (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0203
310 ? lh->initrd_addr_max : LINUX_INITRD_MAX_ADDRESS);
312 + max_addr = LINUX_INITRD_MAX_ADDRESS;
314 if (moveto + len >= max_addr)
315 moveto = (max_addr - len) & 0xfffff000;
317 diff -Naur grub-0.97.orig/stage2/disk_io.c grub-0.97/stage2/disk_io.c
318 --- grub-0.97.orig/stage2/disk_io.c 2004-05-23 09:35:24.000000000 -0700
319 +++ grub-0.97/stage2/disk_io.c 2006-05-28 20:28:41.582818634 -0700
320 @@ -127,12 +127,19 @@
324 -static inline unsigned long
325 -log2 (unsigned long word)
326 +#define log2(n) ffz(~(n))
328 +/* include/asm-i386/bitops.h */
330 + * ffz = Find First Zero in word. Undefined if no zero exists,
331 + * so code should check against ~0UL first..
333 +static __inline__ unsigned long
334 +ffz (unsigned long word)
336 - asm volatile ("bsfl %1,%0"
339 + __asm__ ("bsfl %1,%0"
345 diff -Naur grub-0.97.orig/stage2/freebsd.h grub-0.97/stage2/freebsd.h
346 --- grub-0.97.orig/stage2/freebsd.h 2003-07-09 04:45:52.000000000 -0700
347 +++ grub-0.97/stage2/freebsd.h 2006-05-28 20:28:41.582818634 -0700
351 unsigned int bi_version;
352 - unsigned char *bi_kernelname;
353 + char *bi_kernelname;
354 struct nfs_diskless *bi_nfs_diskless;
355 /* End of fields that are always present. */
356 #define bi_endcommon bi_n_bios_used
357 diff -Naur grub-0.97.orig/stage2/fsys_fat.c grub-0.97/stage2/fsys_fat.c
358 --- grub-0.97.orig/stage2/fsys_fat.c 2005-03-15 08:52:00.000000000 -0800
359 +++ grub-0.97/stage2/fsys_fat.c 2006-05-28 20:28:41.582818634 -0700
362 #define FAT_CACHE_SIZE 2048
364 +#define log2(n) ffz(~(n))
366 +/* include/asm-i386/bitops.h */
368 + * ffz = Find First Zero in word. Undefined if no zero exists,
369 + * so code should check against ~0UL first..
371 static __inline__ unsigned long
372 -log2 (unsigned long word)
373 +ffz (unsigned long word)
375 __asm__ ("bsfl %1,%0"
383 diff -Naur grub-0.97.orig/stage2/fsys_iso9660.c grub-0.97/stage2/fsys_iso9660.c
384 --- grub-0.97.orig/stage2/fsys_iso9660.c 2004-05-11 05:11:19.000000000 -0700
385 +++ grub-0.97/stage2/fsys_iso9660.c 2006-05-28 20:28:41.582818634 -0700
387 #define RRCONT_BUF ((unsigned char *)(FSYS_BUF + 6144))
388 #define NAME_BUF ((unsigned char *)(FSYS_BUF + 8192))
390 +#define log2(n) ffz(~(n))
392 -static inline unsigned long
393 -log2 (unsigned long word)
394 +/* include/asm-i386/bitops.h */
396 + * ffz = Find First Zero in word. Undefined if no zero exists,
397 + * so code should check against ~0UL first..
399 +static __inline__ unsigned long
400 +ffz (unsigned long word)
402 - asm volatile ("bsfl %1,%0"
405 + __asm__ ("bsfl %1,%0"
413 /* check ISO_VD_PRIMARY and ISO_STANDARD_ID */
414 if (PRIMDESC->type.l == ISO_VD_PRIMARY
415 - && !memcmp(PRIMDESC->id, ISO_STANDARD_ID, sizeof(PRIMDESC->id)))
416 + && !memcmp((char *) PRIMDESC->id, ISO_STANDARD_ID, sizeof(PRIMDESC->id)))
418 ISO_SUPER->vol_sector = sector;
419 INODE->file_start = 0;
421 for (; idr->length.l > 0;
422 idr = (struct iso_directory_record *)((char *)idr + idr->length.l) )
424 - const char *name = idr->name;
425 + const u_int8_t *name = idr->name;
426 unsigned int name_len = idr->name_len.l;
428 file_type = (idr->flags.l & 2) ? ISO_DIRECTORY : ISO_REGULAR;
430 rr_len = (idr->length.l - idr->name_len.l
431 - sizeof(struct iso_directory_record)
432 + sizeof(idr->name));
433 - rr_ptr.ptr = ((unsigned char *)idr + idr->name_len.l
434 + rr_ptr.ptr = ((char *)idr + idr->name_len.l
435 + sizeof(struct iso_directory_record)
436 - sizeof(idr->name));
439 memcpy(NAME_BUF, name, name_len);
442 - rr_ptr.ptr = RRCONT_BUF + ce_ptr->u.ce.offset.l;
443 + rr_ptr.ptr = (char *) RRCONT_BUF + ce_ptr->u.ce.offset.l;
444 rr_len = ce_ptr->u.ce.size.l;
445 - if (!iso9660_devread(ce_ptr->u.ce.extent.l, 0, ISO_SECTOR_SIZE, RRCONT_BUF))
446 + if (!iso9660_devread(ce_ptr->u.ce.extent.l, 0, ISO_SECTOR_SIZE, (char *) RRCONT_BUF))
448 errnum = 0; /* this is not fatal. */
453 if (name_len >= pathlen
454 - && !memcmp(name, dirname, pathlen))
455 + && !memcmp((char *) name, dirname, pathlen))
457 if (dirname[pathlen] == '/' || !print_possibilities)
460 print_possibilities = -print_possibilities;
461 memcpy(NAME_BUF, name, name_len);
462 NAME_BUF[name_len] = '\0';
463 - print_a_completion (NAME_BUF);
464 + print_a_completion ((char *) NAME_BUF);
468 diff -Naur grub-0.97.orig/stage2/fsys_reiserfs.c grub-0.97/stage2/fsys_reiserfs.c
469 --- grub-0.97.orig/stage2/fsys_reiserfs.c 2004-02-18 14:09:10.000000000 -0800
470 +++ grub-0.97/stage2/fsys_reiserfs.c 2006-05-28 20:28:41.586818535 -0700
471 @@ -365,13 +365,19 @@
472 #define JOURNAL_START ((__u32 *) (INFO + 1))
473 #define JOURNAL_END ((__u32 *) (FSYS_BUF + FSYS_BUFLEN))
475 +#define log2(n) ffz(~(n))
477 +/* include/asm-i386/bitops.h */
479 + * ffz = Find First Zero in word. Undefined if no zero exists,
480 + * so code should check against ~0UL first..
482 static __inline__ unsigned long
483 -log2 (unsigned long word)
484 +ffz (unsigned long word)
486 __asm__ ("bsfl %1,%0"
494 diff -Naur grub-0.97.orig/stage2/fsys_vstafs.c grub-0.97/stage2/fsys_vstafs.c
495 --- grub-0.97.orig/stage2/fsys_vstafs.c 2003-07-09 04:45:53.000000000 -0700
496 +++ grub-0.97/stage2/fsys_vstafs.c 2006-05-28 20:28:41.586818535 -0700
497 @@ -186,35 +186,35 @@
499 vstafs_read (char *addr, int len)
503 int size, ret = 0, offset, curr_len = 0;
510 get_file_info (f_sector);
511 size = FILE_INFO->len-VSTAFS_START_DATA;
512 - a = FILE_INFO->blocks;
513 + b = FILE_INFO->blocks;
517 - if (filepos < a[0].a_len * 512 - VSTAFS_START_DATA)
518 + if (filepos < b[0].a_len * 512 - VSTAFS_START_DATA)
520 offset = filepos + VSTAFS_START_DATA;
522 - curr_len = a[0].a_len * 512 - offset - filepos;
523 + curr_len = b[0].a_len * 512 - offset - filepos;
527 - ext_size = a[0].a_len * 512 - VSTAFS_START_DATA;
528 + ext_size = b[0].a_len * 512 - VSTAFS_START_DATA;
529 offset = filepos - ext_size;
533 curr_len -= ext_size;
535 - ext_size = a[extent+1].a_len * 512;
536 + ext_size = b[extent+1].a_len * 512;
538 while (extent < FILE_INFO->extents && offset>ext_size);
540 @@ -223,16 +223,16 @@
542 offset = VSTAFS_START_DATA;
544 - curr_len = a[0].a_len * 512 - offset;
545 + curr_len = b[0].a_len * 512 - offset;
552 - for (curr_ext=extent;
553 - curr_ext < FILE_INFO->extents;
554 - curr_len = a[curr_ext].a_len * 512, curr_pos += curr_len, curr_ext++)
555 + for (curr_exten = extent;
556 + curr_exten < FILE_INFO->extents;
557 + curr_len = b[curr_exten].a_len * 512, curr_pos += curr_len, curr_exten++)
565 - devread (a[curr_ext].a_start,offset, curr_len, curr_pos);
566 + devread (b[curr_exten].a_start, offset, curr_len, curr_pos);
570 diff -Naur grub-0.97.orig/stage2/fsys_xfs.c grub-0.97/stage2/fsys_xfs.c
571 --- grub-0.97.orig/stage2/fsys_xfs.c 2005-05-07 19:15:55.000000000 -0700
572 +++ grub-0.97/stage2/fsys_xfs.c 2006-05-28 20:28:41.586818535 -0700
574 return ino & XFS_INO_MASK(XFS_INO_OFFSET_BITS);
577 -static inline __const__ xfs_uint16_t
578 +static inline __attribute__((const)) xfs_uint16_t
579 le16 (xfs_uint16_t x)
581 __asm__("xchgb %b0,%h0" \
586 -static inline __const__ xfs_uint32_t
587 +static inline __attribute__((const)) xfs_uint32_t
588 le32 (xfs_uint32_t x)
595 -static inline __const__ xfs_uint64_t
596 +static inline __attribute__((const)) xfs_uint64_t
597 le64 (xfs_uint64_t x)
599 xfs_uint32_t h = x >> 32;
602 namelen = sfe->namelen;
603 *ino = sf_ino ((char *)sfe, namelen);
605 + name = (char *) sfe->name;
606 sfe = (xfs_dir2_sf_entry_t *)
607 ((char *)sfe + namelen + 11 - xfs.i8param);
609 diff -Naur grub-0.97.orig/stage2/gunzip.c grub-0.97/stage2/gunzip.c
610 --- grub-0.97.orig/stage2/gunzip.c 2003-07-09 04:45:53.000000000 -0700
611 +++ grub-0.97/stage2/gunzip.c 2006-05-28 20:28:41.586818535 -0700
613 * is a compressed file, and simply mark it as such.
616 - || grub_read (buf, 10) != 10
617 + || grub_read ((char *) buf, 10) != 10
618 || ((*((unsigned short *) buf) != GZIP_HDR_LE)
619 && (*((unsigned short *) buf) != OLD_GZIP_HDR_LE)))
622 if (buf[2] != DEFLATED
623 || (buf[3] & UNSUPP_FLAGS)
624 || ((buf[3] & EXTRA_FIELD)
625 - && (grub_read (buf, 2) != 2
626 + && (grub_read ((char *) buf, 2) != 2
627 || bad_field (*((unsigned short *) buf))))
628 || ((buf[3] & ORIG_NAME) && bad_field (-1))
629 || ((buf[3] & COMMENT) && bad_field (-1)))
632 filepos = filemax - 8;
634 - if (grub_read (buf, 8) != 8)
635 + if (grub_read ((char *) buf, 8) != 8)
638 errnum = ERR_BAD_GZIP_HEADER;
641 #define INBUFSIZ 0x2000
643 -static uch inbuf[INBUFSIZ];
645 +static unsigned char inbuf[INBUFSIZ];
651 if (filepos == gzip_data_offset || bufloc == INBUFSIZ)
654 - grub_read (inbuf, INBUFSIZ);
655 + grub_read ((char *) inbuf, INBUFSIZ);
658 return inbuf[bufloc++];
660 unsigned m; /* mask for bit lengths table */
661 unsigned n; /* number of lengths to get */
662 unsigned nb; /* number of bit length codes */
663 - unsigned nl; /* number of literal/length codes */
664 + unsigned nc; /* number of literal/length codes */
665 unsigned nd; /* number of distance codes */
666 unsigned ll[286 + 30]; /* literal/length and distance code lengths */
667 register ulg b; /* bit buffer */
670 /* read in table lengths */
672 - nl = 257 + ((unsigned) b & 0x1f); /* number of literal/length codes */
673 + nc = 257 + ((unsigned) b & 0x1f); /* number of literal/length codes */
676 nd = 1 + ((unsigned) b & 0x1f); /* number of distance codes */
679 nb = 4 + ((unsigned) b & 0xf); /* number of bit length codes */
681 - if (nl > 286 || nd > 30)
682 + if (nc > 286 || nd > 30)
684 errnum = ERR_BAD_GZIP_DATA;
689 /* read in literal and distance code lengths */
694 while ((unsigned) i < n)
695 @@ -1034,7 +1034,7 @@
697 /* build the decoding tables for literal/length and distance codes */
699 - if ((i = huft_build (ll, nl, 257, cplens, cplext, &tl, &bl)) != 0)
700 + if ((i = huft_build (ll, nc, 257, cplens, cplext, &tl, &bl)) != 0)
704 @@ -1045,7 +1045,7 @@
708 - if ((i = huft_build (ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0)
709 + if ((i = huft_build (ll + nc, nd, 0, cpdist, cpdext, &td, &bd)) != 0)
713 diff -Naur grub-0.97.orig/stage2/md5.c grub-0.97/stage2/md5.c
714 --- grub-0.97.orig/stage2/md5.c 2003-07-09 04:45:53.000000000 -0700
715 +++ grub-0.97/stage2/md5.c 2006-05-28 20:28:41.590818435 -0700
717 inputlen -= 64 - buflen;
718 while (inputlen >= 64)
720 - md5_transform (input);
721 + md5_transform ((unsigned char *) input);
729 - unsigned char alt_result[16];
730 + char alt_result[16];
731 unsigned char *digest;
734 diff -Naur grub-0.97.orig/stage2/start_eltorito.S grub-0.97/stage2/start_eltorito.S
735 --- grub-0.97.orig/stage2/start_eltorito.S 2004-03-27 08:14:20.000000000 -0800
736 +++ grub-0.97/stage2/start_eltorito.S 2006-05-28 20:31:17.770936712 -0700
738 #define ABS(x) (x-_start+BOOTSEC_LOCATION)
741 -# define STAGE_ADDR 0x2000
742 +# define STAGE_ADDR 0x2200
744 -# define STAGE_ADDR 0x8000
745 +# define STAGE_ADDR 0x8200
746 #endif /* STAGE1_5 */
748 /* Print message string */
750 . = _start + 8 /* Pad to file offset 8 */
752 /* This table gets filled in by mkisofs using the
753 - -boot-info-table option */
754 -bi_pvd: .long 0xDEADBEEF /* LBA of primary volume descript */
755 -bi_file: .long 0xDEADBEEF /* LBA of boot file */
756 -bi_length: .long 0xDEADBEEF /* Length of boot file */
757 -bi_csum: .long 0xDEADBEEF /* Checksum of boot file */
758 -bi_reserved: .space (10*4) /* Reserved */
759 + -boot-info-table option If not, the values in this
760 + table are default values that we can use to get us
761 + what we need, at least under a certain set of assumptions. */
762 +bi_pvd: .long 16 /* LBA of primary volume descript */
763 +bi_file: .long 0 /* LBA of boot file */
764 +bi_length: .long 0xDEADBEEF /* Length of boot file */
765 +bi_csum: .long 0xDEADBEEF /* Checksum of boot file */
766 +bi_reserved: .space (10*4) /* Reserved */
771 /* save drive reference first thing! */
772 mov %dl, ABS(BootDrive)
774 - /* print a notification message on the screen */
775 - MSG(notification_string)
776 + /* check if machine support IBM/MS int 13h extensions */
782 + /* bios doesn't support int 13h extensions, print error messages */
783 + MSG(int13_error_string1)
784 + MSG(notification_done)
785 + MSG(int13_error_string2)
786 + MSG(notification_done)
787 + MSG(int13_error_string3)
788 + MSG(notification_done)
789 + /* even when bios says that it doesn't support int 13h
790 + extensions, do not stop here and try to load image anyway,
791 + because some bioses says that there isn't support for
792 + extended functions but have the needed extended read function
793 + (int 13h, function AH=42h) */
796 + /* print a notification message on the screen */
797 + MSG(notification_string)
798 /* Set up boot file sector, size, load address */
799 mov ABS(bi_length), %eax
800 add $(ISO_SECTOR_SIZE-1), %eax
804 mov ABS(bi_file), %eax
805 + inc %eax /* do not reload the first sector (this code) */
806 + dec %bp /* this way we have more room for code in stage1 */
811 mov $ABS(firstlist - BOOTSEC_LISTSIZE), %si
813 mov ABS(BootDrive), %dl /* this makes sure %dl is our "boot" drive */
814 - ljmp $0, $(STAGE_ADDR+SECTOR_SIZE) /* jump to main() in asm.S */
815 + ljmp $0, $(STAGE_ADDR) /* jump to main() in asm.S */
817 /* go here when you need to stop the machine hard after an error condition */
819 @@ -171,11 +193,11 @@
822 movb $6, ABS(RetryCount)
828 - add $(8*4), %sp /* Clean up stack */
829 + popal /* Clean up stack */
832 mov %ah, %dl /* Save error code */
835 read_error_string: .string "Read error 0x"
837 +int13_error_string1: .string "Support for IBM/MS INT 13h extensions not found"
838 +int13_error_string2: .string "GRUB cannot be loaded if int 13h/function AH=42h isn't present"
839 +int13_error_string3: .string "Trying to load stage 2 anyway..."
842 * EBIOS disk address packet
848 - . = _start + SECTOR_SIZE - BOOTSEC_LISTSIZE
849 + /* size of the code we can place between main body and fixed top location */
850 + . = _start + 1536 - BOOTSEC_LISTSIZE
852 /* fill the first data listing with the default */
853 blocklist_default_start:/* this is the sector start parameter, in logical
856 blocklist_default_seg: /* this is the segment of the starting address
857 to load the data into */
858 - .word (STAGE_ADDR + SECTOR_SIZE) >> 4
859 + .word (STAGE_ADDR) >> 4
861 firstlist: /* this label has to be after the list data!!! */
863 + /* this is a workaround to allow more code to be added in stage1,
864 + it allows more code to be added for this stage, but for this
865 + we can't reload the first sector. So we have to align the code
866 + to ISO_SECTOR_SIZE. */
867 + . = _start + ISO_SECTOR_SIZE
868 diff -Naur grub-0.97.orig/util/grub-install.in grub-0.97/util/grub-install.in
869 --- grub-0.97.orig/util/grub-install.in 2004-07-24 11:57:31.000000000 -0700
870 +++ grub-0.97/util/grub-install.in 2006-05-28 20:30:31.484088268 -0700
872 # Create a safe temporary file.
873 test -n "$mklog" && log_file=`$mklog`
875 + # Before all invocations of the grub shell, call sync to make sure
876 + # the raw device is in sync with any bufferring in filesystems.
879 $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
883 # Create a safe temporary file.
884 test -n "$mklog" && log_file=`$mklog`
886 +# Before all invocations of the grub shell, call sync to make sure
887 +# the raw device is in sync with any bufferring in filesystems.
890 # Now perform the installation.
891 $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file