Skip to contentSkip to conversation

add grub-mbchk utility to grub

PATCH In review Scott Moser 3 participants 5 messages Aug 12, 2010 – Sep 3, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add grub-mbchk utility to grub

Hi all,
I've been playing around with multiboot images, and found grub 0.97's
'mbchk' to be very useful. Its really nice from a shell script or other to easily answer "is this file a multiboot image?".

The attached patch basically copies mbchk.c from grub-0.97 to current
bzr with minimal changes.
Is that something that could be carried in grub2 ?

Thanks,
Scott

=== modified file 'conf/common.rmk'

common.rmk +5 -0
@@ -165,6 +165,11 @@
 grub_editenv_SOURCES = gnulib/progname.c util/grub-editenv.c lib/envblk.c util/misc.c kern/emu/misc.c kern/emu/mm.c kern/misc.c kern/err.c
 CLEANFILES += grub-editenv
 
+# for grub-mbchk
+bin_UTILITIES += grub-mbchk
+grub_mbchk_SOURCES = gnulib/progname.c util/grub-mbchk.c kern/emu/misc.c util/misc.c
+CLEANFILES += grub-mbchk
+
 # Needed for genmk.rb to work
 ifeq (0,1)
 bin_UTILITIES += grub-macho2img grub-pe2elf

=== added file 'docs/man/grub-mbchk.h2m'

man/grub-mbchk.h2m +2 -0
@@ -0,0 +1,2 @@
+[NAME]
+grub-mbchk \- check the format of a Multiboot kernel

=== added file 'util/grub-mbchk.c'

grub-mbchk.c +260 -0

260 lines not on this page · raw message

#1 lore raw

2010/8/10, Scott Moser <[email protected]>:

Quoted 8 lines

Hi all,
I've been playing around with multiboot images, and found grub 0.97's
'mbchk' to be very useful. Its really nice from a shell script or other to easily answer "is this file a multiboot image?".

The attached patch basically copies mbchk.c from grub-0.97 to current
bzr with minimal changes.
Is that something that could be carried in grub2 ?

I think it would make more sense in multiboot itself (multiboot package doesn't just include documentation, there's also sample C code and such).

#2 lore raw
Quoted 6 lines · Robert Millan

2010/8/10, Scott Moser <[email protected]>:

Quoted 5 lines

Hi all,
I've been playing around with multiboot images, and found grub 0.97's
'mbchk' to be very useful. Its really nice from a shell script or other to easily answer "is this file a multiboot image?".

Quoted 7 lines
Quoted 3 lines

The attached patch basically copies mbchk.c from grub-0.97 to current
bzr with minimal changes.
Is that something that could be carried in grub2 ?

I think it would make more sense in multiboot itself (multiboot package doesn't just include documentation, there's also sample C code and such).

Well, I would prefer it in grub, but admittedly, that is for reasons other than "its the best place for it". Being part of the grub package means it would be likely installed on systems and easy to use. I won't disagree that 'multiboot' is probably a better place, but will suggest that it is less discoverable.

Attached is a patch against multiboot-0.6.96 to add a 'tools/' subdir and
'mbchk.c' to that. The reason for the tools/ dir rather than putting it
into examples was to allow to examples/ dir to continue using '-m32' on all c files. I couldn't see an easy way to work around that otherwise.

Makefile +1 -1
Index: multiboot-0.6.96/Makefile
===================================================================
@@ -188,7 +188,7 @@
 
 # Do not change this order if you don't know what you are doing.
 AUTOMAKE_OPTIONS = 1.7 gnu
-SUBDIRS = docs
+SUBDIRS = docs tools
 all: config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
Makefile.am +1 -1
Index: multiboot-0.6.96/Makefile.am
===================================================================
@@ -1,3 +1,3 @@
 # Do not change this order if you don't know what you are doing.
 AUTOMAKE_OPTIONS = 1.7 gnu
-SUBDIRS = docs
+SUBDIRS = docs tools
configure.ac +2 -2
Index: multiboot-0.6.96/configure.ac
===================================================================
@@ -18,7 +18,7 @@
 AC_CONFIG_HEADER([config.h])
 AM_INIT_AUTOMAKE
 
-CFLAGS="-m32 $CFLAGS"
+CFLAGS="$CFLAGS"
 
 #
 # Programs
@@ -46,5 +46,5 @@
 
 
 dnl Output.
-AC_CONFIG_FILES([Makefile docs/Makefile])
+AC_CONFIG_FILES([Makefile docs/Makefile tools/Makefile])
 AC_OUTPUT
docs/Makefile.am +2 -0
Index: multiboot-0.6.96/docs/Makefile.am
===================================================================
@@ -1,3 +1,5 @@
+AM_CFLAGS = -m32
+
 info_TEXINFOS = multiboot.texi
 EXAMPLES = boot.S kernel.c multiboot.h
 multiboot_TEXINFOS = boot.S.texi kernel.c.texi multiboot.h.texi
tools/Makefile.am new file +5 -0
Index: multiboot-0.6.96/tools/Makefile.am
===================================================================
@@ -0,0 +1,5 @@
+bin_PROGRAMS = mbchk
+
+AM_CPPFLAGS = -I$(top_builddir)/docs
+
+mbchk_SOURCES = mbchk.c multiboot.h
tools/mbchk.c new file +257 -0

257 lines not on this page · raw message

#3 lore raw
In reply to Scott Moser

Btw I think this is not true anymore:

+ /* This is a GRUB-specific limitation. */
+ if (mbh->load_addr < 0x100000)
+ {
+ fprintf (stderr,

+		   "%s: Cannot be loaded at less than 1MB by GRUB"
+		   " (0x%x).\n",
+		   filename, mbh->load_addr);

+ return 0;
+ }

Signature · 1 line
Robert Millan
#4 lore raw
In reply to Scott Moser
Quoted 6 lines · Scott Moser

Hi all,
I've been playing around with multiboot images, and found grub 0.97's
'mbchk' to be very useful. Its really nice from a shell script or other to easily answer "is this file a multiboot image?".

I remerged mbchk into multiboot using the files from legacy (not using your patch)

Quoted 13 lines

The attached patch basically copies mbchk.c from grub-0.97 to current
bzr with minimal changes.
Is that something that could be carried in grub2 ?

Thanks,
Scott

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko