Magellan Linux

Contents of /trunk/grub/patches/grub-0.97-reiser4.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 329 - (show annotations) (download)
Sun Sep 2 22:53:40 2007 UTC (16 years, 8 months ago) by niro
File size: 44241 byte(s)
-added reiser4 patch

1 diff -Naur grub-0.97/config.h.in grub-0.97-magellan/config.h.in
2 --- grub-0.97/config.h.in 2005-05-08 04:48:19.000000000 +0200
3 +++ grub-0.97-magellan/config.h.in 2007-09-03 00:37:37.000000000 +0200
4 @@ -27,9 +27,16 @@
5 /* Define to 1 if you have the <inttypes.h> header file. */
6 #undef HAVE_INTTYPES_H
7
8 +/* Define to 1 if you have the `aal-minimal' library (-laal-minimal). */
9 +#undef HAVE_LIBAAL_MINIMAL
10 +
11 /* Define if you have a curses library */
12 #undef HAVE_LIBCURSES
13
14 +/* Define to 1 if you have the `reiser4-minimal' library (-lreiser4-minimal).
15 + */
16 +#undef HAVE_LIBREISER4_MINIMAL
17 +
18 /* Define to 1 if you have the <memory.h> header file. */
19 #undef HAVE_MEMORY_H
20
21 diff -Naur grub-0.97/configure.ac grub-0.97-magellan/configure.ac
22 --- grub-0.97/configure.ac 2007-09-03 00:48:33.000000000 +0200
23 +++ grub-0.97-magellan/configure.ac 2007-09-03 00:37:37.000000000 +0200
24 @@ -263,6 +263,77 @@
25 FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_REISERFS=1"
26 fi
27
28 +dnl Checking for reiser4
29 +REISER4_LIBS=""
30 +REISER4_CFLAGS=""
31 +
32 +OLD_LIBS=$LIBS
33 +OLD_CFLAGS=$CFLAGS
34 +LIBS=""
35 +CFLAGS=""
36 +
37 +AC_ARG_ENABLE(reiser4,
38 + [ --disable-reiser4 disable Reiser4 support in Stage 2])
39 +
40 +if test x"$enable_reiser4" != xno; then
41 + AC_CHECK_LIB(aal-minimal, aal_mem_init, ,
42 + AC_MSG_WARN(
43 +Reiser4 support is disabled due to inability find libaal-minimal with
44 +memory manager support turned on.)
45 + enable_reiser4=no
46 + )
47 +fi
48 +
49 +if test x"$enable_reiser4" != xno; then
50 + AC_CHECK_HEADER(aal/libaal.h, ,
51 + AC_MSG_WARN(
52 +Libaal header files are not found. Reiser4 support is disabled
53 + )
54 + enable_reiser4=no)
55 +fi
56 +
57 +if test x"$enable_reiser4" != xno; then
58 + AC_CHECK_LIB(reiser4-minimal, reiser4_fs_open, ,
59 + AC_MSG_WARN(
60 +Reiser4 support is disabled due to inability find valid libreiser4-minimal.)
61 + enable_reiser4=no,
62 + -laal-minimal
63 + )
64 +fi
65 +
66 +if test x"$enable_reiser4" != xno; then
67 + AC_CHECK_HEADER(reiser4/libreiser4.h, ,
68 + AC_MSG_WARN(
69 +Reiser4 header files are not found. Reiser4 support is disabled.
70 + )
71 + enable_reiser4=no)
72 +fi
73 +
74 +if test x"$enable_reiser4" != xno; then
75 + REISER4_CFLAGS="$REISER4_CFLAGS -DFSYS_REISER4=1"
76 + REISER4_LIBS=$LIBS
77 +fi
78 +
79 +if test x"$enable_reiser4" != xno; then
80 + AC_CHECK_LIB(reiser4-minimal, __sym40_plug_init,
81 + REISER4_CFLAGS="$REISER4_CFLAGS -DENABLE_SYMLINKS=1",
82 +AC_MSG_WARN(Reiser4 symlinks support is disabled.),
83 + -laal-minimal
84 + )
85 +fi
86 +
87 +LIBS=$OLD_LIBS
88 +CFLAGS=$OLD_CFLAGS
89 +
90 +if test x"$enable_reiser4" != xno; then
91 + enable_reiser4_support=yes
92 + FSYS_CFLAGS="$FSYS_CFLAGS $REISER4_CFLAGS"
93 +fi
94 +
95 +AC_SUBST(REISER4_LIBS)
96 +AC_SUBST(REISER4_CFLAGS)
97 +AM_CONDITIONAL(ENABLE_REISER4_SUPPORT, test x"$enable_reiser4" != xno)
98 +
99 AC_ARG_ENABLE(vstafs,
100 [ --disable-vstafs disable VSTa FS support in Stage 2])
101
102 diff -Naur grub-0.97/docs/grub.texi grub-0.97-magellan/docs/grub.texi
103 --- grub-0.97/docs/grub.texi 2005-05-08 04:59:59.000000000 +0200
104 +++ grub-0.97-magellan/docs/grub.texi 2007-09-03 00:37:37.000000000 +0200
105 @@ -283,7 +283,7 @@
106 Support multiple filesystem types transparently, plus a useful explicit
107 blocklist notation. The currently supported filesystem types are
108 @dfn{BSD FFS}, @dfn{DOS FAT16 and FAT32}, @dfn{Minix fs}, @dfn{Linux
109 -ext2fs}, @dfn{ReiserFS}, @dfn{JFS}, @dfn{XFS}, and @dfn{VSTa
110 +ext2fs}, @dfn{ReiserFS}, @dfn{ReiserFS}, @dfn{JFS}, @dfn{XFS}, and @dfn{VSTa
111 fs}. @xref{Filesystem}, for more information.
112
113 @item Support automatic decompression
114 @@ -1776,6 +1776,7 @@
115 @itemx jfs_stage1_5
116 @itemx minix_stage1_5
117 @itemx reiserfs_stage1_5
118 +@itemx reiser4_stage1_5
119 @itemx vstafs_stage1_5
120 @itemx xfs_stage1_5
121
122 diff -Naur grub-0.97/grub/Makefile.am grub-0.97-magellan/grub/Makefile.am
123 --- grub-0.97/grub/Makefile.am 2005-02-02 21:38:19.000000000 +0100
124 +++ grub-0.97-magellan/grub/Makefile.am 2007-09-03 00:37:37.000000000 +0200
125 @@ -16,4 +16,4 @@
126 AM_CFLAGS = $(GRUB_CFLAGS)
127
128 grub_SOURCES = main.c asmstub.c
129 -grub_LDADD = ../stage2/libgrub.a ../lib/libcommon.a $(GRUB_LIBS)
130 +grub_LDADD = ../stage2/libgrub.a ../lib/libcommon.a $(GRUB_LIBS) $(REISER4_LIBS)
131 diff -Naur grub-0.97/INSTALL grub-0.97-magellan/INSTALL
132 --- grub-0.97/INSTALL 2005-05-08 04:43:15.000000000 +0200
133 +++ grub-0.97-magellan/INSTALL 2007-09-03 00:37:37.000000000 +0200
134 @@ -207,6 +207,9 @@
135 `--disable-reiserfs'
136 Omit the ReiserFS support in Stage 2.
137
138 +`--disable-reiser4'
139 + Omit the Reiser4 support in Stage 2.
140 +
141 `--disable-vstafs'
142 Omit the VSTa filesystem support in Stage 2.
143
144 diff -Naur grub-0.97/stage2/builtins.c grub-0.97-magellan/stage2/builtins.c
145 --- grub-0.97/stage2/builtins.c 2007-09-03 00:48:45.000000000 +0200
146 +++ grub-0.97-magellan/stage2/builtins.c 2007-09-03 00:37:37.000000000 +0200
147 @@ -4069,6 +4069,7 @@
148 {"jfs", "/jfs_stage1_5"},
149 {"minix", "/minix_stage1_5"},
150 {"reiserfs", "/reiserfs_stage1_5"},
151 + {"reiser4", "/reiser4_stage1_5"},
152 {"vstafs", "/vstafs_stage1_5"},
153 {"xfs", "/xfs_stage1_5"}
154 };
155 diff -Naur grub-0.97/stage2/builtins.c.orig grub-0.97-magellan/stage2/builtins.c.orig
156 --- grub-0.97/stage2/builtins.c.orig 2007-09-03 00:48:33.000000000 +0200
157 +++ grub-0.97-magellan/stage2/builtins.c.orig 2007-09-03 00:36:55.000000000 +0200
158 @@ -131,63 +131,98 @@
159 }
160
161
162 +/* blocklist_read_helper nee disk_read_blocklist_func was a nested
163 + * function, to which pointers were taken and exposed globally. Even
164 + * in the GNU-C nested functions extension, they have local linkage,
165 + * and aren't guaranteed to be accessable *at all* outside of their
166 + * containing scope.
167 + *
168 + * Above and beyond all of that, the variables within blocklist_func_context
169 + * are originally local variables, with local (not even static) linkage,
170 + * from within blocklist_func. These were each referenced by
171 + * disk_read_blocklist_func, which is only called from other functions
172 + * through a globally scoped pointer.
173 + *
174 + * The documentation in GCC actually uses the words "all hell will break
175 + * loose" to describe this scenario.
176 + *
177 + * Also, "start_sector" was also used uninitialized, but gcc doesn't warn
178 + * about it (possibly because of the scoping madness?)
179 + */
180 +
181 +static struct {
182 + int start_sector;
183 + int num_sectors;
184 + int num_entries;
185 + int last_length;
186 +} blocklist_func_context = {
187 + .start_sector = 0,
188 + .num_sectors = 0,
189 + .num_entries = 0,
190 + .last_length = 0
191 +};
192 +
193 +/* Collect contiguous blocks into one entry as many as possible,
194 + and print the blocklist notation on the screen. */
195 +static void
196 +blocklist_read_helper (int sector, int offset, int length)
197 +{
198 + int *start_sector = &blocklist_func_context.start_sector;
199 + int *num_sectors = &blocklist_func_context.num_sectors;
200 + int *num_entries = &blocklist_func_context.num_entries;
201 + int *last_length = &blocklist_func_context.last_length;
202 +
203 + if (*num_sectors > 0)
204 + {
205 + if (*start_sector + *num_sectors == sector
206 + && offset == 0 && *last_length == SECTOR_SIZE)
207 + {
208 + *num_sectors++;
209 + *last_length = length;
210 + return;
211 + }
212 + else
213 + {
214 + if (*last_length == SECTOR_SIZE)
215 + grub_printf ("%s%d+%d", *num_entries ? "," : "",
216 + *start_sector - part_start, *num_sectors);
217 + else if (*num_sectors > 1)
218 + grub_printf ("%s%d+%d,%d[0-%d]", *num_entries ? "," : "",
219 + *start_sector - part_start, *num_sectors-1,
220 + *start_sector + *num_sectors-1 - part_start,
221 + *last_length);
222 + else
223 + grub_printf ("%s%d[0-%d]", *num_entries ? "," : "",
224 + *start_sector - part_start, *last_length);
225 + *num_entries++;
226 + *num_sectors = 0;
227 + }
228 + }
229 +
230 + if (offset > 0)
231 + {
232 + grub_printf("%s%d[%d-%d]", *num_entries ? "," : "",
233 + sector-part_start, offset, offset+length);
234 + *num_entries++;
235 + }
236 + else
237 + {
238 + *start_sector = sector;
239 + *num_sectors = 1;
240 + *last_length = length;
241 + }
242 +}
243 +
244 /* blocklist */
245 static int
246 blocklist_func (char *arg, int flags)
247 {
248 char *dummy = (char *) RAW_ADDR (0x100000);
249 - int start_sector;
250 - int num_sectors = 0;
251 - int num_entries = 0;
252 - int last_length = 0;
253
254 - auto void disk_read_blocklist_func (int sector, int offset, int length);
255 + int *start_sector = &blocklist_func_context.start_sector;
256 + int *num_sectors = &blocklist_func_context.num_sectors;
257 + int *num_entries = &blocklist_func_context.num_entries;
258
259 - /* Collect contiguous blocks into one entry as many as possible,
260 - and print the blocklist notation on the screen. */
261 - auto void disk_read_blocklist_func (int sector, int offset, int length)
262 - {
263 - if (num_sectors > 0)
264 - {
265 - if (start_sector + num_sectors == sector
266 - && offset == 0 && last_length == SECTOR_SIZE)
267 - {
268 - num_sectors++;
269 - last_length = length;
270 - return;
271 - }
272 - else
273 - {
274 - if (last_length == SECTOR_SIZE)
275 - grub_printf ("%s%d+%d", num_entries ? "," : "",
276 - start_sector - part_start, num_sectors);
277 - else if (num_sectors > 1)
278 - grub_printf ("%s%d+%d,%d[0-%d]", num_entries ? "," : "",
279 - start_sector - part_start, num_sectors-1,
280 - start_sector + num_sectors-1 - part_start,
281 - last_length);
282 - else
283 - grub_printf ("%s%d[0-%d]", num_entries ? "," : "",
284 - start_sector - part_start, last_length);
285 - num_entries++;
286 - num_sectors = 0;
287 - }
288 - }
289 -
290 - if (offset > 0)
291 - {
292 - grub_printf("%s%d[%d-%d]", num_entries ? "," : "",
293 - sector-part_start, offset, offset+length);
294 - num_entries++;
295 - }
296 - else
297 - {
298 - start_sector = sector;
299 - num_sectors = 1;
300 - last_length = length;
301 - }
302 - }
303 -
304 /* Open the file. */
305 if (! grub_open (arg))
306 return 1;
307 @@ -206,15 +241,15 @@
308 grub_printf (")");
309
310 /* Read in the whole file to DUMMY. */
311 - disk_read_hook = disk_read_blocklist_func;
312 + disk_read_hook = blocklist_read_helper;
313 if (! grub_read (dummy, -1))
314 goto fail;
315
316 /* The last entry may not be printed yet. Don't check if it is a
317 * full sector, since it doesn't matter if we read too much. */
318 - if (num_sectors > 0)
319 - grub_printf ("%s%d+%d", num_entries ? "," : "",
320 - start_sector - part_start, num_sectors);
321 + if (*num_sectors > 0)
322 + grub_printf ("%s%d+%d", *num_entries ? "," : "",
323 + *start_sector - part_start, *num_sectors);
324
325 grub_printf ("\n");
326
327 @@ -1872,6 +1907,77 @@
328
329
330 /* install */
331 +static struct {
332 + int saved_sector;
333 + int installaddr;
334 + int installlist;
335 + char *stage2_first_buffer;
336 +} install_func_context = {
337 + .saved_sector = 0,
338 + .installaddr = 0,
339 + .installlist = 0,
340 + .stage2_first_buffer = NULL,
341 +};
342 +
343 +/* Save the first sector of Stage2 in STAGE2_SECT. */
344 +/* Formerly disk_read_savesect_func with local scope inside install_func */
345 +static void
346 +install_savesect_helper(int sector, int offset, int length)
347 +{
348 + if (debug)
349 + printf ("[%d]", sector);
350 +
351 + /* ReiserFS has files which sometimes contain data not aligned
352 + on sector boundaries. Returning an error is better than
353 + silently failing. */
354 + if (offset != 0 || length != SECTOR_SIZE)
355 + errnum = ERR_UNALIGNED;
356 +
357 + install_func_context.saved_sector = sector;
358 +}
359 +
360 +/* Write SECTOR to INSTALLLIST, and update INSTALLADDR and INSTALLSECT. */
361 +/* Formerly disk_read_blocklist_func with local scope inside install_func */
362 +static void
363 +install_blocklist_helper (int sector, int offset, int length)
364 +{
365 + int *installaddr = &install_func_context.installaddr;
366 + int *installlist = &install_func_context.installlist;
367 + char **stage2_first_buffer = &install_func_context.stage2_first_buffer;
368 + /* Was the last sector full? */
369 + static int last_length = SECTOR_SIZE;
370 +
371 + if (debug)
372 + printf("[%d]", sector);
373 +
374 + if (offset != 0 || last_length != SECTOR_SIZE)
375 + {
376 + /* We found a non-sector-aligned data block. */
377 + errnum = ERR_UNALIGNED;
378 + return;
379 + }
380 +
381 + last_length = length;
382 +
383 + if (*((unsigned long *) (*installlist - 4))
384 + + *((unsigned short *) *installlist) != sector
385 + || *installlist == (int) *stage2_first_buffer + SECTOR_SIZE + 4)
386 + {
387 + *installlist -= 8;
388 +
389 + if (*((unsigned long *) (*installlist - 8)))
390 + errnum = ERR_WONT_FIT;
391 + else
392 + {
393 + *((unsigned short *) (*installlist + 2)) = (*installaddr >> 4);
394 + *((unsigned long *) (*installlist - 4)) = sector;
395 + }
396 + }
397 +
398 + *((unsigned short *) *installlist) += 1;
399 + *installaddr += 512;
400 +}
401 +
402 static int
403 install_func (char *arg, int flags)
404 {
405 @@ -1879,8 +1985,12 @@
406 char *stage1_buffer = (char *) RAW_ADDR (0x100000);
407 char *stage2_buffer = stage1_buffer + SECTOR_SIZE;
408 char *old_sect = stage2_buffer + SECTOR_SIZE;
409 - char *stage2_first_buffer = old_sect + SECTOR_SIZE;
410 - char *stage2_second_buffer = stage2_first_buffer + SECTOR_SIZE;
411 + /* stage2_first_buffer used to be defined as:
412 + * char *stage2_first_buffer = old_sect + SECTOR_SIZE; */
413 + char **stage2_first_buffer = &install_func_context.stage2_first_buffer;
414 + /* and stage2_second_buffer was:
415 + * char *stage2_second_buffer = stage2_first_buffer + SECTOR_SIZE; */
416 + char *stage2_second_buffer = old_sect + SECTOR_SIZE + SECTOR_SIZE;
417 /* XXX: Probably SECTOR_SIZE is reasonable. */
418 char *config_filename = stage2_second_buffer + SECTOR_SIZE;
419 char *dummy = config_filename + SECTOR_SIZE;
420 @@ -1889,10 +1999,11 @@
421 int src_drive, src_partition, src_part_start;
422 int i;
423 struct geometry dest_geom, src_geom;
424 - int saved_sector;
425 + int *saved_sector = &install_func_context.saved_sector;
426 int stage2_first_sector, stage2_second_sector;
427 char *ptr;
428 - int installaddr, installlist;
429 + int *installaddr = &install_func_context.installaddr;
430 + int *installlist = &install_func_context.installlist;
431 /* Point to the location of the name of a configuration file in Stage 2. */
432 char *config_file_location;
433 /* If FILE is a Stage 1.5? */
434 @@ -1901,67 +2012,13 @@
435 int is_open = 0;
436 /* If LBA is forced? */
437 int is_force_lba = 0;
438 - /* Was the last sector full? */
439 - int last_length = SECTOR_SIZE;
440 -
441 +
442 + *stage2_first_buffer = old_sect + SECTOR_SIZE;
443 #ifdef GRUB_UTIL
444 /* If the Stage 2 is in a partition mounted by an OS, this will store
445 the filename under the OS. */
446 char *stage2_os_file = 0;
447 #endif /* GRUB_UTIL */
448 -
449 - auto void disk_read_savesect_func (int sector, int offset, int length);
450 - auto void disk_read_blocklist_func (int sector, int offset, int length);
451 -
452 - /* Save the first sector of Stage2 in STAGE2_SECT. */
453 - auto void disk_read_savesect_func (int sector, int offset, int length)
454 - {
455 - if (debug)
456 - printf ("[%d]", sector);
457 -
458 - /* ReiserFS has files which sometimes contain data not aligned
459 - on sector boundaries. Returning an error is better than
460 - silently failing. */
461 - if (offset != 0 || length != SECTOR_SIZE)
462 - errnum = ERR_UNALIGNED;
463 -
464 - saved_sector = sector;
465 - }
466 -
467 - /* Write SECTOR to INSTALLLIST, and update INSTALLADDR and
468 - INSTALLSECT. */
469 - auto void disk_read_blocklist_func (int sector, int offset, int length)
470 - {
471 - if (debug)
472 - printf("[%d]", sector);
473 -
474 - if (offset != 0 || last_length != SECTOR_SIZE)
475 - {
476 - /* We found a non-sector-aligned data block. */
477 - errnum = ERR_UNALIGNED;
478 - return;
479 - }
480 -
481 - last_length = length;
482 -
483 - if (*((unsigned long *) (installlist - 4))
484 - + *((unsigned short *) installlist) != sector
485 - || installlist == (int) stage2_first_buffer + SECTOR_SIZE + 4)
486 - {
487 - installlist -= 8;
488 -
489 - if (*((unsigned long *) (installlist - 8)))
490 - errnum = ERR_WONT_FIT;
491 - else
492 - {
493 - *((unsigned short *) (installlist + 2)) = (installaddr >> 4);
494 - *((unsigned long *) (installlist - 4)) = sector;
495 - }
496 - }
497 -
498 - *((unsigned short *) installlist) += 1;
499 - installaddr += 512;
500 - }
501
502 /* First, check the GNU-style long option. */
503 while (1)
504 @@ -1994,10 +2051,10 @@
505 addr = skip_to (0, file);
506
507 /* Get the installation address. */
508 - if (! safe_parse_maxint (&addr, &installaddr))
509 + if (! safe_parse_maxint (&addr, installaddr))
510 {
511 /* ADDR is not specified. */
512 - installaddr = 0;
513 + *installaddr = 0;
514 ptr = addr;
515 errnum = 0;
516 }
517 @@ -2093,17 +2150,17 @@
518 = 0x9090;
519
520 /* Read the first sector of Stage 2. */
521 - disk_read_hook = disk_read_savesect_func;
522 - if (grub_read (stage2_first_buffer, SECTOR_SIZE) != SECTOR_SIZE)
523 + disk_read_hook = install_savesect_helper;
524 + if (grub_read (*stage2_first_buffer, SECTOR_SIZE) != SECTOR_SIZE)
525 goto fail;
526
527 - stage2_first_sector = saved_sector;
528 + stage2_first_sector = *saved_sector;
529
530 /* Read the second sector of Stage 2. */
531 if (grub_read (stage2_second_buffer, SECTOR_SIZE) != SECTOR_SIZE)
532 goto fail;
533
534 - stage2_second_sector = saved_sector;
535 + stage2_second_sector = *saved_sector;
536
537 /* Check for the version of Stage 2. */
538 if (*((short *) (stage2_second_buffer + STAGE2_VER_MAJ_OFFS))
539 @@ -2119,27 +2176,27 @@
540
541 /* If INSTALLADDR is not specified explicitly in the command-line,
542 determine it by the Stage 2 id. */
543 - if (! installaddr)
544 + if (! *installaddr)
545 {
546 if (! is_stage1_5)
547 /* Stage 2. */
548 - installaddr = 0x8000;
549 + *installaddr = 0x8000;
550 else
551 /* Stage 1.5. */
552 - installaddr = 0x2000;
553 + *installaddr = 0x2000;
554 }
555
556 *((unsigned long *) (stage1_buffer + STAGE1_STAGE2_SECTOR))
557 = stage2_first_sector;
558 *((unsigned short *) (stage1_buffer + STAGE1_STAGE2_ADDRESS))
559 - = installaddr;
560 + = *installaddr;
561 *((unsigned short *) (stage1_buffer + STAGE1_STAGE2_SEGMENT))
562 - = installaddr >> 4;
563 + = *installaddr >> 4;
564
565 - i = (int) stage2_first_buffer + SECTOR_SIZE - 4;
566 + i = (int) *stage2_first_buffer + SECTOR_SIZE - 4;
567 while (*((unsigned long *) i))
568 {
569 - if (i < (int) stage2_first_buffer
570 + if (i < (int) *stage2_first_buffer
571 || (*((int *) (i - 4)) & 0x80000000)
572 || *((unsigned short *) i) >= 0xA00
573 || *((short *) (i + 2)) == 0)
574 @@ -2153,13 +2210,13 @@
575 i -= 8;
576 }
577
578 - installlist = (int) stage2_first_buffer + SECTOR_SIZE + 4;
579 - installaddr += SECTOR_SIZE;
580 + *installlist = (int) *stage2_first_buffer + SECTOR_SIZE + 4;
581 + *installaddr += SECTOR_SIZE;
582
583 /* Read the whole of Stage2 except for the first sector. */
584 grub_seek (SECTOR_SIZE);
585
586 - disk_read_hook = disk_read_blocklist_func;
587 + disk_read_hook = install_blocklist_helper;
588 if (! grub_read (dummy, -1))
589 goto fail;
590
591 @@ -2242,7 +2299,7 @@
592 /* Skip the first sector. */
593 grub_seek (SECTOR_SIZE);
594
595 - disk_read_hook = disk_read_savesect_func;
596 + disk_read_hook = install_savesect_helper;
597 if (grub_read (stage2_buffer, SECTOR_SIZE) != SECTOR_SIZE)
598 goto fail;
599
600 @@ -2312,7 +2369,7 @@
601 else
602 #endif /* GRUB_UTIL */
603 {
604 - if (! devwrite (saved_sector - part_start, 1, stage2_buffer))
605 + if (! devwrite (*saved_sector - part_start, 1, stage2_buffer))
606 goto fail;
607 }
608 }
609 @@ -2334,7 +2391,7 @@
610 goto fail;
611 }
612
613 - if (fwrite (stage2_first_buffer, 1, SECTOR_SIZE, fp) != SECTOR_SIZE)
614 + if (fwrite (*stage2_first_buffer, 1, SECTOR_SIZE, fp) != SECTOR_SIZE)
615 {
616 fclose (fp);
617 errnum = ERR_WRITE;
618 @@ -2361,7 +2418,7 @@
619 goto fail;
620
621 if (! devwrite (stage2_first_sector - src_part_start, 1,
622 - stage2_first_buffer))
623 + *stage2_first_buffer))
624 goto fail;
625
626 if (! devwrite (stage2_second_sector - src_part_start, 1,
627 diff -Naur grub-0.97/stage2/disk_io.c grub-0.97-magellan/stage2/disk_io.c
628 --- grub-0.97/stage2/disk_io.c 2004-05-23 18:35:24.000000000 +0200
629 +++ grub-0.97-magellan/stage2/disk_io.c 2007-09-03 00:37:37.000000000 +0200
630 @@ -63,6 +63,9 @@
631 # ifdef FSYS_REISERFS
632 {"reiserfs", reiserfs_mount, reiserfs_read, reiserfs_dir, 0, reiserfs_embed},
633 # endif
634 +# ifdef FSYS_REISER4
635 + {"reiser4", reiser4_mount, reiser4_read, reiser4_dir, 0, reiser4_embed},
636 +# endif
637 # ifdef FSYS_VSTAFS
638 {"vstafs", vstafs_mount, vstafs_read, vstafs_dir, 0, 0},
639 # endif
640 diff -Naur grub-0.97/stage2/filesys.h grub-0.97-magellan/stage2/filesys.h
641 --- grub-0.97/stage2/filesys.h 2004-05-14 21:36:43.000000000 +0200
642 +++ grub-0.97-magellan/stage2/filesys.h 2007-09-03 00:37:37.000000000 +0200
643 @@ -77,6 +77,16 @@
644 #define FSYS_REISERFS_NUM 0
645 #endif
646
647 +#ifdef FSYS_REISER4
648 +#define FSYS_REISER4_NUM 1
649 +int reiser4_mount (void);
650 +int reiser4_read (char *buf, int len);
651 +int reiser4_dir (char *dirname);
652 +int reiser4_embed (int *start_sector, int needed_sectors);
653 +#else
654 +#define FSYS_REISER4_NUM 0
655 +#endif
656 +
657 #ifdef FSYS_VSTAFS
658 #define FSYS_VSTAFS_NUM 1
659 int vstafs_mount (void);
660 @@ -127,8 +137,8 @@
661 #ifndef NUM_FSYS
662 #define NUM_FSYS \
663 (FSYS_FFS_NUM + FSYS_FAT_NUM + FSYS_EXT2FS_NUM + FSYS_MINIX_NUM \
664 - + FSYS_REISERFS_NUM + FSYS_VSTAFS_NUM + FSYS_JFS_NUM + FSYS_XFS_NUM \
665 - + FSYS_TFTP_NUM + FSYS_ISO9660_NUM + FSYS_UFS2_NUM)
666 + + FSYS_REISERFS_NUM + FSYS_REISER4_NUM + FSYS_VSTAFS_NUM + FSYS_JFS_NUM \
667 + + FSYS_XFS_NUM + FSYS_TFTP_NUM + FSYS_ISO9660_NUM + FSYS_UFS2_NUM)
668 #endif
669
670 /* defines for the block filesystem info area */
671 diff -Naur grub-0.97/stage2/fsys_reiser4.c grub-0.97-magellan/stage2/fsys_reiser4.c
672 --- grub-0.97/stage2/fsys_reiser4.c 1970-01-01 01:00:00.000000000 +0100
673 +++ grub-0.97-magellan/stage2/fsys_reiser4.c 2007-09-03 00:37:37.000000000 +0200
674 @@ -0,0 +1,260 @@
675 +/*
676 + * fsys_reiser4.c -- reiser4 filesystem support.
677 + * Copyright (C) 2000, 2001 Free Software Foundation, Inc.
678 + *
679 + * GRUB -- GRand Unified Bootloader
680 + *
681 + * This program is free software; you can redistribute it and/or modify
682 + * it under the terms of the GNU General Public License as published by
683 + * the Free Software Foundation; either version 2 of the License, or
684 + * (at your option) any later version.
685 + *
686 + * This program is distributed in the hope that it will be useful,
687 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
688 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
689 + * GNU General Public License for more details.
690 + *
691 + * You should have received a copy of the GNU General Public License
692 + * along with this program; if not, write to the Free Software
693 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
694 +*/
695 +
696 +#ifdef FSYS_REISER4
697 +#include "shared.h"
698 +#include "filesys.h"
699 +
700 +#define ENABLE_MINIMAL
701 +#include <reiser4/libreiser4.h>
702 +
703 +static reiser4_fs_t *fs = NULL;
704 +static aal_device_t *dev = NULL;
705 +static reiser4_object_t *object = NULL;
706 +
707 +/* Read callback of grub specific device. It uses devread() for reading passed
708 + @count of device blocks starting from @blk to passed @buff. */
709 +static errno_t grub_dev_read(aal_device_t *device,
710 + void *buff, blk_t blk,
711 + count_t count)
712 +{
713 + unsigned int size;
714 + unsigned int factor;
715 + unsigned int sector;
716 +
717 + /* Calculating actual sector and size in bytes to be read from
718 + device. */
719 + factor = device->blksize / SECTOR_SIZE;
720 + sector = (unsigned int)blk << aal_log2(factor);
721 + size = (unsigned int)count * (SECTOR_SIZE * factor);
722 +
723 + /* Reading from the current device */
724 + if (!devread(sector, 0, size, buff))
725 + return -EIO;
726 +
727 + return 0;
728 +}
729 +
730 +/* Length callback of grub device */
731 +static count_t grub_dev_len(aal_device_t *device) {
732 + unsigned int factor;
733 +
734 + /* Getting partition length in device blocks */
735 + factor = device->blksize / SECTOR_SIZE;
736 + return (part_length >> aal_log2(factor));
737 +}
738 +
739 +/*
740 + Initializing grub device abstraction instance. It will use devread and friends
741 + for providing needed functionality.
742 +*/
743 +struct aal_device_ops grub_dev_ops = {
744 + .read = grub_dev_read,
745 + .len = grub_dev_len
746 +};
747 +
748 +/* Initializes reiser4 */
749 +static int reiser4_init(void) {
750 + extern aal_hash_table_t *plugins;
751 +
752 + plugins = NULL;
753 +
754 + /* Initializing memory manager */
755 + aal_mem_init((void *)FSYS_BUF, FSYS_BUFLEN);
756 +
757 + /* Initializing device abstraction on current device GRUB uses. */
758 + if (!(dev = aal_device_open(&grub_dev_ops, NULL,
759 + SECTOR_SIZE, 0)))
760 + {
761 + return 0;
762 + }
763 +
764 + /* Initializing libreiser4 (plugins, etc) */
765 + return !libreiser4_init();
766 +}
767 +
768 +#define MEMORY_WATERMARK 8192
769 +
770 +/* Memory pressure detect function. */
771 +static int mpressure_detect(reiser4_tree_t *tree) {
772 + return (aal_mem_free() <= MEMORY_WATERMARK);
773 +}
774 +
775 +/* Reiser4 mount() routine */
776 +int reiser4_mount(void) {
777 +
778 + /* Initialize all reiser4 related stuff first */
779 + if (!reiser4_init())
780 + return 0;
781 +
782 + /* Open filesystem on @dev. */
783 + if (!(fs = reiser4_fs_open(dev)))
784 + return 0;
785 +
786 + fs->tree->mpc_func = mpressure_detect;
787 +
788 + object = NULL;
789 + return 1;
790 +}
791 +
792 +/* Reiser4 read() handler */
793 +int reiser4_read(char *buf, int len) {
794 + int64_t read;
795 +
796 + if (object == NULL)
797 + return 0;
798 +
799 + /* Seet at current position denoted by @filepos */
800 + if (objplug(object)->o.object_ops->seek) {
801 + plug_call(objplug(object)->o.object_ops,
802 + seek, object->ent, filepos);
803 + }
804 +
805 + /* Reading current file data starting from @filepos */
806 + disk_read_func = disk_read_hook;
807 + read = objplug(object)->o.object_ops->read ?
808 + plug_call(objplug(object)->o.object_ops, read,
809 + object->ent, buf, len) : -EINVAL;
810 + disk_read_func = NULL;
811 +
812 + if (read < 0) {
813 + errnum = ERR_FSYS_CORRUPT;
814 + return 0;
815 + }
816 +
817 + filepos += read;
818 + return read;
819 +}
820 +
821 +/* Reiser4 file open() routine */
822 +int reiser4_dir(char *dirname) {
823 + char *ch;
824 +
825 + if (fs == NULL)
826 + return 0;
827 +
828 + if (object != NULL) {
829 + plug_call(objplug(object)->o.object_ops,
830 + close, object->ent);
831 + aal_free(object);
832 + object = NULL;
833 + }
834 +
835 + /* Cutting out string after first space character */
836 + if ((ch = aal_strchr(dirname, ' ')))
837 + *ch = '\0';
838 +
839 + /* This function is also called for getting directory list for
840 + maintaining the bash-like completion. */
841 +#ifndef STAGE1_5
842 + if (print_possibilities) {
843 + char entry[256];
844 + entry_hint_t entry_hint;
845 +
846 + /* Getting last part of name (jsut after last '/') */
847 + if (*(dirname + aal_strlen(dirname) - 1) != '/') {
848 +
849 + if (!(ch = aal_strrchr(dirname, '/'))) {
850 + errnum = ERR_BAD_FILETYPE;
851 + return 0;
852 + }
853 +
854 + aal_strncpy(entry, ch + 1, sizeof(entry));
855 + *(ch + 1) = '\0';
856 + } else {
857 + aal_memset(entry, 0, sizeof(entry));
858 + }
859 +
860 + /* Open obejct by @dirname */
861 + if (!(object = reiser4_semantic_open(fs->tree, dirname,
862 + NULL, 1)))
863 + {
864 + errnum = ERR_FILE_NOT_FOUND;
865 + return 0;
866 + }
867 +
868 + /* Checking if it is a directory object */
869 + if (object->ent->opset.plug[OPSET_OBJ]->id.group != DIR_OBJECT)
870 + {
871 + /* If not, cutting out last '/' character */
872 + if ((ch = aal_strrchr(dirname, '/')))
873 + *ch = '\0';
874 +
875 + /* Close current object */
876 + plug_call(objplug(object)->o.object_ops,
877 + close, object->ent);
878 + aal_free(object);
879 + return 0;
880 + }
881 +
882 + /* Reading the opened directory to build the completion list. */
883 + if (objplug(object)->o.object_ops->readdir) {
884 + while (plug_call(objplug(object)->o.object_ops, readdir,
885 + object->ent, &entry_hint) > 0)
886 + {
887 + if (substring(entry, entry_hint.name) <= 0) {
888 + if (print_possibilities > 0)
889 + print_possibilities =
890 + -print_possibilities;
891 +
892 + print_a_completion(entry_hint.name);
893 + }
894 + }
895 + }
896 + } else {
897 +#endif
898 + /* This is the case when resier4_dir() is called for open the
899 + file @dirname, not for building completion list. */
900 + if (!(object = reiser4_semantic_open(fs->tree, dirname,
901 + NULL, 1)))
902 + {
903 + errnum = ERR_FILE_NOT_FOUND;
904 + return 0;
905 + }
906 +
907 + if (object->ent->opset.plug[OPSET_OBJ]->id.group != REG_OBJECT)
908 + {
909 + errnum = ERR_BAD_FILETYPE;
910 + return 0;
911 + }
912 +
913 + /* Initializing GRUB global variables @filepos and @filemax. */
914 + filepos = 0;
915 + filemax = reiser4_object_size(object);
916 +
917 + return 1;
918 +#ifndef STAGE1_5
919 + }
920 +
921 + return 1;
922 +#endif
923 +
924 + errnum = ERR_FILE_NOT_FOUND;
925 + return 0;
926 +}
927 +
928 +/* Returns how many sectors may be used for embeding reiser4_stage1_5 in teh
929 + case of installing GRUB to partition instead of MBR. */
930 +int reiser4_embed (int *start_sector, int needed_sectors) {
931 + *start_sector = 1;
932 + return needed_sectors <= ((REISER4_MASTER_OFFSET >> SECTOR_BITS) - 1);
933 +}
934 +#endif /* FSYS_REISER4 */
935 diff -Naur grub-0.97/stage2/Makefile.am grub-0.97-magellan/stage2/Makefile.am
936 --- grub-0.97/stage2/Makefile.am 2007-09-03 00:48:33.000000000 +0200
937 +++ grub-0.97-magellan/stage2/Makefile.am 2007-09-03 00:47:50.000000000 +0200
938 @@ -13,17 +13,25 @@
939 # For <stage1.h>.
940 INCLUDES = -I$(top_srcdir)/stage1
941
942 +if ENABLE_REISER4_SUPPORT
943 +REISER4_STAGE1_5 = reiser4_stage1_5
944 +REISER4_STAGE1_5_EXEC = reiser4_stage1_5.exec
945 +else
946 +REISER4_STAGE1_5 =
947 +REISER4_STAGE1_5_EXEC =
948 +endif
949 +
950 # The library for /sbin/grub.
951 noinst_LIBRARIES = libgrub.a
952 libgrub_a_SOURCES = boot.c builtins.c char_io.c cmdline.c common.c \
953 disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \
954 - fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \
955 + fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_reiser4.c fsys_ufs2.c \
956 fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \
957 terminfo.c tparm.c graphics.c
958 libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
959 -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
960 -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
961 - -DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \
962 + $(REISER4_CFLAGS) -DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \
963 -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1
964
965 # Stage 2 and Stage 1.5's.
966 @@ -34,24 +42,26 @@
967 if DISKLESS_SUPPORT
968 pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \
969 ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \
970 - reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5 \
971 - nbgrub pxegrub
972 + reiserfs_stage1_5 $(REISER4_STAGE1_5) ufs2_stage1_5 \
973 + vstafs_stage1_5 xfs_stage1_5 nbgrub pxegrub
974 noinst_DATA = pre_stage2 start start_eltorito nbloader pxeloader diskless
975 noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \
976 e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \
977 iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \
978 - reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \
979 - xfs_stage1_5.exec nbloader.exec pxeloader.exec diskless.exec
980 + reiserfs_stage1_5.exec $(REISER4_STAGE1_5_EXEC) ufs2_stage1_5.exec \
981 + vstafs_stage1_5.exec xfs_stage1_5.exec nbloader.exec pxeloader.exec \
982 + diskless.exec
983 else
984 pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \
985 ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \
986 - reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5
987 + reiserfs_stage1_5 $(REISER4_STAGE1_5) ufs2_stage1_5 \
988 + vstafs_stage1_5 xfs_stage1_5
989 noinst_DATA = pre_stage2 start start_eltorito
990 noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \
991 e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \
992 iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \
993 - reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \
994 - xfs_stage1_5.exec
995 + reiserfs_stage1_5.exec $(REISER4_STAGE1_5_EXEC) ufs2_stage1_5.exec \
996 + vstafs_stage1_5.exec xfs_stage1_5.exec
997 endif
998 MOSTLYCLEANFILES = $(noinst_PROGRAMS)
999
1000 @@ -85,7 +95,7 @@
1001 GRAPHICS_FLAGS =
1002 endif
1003
1004 -STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
1005 +STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin \
1006 $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS)
1007
1008 STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
1009 @@ -95,15 +105,17 @@
1010 pre_stage2_exec_SOURCES = asm.S bios.c boot.c builtins.c char_io.c \
1011 cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \
1012 fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \
1013 - fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \
1014 - hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c \
1015 - graphics.c
1016 + fsys_reiserfs.c fsys_reiser4.c fsys_ufs2.c fsys_vstafs.c \
1017 + fsys_xfs.c gunzip.c hercules.c md5.c serial.c smp-imps.c \
1018 + stage2.c terminfo.c tparm.c graphics.c
1019 pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
1020 pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
1021 pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
1022
1023 if NETBOOT_SUPPORT
1024 -pre_stage2_exec_LDADD = ../netboot/libdrivers.a
1025 +pre_stage2_exec_LDADD = ../netboot/libdrivers.a $(REISER4_LIBS)
1026 +else
1027 +pre_stage2_exec_LDADD = $(REISER4_LIBS)
1028 endif
1029
1030 if DISKLESS_SUPPORT
1031 @@ -197,6 +209,16 @@
1032 -DNO_BLOCK_FILES=1
1033 reiserfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
1034
1035 +# For reiser4_stage1_5 target.
1036 +reiser4_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
1037 + disk_io.c stage1_5.c fsys_reiser4.c bios.c
1038 +reiser4_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) $(REISER4_CFLAGS) \
1039 + -DNO_BLOCK_FILES=1
1040 +reiser4_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) $(REISER4_CFLAGS) \
1041 + -DNO_BLOCK_FILES=1
1042 +reiser4_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
1043 +reiser4_stage1_5_exec_LDADD = $(REISER4_LIBS)
1044 +
1045 # For vstafs_stage1_5 target.
1046 vstafs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
1047 disk_io.c stage1_5.c fsys_vstafs.c bios.c
1048 diff -Naur grub-0.97/stage2/Makefile.am.orig grub-0.97-magellan/stage2/Makefile.am.orig
1049 --- grub-0.97/stage2/Makefile.am.orig 2005-02-02 21:37:35.000000000 +0100
1050 +++ grub-0.97-magellan/stage2/Makefile.am.orig 1970-01-01 01:00:00.000000000 +0100
1051 @@ -1,272 +0,0 @@
1052 -# For test target.
1053 -TESTS = size_test
1054 -noinst_SCRIPTS = $(TESTS)
1055 -
1056 -# For dist target.
1057 -noinst_HEADERS = apic.h defs.h dir.h disk_inode.h disk_inode_ffs.h \
1058 - fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \
1059 - imgact_aout.h iso9660.h jfs.h mb_header.h mb_info.h md5.h \
1060 - nbi.h pc_slice.h serial.h shared.h smp-imps.h term.h \
1061 - terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h
1062 -EXTRA_DIST = setjmp.S apm.S $(noinst_SCRIPTS)
1063 -
1064 -# For <stage1.h>.
1065 -INCLUDES = -I$(top_srcdir)/stage1
1066 -
1067 -# The library for /sbin/grub.
1068 -noinst_LIBRARIES = libgrub.a
1069 -libgrub_a_SOURCES = boot.c builtins.c char_io.c cmdline.c common.c \
1070 - disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \
1071 - fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \
1072 - fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \
1073 - terminfo.c tparm.c
1074 -libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
1075 - -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
1076 - -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
1077 - -DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \
1078 - -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1
1079 -
1080 -# Stage 2 and Stage 1.5's.
1081 -pkglibdir = $(libdir)/$(PACKAGE)/$(host_cpu)-$(host_vendor)
1082 -
1083 -EXTRA_PROGRAMS = nbloader.exec pxeloader.exec diskless.exec
1084 -
1085 -if DISKLESS_SUPPORT
1086 -pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \
1087 - ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \
1088 - reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5 \
1089 - nbgrub pxegrub
1090 -noinst_DATA = pre_stage2 start start_eltorito nbloader pxeloader diskless
1091 -noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \
1092 - e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \
1093 - iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \
1094 - reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \
1095 - xfs_stage1_5.exec nbloader.exec pxeloader.exec diskless.exec
1096 -else
1097 -pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \
1098 - ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \
1099 - reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5
1100 -noinst_DATA = pre_stage2 start start_eltorito
1101 -noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \
1102 - e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \
1103 - iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \
1104 - reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \
1105 - xfs_stage1_5.exec
1106 -endif
1107 -MOSTLYCLEANFILES = $(noinst_PROGRAMS)
1108 -
1109 -PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8200
1110 -START_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000
1111 -NBLOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,0
1112 -PXELOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00
1113 -START_ELTORITO_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00
1114 -
1115 -if NETBOOT_SUPPORT
1116 -NETBOOT_FLAGS = -I$(top_srcdir)/netboot -DSUPPORT_NETBOOT=1
1117 -else
1118 -NETBOOT_FLAGS =
1119 -endif
1120 -
1121 -if SERIAL_SUPPORT
1122 -SERIAL_FLAGS = -DSUPPORT_SERIAL=1
1123 -else
1124 -SERIAL_FLAGS =
1125 -endif
1126 -
1127 -if HERCULES_SUPPORT
1128 -HERCULES_FLAGS = -DSUPPORT_HERCULES=1
1129 -else
1130 -HERCULES_FLAGS =
1131 -endif
1132 -
1133 -STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
1134 - $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS)
1135 -
1136 -STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
1137 -STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1
1138 -
1139 -# For stage2 target.
1140 -pre_stage2_exec_SOURCES = asm.S bios.c boot.c builtins.c char_io.c \
1141 - cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \
1142 - fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \
1143 - fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \
1144 - hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c
1145 -pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
1146 -pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
1147 -pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
1148 -
1149 -if NETBOOT_SUPPORT
1150 -pre_stage2_exec_LDADD = ../netboot/libdrivers.a
1151 -endif
1152 -
1153 -if DISKLESS_SUPPORT
1154 -BUILT_SOURCES = stage2_size.h diskless_size.h
1155 -else
1156 -BUILT_SOURCES = stage2_size.h
1157 -endif
1158 -
1159 -CLEANFILES = $(pkglib_DATA) $(noinst_DATA) $(BUILT_SOURCES)
1160 -
1161 -stage2_size.h: pre_stage2
1162 - -rm -f stage2_size.h
1163 - set dummy `ls -l pre_stage2`; \
1164 - echo "#define STAGE2_SIZE $$6" > stage2_size.h
1165 -
1166 -start_exec_SOURCES = start.S
1167 -start_exec_CCASFLAGS = $(STAGE2_COMPILE)
1168 -start_exec_LDFLAGS = $(START_LINK)
1169 -
1170 -# XXX: automake doesn't provide a way to specify dependencies for object
1171 -# files explicitly, so we must write this by a general Makefile scheme.
1172 -# If automake change the naming scheme for per-executable objects, this
1173 -# will be broken.
1174 -start_exec-start.$(OBJEXT): stage2_size.h
1175 -
1176 -stage2: pre_stage2 start
1177 - -rm -f stage2
1178 - cat start pre_stage2 > stage2
1179 -
1180 -start_eltorito_exec_SOURCES = start_eltorito.S
1181 -start_eltorito_exec_CCASFLAGS = $(STAGE2_COMPILE)
1182 -start_eltorito_exec_LDFLAGS = $(START_ELTORITO_LINK)
1183 -
1184 -start_eltorito_exec-start.$(OBJEXT): stage2_size.h
1185 -
1186 -stage2_eltorito: pre_stage2 start_eltorito
1187 - -rm -f stage2_eltorito
1188 - cat start_eltorito pre_stage2 > stage2_eltorito
1189 -
1190 -# For e2fs_stage1_5 target.
1191 -e2fs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
1192 - stage1_5.c fsys_ext2fs.c bios.c
1193 -e2fs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_EXT2FS=1 \
1194 - -DNO_BLOCK_FILES=1
1195 -e2fs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_EXT2FS=1 \
1196 - -DNO_BLOCK_FILES=1
1197 -e2fs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
1198 -
1199 -# For fat_stage1_5 target.
1200 -fat_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
1201 - stage1_5.c fsys_fat.c bios.c
1202 -fat_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_FAT=1 \
1203 - -DNO_BLOCK_FILES=1
1204 -fat_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_FAT=1 \
1205 - -DNO_BLOCK_FILES=1
1206 -fat_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
1207 -
1208 -# For ffs_stage1_5 target.
1209 -ffs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
1210 - stage1_5.c fsys_ffs.c bios.c
1211 -ffs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_FFS=1 \
1212 - -DNO_BLOCK_FILES=1
1213 -ffs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_FFS=1 \
1214 - -DNO_BLOCK_FILES=1
1215 -ffs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
1216 -
1217 -# For ufs2_stage1_5 target.
1218 -ufs2_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
1219 - stage1_5.c fsys_ufs2.c bios.c
1220 -ufs2_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_UFS2=1 \
1221 - -DNO_BLOCK_FILES=1
1222 -ufs2_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_UFS2=1 \
1223 - -DNO_BLOCK_FILES=1
1224 -ufs2_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
1225 -
1226 -# For minix_stage1_5 target.
1227 -minix_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
1228 - stage1_5.c fsys_minix.c bios.c
1229 -minix_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_MINIX=1 \
1230 - -DNO_BLOCK_FILES=1
1231 -minix_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_MINIX=1 \
1232 - -DNO_BLOCK_FILES=1
1233 -minix_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
1234 -
1235 -# For reiserfs_stage1_5 target.
1236 -reiserfs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
1237 - disk_io.c stage1_5.c fsys_reiserfs.c bios.c
1238 -reiserfs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_REISERFS=1 \
1239 - -DNO_BLOCK_FILES=1
1240 -reiserfs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_REISERFS=1 \
1241 - -DNO_BLOCK_FILES=1
1242 -reiserfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
1243 -
1244 -# For vstafs_stage1_5 target.
1245 -vstafs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
1246 - disk_io.c stage1_5.c fsys_vstafs.c bios.c
1247 -vstafs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_VSTAFS=1 \
1248 - -DNO_BLOCK_FILES=1
1249 -vstafs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_VSTAFS=1 \
1250 - -DNO_BLOCK_FILES=1
1251 -vstafs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
1252 -
1253 -# For jfs_stage1_5 target.
1254 -jfs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
1255 - disk_io.c stage1_5.c fsys_jfs.c bios.c
1256 -jfs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_JFS=1 \
1257 - -DNO_BLOCK_FILES=1
1258 -jfs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_JFS=1 \
1259 - -DNO_BLOCK_FILES=1
1260 -jfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
1261 -
1262 -# For xfs_stage1_5 target.
1263 -xfs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
1264 - disk_io.c stage1_5.c fsys_xfs.c bios.c
1265 -xfs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_XFS=1 \
1266 - -DNO_BLOCK_FILES=1
1267 -xfs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_XFS=1 \
1268 - -DNO_BLOCK_FILES=1
1269 -xfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
1270 -
1271 -# For iso9660_stage1_5 target.
1272 -iso9660_stage1_5_exec_SOURCES = start_eltorito.S asm.S common.c char_io.c \
1273 - disk_io.c stage1_5.c fsys_iso9660.c bios.c
1274 -iso9660_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_ISO9660=1 \
1275 - -DNO_BLOCK_FILES=1
1276 -iso9660_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_ISO9660=1 \
1277 - -DNO_BLOCK_FILES=1
1278 -iso9660_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
1279 -
1280 -# For diskless target.
1281 -diskless_exec_SOURCES = $(pre_stage2_exec_SOURCES)
1282 -diskless_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) \
1283 - -DSUPPORT_DISKLESS=1
1284 -diskless_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) \
1285 - -DSUPPORT_DISKLESS=1
1286 -diskless_exec_LDFLAGS = $(PRE_STAGE2_LINK)
1287 -diskless_exec_LDADD = ../netboot/libdrivers.a
1288 -
1289 -diskless_size.h: diskless
1290 - -rm -f $@
1291 - set dummy `ls -l $^`; \
1292 - echo "#define DISKLESS_SIZE $$6" > $@
1293 -
1294 -# For nbloader target.
1295 -nbloader_exec_SOURCES = nbloader.S
1296 -nbloader_exec_CCASFLAGS = $(STAGE2_COMPILE)
1297 -nbloader_exec_LDFLAGS = $(NBLOADER_LINK)
1298 -
1299 -# XXX: See the comment for start_exec-start.o.
1300 -nbloader_exec-nbloader.$(OBJEXT): diskless_size.h
1301 -
1302 -# For nbgrub target.
1303 -nbgrub: nbloader diskless
1304 - -rm -f $@
1305 - cat $^ > $@
1306 -
1307 -# For pxeloader target.
1308 -pxeloader_exec_SOURCES = pxeloader.S
1309 -pxeloader_exec_CCASFLAGS = $(STAGE2_COMPILE)
1310 -pxeloader_exec_LDFLAGS = $(PXELOADER_LINK)
1311 -
1312 -# XXX: See the comment for start_exec-start.o.
1313 -pxeloader_exec-pxeloader.$(OBJEXT): diskless_size.h
1314 -
1315 -# For pxegrub target.
1316 -pxegrub: pxeloader diskless
1317 - -rm -f $@
1318 - cat $^ > $@
1319 -
1320 -# General rule for making a raw binary.
1321 -SUFFIXES = .exec
1322 -.exec:
1323 - $(OBJCOPY) -O binary $< $@
1324 diff -Naur grub-0.97/stage2/shared.h grub-0.97-magellan/stage2/shared.h
1325 --- grub-0.97/stage2/shared.h 2007-09-03 00:48:49.000000000 +0200
1326 +++ grub-0.97-magellan/stage2/shared.h 2007-09-03 00:37:37.000000000 +0200
1327 @@ -207,11 +207,12 @@
1328 #define STAGE2_ID_FAT_STAGE1_5 3
1329 #define STAGE2_ID_MINIX_STAGE1_5 4
1330 #define STAGE2_ID_REISERFS_STAGE1_5 5
1331 -#define STAGE2_ID_VSTAFS_STAGE1_5 6
1332 -#define STAGE2_ID_JFS_STAGE1_5 7
1333 -#define STAGE2_ID_XFS_STAGE1_5 8
1334 -#define STAGE2_ID_ISO9660_STAGE1_5 9
1335 -#define STAGE2_ID_UFS2_STAGE1_5 10
1336 +#define STAGE2_ID_REISER4_STAGE1_5 6
1337 +#define STAGE2_ID_VSTAFS_STAGE1_5 7
1338 +#define STAGE2_ID_JFS_STAGE1_5 8
1339 +#define STAGE2_ID_XFS_STAGE1_5 9
1340 +#define STAGE2_ID_ISO9660_STAGE1_5 10
1341 +#define STAGE2_ID_UFS2_STAGE1_5 11
1342
1343 #ifndef STAGE1_5
1344 # define STAGE2_ID STAGE2_ID_STAGE2
1345 @@ -226,6 +227,8 @@
1346 # define STAGE2_ID STAGE2_ID_MINIX_STAGE1_5
1347 # elif defined(FSYS_REISERFS)
1348 # define STAGE2_ID STAGE2_ID_REISERFS_STAGE1_5
1349 +# elif defined(FSYS_REISER4)
1350 +# define STAGE2_ID STAGE2_ID_REISER4_STAGE1_5
1351 # elif defined(FSYS_VSTAFS)
1352 # define STAGE2_ID STAGE2_ID_VSTAFS_STAGE1_5
1353 # elif defined(FSYS_JFS)