"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xorriso/iso_img.c" between
xorriso-1.5.2.tar.gz and xorriso-1.5.4.tar.gz

About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.

iso_img.c  (xorriso-1.5.2):iso_img.c  (xorriso-1.5.4)
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images. /* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
Copyright 2007-2019 Thomas Schmitt, <scdbackup@gmx.net> Copyright 2007-2020 Thomas Schmitt, <scdbackup@gmx.net>
Provided under GPL version 2 or later. Provided under GPL version 2 or later.
This file contains functions which operate on ISO images and their This file contains functions which operate on ISO images and their
global properties. global properties.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "../config.h" #include "../config.h"
#endif #endif
skipping to change at line 1079 skipping to change at line 1079
mount_chardev= 1; mount_chardev= 1;
if(!(S_ISREG(stbuf.st_mode) || (S_ISBLK(stbuf.st_mode) && !mount_chardev) if(!(S_ISREG(stbuf.st_mode) || (S_ISBLK(stbuf.st_mode) && !mount_chardev)
|| (S_ISCHR(stbuf.st_mode) && !mount_chardev))) { || (S_ISCHR(stbuf.st_mode) && !mount_chardev))) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"File object is not suitable as mount device: "); "File object is not suitable as mount device: ");
Text_shellsafe(dev_path, xorriso->info_text, 1); Text_shellsafe(dev_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex; ret= 0; goto ex;
} }
/* Aquire drive as direct libburn address or via stdio: prefix */ /* Acquire drive as direct libburn address or via stdio: prefix */
if(strncmp(dev, "mmc:", 4) == 0) if(strncmp(dev, "mmc:", 4) == 0)
ret= burn_drive_convert_fs_adr(dev + 4, libburn_adr); ret= burn_drive_convert_fs_adr(dev + 4, libburn_adr);
else else
ret= burn_drive_convert_fs_adr(dev, libburn_adr); ret= burn_drive_convert_fs_adr(dev, libburn_adr);
Xorriso_process_msg_queues(xorriso,0); Xorriso_process_msg_queues(xorriso,0);
if(ret < 0) if(ret < 0)
{ret= -1; goto ex;} {ret= -1; goto ex;}
if(ret == 0 && strncmp(dev, "stdio:", 6) != 0 && if(ret == 0 && strncmp(dev, "stdio:", 6) != 0 &&
strncmp(dev, "mmc:", 4) != 0) strncmp(dev, "mmc:", 4) != 0)
sprintf(libburn_adr, "stdio:%s", dev); sprintf(libburn_adr, "stdio:%s", dev);
skipping to change at line 1509 skipping to change at line 1509
if(buf[strlen(buf) - 1] == ',') if(buf[strlen(buf) - 1] == ',')
buf[strlen(buf) - 1] = 0; buf[strlen(buf) - 1] = 0;
strcat(buf, ":"); strcat(buf, ":");
path= xorriso->indev; path= xorriso->indev;
if(strncmp(path, "stdio:", 6) == 0) if(strncmp(path, "stdio:", 6) == 0)
path+= 6; path+= 6;
Text_shellsafe(path, buf, 1); Text_shellsafe(path, buf, 1);
return(1); return(1);
} }
int Xorriso_add_offset_size(struct XorrisO *xorriso, char *buf,
off_t byte_offset, off_t byte_size, int flag)
{
strcat(buf, " ");
Sfile_off_t_text(buf + strlen(buf), byte_offset, 0);
strcat(buf, " ");
Sfile_off_t_text(buf + strlen(buf), byte_size, 0);
return(1);
}
struct elto_img_par { struct elto_img_par {
int n, ldsiz, boot_info_table, grub2_boot_info; int n, ldsiz, boot_info_table, grub2_boot_info;
int do_gpt_basdat, do_gpt_hfsplus, do_apm_hfsplus; int do_gpt_basdat, do_gpt_hfsplus, do_apm_hfsplus;
unsigned int ld_seg, hdpt, platform_id; unsigned int ld_seg, hdpt, platform_id;
unsigned long int lba; unsigned long int lba, extract_size;
char pltf[8], b[8], emul[8], boot_image_type[16]; char pltf[8], b[8], emul[8], boot_image_type[16];
char *path, *id_string, *sel_crit; char *path, *id_string, *sel_crit;
}; };
/* @param ptype 0= unknown, 1= gpt-basdat, 2=gpt-hfsplus, 3=EFI /* @param ptype 0= unknown, 1= gpt-basdat, 2=gpt-hfsplus, 3=EFI
@param flag bit0= isohybrid @param flag bit0= isohybrid
*/ */
static int Xorriso_register_eltorito_gpt(struct XorrisO *xorriso, static int Xorriso_register_eltorito_gpt(struct XorrisO *xorriso,
struct elto_img_par *et_img, struct elto_img_par *et_img,
int ptype, int ptype,
skipping to change at line 1610 skipping to change at line 1620
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
Findjob_get_last_data_file_block(job, high_block, 0); Findjob_get_last_data_file_block(job, high_block, 0);
ex:; ex:;
Findjob_destroy(&job, 0); Findjob_destroy(&job, 0);
return(ret); return(ret);
} }
/* @param flag bit0= do not record but only count /* @param flag bit0= do not record but only count
bit1= as_mkisofs bit1= as_mkisofs
bit2= no sorry messages
*/ */
static int Xorriso_scan_report_lines(struct XorrisO *xorriso, static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
char **et_lines, int et_line_count, char **et_lines, int et_line_count,
char **sa_lines, int sa_line_count, char **sa_lines, int sa_line_count,
char **cmds, int *cmd_count, int flag) char **cmds, int *cmd_count,
char **boot_imgs, int *boot_img_count,
int flag)
{ {
int ret= 0, i, num_count, mkisofs, line_count, idx, et_idx, isohybrid= 0; int ret= 0, i, num_count, mkisofs, line_count, idx, et_idx, isohybrid= 0;
int ptype, gpt_idx, j, pad, mbr_idx; int ptype, gpt_idx, j, pad, mbr_idx;
int efi_boot_part= 0, full_sparc_part= 0, have_sparc_part= 0, fe_dummy= 1; int efi_boot_part= 0, full_sparc_part= 0, have_sparc_part= 0, fe_dummy= 1;
int appended_as_gpt= 0, have_prep= 0, did_sysarea= 0, cared_for_apm= 0; int appended_as_gpt= 0, have_prep= 0, did_sysarea= 0, cared_for_apm= 0;
int cared_for_sparc= 0, have_hfsplus= 0; int cared_for_sparc= 0, have_hfsplus= 0;
int have_sysarea= 0, ptable_killer, imported_iso, have_alpha_ldr_path= 0; int have_sysarea= 0, ptable_killer, imported_iso, have_alpha_ldr_path= 0;
int have_protective_msdos= 0, part_like_isohybrid= 0; int have_protective_msdos= 0, part_like_isohybrid= 0;
#ifdef Not_any_more_because_padding_is_now_after_partitions #ifdef Not_any_more_because_padding_is_now_after_partitions
int appended_partition= 0; int appended_partition= 0;
#endif #endif
int iso_mbr_part_type= -1, iso_gpt_part_idx= -1; int iso_mbr_part_type= -1, iso_gpt_part_idx= -1;
unsigned int prev_pltf= 0; unsigned int prev_pltf= 0;
unsigned long int sa_options= 0, partno, id_tag, perms, start_cyl, num_blocks; unsigned long int sa_options= 0, partno, id_tag, perms, start_cyl;
unsigned long int part_status, part_type, start_block, partition_offset= 0; unsigned long int part_status, part_type, mbr_start_block, mbr_num_blocks;
uint32_t high_block= 0; unsigned long int partition_offset= 0;
uint32_t high_block= 0, indev_blocks;
char name[24], *textpt, *contentpt, *buf= NULL, part_type_text[37]; char name[24], *textpt, *contentpt, *buf= NULL, part_type_text[37];
char **lines= NULL; char **lines= NULL;
double num[8]; double num[8];
char *cat_path= ""; char *cat_path= "";
struct elto_img_par *et_imgs= NULL; struct elto_img_par *et_imgs= NULL;
int elto_count= 0; int elto_count= 0;
uint32_t img_blocks= 0, mbr_parts_end= 0, iso_part_blocks; uint32_t mbr_parts_end= 0, extract_size;
struct FindjoB *job= NULL; struct FindjoB *job= NULL;
struct stat dir_stbuf; struct stat dir_stbuf;
IsoImage *image; IsoImage *image;
char *volid, *crt, *mdt, *ext, *eft, uuid[17], *uuid_time; char *volid, *crt, *mdt, *ext, *eft, uuid[17], *uuid_time;
char **app_pseudo_paths= NULL; char **app_pseudo_paths= NULL;
struct tm tm_erg; struct tm tm_erg;
int was_force_bootable= 0; int was_force_bootable= 0, have_mbr_force_bootable= 0;
uint64_t gpt_bheader_block= 0; uint64_t gpt_bheader_block= 0, start_block, num_blocks;
uint64_t img_blocks= 0, iso_part_blocks;
struct mbr_par { struct mbr_par {
uint8_t ptype; uint8_t ptype;
uint64_t start_block; uint64_t start_block;
uint64_t block_count; uint64_t block_count;
int appended; int appended;
int has_path; int has_path;
}; };
struct mbr_par *mbrpts= NULL; struct mbr_par *mbrpts= NULL;
int mbr_count= 0; int mbr_count= 0;
skipping to change at line 1680 skipping to change at line 1695
struct apm_par { struct apm_par {
int ptype; /* bit0= type Apple_HFS , bit1= name HFSPLUS_Hybrid */ int ptype; /* bit0= type Apple_HFS , bit1= name HFSPLUS_Hybrid */
char *path; char *path;
}; };
struct apm_par *apms= NULL; struct apm_par *apms= NULL;
int apm_count= 0; int apm_count= 0;
#define Xorriso_record_cmd_linE { \ #define Xorriso_record_cmd_linE { \
ret= Xorriso_record_cmd_line(xorriso, buf, cmds, cmd_count, flag & 1); \ ret= Xorriso_record_cmd_line(xorriso, buf, cmds, cmd_count, flag & 1); \
buf[0]= 0; \
if(ret <= 0) \
goto ex; \
}
#define Xorriso_record_boot_imglinE { \
ret= Xorriso_record_cmd_line(xorriso, buf, boot_imgs, boot_img_count, \
flag & 1); \
buf[0]= 0; \
if(ret <= 0) \ if(ret <= 0) \
goto ex; \ goto ex; \
} }
/* 2 exp 19 blocks = 1 GiB */
#define Xorriso_max_endless_uefi_sizE (1 << 19)
mkisofs= !!(flag & 2); mkisofs= !!(flag & 2);
imported_iso= (!mkisofs) << 30; imported_iso= (!mkisofs) << 30;
*cmd_count= 0; *cmd_count= 0;
*boot_img_count= 0;
line_count= et_line_count + sa_line_count; line_count= et_line_count + sa_line_count;
if(line_count <= 0) if(line_count <= 0)
{ret= 1; goto ex;} {ret= 1; goto ex;}
Xorriso_alloc_meM(buf, char, 80 + SfileadrL); Xorriso_alloc_meM(buf, char, 80 + SfileadrL);
Xorriso_alloc_meM(lines, char *, line_count); Xorriso_alloc_meM(lines, char *, line_count);
for(i= 0; i < et_line_count; i++) for(i= 0; i < et_line_count; i++)
lines[i]= et_lines[i]; lines[i]= et_lines[i];
for(i= 0; i < sa_line_count; i++) for(i= 0; i < sa_line_count; i++)
lines[i + et_line_count]= sa_lines[i]; lines[i + et_line_count]= sa_lines[i];
skipping to change at line 1721 skipping to change at line 1748
} else if(strcmp(name, "El Torito boot img :") == 0) { } else if(strcmp(name, "El Torito boot img :") == 0) {
if(num[0] > elto_count) if(num[0] > elto_count)
elto_count= num[0]; elto_count= num[0];
} else if(strcmp(name, "PReP boot partition:") == 0) { } else if(strcmp(name, "PReP boot partition:") == 0) {
have_prep= 1; have_prep= 1;
} else if(strcmp(name, "MBR partition :") == 0) { } else if(strcmp(name, "MBR partition :") == 0) {
if(num[0] > mbr_count) if(num[0] > mbr_count)
mbr_count= num[0]; mbr_count= num[0];
if(strcmp(textpt, "0x80 0x00 0 1") == 0)
have_mbr_force_bootable= 1;
} else if(strcmp(name, "GPT partition name :") == 0) { } else if(strcmp(name, "GPT partition name :") == 0) {
if(num[0] > gpt_count) if(num[0] > gpt_count)
gpt_count= num[0]; gpt_count= num[0];
} else if(strcmp(name, "APM partition name :") == 0) { } else if(strcmp(name, "APM partition name :") == 0) {
if(num[0] > apm_count) if(num[0] > apm_count)
apm_count= num[0]; apm_count= num[0];
} else if(strcmp(name, "ISO image size/512 :") == 0) { } else if(strcmp(name, "ISO image size/512 :") == 0) {
skipping to change at line 1744 skipping to change at line 1773
(num[0] == 0 || num[0] == 16)) { (num[0] == 0 || num[0] == 16)) {
partition_offset= num[0]; partition_offset= num[0];
} }
} }
ret= Xorriso_highest_data_block(xorriso, &high_block, 0); ret= Xorriso_highest_data_block(xorriso, &high_block, 0);
if(ret < 0) if(ret < 0)
goto ex; goto ex;
if(ret == 0) if(ret == 0)
high_block = img_blocks - 1; high_block = img_blocks / 4 - 1;
if(elto_count > 0) { if(elto_count > 0) {
Xorriso_alloc_meM(et_imgs, struct elto_img_par, elto_count); Xorriso_alloc_meM(et_imgs, struct elto_img_par, elto_count);
for(et_idx= 0; et_idx < elto_count; et_idx++) { for(et_idx= 0; et_idx < elto_count; et_idx++) {
et_imgs[et_idx].path= NULL; et_imgs[et_idx].path= NULL;
et_imgs[et_idx].ldsiz= -1; et_imgs[et_idx].ldsiz= -1;
} }
Xorriso_alloc_meM(app_pseudo_paths, char *, elto_count); Xorriso_alloc_meM(app_pseudo_paths, char *, elto_count);
for(i= 0; i < elto_count; i++) for(i= 0; i < elto_count; i++)
app_pseudo_paths[i]= NULL; app_pseudo_paths[i]= NULL;
skipping to change at line 1833 skipping to change at line 1862
for(i= 0; i < line_count; i++) { for(i= 0; i < line_count; i++) {
buf[0]= 0; buf[0]= 0;
ret= Xorriso_split_report_line(xorriso, lines[i], 8, name, &contentpt, ret= Xorriso_split_report_line(xorriso, lines[i], 8, name, &contentpt,
num, &num_count, &textpt, 0); num, &num_count, &textpt, 0);
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
if(strcmp(name, "El Torito cat path :") == 0) { if(strcmp(name, "El Torito cat path :") == 0) {
cat_path= textpt; cat_path= textpt;
} else if(strcmp(name, "El Torito catalog :") == 0) {
strcpy(buf, "eltorito_catalog.img/");
Xorriso_add_offset_size(xorriso, buf, ((off_t) num[0]) * 2048,
((off_t) num[1]) * 2048, 0);
Xorriso_record_boot_imglinE
} else if(strcmp(name, "El Torito boot img :") == 0) { } else if(strcmp(name, "El Torito boot img :") == 0) {
/* Platform Id, bootability, emulation, load segment, /* Platform Id, bootability, emulation, load segment,
Hard disk emulation partition type, Load size Hard disk emulation partition type, Load size
*/ */
idx= num[0] - 1; idx= num[0] - 1;
sscanf(contentpt, "%d %s %s %s %x %x %d %lu", sscanf(contentpt, "%d %s %s %s %x %x %d %lu",
&(et_imgs[idx].n), et_imgs[idx].pltf, et_imgs[idx].b, &(et_imgs[idx].n), et_imgs[idx].pltf, et_imgs[idx].b,
et_imgs[idx].emul, &(et_imgs[idx].ld_seg), &(et_imgs[idx].hdpt), et_imgs[idx].emul, &(et_imgs[idx].ld_seg), &(et_imgs[idx].hdpt),
&(et_imgs[idx].ldsiz), &(et_imgs[idx].lba)); &(et_imgs[idx].ldsiz), &(et_imgs[idx].lba));
if(strcmp(et_imgs[idx].pltf, "BIOS") == 0) if(strcmp(et_imgs[idx].pltf, "BIOS") == 0)
skipping to change at line 1859 skipping to change at line 1894
et_imgs[idx].platform_id= 0xef; et_imgs[idx].platform_id= 0xef;
else else
sscanf(et_imgs[idx].pltf, "%x", &(et_imgs[idx].platform_id)); sscanf(et_imgs[idx].pltf, "%x", &(et_imgs[idx].platform_id));
strcpy(et_imgs[idx].boot_image_type, "any"); strcpy(et_imgs[idx].boot_image_type, "any");
et_imgs[idx].boot_info_table= 0; et_imgs[idx].boot_info_table= 0;
et_imgs[idx].grub2_boot_info= 0; et_imgs[idx].grub2_boot_info= 0;
et_imgs[idx].path= et_imgs[idx].id_string= et_imgs[idx].sel_crit= ""; et_imgs[idx].path= et_imgs[idx].id_string= et_imgs[idx].sel_crit= "";
et_imgs[idx].do_gpt_basdat= et_imgs[idx].do_gpt_hfsplus= 0; et_imgs[idx].do_gpt_basdat= et_imgs[idx].do_gpt_hfsplus= 0;
et_imgs[idx].do_apm_hfsplus= 0; et_imgs[idx].do_apm_hfsplus= 0;
et_imgs[idx].extract_size= (et_imgs[idx].ldsiz + 3) / 4;
} else if(strcmp(name, "El Torito img path :") == 0) { } else if(strcmp(name, "El Torito img path :") == 0) {
idx= num[0] - 1; idx= num[0] - 1;
et_imgs[idx].path= textpt; et_imgs[idx].path= textpt;
ret= Xorriso_iso_lstat(xorriso, et_imgs[idx].path, &dir_stbuf, 0);
if(ret == 0) {
extract_size = (dir_stbuf.st_size + 2047) / 2048;
if(extract_size > et_imgs[idx].extract_size)
et_imgs[idx].extract_size= extract_size;
}
} else if(strcmp(name, "El Torito img blks :") == 0) {
idx= num[0] - 1;
if(num[1] > et_imgs[idx].extract_size)
et_imgs[idx].extract_size= num[1];
} else if(strcmp(name, "El Torito img opts :") == 0) { } else if(strcmp(name, "El Torito img opts :") == 0) {
idx= num[0] - 1; idx= num[0] - 1;
if(strstr(textpt, "boot-info-table") != NULL) if(strstr(textpt, "boot-info-table") != NULL)
et_imgs[idx].boot_info_table= 1; et_imgs[idx].boot_info_table= 1;
if(strstr(textpt, "isohybrid-suitable") != NULL) if(strstr(textpt, "isohybrid-suitable") != NULL)
strcpy(et_imgs[idx].boot_image_type, "isolinux"); strcpy(et_imgs[idx].boot_image_type, "isolinux");
if(strstr(textpt, "grub2-boot-info") != NULL) { if(strstr(textpt, "grub2-boot-info") != NULL) {
strcpy(et_imgs[idx].boot_image_type, "grub"); strcpy(et_imgs[idx].boot_image_type, "grub");
et_imgs[idx].grub2_boot_info= 1; et_imgs[idx].grub2_boot_info= 1;
skipping to change at line 1889 skipping to change at line 1936
} else if(strcmp(name, "El Torito sel crit :") == 0) { } else if(strcmp(name, "El Torito sel crit :") == 0) {
idx= num[0] - 1; idx= num[0] - 1;
et_imgs[idx].sel_crit= textpt; et_imgs[idx].sel_crit= textpt;
} else if(strcmp(name, "System area summary:") == 0) { } else if(strcmp(name, "System area summary:") == 0) {
if(strstr(textpt, "protective-msdos-label") != NULL) if(strstr(textpt, "protective-msdos-label") != NULL)
have_protective_msdos= 1; have_protective_msdos= 1;
} else if(strcmp(name, "MBR partition :") == 0) { } else if(strcmp(name, "MBR partition :") == 0) {
sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu", sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu",
&partno, &part_status, &part_type, &start_block, &num_blocks); &partno, &part_status, &part_type, &mbr_start_block,
&mbr_num_blocks);
idx= partno - 1; idx= partno - 1;
mbrpts[idx].ptype= part_type; mbrpts[idx].ptype= part_type;
mbrpts[idx].start_block= start_block; mbrpts[idx].start_block= mbr_start_block;
mbrpts[idx].block_count= num_blocks; mbrpts[idx].block_count= mbr_num_blocks;
if(num_blocks > 0 && start_block + num_blocks > mbr_parts_end) if(mbr_num_blocks > 0 && mbr_start_block + mbr_num_blocks > mbr_parts_end)
mbr_parts_end= start_block + num_blocks; mbr_parts_end= mbr_start_block + mbr_num_blocks;
if(start_block == partition_offset * 4 && if(mbr_start_block == partition_offset * 4 &&
(start_block + num_blocks) >= high_block * 4 && iso_mbr_part_type < 0) (mbr_start_block + mbr_num_blocks) >= high_block * 4 &&
iso_mbr_part_type < 0)
iso_mbr_part_type = part_type; iso_mbr_part_type = part_type;
} else if(strcmp(name, "MBR partition path :") == 0) { } else if(strcmp(name, "MBR partition path :") == 0) {
idx= num[0] - 1; idx= num[0] - 1;
mbrpts[idx].has_path= 1; mbrpts[idx].has_path= 1;
} else if(strcmp(name, "GPT lba range :") == 0) { } else if(strcmp(name, "GPT lba range :") == 0) {
gpt_bheader_block= num[2]; gpt_bheader_block= num[2];
} else if(strcmp(name, "GPT type GUID :") == 0) { } else if(strcmp(name, "GPT type GUID :") == 0) {
skipping to change at line 2004 skipping to change at line 2053
} else if(strcmp(name, "System area summary:") == 0) { } else if(strcmp(name, "System area summary:") == 0) {
if(strstr(textpt, "isohybrid") != NULL) { if(strstr(textpt, "isohybrid") != NULL) {
isohybrid= 1; isohybrid= 1;
if(mkisofs) if(mkisofs)
sprintf(buf, "-isohybrid-mbr "); sprintf(buf, "-isohybrid-mbr ");
else else
sprintf(buf, "-boot_image isolinux system_area="); sprintf(buf, "-boot_image isolinux system_area=");
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s", Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
imported_iso | ptable_killer); imported_iso | ptable_killer);
Xorriso_record_cmd_linE Xorriso_record_cmd_linE
strcpy(buf, "mbr_code_isohybrid.img/");
Xorriso_add_offset_size(xorriso, buf, (off_t) 0, (off_t) 446, 0);
Xorriso_record_boot_imglinE
did_sysarea= 1; did_sysarea= 1;
} }
if(strstr(textpt, "grub2-mbr") != NULL) { if(strstr(textpt, "grub2-mbr") != NULL) {
if(mkisofs) if(mkisofs)
sprintf(buf, "--grub2-mbr "); sprintf(buf, "--grub2-mbr ");
else else
sprintf(buf, "-boot_image grub grub2_mbr="); sprintf(buf, "-boot_image grub grub2_mbr=");
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s", Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
imported_iso | ptable_killer); imported_iso | ptable_killer);
Xorriso_record_cmd_linE Xorriso_record_cmd_linE
strcpy(buf, "mbr_code_grub2.img/");
Xorriso_add_offset_size(xorriso, buf, (off_t) 0, (off_t) 446, 0);
Xorriso_record_boot_imglinE
did_sysarea= 1; did_sysarea= 1;
} }
if(strstr(textpt, "protective-msdos-label") != NULL) { if(strstr(textpt, "protective-msdos-label") != NULL) {
if(mkisofs) if(mkisofs)
sprintf(buf, "--protective-msdos-label"); sprintf(buf, "--protective-msdos-label");
else else
sprintf(buf, "-boot_image any partition_table=on"); sprintf(buf, "-boot_image any partition_table=on");
Xorriso_record_cmd_linE Xorriso_record_cmd_linE
} }
if(strstr(textpt, "cyl-align-off") != NULL) { if(strstr(textpt, "cyl-align-off") != NULL) {
skipping to change at line 2064 skipping to change at line 2119
} else if(strcmp(name, "MBR secs per head :") == 0 && } else if(strcmp(name, "MBR secs per head :") == 0 &&
(num[0] > 0 && num[0] <= 63)) { (num[0] > 0 && num[0] <= 63)) {
if(mkisofs) if(mkisofs)
sprintf(buf, "-partition_sec_hd %.f", num[0]); sprintf(buf, "-partition_sec_hd %.f", num[0]);
else else
sprintf(buf, "-boot_image any partition_sec_hd=%.f", num[0]); sprintf(buf, "-boot_image any partition_sec_hd=%.f", num[0]);
} else if(strcmp(name, "MBR partition :") == 0) { } else if(strcmp(name, "MBR partition :") == 0) {
sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu", sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu",
&partno, &part_status, &part_type, &start_block, &num_blocks); &partno, &part_status, &part_type, &mbr_start_block,
if(num_blocks > 0 && part_type != 0x00 && part_type != 0xee && &mbr_num_blocks);
(iso_part_blocks <= start_block || if(mbr_num_blocks > 0 && part_type != 0x00 && part_type != 0xee &&
(iso_part_blocks <= mbr_start_block ||
(have_protective_msdos && img_blocks == mbr_parts_end && (have_protective_msdos && img_blocks == mbr_parts_end &&
partno > 1))) { partno > 1))) {
if(!appended_as_gpt) { if(!appended_as_gpt) {
sprintf(buf, "-append_partition %lu 0x%lx ", partno, part_type); sprintf(buf, "-append_partition %lu 0x%lx ", partno, part_type);
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) start_block, Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) mbr_start_block,
((uint64_t) start_block) + num_blocks - 1, "d", ((uint64_t) mbr_start_block) + mbr_num_blocks - 1,
imported_iso); "d", imported_iso);
Xorriso_record_cmd_linE
if(partno >= 1 && (int) partno <= mbr_count) if(partno >= 1 && (int) partno <= mbr_count)
mbrpts[partno - 1].appended= 1; mbrpts[partno - 1].appended= 1;
#ifdef Not_any_more_because_padding_is_now_after_partitions #ifdef Not_any_more_because_padding_is_now_after_partitions
appended_partition= 1; appended_partition= 1;
#endif #endif
} }
if(part_type == 0xef) {
sprintf(buf, "mbr_part%lu_efi.img/", partno);
Xorriso_add_offset_size(xorriso, buf, ((off_t) mbr_start_block) * 512,
((off_t) mbr_num_blocks) * 512, 0);
Xorriso_record_boot_imglinE
}
} else if(part_type == 0x41 && have_prep) { } else if(part_type == 0x41 && have_prep) {
if(mkisofs) { if(mkisofs) {
sprintf(buf, "-prep-boot-part "); sprintf(buf, "-prep-boot-part ");
} else { } else {
sprintf(buf, "-boot_image any prep_boot_part="); sprintf(buf, "-boot_image any prep_boot_part=");
} }
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) start_block, Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) mbr_start_block,
((uint64_t) start_block) + num_blocks - 1, "d", ((uint64_t) mbr_start_block) + mbr_num_blocks - 1,
imported_iso); "d", imported_iso);
Xorriso_record_cmd_linE
sprintf(buf, "mbr_part%lu_prep.img/", partno);
Xorriso_add_offset_size(xorriso, buf, ((off_t) mbr_start_block) * 512,
((off_t) mbr_num_blocks) * 512, 0);
Xorriso_record_boot_imglinE
} else if(part_type == 0xef) {
sprintf(buf, "mbr_part%lu_efi.img/", partno);
Xorriso_add_offset_size(xorriso, buf, ((off_t) mbr_start_block) * 512,
((off_t) mbr_num_blocks) * 512, 0);
Xorriso_record_boot_imglinE
} }
if((part_status & 0x80) && !was_force_bootable) { if((part_status & 0x80) && !was_force_bootable) {
was_force_bootable= 1; was_force_bootable= 1;
if(buf[0]) { if(buf[0]) {
Xorriso_record_cmd_linE Xorriso_record_cmd_linE
buf[0]= 0;
} }
if(mkisofs) if(mkisofs)
sprintf(buf, "--mbr-force-bootable"); sprintf(buf, "--mbr-force-bootable");
else else
sprintf(buf, "-boot_image any mbr_force_bootable=on"); sprintf(buf, "-boot_image any mbr_force_bootable=on");
} }
} else if(strcmp(name, "MBR partition path :") == 0) { } else if(strcmp(name, "MBR partition path :") == 0) {
idx= num[0] - 1; idx= num[0] - 1;
if(mbrpts[idx].ptype == 0x41) { if(mbrpts[idx].ptype == 0x41) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Cannot make proposal to mark PReP partition by data file: "); "Cannot make proposal to mark PReP partition by data file: ");
Text_shellsafe(textpt, xorriso->info_text, 1); Text_shellsafe(textpt, xorriso->info_text, 1);
if(!(flag & 1)) if(!(flag & 5))
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
continue; continue;
} }
ptype= 0; ptype= 0;
if(mbrpts[idx].ptype == 0xef) if(mbrpts[idx].ptype == 0xef)
ptype= 3; ptype= 3;
ret= Xorriso_search_eltorito_path(xorriso, et_imgs, elto_count, ret= Xorriso_search_eltorito_path(xorriso, et_imgs, elto_count,
textpt, ptype, textpt, ptype,
&et_idx, &efi_boot_part, !!isohybrid); &et_idx, &efi_boot_part, !!isohybrid);
if(ret <= 0) { if(ret <= 0) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Cannot make proposal to mark data file as MBR partition without being an El Torito boot image : "); "Cannot make proposal to mark data file as MBR partition without being an El Torito boot image : ");
Text_shellsafe(textpt, xorriso->info_text, 1); Text_shellsafe(textpt, xorriso->info_text, 1);
if(!(flag & 1)) if(!(flag & 5))
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
} else { } else {
for(gpt_idx= 0; gpt_idx < gpt_count; gpt_idx++) { for(gpt_idx= 0; gpt_idx < gpt_count; gpt_idx++) {
if(gpts[gpt_idx].path != NULL) if(gpts[gpt_idx].path != NULL)
if(strcmp(gpts[gpt_idx].path, textpt) == 0) if(strcmp(gpts[gpt_idx].path, textpt) == 0)
break; break;
} }
if(gpt_idx >= gpt_count) { if(gpt_idx >= gpt_count) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Cannot make proposal to mark data file as MBR partition withou t being in GPT : "); "Cannot make proposal to mark data file as MBR partition withou t being in GPT : ");
Text_shellsafe(textpt, xorriso->info_text, 1); Text_shellsafe(textpt, xorriso->info_text, 1);
if(!(flag & 1)) if(!(flag & 5))
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
} }
} }
} else if(strcmp(name, "GPT disk GUID :") == 0) { } else if(strcmp(name, "GPT disk GUID :") == 0) {
/* >>> ??? need command to set disk GUID */; /* >>> ??? need command to set disk GUID */;
} else if(strcmp(name, "GPT partition name :") == 0) { } else if(strcmp(name, "GPT partition name :") == 0) {
skipping to change at line 2165 skipping to change at line 2237
} else if(strcmp(name, "GPT partition path :") == 0) { } else if(strcmp(name, "GPT partition path :") == 0) {
idx= num[0] - 1; idx= num[0] - 1;
ret= Xorriso_search_eltorito_path(xorriso, et_imgs, elto_count, ret= Xorriso_search_eltorito_path(xorriso, et_imgs, elto_count,
textpt, gpts[idx].ptype, textpt, gpts[idx].ptype,
&et_idx, &efi_boot_part, !!isohybrid); &et_idx, &efi_boot_part, !!isohybrid);
if(ret <= 0) { if(ret <= 0) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Cannot make proposal to mark data file as GPT partition : "); "Cannot make proposal to mark data file as GPT partition : ");
Text_shellsafe(textpt, xorriso->info_text, 1); Text_shellsafe(textpt, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); if(!(flag & 5))
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
} }
} else if(strcmp(name, "GPT start and size :") == 0) { } else if(strcmp(name, "GPT start and size :") == 0) {
idx= num[0] - 1; idx= num[0] - 1;
if(gpts[idx].ptype == 3) if(gpts[idx].ptype == 3)
part_type= 0xef; part_type= 0xef;
else else
part_type= 0xcd; part_type= 0xcd;
if(high_block * 4 < num[1] && num[2] > 0 && !gpts[idx].is_gap) { if(high_block * 4 < num[1] && num[2] > 0 && !gpts[idx].is_gap) {
skipping to change at line 2201 skipping to change at line 2274
appended_as_gpt= 2; appended_as_gpt= 2;
Xorriso__format_guid(gpts[idx].type_guid, part_type_text, 0); Xorriso__format_guid(gpts[idx].type_guid, part_type_text, 0);
} else { } else {
sprintf(part_type_text, "0x%lx", part_type); sprintf(part_type_text, "0x%lx", part_type);
} }
sprintf(buf, "-append_partition %d %s ", idx + 1, part_type_text); sprintf(buf, "-append_partition %d %s ", idx + 1, part_type_text);
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) num[1], Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) num[1],
(uint64_t) (num[1] + num[2] - 1.0), "d", (uint64_t) (num[1] + num[2] - 1.0), "d",
imported_iso); imported_iso);
Xorriso_record_cmd_linE Xorriso_record_cmd_linE
buf[0]= 0;
#ifdef Not_any_more_because_padding_is_now_after_partitions #ifdef Not_any_more_because_padding_is_now_after_partitions
appended_partition= 1; appended_partition= 1;
#endif #endif
} }
/* Check for isohybri-ish MBR and GPT mix */ /* Check for isohybri-ish MBR and GPT mix */
if(mbr_count == 1 && mbrpts[0].ptype == 0xee && have_protective_msdos) { if((mbr_count == 1 || (mbr_count == 2 && have_mbr_force_bootable)) &&
/* real GPT is not -part_like_isohybrid */ mbrpts[0].ptype == 0xee && have_protective_msdos) {
/* real GPT (+/- mbr_force_bootable) is not -part_like_isohybrid */
ret= 0; ret= 0;
} else { } else {
ret= Xorriso_search_eltorito_lba(xorriso, et_imgs, elto_count, ret= Xorriso_search_eltorito_lba(xorriso, et_imgs, elto_count,
(unsigned int) (num[1] / 4.0), (unsigned int) (num[1] / 4.0),
&et_idx, 0); &et_idx, 0);
} }
if(ret > 0) { if(ret > 0) {
if(!(et_imgs[et_idx].do_gpt_basdat || if(!(et_imgs[et_idx].do_gpt_basdat ||
et_imgs[et_idx].do_gpt_hfsplus || et_imgs[et_idx].do_gpt_hfsplus ||
part_like_isohybrid)) { part_like_isohybrid)) {
if(mkisofs) if(mkisofs)
sprintf(buf, "-part_like_isohybrid"); sprintf(buf, "-part_like_isohybrid");
else else
sprintf(buf, "-boot_image any part_like_isohybrid=on"); sprintf(buf, "-boot_image any part_like_isohybrid=on");
Xorriso_record_cmd_linE Xorriso_record_cmd_linE
buf[0]= 0;
part_like_isohybrid= 1; part_like_isohybrid= 1;
appended_as_gpt= 0; appended_as_gpt= 0;
} }
/* mark el torito for -isohybrid-gpt-... */ /* mark el torito for -isohybrid-gpt-... */
Xorriso_register_eltorito_gpt(xorriso, et_imgs + et_idx, Xorriso_register_eltorito_gpt(xorriso, et_imgs + et_idx,
gpts[idx].ptype, &efi_boot_part, gpts[idx].ptype, &efi_boot_part,
&fe_dummy, 1); &fe_dummy, 1);
} }
} else if(gpts[idx].ptype == 3 && gpts[idx].has_path == 0 && } else if(gpts[idx].ptype == 3 && gpts[idx].has_path == 0 &&
img_blocks >= num[1] + num[2] && !efi_boot_part) { img_blocks >= num[1] + num[2] && !efi_boot_part) {
if(mkisofs) if(mkisofs)
sprintf(buf, "-efi-boot-part "); sprintf(buf, "-efi-boot-part ");
else else
sprintf(buf, "-boot_image any efi_boot_part="); sprintf(buf, "-boot_image any efi_boot_part=");
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) num[1], Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) num[1],
(uint64_t) (num[1] + num[2] - 1.0), "d", (uint64_t) (num[1] + num[2] - 1.0), "d",
imported_iso); imported_iso);
efi_boot_part= 2; efi_boot_part= 2;
Xorriso_record_cmd_linE
}
if(gpts[idx].ptype == 2 &&
(img_blocks / 2 > num[2] || num[1] >= img_blocks)) {
/* Obviously not a HFS+ tree covering the ISO */
sprintf(buf, "gpt_part%d_hfsplus.img/", idx + 1);
Xorriso_add_offset_size(xorriso, buf, ((off_t) num[1]) * 512,
((off_t) num[2]) * 512, 0);
Xorriso_record_boot_imglinE
} else if(gpts[idx].ptype == 3) {
sprintf(buf, "gpt_part%d_efi.img/", idx + 1);
Xorriso_add_offset_size(xorriso, buf, ((off_t) num[1]) * 512,
((off_t) num[2]) * 512, 0);
Xorriso_record_boot_imglinE
} }
} else if(strcmp(name, "APM block size :") == 0) { } else if(strcmp(name, "APM block size :") == 0) {
if(mkisofs) if(mkisofs)
sprintf(buf, "-apm-block-size %.f", num[0]); sprintf(buf, "-apm-block-size %.f", num[0]);
else else
sprintf(buf, "-boot_image any apm_block_size=%.f", num[0]); sprintf(buf, "-boot_image any apm_block_size=%.f", num[0]);
} else if(strcmp(name, "APM partition name :") == 0) { } else if(strcmp(name, "APM partition name :") == 0) {
skipping to change at line 2289 skipping to change at line 2375
/* >>> Read byte 1024 and 1025 after partition start /* >>> Read byte 1024 and 1025 after partition start
Must be {'H', '+'} (0x482b big endian) Must be {'H', '+'} (0x482b big endian)
*/; */;
/* ??? >>> Do this recognition in libisofs ? */ /* ??? >>> Do this recognition in libisofs ? */
if(mkisofs) if(mkisofs)
sprintf(buf, "-hfsplus"); sprintf(buf, "-hfsplus");
else else
sprintf(buf, "-hfsplus on"); sprintf(buf, "-hfsplus on");
Xorriso_record_cmd_linE Xorriso_record_cmd_linE
buf[0]= 0;
/* Report commands for blessings and creator-type */ /* Report commands for blessings and creator-type */
ret= Findjob_new(&job, "/", 0); ret= Findjob_new(&job, "/", 0);
if(ret <= 0) { if(ret <= 0) {
Xorriso_no_findjob(xorriso, "xorriso", 0); Xorriso_no_findjob(xorriso, "xorriso", 0);
{ret= -1; goto ex;} {ret= -1; goto ex;}
} }
Findjob_set_action_target(job, 53, NULL, 0); Findjob_set_action_target(job, 53, NULL, 0);
xorriso->show_hfs_cmd_count= *cmd_count; xorriso->show_hfs_cmd_count= *cmd_count;
xorriso->show_hfs_cmds= cmds; xorriso->show_hfs_cmds= cmds;
skipping to change at line 2346 skipping to change at line 2431
} else } else
sprintf(buf, "-boot_image grub grub2_sparc_core="); sprintf(buf, "-boot_image grub grub2_sparc_core=");
Text_shellsafe(textpt, buf, 1); Text_shellsafe(textpt, buf, 1);
cared_for_sparc= 1; cared_for_sparc= 1;
} else if(strcmp(name, "SUN SPARC partition:") == 0) { } else if(strcmp(name, "SUN SPARC partition:") == 0) {
have_sparc_part= 1; have_sparc_part= 1;
partno= id_tag= perms= num_blocks= 0; partno= id_tag= perms= num_blocks= 0;
start_cyl= 0xffffffff; start_cyl= 0xffffffff;
sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu", sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu",
&partno, &id_tag, &perms, &start_cyl, &num_blocks); &partno, &id_tag, &perms, &start_cyl, &mbr_num_blocks);
if(partno > 0 && partno < 9 && start_cyl == 0 && if(partno > 0 && partno < 9 && start_cyl == 0 &&
num_blocks >= img_blocks - 600 && num_blocks <= img_blocks && mbr_num_blocks >= img_blocks - 600 && mbr_num_blocks <= img_blocks &&
((partno == 1 && id_tag == 4) || (partno > 1 && id_tag == 2))) ((partno == 1 && id_tag == 4) || (partno > 1 && id_tag == 2)))
full_sparc_part|= (1 << (partno - 1)); full_sparc_part|= (1 << (partno - 1));
} else if(strcmp(name, "PALO header version:") == 0) { } else if(strcmp(name, "PALO header version:") == 0) {
if(mkisofs) if(mkisofs)
sprintf(buf, "-hppa-hdrversion %.f", num[0]); sprintf(buf, "-hppa-hdrversion %.f", num[0]);
else else
sprintf(buf, "-boot_image any hppa_hdrversion=%.f", num[0]); sprintf(buf, "-boot_image any hppa_hdrversion=%.f", num[0]);
} else if(strcmp(name, "HP-PA cmdline :") == 0) { } else if(strcmp(name, "HP-PA cmdline :") == 0) {
skipping to change at line 2397 skipping to change at line 2482
if(mkisofs) if(mkisofs)
sprintf(buf, "-hppa-bootloader "); sprintf(buf, "-hppa-bootloader ");
else else
sprintf(buf, "-boot_image any hppa_bootloader="); sprintf(buf, "-boot_image any hppa_bootloader=");
Text_shellsafe(textpt, buf, 1); Text_shellsafe(textpt, buf, 1);
} else if(strcmp(name, "DEC Alpha ldr adr :") == 0) { } else if(strcmp(name, "DEC Alpha ldr adr :") == 0) {
if(!have_alpha_ldr_path) { if(!have_alpha_ldr_path) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Cannot enable DEC Alpha boot loader because it is not a data fil e in the ISO filesystem"); "Cannot enable DEC Alpha boot loader because it is not a data fil e in the ISO filesystem");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); if(!(flag & 5))
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
} }
} else if(strcmp(name, "DEC Alpha ldr path :") == 0) { } else if(strcmp(name, "DEC Alpha ldr path :") == 0) {
if(mkisofs) if(mkisofs)
sprintf(buf, "-alpha-boot "); sprintf(buf, "-alpha-boot ");
else else
sprintf(buf, "-boot_image any alpha_boot="); sprintf(buf, "-boot_image any alpha_boot=");
Text_shellsafe(textpt, buf, 1); Text_shellsafe(textpt, buf, 1);
} }
skipping to change at line 2446 skipping to change at line 2532
did_sysarea= 1; did_sysarea= 1;
for(i= 2; i <= 8; i++) { for(i= 2; i <= 8; i++) {
sprintf(buf, "-append_partition %d 0x00 .", i); sprintf(buf, "-append_partition %d 0x00 .", i);
Xorriso_record_cmd_linE Xorriso_record_cmd_linE
} }
} }
cared_for_sparc= 1; cared_for_sparc= 1;
} else if(!cared_for_sparc) { } else if(!cared_for_sparc) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Cannot enable SUN Disk Label because of non-trivial partition layout"); "Cannot enable SUN Disk Label because of non-trivial partition layout");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); if(!(flag & 5))
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
} }
} }
if(have_sysarea && !did_sysarea) { if(have_sysarea && !did_sysarea) {
/* Zeroize old partition tables from -indev */ /* Zeroize old partition tables from -indev */
if(mkisofs) if(mkisofs)
sprintf(buf, "-G "); sprintf(buf, "-G ");
else else
sprintf(buf, "-boot_image any system_area="); sprintf(buf, "-boot_image any system_area=");
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s", Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
imported_iso | ptable_killer); imported_iso | ptable_killer);
Xorriso_record_cmd_linE Xorriso_record_cmd_linE
did_sysarea= 1; did_sysarea= 1;
} }
if(have_sysarea) {
strcpy(buf, "systemarea.img/");
Xorriso_add_offset_size(xorriso, buf, (off_t) 0, (off_t) 16 * 2048, 0);
Xorriso_record_boot_imglinE
}
if(iso_mbr_part_type >= 0) { if(iso_mbr_part_type >= 0) {
if(mkisofs) if(mkisofs)
sprintf(buf, "-iso_mbr_part_type 0x%2.2x", sprintf(buf, "-iso_mbr_part_type 0x%2.2x",
(unsigned int) iso_mbr_part_type); (unsigned int) iso_mbr_part_type);
else else
sprintf(buf, "-boot_image any iso_mbr_part_type=0x%2.2x", sprintf(buf, "-boot_image any iso_mbr_part_type=0x%2.2x",
(unsigned int) iso_mbr_part_type); (unsigned int) iso_mbr_part_type);
Xorriso_record_cmd_linE Xorriso_record_cmd_linE
} else if(iso_gpt_part_idx >= 0) { } else if(iso_gpt_part_idx >= 0) {
skipping to change at line 2505 skipping to change at line 2597
sprintf(buf, "-boot_image any cat_path="); sprintf(buf, "-boot_image any cat_path=");
Text_shellsafe(cat_path, buf, 1); Text_shellsafe(cat_path, buf, 1);
} else { } else {
if(mkisofs) if(mkisofs)
sprintf(buf, "--boot-catalog-hide"); sprintf(buf, "--boot-catalog-hide");
else else
sprintf(buf, "-boot_image any cat_hidden=on"); sprintf(buf, "-boot_image any cat_hidden=on");
} }
Xorriso_record_cmd_linE Xorriso_record_cmd_linE
for(idx= 0; idx < elto_count; idx++) { for(idx= 0; idx < elto_count; idx++) {
if(strcmp(et_imgs[idx].pltf, "UEFI") == 0 &&
et_imgs[idx].extract_size <= 0) {
ret= Xorriso_obtain_indev_readsize(xorriso, &indev_blocks, 0);
if(ret > 0) {
if(indev_blocks > et_imgs[idx].lba &&
indev_blocks - et_imgs[idx].lba <= Xorriso_max_endless_uefi_sizE)
et_imgs[idx].extract_size= indev_blocks - et_imgs[idx].lba;
}
if(et_imgs[idx].extract_size <= 0)
continue;
}
sprintf(buf, "eltorito_img%d_", idx + 1);
for(j= 0; j < 4 && et_imgs[idx].pltf[j] != 0; j++) {
buf[strlen(buf) + 1]= 0;
buf[strlen(buf)]= tolower(et_imgs[idx].pltf[j]);
}
strcat(buf, ".img/");
Xorriso_add_offset_size(xorriso, buf, ((off_t) et_imgs[idx].lba) * 2048,
((off_t) et_imgs[idx].extract_size) * 2048, 0);
Xorriso_record_boot_imglinE
if(et_imgs[idx].ld_seg != 0 && et_imgs[idx].ld_seg != 0x07c0) { if(et_imgs[idx].ld_seg != 0 && et_imgs[idx].ld_seg != 0x07c0) {
if(!(flag & 1)) { if(!(flag & 5)) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Cannot enable EL Torito boot image #%d because its Load Segment i s neither 0x0 nor 0x7c0", "Cannot enable EL Torito boot image #%d because its Load Segment i s neither 0x0 nor 0x7c0",
idx + 1); idx + 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
} }
continue; continue;
} }
if(idx > 0) { if(idx > 0) {
if(mkisofs) if(mkisofs)
sprintf(buf, "-eltorito-alt-boot"); sprintf(buf, "-eltorito-alt-boot");
else else
sprintf(buf, "-boot_image any next"); sprintf(buf, "-boot_image any next");
Xorriso_record_cmd_linE Xorriso_record_cmd_linE
} }
if(et_imgs[idx].path[0] == 0) { if(et_imgs[idx].path[0] == 0) {
/* >>> need way to eploit El Torito img blks : */;
/* Check whether appended partition */; /* Check whether appended partition */;
for(i= 0; i < mbr_count; i++) for(i= 0; i < mbr_count; i++)
if((mbrpts[i].appended || !mbrpts[i].has_path) && if((mbrpts[i].appended || !mbrpts[i].has_path) &&
mbrpts[i].start_block == ((uint64_t) et_imgs[idx].lba) * 4 && mbrpts[i].start_block == ((uint64_t) et_imgs[idx].lba) * 4 &&
(mbrpts[i].block_count == (uint64_t) et_imgs[idx].ldsiz || (mbrpts[i].block_count == (uint64_t) et_imgs[idx].ldsiz ||
et_imgs[idx].ldsiz == 0 || et_imgs[idx].ldsiz == 1)) et_imgs[idx].ldsiz == 0 || et_imgs[idx].ldsiz == 1))
break; break;
if (i < mbr_count) { if (i < mbr_count) {
if(!mbrpts[i].appended) { if(!mbrpts[i].appended) {
mbrpts[i].appended= 1; mbrpts[i].appended= 1;
skipping to change at line 2576 skipping to change at line 2686
} }
if (i < gpt_count) { if (i < gpt_count) {
sprintf(app_pseudo_paths[idx], sprintf(app_pseudo_paths[idx],
"--interval:appended_partition_%d_start_%lus_size_%lud:all::", "--interval:appended_partition_%d_start_%lus_size_%lud:all::",
i + 1, i + 1,
(unsigned long) et_imgs[idx].lba, (unsigned long) et_imgs[idx].lba,
(unsigned long) gpts[i].block_count); (unsigned long) gpts[i].block_count);
et_imgs[idx].path= app_pseudo_paths[idx]; et_imgs[idx].path= app_pseudo_paths[idx];
} }
} }
if (et_imgs[idx].path[0] == 0) { if (et_imgs[idx].path[0] == 0) {
if(!(flag & 1)) {
/* >>> need way to exploit .extract_size by cutting out from ISO */;
}
if (et_imgs[idx].path[0] == 0) {
if(!(flag & 5)) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Cannot enable EL Torito boot image #%d because it is not a data f ile in the ISO filesystem", "Cannot enable EL Torito boot image #%d because it is not a data f ile in the ISO filesystem",
idx + 1); idx + 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
} }
buf[0]= 0; buf[0]= 0;
continue; continue;
} }
} }
if(et_imgs[idx].platform_id != 0xef) { if(et_imgs[idx].platform_id != 0xef) {
skipping to change at line 2690 skipping to change at line 2807
if(et_imgs[idx].do_apm_hfsplus) { if(et_imgs[idx].do_apm_hfsplus) {
if(mkisofs) if(mkisofs)
sprintf(buf, "-isohybrid-apm-hfsplus"); sprintf(buf, "-isohybrid-apm-hfsplus");
else else
sprintf(buf, "-boot_image isolinux partition_entry=apm_hfsplus"); sprintf(buf, "-boot_image isolinux partition_entry=apm_hfsplus");
Xorriso_record_cmd_linE Xorriso_record_cmd_linE
} }
} }
after_el_torito: after_el_torito:
if((apm_count > 0 && !cared_for_apm) && !(flag & 1)) { if((apm_count > 0 && !cared_for_apm) && !(flag & 5)) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Cannot make proposal to produce APM of loaded image"); "Cannot make proposal to produce APM of loaded image");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
} }
#ifdef Not_any_more_because_padding_is_now_after_partitions #ifdef Not_any_more_because_padding_is_now_after_partitions
if(appended_partition) { if(appended_partition) {
if(mkisofs) if(mkisofs)
sprintf(buf, "-no-pad"); sprintf(buf, "-no-pad");
skipping to change at line 2727 skipping to change at line 2844
if(app_pseudo_paths[i] != NULL) if(app_pseudo_paths[i] != NULL)
Xorriso_free_meM(app_pseudo_paths[i]); Xorriso_free_meM(app_pseudo_paths[i]);
Xorriso_free_meM(app_pseudo_paths); Xorriso_free_meM(app_pseudo_paths);
} }
Xorriso_free_meM(et_imgs); Xorriso_free_meM(et_imgs);
Xorriso_free_meM(lines); Xorriso_free_meM(lines);
Xorriso_free_meM(buf); Xorriso_free_meM(buf);
return(ret); return(ret);
#undef Xorriso_record_cmd_linE #undef Xorriso_record_cmd_linE
#undef Xorriso_record_boot_imglinE
#undef Xorriso_max_endless_uefi_sizE
} }
/* @param flag bit0= currently not significant: /* @param flag bit0= currently not significant:
report is about El Torito rather than System Area report is about El Torito rather than System Area
bit1= report -as mkisofs options bit1= report -as mkisofs options in cmds
bit15= dispose cmds bit2= no sorry messages
bit15= dispose cmds and boot_imgs
*/ */
static int Xorriso_report_to_cmd(struct XorrisO *xorriso, static int Xorriso_report_to_cmd(struct XorrisO *xorriso,
char **et_lines, int et_line_count, char **et_lines, int et_line_count,
char **sa_lines, int sa_line_count, char **sa_lines, int sa_line_count,
char ***cmds, int *cmd_count, int flag) char ***cmds, int *cmd_count,
char ***boot_imgs, int *boot_img_count,
int flag)
{ {
int ret= 0, i; int ret= 0, i;
if(flag & (1 << 15)) if(flag & (1 << 15))
{ret= 1; goto ex;} {ret= 1; goto ex;}
*cmds= NULL; *cmds= NULL;
*cmd_count= 0; *cmd_count= 0;
/* Count commands */ /* Count commands */
ret= Xorriso_scan_report_lines(xorriso, et_lines, et_line_count, ret= Xorriso_scan_report_lines(xorriso, et_lines, et_line_count,
sa_lines, sa_line_count, *cmds, cmd_count, sa_lines, sa_line_count, *cmds, cmd_count,
1 | (flag & 2)); *boot_imgs, boot_img_count,
1 | (flag & 6));
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
if(*cmd_count <= 0) if(*cmd_count <= 0 && *boot_img_count <= 0)
{ret= 2; goto ex;} {ret= 2; goto ex;}
Xorriso_alloc_meM(*cmds, char *, *cmd_count); if(*cmd_count > 0) {
for(i= 0; i < *cmd_count; i++) Xorriso_alloc_meM(*cmds, char *, *cmd_count);
(*cmds)[i]= NULL; for(i= 0; i < *cmd_count; i++)
(*cmds)[i]= NULL;
}
if(*boot_img_count > 0) {
Xorriso_alloc_meM(*boot_imgs, char *, *boot_img_count);
for(i= 0; i < *boot_img_count; i++)
(*boot_imgs)[i]= NULL;
}
/* Record commands */ /* Record commands */
ret= Xorriso_scan_report_lines(xorriso, et_lines, et_line_count, ret= Xorriso_scan_report_lines(xorriso, et_lines, et_line_count,
sa_lines, sa_line_count, *cmds, cmd_count, sa_lines, sa_line_count, *cmds, cmd_count,
flag & 2); *boot_imgs, boot_img_count,
flag & 6);
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
ret= 1; ret= 1;
ex: ex:
if(ret <= 0 || (flag & (1 << 15))) { if(ret <= 0 || (flag & (1 << 15))) {
if(*cmds != NULL) { if(*cmds != NULL) {
for(i= 0; i < *cmd_count; i++) for(i= 0; i < *cmd_count; i++)
if((*cmds)[i] != NULL) if((*cmds)[i] != NULL)
Xorriso_free_meM((*cmds)[i]); Xorriso_free_meM((*cmds)[i]);
Xorriso_free_meM(*cmds); Xorriso_free_meM(*cmds);
*cmds= NULL; *cmds= NULL;
} }
if(*boot_imgs != NULL) {
for(i= 0; i < *boot_img_count; i++)
if((*boot_imgs)[i] != NULL)
Xorriso_free_meM((*boot_imgs)[i]);
Xorriso_free_meM(*boot_imgs);
*boot_imgs= NULL;
}
} }
return(ret); return(ret);
} }
static void Xorriso_report_lines(struct XorrisO *xorriso, static void Xorriso_report_lines(struct XorrisO *xorriso,
char **lines, int line_count) char **lines, int line_count)
{ {
int i; int i;
for(i = 0; i < line_count ; i++) { for(i = 0; i < line_count ; i++) {
skipping to change at line 2798 skipping to change at line 2936
Xorriso_result(xorriso,0); Xorriso_result(xorriso,0);
} }
} }
/* @param flag bit0= report El Torito rather than System Area /* @param flag bit0= report El Torito rather than System Area
bit1= with form "cmd" do not report but rather execute bit1= with form "cmd" do not report but rather execute
*/ */
int Xorriso_report_system_area(struct XorrisO *xorriso, char *form, int flag) int Xorriso_report_system_area(struct XorrisO *xorriso, char *form, int flag)
{ {
int ret, line_count, cmd_count= 0, et_line_count= 0, sa_line_count= 0; int ret, line_count, cmd_count= 0, et_line_count= 0, sa_line_count= 0;
int do_cmd= 0, as_mkisofs= 0, i, bin_count; int do_cmd= 0, as_mkisofs= 0, i, bin_count, boot_img_count= 0;
char **lines = NULL, **et_lines= NULL, **sa_lines= NULL, **cmds= NULL; char **lines = NULL, **et_lines= NULL, **sa_lines= NULL, **cmds= NULL;
char **boot_imgs= NULL;
uint8_t guid[16]; uint8_t guid[16];
IsoImage *image; IsoImage *image;
if(strcmp(form, "cmd") == 0 || strcmp(form, "as_mkisofs") == 0 || (flag & 2)) if(strcmp(form, "cmd") == 0 || strcmp(form, "as_mkisofs") == 0 || (flag & 2))
do_cmd= 1; do_cmd= 1;
if(strcmp(form, "as_mkisofs") == 0) if(strcmp(form, "as_mkisofs") == 0)
as_mkisofs= 1; as_mkisofs= 1;
if(strcmp(form, "help") == 0) { if(strcmp(form, "help") == 0) {
if(flag & 1) if(flag & 1)
skipping to change at line 2844 skipping to change at line 2983
ret= iso_image_report_el_torito(image, &et_lines, &et_line_count, 0); ret= iso_image_report_el_torito(image, &et_lines, &et_line_count, 0);
if(ret < 0) if(ret < 0)
goto ex; goto ex;
if(do_cmd || !(flag & 1)) if(do_cmd || !(flag & 1))
ret= iso_image_report_system_area(image, &sa_lines, &sa_line_count, 0); ret= iso_image_report_system_area(image, &sa_lines, &sa_line_count, 0);
if(ret < 0) if(ret < 0)
goto ex; goto ex;
if(do_cmd) { if(do_cmd) {
ret= Xorriso_report_to_cmd(xorriso, et_lines, et_line_count, ret= Xorriso_report_to_cmd(xorriso, et_lines, et_line_count,
sa_lines, sa_line_count, &cmds, &cmd_count, sa_lines, sa_line_count, &cmds, &cmd_count,
&boot_imgs, &boot_img_count,
(flag & 1) | (as_mkisofs << 1)); (flag & 1) | (as_mkisofs << 1));
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
} }
} else if(strncmp(form, "gpt_crc_of:", 11) == 0 && !(flag & 1)) { } else if(strncmp(form, "gpt_crc_of:", 11) == 0 && !(flag & 1)) {
ret = Xorriso_gpt_crc(xorriso, form + 11, 0); ret = Xorriso_gpt_crc(xorriso, form + 11, 0);
goto ex; goto ex;
} else if(strcmp(form, "make_guid") == 0 && !(flag & 1)) { } else if(strcmp(form, "make_guid") == 0 && !(flag & 1)) {
ret= Xorriso_make_guid(xorriso, xorriso->result_line, 0); ret= Xorriso_make_guid(xorriso, xorriso->result_line, 0);
if(ret < 0) if(ret < 0)
goto ex; goto ex;
strcat(xorriso->result_line, "\n"); strcat(xorriso->result_line, "\n");
Xorriso_result(xorriso,0); Xorriso_result(xorriso,0);
skipping to change at line 2945 skipping to change at line 3086
0, "NOTE", 0); 0, "NOTE", 0);
ret= 2; goto ex; ret= 2; goto ex;
} }
} else if(do_cmd) { } else if(do_cmd) {
Xorriso_report_lines(xorriso, cmds, cmd_count); Xorriso_report_lines(xorriso, cmds, cmd_count);
} else { } else {
Xorriso_report_lines(xorriso, lines, line_count); Xorriso_report_lines(xorriso, lines, line_count);
} }
ret= 1; ret= 1;
ex:; ex:;
Xorriso_report_to_cmd(xorriso, NULL, 0, NULL, 0, &cmds, &cmd_count, 1 << 15); Xorriso_report_to_cmd(xorriso, NULL, 0, NULL, 0, &cmds, &cmd_count,
&boot_imgs, &boot_img_count, 1 << 15);
if(et_lines != NULL)
iso_image_report_el_torito(NULL, &et_lines, &et_line_count, 1 << 15);
if(sa_lines != NULL)
iso_image_report_system_area(NULL, &sa_lines, &sa_line_count, 1 << 15);
return(ret);
}
/* @param flag bit15= dispose imgs
*/
int Xorriso_list_boot_images(struct XorrisO *xorriso,
char ***imgs, int *img_count, int flag)
{
int ret, cmd_count= 0, et_line_count= 0, sa_line_count= 0, boot_img_count= 0;
char **et_lines= NULL, **sa_lines= NULL, **cmds= NULL, **boot_imgs= NULL;
IsoImage *image;
if(flag & (1 << 15)) {
boot_imgs= *imgs;
boot_img_count= *img_count;
Xorriso_report_to_cmd(xorriso, NULL, 0, NULL, 0, &cmds, &cmd_count,
&boot_imgs, &boot_img_count, 1 << 15);
*imgs= NULL;
*img_count= 0;
return(1);
}
*imgs= NULL;
*img_count= 0;
ret= Xorriso_get_volume(xorriso, &image, 0);
if(ret <= 0)
goto ex;
ret= iso_image_report_el_torito(image, &et_lines, &et_line_count, 0);
if(ret < 0)
goto ex;
ret= iso_image_report_system_area(image, &sa_lines, &sa_line_count, 0);
if(ret < 0)
goto ex;
ret= Xorriso_report_to_cmd(xorriso, et_lines, et_line_count,
sa_lines, sa_line_count, &cmds, &cmd_count,
&boot_imgs, &boot_img_count, 4);
if(ret <= 0)
goto ex;
*imgs= boot_imgs;
*img_count= boot_img_count;
boot_imgs= NULL;
boot_img_count= 0;
ret= 1;
ex:;
Xorriso_report_to_cmd(xorriso, NULL, 0, NULL, 0, &cmds, &cmd_count,
&boot_imgs, &boot_img_count, 1 << 15);
if(et_lines != NULL) if(et_lines != NULL)
iso_image_report_el_torito(NULL, &et_lines, &et_line_count, 1 << 15); iso_image_report_el_torito(NULL, &et_lines, &et_line_count, 1 << 15);
if(sa_lines != NULL) if(sa_lines != NULL)
iso_image_report_system_area(NULL, &sa_lines, &sa_line_count, 1 << 15); iso_image_report_system_area(NULL, &sa_lines, &sa_line_count, 1 << 15);
return(ret); return(ret);
} }
 End of changes. 60 change blocks. 
58 lines changed or deleted 251 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)