]> git.proxmox.com Git - grub2.git/commitdiff
2009-12-21 Robert Millan <rmh.grub@aybabtu.com>
authorRobert Millan <rmh@aybabtu.com>
Mon, 21 Dec 2009 17:40:26 +0000 (17:40 +0000)
committerRobert Millan <rmh@aybabtu.com>
Mon, 21 Dec 2009 17:40:26 +0000 (17:40 +0000)
        * util/mkisofs/mkisofs.c (use_embedded_boot, boot_image_embed): New
        variables.
        (ld_options, main): Recognize `--embedded-boot'.
        * util/mkisofs/mkisofs.h (use_embedded_boot, boot_image_embed): New
        declarations.
        * util/mkisofs/write.c (PADBLOCK_SIZE): New variable.
        (padblock_size): Use `PADBLOCK_SIZE' instead of hardcoding 16.
        (padblock_write): Likewise.  Rewrite to support embedded boot image.

        * util/grub-mkrescue.in: When building i386-pc images, embed core.img
        for BIOS-based disk boot instead of only ElTorito.

ChangeLog
util/grub-mkrescue.in
util/mkisofs/mkisofs.c
util/mkisofs/mkisofs.h
util/mkisofs/write.c

index 10d094b7ab1ea0f6ae28937db5b24459836b53f2..38d1e4fc4ca2aa681fd2ce414bba0785212b214b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2009-12-21  Robert Millan  <rmh.grub@aybabtu.com>
+
+       * util/mkisofs/mkisofs.c (use_embedded_boot, boot_image_embed): New
+       variables.
+       (ld_options, main): Recognize `--embedded-boot'.
+       * util/mkisofs/mkisofs.h (use_embedded_boot, boot_image_embed): New
+       declarations.
+       * util/mkisofs/write.c (PADBLOCK_SIZE): New variable.
+       (padblock_size): Use `PADBLOCK_SIZE' instead of hardcoding 16.
+       (padblock_write): Likewise.  Rewrite to support embedded boot image.
+
+       * util/grub-mkrescue.in: When building i386-pc images, embed core.img
+       for BIOS-based disk boot instead of only ElTorito.
+
 2009-12-21  Robert Millan  <rmh.grub@aybabtu.com>
 
        * util/grub-mkrescue.in: Remove `configfile' and `sh' from i386-pc
index a667031c26d219b60f552c9502d1cbd8dad05184..2687da4175047d43515bf297b47980cb80ad9431 100644 (file)
@@ -162,6 +162,10 @@ if test -e "${pc_dir}" ; then
     grub-mkimage -d ${pc_dir}/ -o ${core_img} --prefix=/boot/grub/i386-pc \
         iso9660 biosdisk
     cat ${pc_dir}/cdboot.img ${core_img} > ${iso9660_dir}/boot/grub/i386-pc/eltorito.img
+
+    embed_img=`mktemp`
+    cat ${pc_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=32 > ${embed_img}
+
     rm -f ${core_img}
 
     modules="$(cat ${pc_dir}/partmap.lst) ${modules}"
@@ -171,11 +175,14 @@ if test -e "${pc_dir}" ; then
     echo "source /boot/grub/grub.cfg") \
     > ${iso9660_dir}/boot/grub/i386-pc/grub.cfg
 
-    grub_mkisofs_arguments="${grub_mkisofs_arguments} -b boot/grub/i386-pc/eltorito.img -boot-info-table"
+    grub_mkisofs_arguments="${grub_mkisofs_arguments} -b boot/grub/i386-pc/eltorito.img -boot-info-table \
+               --embedded-boot ${embed_img}"
 fi
 
 # build iso image
 grub-mkisofs ${grub_mkisofs_arguments} -o ${output_image} -r ${iso9660_dir} ${source}
 rm -rf ${iso9660_dir}
 
+rm -f ${embed_img}
+
 exit 0
index 803317ba061b880fcb83ed83c39940848c3b4c7d..98fcf2f20bf132f00f72ef83fa8e2f99dcb6f538 100644 (file)
@@ -90,6 +90,7 @@ int extension_record_size = 0;
 /* These variables are associated with command line options */
 int use_eltorito = 0;
 int use_eltorito_emul_floppy = 0;
+int use_embedded_boot = 0;
 int use_boot_info_table = 0;
 int use_RockRidge = 0;
 int use_Joliet = 0;
@@ -100,17 +101,18 @@ int rationalize = 0;
 int generate_tables = 0;
 int print_size = 0;
 int split_output = 0;
-char * preparer = PREPARER_DEFAULT;
-char * publisher = PUBLISHER_DEFAULT;
-char * appid = APPID_DEFAULT;
-char * copyright = COPYRIGHT_DEFAULT;
-char * biblio = BIBLIO_DEFAULT;
-char * abstract = ABSTRACT_DEFAULT;
-char * volset_id = VOLSET_ID_DEFAULT;
-char * volume_id = VOLUME_ID_DEFAULT;
-char * system_id = SYSTEM_ID_DEFAULT;
-char * boot_catalog = BOOT_CATALOG_DEFAULT;
-char * boot_image = BOOT_IMAGE_DEFAULT;
+char *preparer = PREPARER_DEFAULT;
+char *publisher = PUBLISHER_DEFAULT;
+char *appid = APPID_DEFAULT;
+char *copyright = COPYRIGHT_DEFAULT;
+char *biblio = BIBLIO_DEFAULT;
+char *abstract = ABSTRACT_DEFAULT;
+char *volset_id = VOLSET_ID_DEFAULT;
+char *volume_id = VOLUME_ID_DEFAULT;
+char *system_id = SYSTEM_ID_DEFAULT;
+char *boot_catalog = BOOT_CATALOG_DEFAULT;
+char *boot_image = BOOT_IMAGE_DEFAULT;
+char *boot_image_embed = NULL;
 int volume_set_size = 1;
 int volume_sequence_number = 1;
 
@@ -209,6 +211,8 @@ static const struct ld_option ld_options[] =
       '\0', N_("FILE"), N_("Set Bibliographic filename"), ONE_DASH },
   { {"copyright", required_argument, NULL, OPTION_COPYRIGHT},
       '\0', N_("FILE"), N_("Set Copyright filename"), ONE_DASH },
+  { {"embedded-boot", required_argument, NULL, 'G'},
+      'G', N_("FILE"), N_("Set embedded boot image name"), TWO_DASHES },
   { {"eltorito-boot", required_argument, NULL, 'b'},
       'b', N_("FILE"), N_("Set El Torito boot image name"), ONE_DASH },
   { {"eltorito-catalog", required_argument, NULL, 'c'},
@@ -719,10 +723,13 @@ int FDECL2(main, int, argc, char **, argv){
        use_eltorito++;
        boot_image = optarg;  /* pathname of the boot image on cd */
        if (boot_image == NULL)
-         {
-           fprintf (stderr, _("Required boot image pathname missing\n"));
-           exit (1);
-         }
+         error (1, 0, _("Required boot image pathname missing"));
+       break;
+      case 'G':
+       use_embedded_boot++;
+       boot_image_embed = optarg;  /* pathname of the boot image on host filesystem */
+       if (boot_image_embed == NULL)
+         error (1, 0, _("Required boot image pathname missing"));
        break;
       case 'c':
        use_eltorito++;
index a1638d80e9f6e95775e6bfb2400eae279ccf3615..adc10e945fd566d9e66f5cbefa99a8119bb93c6f 100644 (file)
@@ -296,6 +296,7 @@ extern struct iso_directory_record root_record;
 extern struct iso_directory_record jroot_record;
 
 extern int use_eltorito;
+extern int use_embedded_boot;
 extern int use_eltorito_emul_floppy;
 extern int use_boot_info_table;
 extern int use_RockRidge;
@@ -438,20 +439,21 @@ extern char * extension_record;
 extern int extension_record_extent;
 extern int n_data_extents;
 
-/* These are a few goodies that can be specified on the command line, and  are
+/* These are a few goodies that can be specified on the command line, and are
    filled into the root record */
 
-extern char * preparer;
-extern char * publisher;
-extern char * copyright;
-extern char * biblio;
-extern char * abstract;
-extern char * appid;
-extern char * volset_id;
-extern char * system_id;
-extern char * volume_id;
-extern char * boot_catalog;
-extern char * boot_image;
+extern char *preparer;
+extern char *publisher;
+extern char *copyright;
+extern char *biblio;
+extern char *abstract;
+extern char *appid;
+extern char *volset_id;
+extern char *system_id;
+extern char *volume_id;
+extern char *boot_catalog;
+extern char *boot_image;
+extern char *boot_image_embed;
 extern int volume_set_size;
 extern int volume_sequence_number;
 
index 73c22082741f3a57789bb318fcfe3bf9ca8c385c..d9c847268924473d0299c621519e97b0e48ca489 100644 (file)
@@ -1344,6 +1344,9 @@ int FDECL1(oneblock_size, int, starting_extent)
 /*
  * Functions to describe padding block at the start of the disc.
  */
+
+#define PADBLOCK_SIZE  16
+
 static int FDECL1(pathtab_size, int, starting_extent)
 {
   path_table[0] = starting_extent;
@@ -1357,7 +1360,7 @@ static int FDECL1(pathtab_size, int, starting_extent)
 
 static int FDECL1(padblock_size, int, starting_extent)
 {
-  last_extent += 16;
+  last_extent += PADBLOCK_SIZE;
   return 0;
 }
 
@@ -1420,17 +1423,23 @@ static int FDECL1(dirtree_cleanup, FILE *, outfile)
 
 static int FDECL1(padblock_write, FILE *, outfile)
 {
-  char                         buffer[2048];
-  int                          i;
+  char *buffer;
+  int i;
 
-  memset(buffer, 0, sizeof(buffer));
+  buffer = e_malloc (2048 * PADBLOCK_SIZE);
+  memset (buffer, 0, 2048 * PADBLOCK_SIZE);
 
-  for(i=0; i<16; i++)
+  if (use_embedded_boot)
     {
-      xfwrite(buffer, 1, sizeof(buffer), outfile);
+      FILE *fp = fopen (boot_image_embed, "rb");
+      if (! fp)
+       error (1, errno, _("Unable to open %s"), boot_image_embed);
+      fread (buffer, 2048 * PADBLOCK_SIZE, 1, fp);
     }
 
-  last_extent_written += 16;
+  xfwrite (buffer, 1, 2048 * PADBLOCK_SIZE, outfile);
+  last_extent_written += PADBLOCK_SIZE;
+
   return 0;
 }