Using libisofs system area summary in -toc line "Boot record"

master
Thomas Schmitt 9 years ago
parent e41108bccd
commit 3dfd764d74
  1. 124
      xorriso/iso_img.c
  2. 2
      xorriso/xorriso_timestamp.h

@ -211,40 +211,6 @@ int Xorriso_is_isohybrid(struct XorrisO *xorriso, IsoFile *bootimg_node,
}
/* @return <0 yes , 0 no , <0 error */
int Xorriso_is_grub2_elto(struct XorrisO *xorriso, IsoFile *bootimg_node,
int flag)
{
#define Xorriso_grub2_boot_info_poS 2548
int ret, i;
unsigned char buf[Xorriso_grub2_boot_info_poS + 8];
void *data_stream= NULL;
off_t blk;
ret= Xorriso_iso_file_open(xorriso, "", (void *) bootimg_node,
&data_stream, 1);
if(ret <= 0)
return(-1);
ret= Xorriso_iso_file_read(xorriso, data_stream, (char *) buf,
Xorriso_grub2_boot_info_poS + 8, 0);
Xorriso_iso_file_close(xorriso, &data_stream, 0);
if(ret < Xorriso_grub2_boot_info_poS + 8)
return(0);
/* >>> ??? Check for some id */;
/* Check whether it has grub2_boot_info patching */
blk= 0;
for(i= 0; i < 8; i++)
blk|= buf[Xorriso_grub2_boot_info_poS + i] << (8 * i);
blk-= 5;
blk/= 4;
if(blk != (off_t) xorriso->loaded_boot_bin_lba)
return(0);
return(1);
}
int Xorriso_image_has_md5(struct XorrisO *xorriso, int flag)
{
int ret;
@ -811,11 +777,8 @@ int Xorriso__append_boot_params(char *line, ElToritoBootImage *bootimg,
*/
int Xorriso_show_boot_info(struct XorrisO *xorriso, int flag)
{
int ret, bin_path_valid= 0,has_isolinux_mbr= 0, i, num_boots, has_mbr= 0;
int has_grub2_mbr= 0;
unsigned int mbr_lba= 0;
off_t lb0_count, blk;
char *respt, *path;
int ret, bin_path_valid= 0, i, num_boots, sa_count;
char *respt, *path= NULL, **sa_report= NULL, *sa_summary= NULL;
unsigned char *lb0= NULL;
struct burn_drive_info *dinfo;
struct burn_drive *drive;
@ -831,7 +794,7 @@ int Xorriso_show_boot_info(struct XorrisO *xorriso, int flag)
if(xorriso->boot_count > 0) {
if(!(flag & 1)) {
sprintf(respt, "Boot record : overridden by -boot_image any next\n");
sprintf(respt, "Boot record : (overridden by -boot_image any next)\n");
Xorriso_toc_line(xorriso, flag & 8);
}
ret= 1; goto ex;
@ -852,11 +815,27 @@ no_boot:;
goto ex;
}
ret= iso_image_report_system_area(image, &sa_report, &sa_count, 0);
if(ret > 0 && sa_report != NULL)
for(i= 0; i < sa_count; i++)
if(strncmp(sa_report[i], "System area summary: ", 21) == 0) {
Xorriso_alloc_meM(sa_summary, char, strlen(sa_report[i] + 21) + 1);
strcpy(sa_summary, sa_report[i] + 21);
break;
}
if(sa_report != NULL)
iso_image_report_system_area(image, &sa_report, &sa_count, 1 << 15);
Xorriso_process_msg_queues(xorriso,0);
/* Using the nodes with extreme care . They might be deleted meanwhile. */
ret= iso_image_get_boot_image(image, &bootimg, &bootimg_node, &bootcat_node);
if(ret != 1)
goto no_boot;
if(ret != 1) {
if(sa_summary == NULL)
goto no_boot;
sprintf(respt, "Boot record : (system area only) , %s\n", sa_summary);
Xorriso_toc_line(xorriso, flag & 8);
ret= 1; goto ex;
}
ret= iso_image_get_all_boot_imgs(image, &num_boots, &boots, &bootnodes, 0);
Xorriso_process_msg_queues(xorriso,0);
if(ret != 1) {
@ -867,59 +846,9 @@ no_boot:;
bin_path_valid= 1;
}
sprintf(respt, "Boot record : El Torito");
/* Load and examine potential MBR */
ret= burn_read_data(drive, (off_t) 0, (char *) lb0, (off_t) 2048,
&lb0_count, 2);
if(ret > 0)
if(lb0[510] == 0x55 && lb0[511] == 0xaa)
has_mbr= 1;
if(bin_path_valid)
ret= Xorriso_is_isohybrid(xorriso, bootimg_node, 0);
else
ret= 0;
if(ret > 0) {
if(has_mbr) {
has_isolinux_mbr= 1;
mbr_lba= lb0[432] | (lb0[433] << 8) | (lb0[434] << 16) | (lb0[435] << 24);
mbr_lba/= 4;
if(mbr_lba != (unsigned int) xorriso->loaded_boot_bin_lba)
has_isolinux_mbr= 0;
if(has_isolinux_mbr) {
for(i= 0; i < 426; i++)
if(strncmp((char *) (lb0 + i), "isolinux", 8) == 0)
break;
if(i >= 426)
has_isolinux_mbr= 0;
}
}
if(has_isolinux_mbr)
strcat(respt, " , ISOLINUX isohybrid MBR pointing to boot image");
else
strcat(respt, " , ISOLINUX boot image capable of isohybrid");
}
if(bin_path_valid)
ret= Xorriso_is_grub2_elto(xorriso, bootimg_node, 0);
else
ret= 0;
if(ret > 0) {
if(has_mbr) {
has_grub2_mbr= 1;
blk= 0;
for(i= 0; i < 8; i++)
blk|= lb0[i + 0x1b0] << (8 * i);
blk-= 4;
blk/= 4;
if(blk != (off_t) xorriso->loaded_boot_bin_lba)
has_grub2_mbr= 0;
for(i= 32; i < 427; i++)
if(strncmp((char *) (lb0 + i), "GRUB", 4) == 0)
break;
if(i >= 427)
has_grub2_mbr= 0;
}
if(has_grub2_mbr)
strcat(respt, " , GRUB2 MBR pointing to first boot image");
}
if(sa_summary != NULL)
sprintf(respt + strlen(respt), " , %s", sa_summary);
strcat(respt, "\n");
Xorriso_toc_line(xorriso, flag & 8);
if(flag & 2)
@ -970,6 +899,7 @@ ex:;
iso_image_unref(image); /* release obtained reference */
Xorriso_free_meM(path);
Xorriso_free_meM(lb0);
Xorriso_free_meM(sa_summary);
return(ret);
}
@ -1464,8 +1394,6 @@ int Xorriso_report_system_area(struct XorrisO *xorriso, char *form, int flag)
if(ret <= 0)
goto ex;
is_elto= 1;
sprintf(xorriso->result_line, "\n");
Xorriso_result(xorriso, 0);
sprintf(xorriso->result_line,
"------------------------------------------------------------------------------\n");
Xorriso_result(xorriso, 0);

@ -1 +1 @@
#define Xorriso_timestamP "2014.04.24.084540"
#define Xorriso_timestamP "2014.04.25.064456"

Loading…
Cancel
Save