A first attempt on making bootable ISO images

This commit is contained in:
2008-09-26 16:14:21 +00:00
parent 1a0346a1a1
commit b2984efc9f
6 changed files with 344 additions and 34 deletions

View File

@ -93,6 +93,8 @@ int Xorriso_read_file_data(struct XorrisO *xorriso, IsoNode *node,
S_ISFIFO(iso_node_get_mode(node)))
#define LIBISO_ISSOCK(node) (iso_node_get_type(node) == LIBISO_SPECIAL && \
S_ISSOCK(iso_node_get_mode(node)))
#define LIBISO_ISBOOT(node) (iso_node_get_type(node) == LIBISO_BOOT)
/* CD specs say one shall not write tracks < 600 kiB */
#define Xorriso_cd_min_track_sizE 300
@ -838,7 +840,7 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
int ret, relax= 0, i, profile, status, num_formats;
int major, minor, micro;
unsigned dummy;
char xorriso_id[256], *img_id, profile_name[80], sfe[5*SfileadrL];
char xorriso_id[256], *img_id, profile_name[80], sfe[5*SfileadrL], *cpt;
struct isoburn_imgen_opts *sopts= NULL;
struct burn_drive_info *dinfo, *source_dinfo;
struct burn_drive *drive, *source_drive;
@ -851,6 +853,8 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
enum burn_disc_status s;
IsoImage *image= NULL;
ElToritoBootImage *bootimg;
enum eltorito_boot_media_type emul_type= ELTORITO_NO_EMUL;
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to write", 2);
@ -916,7 +920,40 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
/* >>> ??? move down to libisoburn ? */
if(image!=NULL && !(flag&1)) {
ret= iso_image_get_boot_image(image, &bootimg, NULL, NULL);
if(xorriso->patch_isolinux_image) {
if(xorriso->boot_image_bin_path[0]) {
/* discard old boot image, set new one */
if(ret == 1)
iso_image_remove_boot_image(image);
if(xorriso->boot_image_emul == 1)
emul_type= ELTORITO_HARD_DISC_EMUL;
else if(xorriso->boot_image_emul == 2)
emul_type= ELTORITO_FLOPPY_EMUL;
if(xorriso->boot_image_cat_path[0] == 0) {
strcpy(xorriso->boot_image_cat_path, xorriso->boot_image_bin_path);
cpt= strrchr(xorriso->boot_image_cat_path, '/');
if(cpt == NULL)
cpt= xorriso->boot_image_cat_path;
else
cpt++;
strcpy(cpt, "boot.cat");
}
ret= iso_image_set_boot_image(image, xorriso->boot_image_bin_path,
emul_type, xorriso->boot_image_cat_path,
&bootimg);
if(ret < 0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, "", ret,
"Error when attaching El-Torito boot image to ISO 9660 image",
0, "FAILURE", 1);
sprintf(xorriso->info_text,
"Could not attach El-Torito boot image to ISO 9660 image");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
{ret= 0; goto ex;}
}
el_torito_set_load_size(bootimg, xorriso->boot_image_load_size / 512);
el_torito_patch_isolinux_image(bootimg);
} else if(xorriso->patch_isolinux_image) {
if(ret==1) {
relax|= isoburn_igopt_allow_full_ascii;
sprintf(xorriso->info_text, "Patching alleged isolinux boot image");
@ -1555,9 +1592,8 @@ int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf,
stbuf->st_mode|= S_IFIFO;
else if(LIBISO_ISSOCK(*node))
stbuf->st_mode|= S_IFSOCK;
/* >>> NG How to represent LIBISO_BOOT ? */
else if(LIBISO_ISBOOT(*node))
stbuf->st_mode|= Xorriso_IFBOOT;
/* >>> With directories this should be : number of subdirs + 2 */
/* >>> ??? How to obtain RR hardlink number for other types ? */
@ -4973,7 +5009,7 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
continue;
link_target[0]= 0;
if((flag&5)==1) { /* -ls_l */
ret= Xorriso_format_ls_l(xorriso, &stbuf, 0);
ret= Xorriso_format_ls_l(xorriso, &stbuf, 1);
if(ret<=0)
continue;
if(LIBISO_ISLNK(node)) {
@ -5109,7 +5145,7 @@ cannot_create_iter:;
ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1);
if(ret<=0)
continue;
ret= Xorriso_format_ls_l(xorriso, &stbuf, 0);
ret= Xorriso_format_ls_l(xorriso, &stbuf, 1);
if(ret<=0)
continue;
}
@ -5890,7 +5926,7 @@ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job,
off_t damage_start, damage_end, size;
int lba_count, *file_end_lbas= NULL, *file_start_lbas= NULL, i;
ret= Findjob_test(job, name, boss_stbuf, stbuf, depth, 0);
ret= Findjob_test(job, name, boss_stbuf, stbuf, depth, 1);
if(ret<=0)
return(ret);