From: Robert Millan Date: Mon, 21 Dec 2009 17:40:26 +0000 (+0000) Subject: 2009-12-21 Robert Millan X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=0ae5692966637f8465d267fc5667b9fcbdcac3de;p=grub2.git 2009-12-21 Robert Millan * 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. --- diff --git a/ChangeLog b/ChangeLog index 10d094b7a..38d1e4fc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2009-12-21 Robert Millan + + * 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 * util/grub-mkrescue.in: Remove `configfile' and `sh' from i386-pc diff --git a/util/grub-mkrescue.in b/util/grub-mkrescue.in index a667031c2..2687da417 100644 --- a/util/grub-mkrescue.in +++ b/util/grub-mkrescue.in @@ -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 diff --git a/util/mkisofs/mkisofs.c b/util/mkisofs/mkisofs.c index 803317ba0..98fcf2f20 100644 --- a/util/mkisofs/mkisofs.c +++ b/util/mkisofs/mkisofs.c @@ -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++; diff --git a/util/mkisofs/mkisofs.h b/util/mkisofs/mkisofs.h index a1638d80e..adc10e945 100644 --- a/util/mkisofs/mkisofs.h +++ b/util/mkisofs/mkisofs.h @@ -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; diff --git a/util/mkisofs/write.c b/util/mkisofs/write.c index 73c220827..d9c847268 100644 --- a/util/mkisofs/write.c +++ b/util/mkisofs/write.c @@ -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; }