source: patches/grub-0.97-disk_geometry-1.patch@ 04ef2143

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 04ef2143 was 94053a6, checked in by Jim Gifford <clfs@…>, 19 years ago

Added: grub-0.97-disk_geometry-1.patch

  • Property mode set to 100644
File size: 27.7 KB
RevLine 
[94053a6]1Submitted By: Jim Gifford <jim@linuxfromscratch.org>
2Date: 05-28-2008
3Initial Package Version: 0.97
4Upstream Status: Unknown
5Origin: Fedora and Mandriva
6Description: 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.
9
10diff -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
13@@ -3485,9 +3485,9 @@
14 echo "$as_me:$LINENO: result: $size_flag" >&5
15 echo "${ECHO_T}$size_flag" >&6
16 if test "x$size_flag" = xyes; then
17- STAGE2_CFLAGS="-Os"
18+ STAGE2_CFLAGS="-Os -fno-strict-aliasing"
19 else
20- STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops"
21+ STAGE2_CFLAGS="-O2 -fno-strict-aliasing -fno-strength-reduce -fno-unroll-loops"
22 fi
23 # OpenBSD has a GCC extension for protecting applications from
24 # stack smashing attacks, but GRUB doesn't want this feature.
25diff -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
28@@ -93,9 +93,9 @@
29 CFLAGS=$saved_CFLAGS
30 ])
31 if test "x$size_flag" = xyes; then
32- STAGE2_CFLAGS="-Os"
33+ STAGE2_CFLAGS="-Os -fno-strict-aliasing"
34 else
35- STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops"
36+ STAGE2_CFLAGS="-O2 -fno-strict-aliasing -fno-strength-reduce -fno-unroll-loops"
37 fi
38 # OpenBSD has a GCC extension for protecting applications from
39 # stack smashing attacks, but GRUB doesn't want this feature.
40diff -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
43@@ -131,6 +131,152 @@
44 #include <shared.h>
45 #include <device.h>
46
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
53+ */
54+static void get_kernel_geometry(int fd, long long *cyl, int *heads, int *sectors) {
55+ struct hd_geometry hdg;
56+
57+ if (ioctl (fd, HDIO_GETGEO, &hdg))
58+ return;
59+
60+ *cyl = hdg.cylinders;
61+ *heads = hdg.heads;
62+ *sectors = hdg.sectors;
63+}
64+
65+struct partition {
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 */
76+};
77+
78+#define ALIGNMENT 2
79+typedef union {
80+ struct {
81+ unsigned char align[ALIGNMENT];
82+ unsigned char b[SECTOR_SIZE];
83+ } c;
84+ struct {
85+ unsigned char align[ALIGNMENT];
86+ unsigned char buffer[0x1BE];
87+ struct partition part[4];
88+ unsigned char magicflag[2];
89+ } p;
90+} partition_table;
91+
92+#define PART_TABLE_FLAG0 0x55
93+#define PART_TABLE_FLAG1 0xAA
94+
95+static void
96+get_partition_table_geometry(partition_table *bufp, long long *cyl, int *heads,
97+ int *sectors) {
98+ struct partition *p;
99+ int i,h,s,hh,ss;
100+ int first = 1;
101+ int bad = 0;
102+
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);
107+ */
108+ fprintf(stderr, "Unknown partition table signature\n");
109+ return;
110+ }
111+
112+ hh = ss = 0;
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);
118+ if (first) {
119+ hh = h;
120+ ss = s;
121+ first = 0;
122+ } else if (hh != h || ss != s)
123+ bad = 1;
124+ }
125+ }
126+
127+ if (!first && !bad) {
128+ *heads = hh;
129+ *sectors = ss;
130+ }
131+}
132+
133+static long long my_lseek (unsigned int fd, long long offset,
134+ unsigned int origin)
135+{
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);
144+
145+ if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET) < 0)
146+ return (long long) -1;
147+ return result;
148+#else
149+ return lseek(fd, offset, SEEK_SET);
150+#endif
151+}
152+
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;
158+
159+ buf_unaligned = malloc(sizeof(partition_table) + 4095);
160+ buff = (char *) (((unsigned long)buf_unaligned + 4096 - 1) &
161+ (~(4096-1)));
162+
163+ get_kernel_geometry(fd, &kern_cyl, &kern_head, &kern_sectors);
164+
165+ if (my_lseek (fd, 0*SECTOR_SIZE, SEEK_SET) < 0) {
166+ fprintf(stderr, "Unable to seek");
167+ }
168+
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);
172+ } else {
173+ fprintf(stderr, "Unable to read partition table: %s\n", strerror(errno));
174+ }
175+
176+ if (pt_head && pt_sectors) {
177+ int cyl_size;
178+
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;
183+ } else {
184+ geom->heads = kern_head;
185+ geom->sectors = kern_sectors;
186+ geom->cylinders = kern_cyl;
187+ }
188+
189+ return;
190+}
191+#endif
192+
193 /* Get the geometry of a drive DRIVE. */
194 void
195 get_drive_geometry (struct geometry *geom, char **map, int drive)
196@@ -151,21 +297,16 @@
197 #if defined(__linux__)
198 /* Linux */
199 {
200- struct hd_geometry hdg;
201 unsigned long nr;
202-
203- if (ioctl (fd, HDIO_GETGEO, &hdg))
204- goto fail;
205
206 if (ioctl (fd, BLKGETSIZE, &nr))
207 goto fail;
208
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;
214-
215+ get_linux_geometry(fd, geom);
216+ if (!geom->heads && !geom->cylinders && !geom->sectors)
217+ goto fail;
218 goto success;
219 }
220
221@@ -844,6 +985,7 @@
222 {
223 char dev[PATH_MAX]; /* XXX */
224 int fd;
225+ off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
226
227 if ((partition & 0x00FF00) != 0x00FF00)
228 {
229@@ -870,35 +1012,13 @@
230 errnum = ERR_NO_PART;
231 return 0;
232 }
233-
234-#if defined(__linux__) && (!defined(__GLIBC__) || \
235- ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
236- /* Maybe libc doesn't have large file support. */
237- {
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);
243
244- offset = (loff_t) sector * (loff_t) SECTOR_SIZE;
245- if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
246- {
247- errnum = ERR_DEV_VALUES;
248- return 0;
249- }
250- }
251-#else
252- {
253- off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
254
255- if (lseek (fd, offset, SEEK_SET) != offset)
256- {
257- errnum = ERR_DEV_VALUES;
258- return 0;
259- }
260- }
261-#endif
262+ if (my_lseek(fd, offset, SEEK_SET) != offset)
263+ {
264+ errnum = ERR_DEV_VALUES;
265+ return 0;
266+ }
267
268 if (write (fd, buf, size * SECTOR_SIZE) != (size * SECTOR_SIZE))
269 {
270diff -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
273@@ -24,7 +24,8 @@
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
280
281 # Stage 2 and Stage 1.5's.
282 pkglibdir = $(libdir)/$(PACKAGE)/$(host_cpu)-$(host_vendor)
283diff -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
286@@ -55,7 +55,7 @@
287 pu;
288 /* presuming that MULTIBOOT_SEARCH is large enough to encompass an
289 executable header */
290- unsigned char buffer[MULTIBOOT_SEARCH];
291+ char buffer[MULTIBOOT_SEARCH];
292
293 /* sets the header pointer to point to the beginning of the
294 buffer by default */
295@@ -98,7 +98,7 @@
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))))
304@@ -824,8 +824,12 @@
305 moveto = (mbi.mem_upper + 0x400) << 10;
306
307 moveto = (moveto - len) & 0xfffff000;
308+#if 0
309 max_addr = (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0203
310 ? lh->initrd_addr_max : LINUX_INITRD_MAX_ADDRESS);
311+#else
312+ max_addr = LINUX_INITRD_MAX_ADDRESS;
313+#endif
314 if (moveto + len >= max_addr)
315 moveto = (max_addr - len) & 0xfffff000;
316
317diff -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 @@
321 int filepos;
322 int filemax;
323
324-static inline unsigned long
325-log2 (unsigned long word)
326+#define log2(n) ffz(~(n))
327+
328+/* include/asm-i386/bitops.h */
329+/*
330+ * ffz = Find First Zero in word. Undefined if no zero exists,
331+ * so code should check against ~0UL first..
332+ */
333+static __inline__ unsigned long
334+ffz (unsigned long word)
335 {
336- asm volatile ("bsfl %1,%0"
337- : "=r" (word)
338- : "r" (word));
339+ __asm__ ("bsfl %1,%0"
340+: "=r" (word)
341+: "r" (~word));
342 return word;
343 }
344
345diff -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
348@@ -78,7 +78,7 @@
349 struct bootinfo
350 {
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
357diff -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
360@@ -54,12 +54,19 @@
361
362 #define FAT_CACHE_SIZE 2048
363
364+#define log2(n) ffz(~(n))
365+
366+/* include/asm-i386/bitops.h */
367+/*
368+ * ffz = Find First Zero in word. Undefined if no zero exists,
369+ * so code should check against ~0UL first..
370+ */
371 static __inline__ unsigned long
372-log2 (unsigned long word)
373+ffz (unsigned long word)
374 {
375 __asm__ ("bsfl %1,%0"
376- : "=r" (word)
377- : "r" (word));
378+: "=r" (word)
379+: "r" (~word));
380 return word;
381 }
382
383diff -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
386@@ -55,13 +55,19 @@
387 #define RRCONT_BUF ((unsigned char *)(FSYS_BUF + 6144))
388 #define NAME_BUF ((unsigned char *)(FSYS_BUF + 8192))
389
390+#define log2(n) ffz(~(n))
391
392-static inline unsigned long
393-log2 (unsigned long word)
394+/* include/asm-i386/bitops.h */
395+/*
396+ * ffz = Find First Zero in word. Undefined if no zero exists,
397+ * so code should check against ~0UL first..
398+ */
399+static __inline__ unsigned long
400+ffz (unsigned long word)
401 {
402- asm volatile ("bsfl %1,%0"
403- : "=r" (word)
404- : "r" (word));
405+ __asm__ ("bsfl %1,%0"
406+: "=r" (word)
407+: "r" (~word));
408 return word;
409 }
410
411@@ -120,7 +126,7 @@
412 break;
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)))
417 {
418 ISO_SUPER->vol_sector = sector;
419 INODE->file_start = 0;
420@@ -175,7 +181,7 @@
421 for (; idr->length.l > 0;
422 idr = (struct iso_directory_record *)((char *)idr + idr->length.l) )
423 {
424- const char *name = idr->name;
425+ const u_int8_t *name = idr->name;
426 unsigned int name_len = idr->name_len.l;
427
428 file_type = (idr->flags.l & 2) ? ISO_DIRECTORY : ISO_REGULAR;
429@@ -198,7 +204,7 @@
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));
437 if (rr_ptr.i & 1)
438@@ -331,9 +337,9 @@
439 memcpy(NAME_BUF, name, name_len);
440 name = NAME_BUF;
441 }
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))
447 {
448 errnum = 0; /* this is not fatal. */
449 break;
450@@ -344,7 +350,7 @@
451
452 filemax = MAXINT;
453 if (name_len >= pathlen
454- && !memcmp(name, dirname, pathlen))
455+ && !memcmp((char *) name, dirname, pathlen))
456 {
457 if (dirname[pathlen] == '/' || !print_possibilities)
458 {
459@@ -381,7 +387,7 @@
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);
465 #endif
466 }
467 }
468diff -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))
474
475+#define log2(n) ffz(~(n))
476
477+/* include/asm-i386/bitops.h */
478+/*
479+ * ffz = Find First Zero in word. Undefined if no zero exists,
480+ * so code should check against ~0UL first..
481+ */
482 static __inline__ unsigned long
483-log2 (unsigned long word)
484+ffz (unsigned long word)
485 {
486 __asm__ ("bsfl %1,%0"
487- : "=r" (word)
488- : "r" (word));
489+: "=r" (word)
490+: "r" (~word));
491 return word;
492 }
493
494diff -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 @@
498 int
499 vstafs_read (char *addr, int len)
500 {
501- struct alloc *a;
502+ struct alloc *b;
503 int size, ret = 0, offset, curr_len = 0;
504- int curr_ext;
505+ int curr_exten;
506 char extent;
507 int ext_size;
508 char *curr_pos;
509
510 get_file_info (f_sector);
511 size = FILE_INFO->len-VSTAFS_START_DATA;
512- a = FILE_INFO->blocks;
513+ b = FILE_INFO->blocks;
514
515 if (filepos > 0)
516 {
517- if (filepos < a[0].a_len * 512 - VSTAFS_START_DATA)
518+ if (filepos < b[0].a_len * 512 - VSTAFS_START_DATA)
519 {
520 offset = filepos + VSTAFS_START_DATA;
521 extent = 0;
522- curr_len = a[0].a_len * 512 - offset - filepos;
523+ curr_len = b[0].a_len * 512 - offset - filepos;
524 }
525 else
526 {
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;
530 extent = 1;
531 do
532 {
533 curr_len -= ext_size;
534 offset -= ext_size;
535- ext_size = a[extent+1].a_len * 512;
536+ ext_size = b[extent+1].a_len * 512;
537 }
538 while (extent < FILE_INFO->extents && offset>ext_size);
539 }
540@@ -223,16 +223,16 @@
541 {
542 offset = VSTAFS_START_DATA;
543 extent = 0;
544- curr_len = a[0].a_len * 512 - offset;
545+ curr_len = b[0].a_len * 512 - offset;
546 }
547
548 curr_pos = addr;
549 if (curr_len > len)
550 curr_len = len;
551
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++)
558 {
559 ret += curr_len;
560 size -= curr_len;
561@@ -242,7 +242,7 @@
562 curr_len += size;
563 }
564
565- devread (a[curr_ext].a_start,offset, curr_len, curr_pos);
566+ devread (b[curr_exten].a_start, offset, curr_len, curr_pos);
567 offset = 0;
568 }
569
570diff -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
573@@ -97,7 +97,7 @@
574 return ino & XFS_INO_MASK(XFS_INO_OFFSET_BITS);
575 }
576
577-static inline __const__ xfs_uint16_t
578+static inline __attribute__((const)) xfs_uint16_t
579 le16 (xfs_uint16_t x)
580 {
581 __asm__("xchgb %b0,%h0" \
582@@ -106,7 +106,7 @@
583 return x;
584 }
585
586-static inline __const__ xfs_uint32_t
587+static inline __attribute__((const)) xfs_uint32_t
588 le32 (xfs_uint32_t x)
589 {
590 #if 0
591@@ -122,7 +122,7 @@
592 return x;
593 }
594
595-static inline __const__ xfs_uint64_t
596+static inline __attribute__((const)) xfs_uint64_t
597 le64 (xfs_uint64_t x)
598 {
599 xfs_uint32_t h = x >> 32;
600@@ -368,7 +368,7 @@
601 default:
602 namelen = sfe->namelen;
603 *ino = sf_ino ((char *)sfe, namelen);
604- name = sfe->name;
605+ name = (char *) sfe->name;
606 sfe = (xfs_dir2_sf_entry_t *)
607 ((char *)sfe + namelen + 11 - xfs.i8param);
608 }
609diff -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
612@@ -277,7 +277,7 @@
613 * is a compressed file, and simply mark it as such.
614 */
615 if (no_decompression
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)))
620 {
621@@ -293,7 +293,7 @@
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)))
630@@ -308,7 +308,7 @@
631
632 filepos = filemax - 8;
633
634- if (grub_read (buf, 8) != 8)
635+ if (grub_read ((char *) buf, 8) != 8)
636 {
637 if (! errnum)
638 errnum = ERR_BAD_GZIP_HEADER;
639@@ -485,8 +485,8 @@
640
641 #define INBUFSIZ 0x2000
642
643-static uch inbuf[INBUFSIZ];
644-static int bufloc;
645+static unsigned char inbuf[INBUFSIZ];
646+static int bufloc;
647
648 static int
649 get_byte (void)
650@@ -494,7 +494,7 @@
651 if (filepos == gzip_data_offset || bufloc == INBUFSIZ)
652 {
653 bufloc = 0;
654- grub_read (inbuf, INBUFSIZ);
655+ grub_read ((char *) inbuf, INBUFSIZ);
656 }
657
658 return inbuf[bufloc++];
659@@ -925,7 +925,7 @@
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 */
668@@ -937,7 +937,7 @@
669
670 /* read in table lengths */
671 NEEDBITS (5);
672- nl = 257 + ((unsigned) b & 0x1f); /* number of literal/length codes */
673+ nc = 257 + ((unsigned) b & 0x1f); /* number of literal/length codes */
674 DUMPBITS (5);
675 NEEDBITS (5);
676 nd = 1 + ((unsigned) b & 0x1f); /* number of distance codes */
677@@ -945,7 +945,7 @@
678 NEEDBITS (4);
679 nb = 4 + ((unsigned) b & 0xf); /* number of bit length codes */
680 DUMPBITS (4);
681- if (nl > 286 || nd > 30)
682+ if (nc > 286 || nd > 30)
683 {
684 errnum = ERR_BAD_GZIP_DATA;
685 return;
686@@ -970,7 +970,7 @@
687 }
688
689 /* read in literal and distance code lengths */
690- n = nl + nd;
691+ n = nc + nd;
692 m = mask_bits[bl];
693 i = l = 0;
694 while ((unsigned) i < n)
695@@ -1034,7 +1034,7 @@
696
697 /* build the decoding tables for literal/length and distance codes */
698 bl = lbits;
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)
701 {
702 #if 0
703 if (i == 1)
704@@ -1045,7 +1045,7 @@
705 return;
706 }
707 bd = dbits;
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)
710 {
711 #if 0
712 if (i == 1)
713diff -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
716@@ -166,7 +166,7 @@
717 inputlen -= 64 - buflen;
718 while (inputlen >= 64)
719 {
720- md5_transform (input);
721+ md5_transform ((unsigned char *) input);
722 input += 64;
723 inputlen -= 64;
724 }
725@@ -211,7 +211,7 @@
726 char *p;
727 int saltlen;
728 int i, n;
729- unsigned char alt_result[16];
730+ char alt_result[16];
731 unsigned char *digest;
732
733 if (check)
734diff -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
737@@ -40,9 +40,9 @@
738 #define ABS(x) (x-_start+BOOTSEC_LOCATION)
739
740 #ifdef STAGE1_5
741-# define STAGE_ADDR 0x2000
742+# define STAGE_ADDR 0x2200
743 #else
744-# define STAGE_ADDR 0x8000
745+# define STAGE_ADDR 0x8200
746 #endif /* STAGE1_5 */
747
748 /* Print message string */
749@@ -71,12 +71,14 @@
750 . = _start + 8 /* Pad to file offset 8 */
751
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 */
767
768 real_start:
769 xor %ax, %ax
770@@ -92,10 +94,28 @@
771 /* save drive reference first thing! */
772 mov %dl, ABS(BootDrive)
773
774- /* print a notification message on the screen */
775- MSG(notification_string)
776+ /* check if machine support IBM/MS int 13h extensions */
777+ mov $0x41, %ah
778+ mov $0x55AA, %bx
779+ int $0x13
780+ jnc load_image
781+
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) */
794
795 load_image:
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
801@@ -105,6 +125,8 @@
802 mov %bx, %es
803 xor %bx, %bx
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 */
807 call getlinsec
808 mov %ds, %ax
809 mov %ax, %es
810@@ -115,7 +137,7 @@
811 mov $ABS(firstlist - BOOTSEC_LISTSIZE), %si
812 mov (%si), %ebp
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 */
816
817 /* go here when you need to stop the machine hard after an error condition */
818 stop: jmp stop
819@@ -171,11 +193,11 @@
820 */
821 xint13:
822 movb $6, ABS(RetryCount)
823- pushal
824 .try:
825+ pushal
826 int $0x13
827 jc 1f
828- add $(8*4), %sp /* Clean up stack */
829+ popal /* Clean up stack */
830 ret
831 1:
832 mov %ah, %dl /* Save error code */
833@@ -276,6 +298,10 @@
834
835 read_error_string: .string "Read error 0x"
836
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..."
840+
841 /*
842 * EBIOS disk address packet
843 */
844@@ -306,7 +332,8 @@
845 .word 0
846 .word 0
847
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
851
852 /* fill the first data listing with the default */
853 blocklist_default_start:/* this is the sector start parameter, in logical
854@@ -321,6 +348,12 @@
855 #endif
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
860
861 firstlist: /* this label has to be after the list data!!! */
862+
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
868diff -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
871@@ -336,6 +336,10 @@
872 # Create a safe temporary file.
873 test -n "$mklog" && log_file=`$mklog`
874
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.
877+ sync
878+
879 $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
880 quit
881 EOF
882@@ -450,6 +454,10 @@
883 # Create a safe temporary file.
884 test -n "$mklog" && log_file=`$mklog`
885
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.
888+sync
889+
890 # Now perform the installation.
891 $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
892 root $root_drive
Note: See TracBrowser for help on using the repository browser.