2010-05-15 18:48:10 +00:00
|
|
|
|
|
|
|
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
|
|
|
|
|
2022-04-22 11:32:25 +00:00
|
|
|
Copyright 2007-2022 Thomas Schmitt, <scdbackup@gmx.net>
|
2010-05-15 18:48:10 +00:00
|
|
|
|
|
|
|
Provided under GPL version 2 or later.
|
|
|
|
|
|
|
|
This file contains functions which operate on ISO images and their
|
|
|
|
global properties.
|
|
|
|
*/
|
|
|
|
|
2010-05-16 09:32:14 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
|
|
|
#include "xorriso.h"
|
|
|
|
#include "xorriso_private.h"
|
|
|
|
#include "xorrisoburn.h"
|
|
|
|
|
|
|
|
#include "lib_mgt.h"
|
|
|
|
#include "iso_img.h"
|
|
|
|
#include "iso_tree.h"
|
|
|
|
#include "drive_mgt.h"
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_set_ignore_aclea(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int ret, hflag;
|
|
|
|
IsoImage *volume;
|
|
|
|
|
|
|
|
ret= Xorriso_get_volume(xorriso, &volume, 1);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
hflag= (~xorriso->do_aaip) & 1;
|
|
|
|
if((xorriso->ino_behavior & (1 | 2)) && !(xorriso->do_aaip & (4 | 16)))
|
|
|
|
hflag|= 2;
|
2017-10-23 10:08:16 +00:00
|
|
|
if(xorriso->do_aaip & 1024)
|
|
|
|
hflag|= 8;
|
2010-05-15 18:48:10 +00:00
|
|
|
iso_image_set_ignore_aclea(volume, hflag);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_update_volid(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int gret, sret= 1;
|
|
|
|
|
|
|
|
gret= Xorriso_get_volid(xorriso, xorriso->loaded_volid, 0);
|
|
|
|
if(gret<=0 || (!xorriso->volid_default) || xorriso->loaded_volid[0]==0)
|
|
|
|
sret= Xorriso_set_volid(xorriso, xorriso->volid, 1);
|
|
|
|
return(gret>0 && sret>0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
IsoImage *volset;
|
|
|
|
struct isoburn_read_opts *ropts;
|
|
|
|
struct burn_drive_info *dinfo= NULL;
|
|
|
|
struct burn_drive *drive= NULL;
|
|
|
|
|
|
|
|
if(xorriso->out_drive_handle != NULL) {
|
|
|
|
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
|
|
|
"on attempt to attach volset to drive", 2);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
if(xorriso->in_volset_handle!=NULL) {
|
|
|
|
iso_image_unref((IsoImage *) xorriso->in_volset_handle);
|
|
|
|
xorriso->in_volset_handle= NULL;
|
|
|
|
Sectorbitmap_destroy(&(xorriso->in_sector_map), 0);
|
|
|
|
Xorriso_destroy_di_array(xorriso, 0);
|
|
|
|
Xorriso_destroy_hln_array(xorriso, 0);
|
|
|
|
xorriso->loaded_volid[0]= 0;
|
|
|
|
xorriso->volset_change_pending= 0;
|
2010-06-23 17:54:41 +00:00
|
|
|
xorriso->boot_count= 0;
|
2010-05-15 18:48:10 +00:00
|
|
|
xorriso->no_volset_present= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret= isoburn_ropt_new(&ropts, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
/* Note: no return before isoburn_ropt_destroy() */
|
|
|
|
isoburn_ropt_set_extensions(ropts, isoburn_ropt_pretend_blank);
|
|
|
|
isoburn_ropt_set_input_charset(ropts, xorriso->in_charset);
|
2012-03-11 16:41:10 +00:00
|
|
|
isoburn_ropt_set_data_cache(ropts, 1, 1, 0);
|
2010-05-15 18:48:10 +00:00
|
|
|
isoburn_set_read_pacifier(drive, NULL, NULL);
|
2015-09-17 12:12:41 +00:00
|
|
|
isoburn_ropt_set_truncate_mode(ropts, 1, xorriso->file_name_limit);
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
ret= isoburn_read_image(drive, ropts, &volset);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
isoburn_ropt_destroy(&ropts, 0);
|
|
|
|
if(ret<=0) {
|
|
|
|
sprintf(xorriso->info_text, "Failed to create new empty ISO image object");
|
|
|
|
Xorriso_report_iso_error(xorriso, "", ret, xorriso->info_text, 0, "FATAL",
|
|
|
|
0);
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
xorriso->in_volset_handle= (void *) volset;
|
|
|
|
xorriso->in_sector_map= NULL;
|
|
|
|
Xorriso_update_volid(xorriso, 0);
|
|
|
|
xorriso->volset_change_pending= 0;
|
2010-06-23 17:54:41 +00:00
|
|
|
xorriso->boot_count= 0;
|
2015-12-23 11:18:38 +00:00
|
|
|
xorriso->system_area_clear_loaded=
|
|
|
|
(strcmp(xorriso->system_area_disk_path, "/dev/zero") == 0);
|
2010-05-15 18:48:10 +00:00
|
|
|
xorriso->no_volset_present= 0;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_record_boot_info(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct burn_drive_info *dinfo;
|
|
|
|
struct burn_drive *drive;
|
|
|
|
IsoImage *image;
|
|
|
|
ElToritoBootImage *bootimg;
|
|
|
|
IsoFile *bootimg_node;
|
|
|
|
IsoBoot *bootcat_node;
|
|
|
|
|
|
|
|
xorriso->loaded_boot_bin_lba= -1;
|
|
|
|
xorriso->loaded_boot_cat_path[0]= 0;
|
|
|
|
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
|
|
|
"on attempt to record boot LBAs", 0);
|
|
|
|
if(ret<=0)
|
|
|
|
return(0);
|
|
|
|
image= isoburn_get_attached_image(drive);
|
|
|
|
if(image == NULL)
|
|
|
|
return(0);
|
|
|
|
ret= iso_image_get_boot_image(image, &bootimg,
|
|
|
|
&bootimg_node, &bootcat_node);
|
|
|
|
iso_image_unref(image); /* release obtained reference */
|
|
|
|
if(ret != 1)
|
|
|
|
return(0);
|
|
|
|
if(bootimg_node != NULL)
|
|
|
|
Xorriso__file_start_lba((IsoNode *) bootimg_node,
|
|
|
|
&(xorriso->loaded_boot_bin_lba), 0);
|
|
|
|
if(bootcat_node != NULL)
|
|
|
|
Xorriso_path_from_lba(xorriso, (IsoNode *) bootcat_node, 0,
|
|
|
|
xorriso->loaded_boot_cat_path, 0);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_assert_volid(struct XorrisO *xorriso, int msc1, int flag)
|
|
|
|
{
|
|
|
|
int ret, image_blocks;
|
|
|
|
char volid[33];
|
|
|
|
struct burn_drive_info *dinfo;
|
|
|
|
struct burn_drive *drive;
|
|
|
|
|
|
|
|
if(xorriso->assert_volid[0] == 0)
|
|
|
|
return(1);
|
|
|
|
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
|
|
|
"on attempt to perform -assert_volid", 0);
|
|
|
|
if(ret<=0)
|
|
|
|
return(0);
|
|
|
|
ret= isoburn_read_iso_head(drive, msc1, &image_blocks, volid, 1);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if(ret <= 0) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"-assert_volid: Cannot determine Volume Id at LBA %d.", msc1);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,
|
|
|
|
xorriso->assert_volid_sev, 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
ret= Sregex_match(xorriso->assert_volid, volid, 0);
|
|
|
|
if(ret < 0)
|
|
|
|
return(2);
|
|
|
|
if(ret == 0) {
|
|
|
|
strcpy(xorriso->info_text,
|
|
|
|
"-assert_volid: Volume id does not match pattern: ");
|
|
|
|
Text_shellsafe(xorriso->assert_volid, xorriso->info_text, 1);
|
|
|
|
strcat(xorriso->info_text, " <> ");
|
|
|
|
Text_shellsafe(volid, xorriso->info_text, 1);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,
|
|
|
|
xorriso->assert_volid_sev, 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @return <0 yes , 0 no , <0 error */
|
|
|
|
int Xorriso_is_isohybrid(struct XorrisO *xorriso, IsoFile *bootimg_node,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
unsigned char buf[68];
|
|
|
|
void *data_stream= NULL;
|
|
|
|
|
|
|
|
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, 68, 0);
|
|
|
|
Xorriso_iso_file_close(xorriso, &data_stream, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
return(0);
|
|
|
|
if(buf[64] == 0xfb && buf[65] == 0xc0 && buf[66] == 0x78 && buf[67] == 0x70)
|
|
|
|
return(1);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_image_has_md5(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
IsoImage *image;
|
|
|
|
uint32_t start_lba, end_lba;
|
|
|
|
char md5[16];
|
|
|
|
|
|
|
|
ret= Xorriso_get_volume(xorriso, &image, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
ret= iso_image_get_session_md5(image, &start_lba, &end_lba, md5, 0);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if(ret <= 0)
|
|
|
|
return(0);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const char *un0(const char *text)
|
|
|
|
{
|
|
|
|
if(text == NULL)
|
|
|
|
return("");
|
|
|
|
return(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-09 14:15:40 +00:00
|
|
|
static int Xorriso_report_pvd_time(struct XorrisO *xorriso, char *head,
|
|
|
|
char *pvd_time, int flag)
|
|
|
|
{
|
|
|
|
char *msg, hr[17];
|
|
|
|
int at;
|
|
|
|
|
|
|
|
msg= xorriso->result_line;
|
|
|
|
strncpy(hr, pvd_time, 16);
|
|
|
|
hr[16]= 0;
|
|
|
|
sprintf(msg, "%s %s\n", head, hr);
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
if(pvd_time[16] != 0) {
|
|
|
|
at= abs(pvd_time[16]);
|
|
|
|
sprintf(msg, "%2.2s. Time Zone: %c%-2.2d:%-2.2d\n", head,
|
|
|
|
pvd_time[16] > 0 ? '+' : '-', at / 4, (at - (at / 4) * 4) * 15);
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
int Xorriso_pvd_info(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int ret, msc1= -1, msc2, i;
|
|
|
|
IsoImage *image;
|
|
|
|
struct burn_drive_info *dinfo;
|
|
|
|
struct burn_drive *drive;
|
2013-03-12 19:51:15 +00:00
|
|
|
char *msg, block_head[8], *crt, *mdt, *ext, *eft;
|
2010-05-15 18:48:10 +00:00
|
|
|
off_t head_count;
|
|
|
|
|
|
|
|
msg= xorriso->result_line;
|
|
|
|
ret= Xorriso_get_volume(xorriso, &image, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, "", 16);
|
|
|
|
if(ret > 0) {
|
|
|
|
ret= Xorriso_msinfo(xorriso, &msc1, &msc2, 1 | 4);
|
|
|
|
if(ret<0)
|
|
|
|
return(ret);
|
|
|
|
Xorriso_toc(xorriso, 128);
|
|
|
|
if(msc1 >= 0) {
|
|
|
|
for(i = msc1 + 16; i < msc1 + 32; i++) {
|
|
|
|
ret= burn_read_data(drive, (off_t) i * (off_t) 2048, block_head,
|
|
|
|
(off_t) sizeof(block_head), &head_count, 2);
|
|
|
|
if(ret <= 0) {
|
|
|
|
i= msc1 + 32;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(block_head[0] == 1 && strncmp(block_head + 1, "CD001", 5) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(i < msc1 + 32) {
|
|
|
|
sprintf(msg, "PVD address : %ds\n", i);
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sprintf(msg, "Volume Id : %s\n", un0(iso_image_get_volume_id(image)));
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
sprintf(msg, "Volume Set Id: %s\n", xorriso->volset_id);
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
sprintf(msg, "Publisher Id : %s\n", xorriso->publisher);
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
sprintf(msg, "Preparer Id : %s\n",
|
|
|
|
un0(iso_image_get_data_preparer_id(image)));
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
sprintf(msg, "App Id : %s\n", xorriso->application_id);
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
sprintf(msg, "System Id : %s\n", xorriso->system_id);
|
|
|
|
Xorriso_result(xorriso,0);
|
2010-06-26 11:40:36 +00:00
|
|
|
sprintf(msg, "CopyrightFile: %s\n", xorriso->copyright_file);
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso_result(xorriso,0);
|
2010-06-26 11:40:36 +00:00
|
|
|
sprintf(msg, "Abstract File: %s\n", xorriso->abstract_file);
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso_result(xorriso,0);
|
2010-06-26 11:40:36 +00:00
|
|
|
sprintf(msg, "Biblio File : %s\n", xorriso->biblio_file);
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso_result(xorriso,0);
|
2013-03-12 19:51:15 +00:00
|
|
|
|
|
|
|
ret= iso_image_get_pvd_times(image, &crt, &mdt, &ext, &eft);
|
|
|
|
if(ret != ISO_SUCCESS)
|
2014-02-13 15:41:30 +00:00
|
|
|
crt= mdt= ext= eft= " "; /* Need 17 bytes. Last byte 0. */
|
2014-02-09 14:15:40 +00:00
|
|
|
Xorriso_report_pvd_time(xorriso, "Creation Time:", crt, 0);
|
|
|
|
Xorriso_report_pvd_time(xorriso, "Modif. Time :", mdt, 0);
|
|
|
|
Xorriso_report_pvd_time(xorriso, "Expir. Time :", ext, 0);
|
|
|
|
Xorriso_report_pvd_time(xorriso, "Eff. Time :", eft, 0);
|
2010-05-15 18:48:10 +00:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit0= do not mark image as changed */
|
|
|
|
int Xorriso_set_volid(struct XorrisO *xorriso, char *volid, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
IsoImage *volume;
|
|
|
|
|
|
|
|
if(xorriso->in_volset_handle == NULL)
|
|
|
|
return(2);
|
|
|
|
ret= Xorriso_get_volume(xorriso, &volume, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
2015-04-23 14:24:49 +00:00
|
|
|
if(iso_image_get_volume_id(volume) == NULL ||
|
|
|
|
strcmp(iso_image_get_volume_id(volume), volid) != 0)
|
|
|
|
if(!(flag&1))
|
|
|
|
Xorriso_set_change_pending(xorriso, 1);
|
2010-05-15 18:48:10 +00:00
|
|
|
iso_image_set_volume_id(volume, volid);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
sprintf(xorriso->info_text,"Volume ID: '%s'",iso_image_get_volume_id(volume));
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_get_volid(struct XorrisO *xorriso, char volid[33], int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
IsoImage *volume;
|
|
|
|
|
|
|
|
ret= Xorriso_get_volume(xorriso, &volume, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
strncpy(volid, iso_image_get_volume_id(volume), 32);
|
|
|
|
volid[32]= 0;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
bit0= do only report non-default settings
|
|
|
|
bit1= do only report to fp
|
|
|
|
bit2= is_default
|
|
|
|
bit3= append -boot_image any next
|
2015-09-20 12:51:53 +00:00
|
|
|
bit4= concentrate boot options
|
2016-11-13 10:13:33 +00:00
|
|
|
bit5= override load_size by "full"
|
2010-05-15 18:48:10 +00:00
|
|
|
*/
|
|
|
|
int Xorriso_boot_item_status(struct XorrisO *xorriso, char *cat_path,
|
|
|
|
char *bin_path, int platform_id,
|
|
|
|
int patch_isolinux, int emul, off_t load_size,
|
|
|
|
unsigned char *id_string,
|
|
|
|
unsigned char *selection_crit, char *form,
|
|
|
|
char *filter, FILE *fp, int flag)
|
|
|
|
{
|
|
|
|
int is_default, no_defaults, i, is_default_id= 0, ret;
|
2014-10-28 14:03:42 +00:00
|
|
|
char *line, *bspec= NULL, zeros[28], *partition_entry;
|
2010-05-15 18:48:10 +00:00
|
|
|
off_t file_size;
|
|
|
|
struct stat stbuf;
|
|
|
|
|
2011-05-03 11:50:43 +00:00
|
|
|
Xorriso_alloc_meM(bspec, char, SfileadrL + 80);
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
no_defaults= flag & 1;
|
|
|
|
line= xorriso->result_line;
|
2016-11-13 10:13:33 +00:00
|
|
|
if(flag & 32)
|
|
|
|
load_size= -1;
|
2010-05-15 18:48:10 +00:00
|
|
|
|
2014-03-06 16:45:11 +00:00
|
|
|
if((flag & 16) && bin_path[0] != 0) {
|
2015-09-20 12:51:53 +00:00
|
|
|
/* Concentrate boot options. */
|
2010-05-15 18:48:10 +00:00
|
|
|
memset(zeros, 0, 28);
|
|
|
|
if(memcmp(id_string, zeros, 28) == 0 &&
|
|
|
|
memcmp(selection_crit, zeros, 20) == 0)
|
|
|
|
is_default_id= 1;
|
|
|
|
|
|
|
|
/* -boot_image isolinux dir= ... */
|
|
|
|
bspec[0]= 0;
|
|
|
|
if(strcmp(form, "isolinux") != 0 && strcmp(form, "any") != 0)
|
|
|
|
;
|
|
|
|
else if(strcmp(bin_path, "/isolinux.bin") == 0 &&
|
|
|
|
strcmp(cat_path, "/boot.cat") == 0)
|
|
|
|
strcpy(bspec, "dir=/");
|
|
|
|
else if(strcmp(bin_path, "/isolinux/isolinux.bin") == 0 &&
|
|
|
|
strcmp(cat_path, "/isolinux/boot.cat") == 0)
|
|
|
|
strcpy(bspec, "dir=/isolinux");
|
|
|
|
else if(strcmp(xorriso->boot_image_bin_path,
|
|
|
|
"/boot/isolinux/isolinux.bin") == 0
|
|
|
|
&& strcmp(xorriso->boot_image_cat_path,
|
|
|
|
"/boot/isolinux/boot.cat") == 0)
|
|
|
|
strcpy(bspec, "dir=/boot/isolinux");
|
|
|
|
memset(zeros, 0, 28);
|
2014-10-28 14:03:42 +00:00
|
|
|
if(bspec[0] && platform_id == 0 && (patch_isolinux & 0x3ff) == 1 &&
|
2010-10-12 18:31:54 +00:00
|
|
|
load_size == 2048 && is_default_id && emul == 0) {
|
2010-05-15 18:48:10 +00:00
|
|
|
sprintf(line, "-boot_image isolinux %s\n", bspec);
|
|
|
|
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
2011-05-03 11:50:43 +00:00
|
|
|
{ret= 1; goto ex;};
|
2010-05-15 18:48:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
file_size= 0;
|
2021-05-25 19:59:32 +00:00
|
|
|
if(strncmp(bin_path, "--interval:appended_partition_", 30) == 0) {
|
|
|
|
ret= -1;
|
|
|
|
} else {
|
|
|
|
ret= Xorriso_iso_lstat(xorriso, bin_path, &stbuf, 2 | 4);
|
|
|
|
}
|
2016-11-13 10:13:33 +00:00
|
|
|
if(ret == 0) {
|
2010-05-15 18:48:10 +00:00
|
|
|
file_size= ((stbuf.st_size / (off_t) 512) +
|
|
|
|
!!(stbuf.st_size % (off_t) 512)) * 512;
|
2016-11-13 10:13:33 +00:00
|
|
|
if(flag & 32)
|
|
|
|
load_size= file_size * 512;
|
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
if(platform_id == 0xef && (patch_isolinux & 0x3ff) == 0 &&
|
2016-11-13 10:13:33 +00:00
|
|
|
load_size / 512 == file_size && is_default_id && emul == 0) {
|
2010-05-15 18:48:10 +00:00
|
|
|
sprintf(line, "-boot_image any efi_path=");
|
|
|
|
Text_shellsafe(bin_path, line, 1);
|
|
|
|
strcat(line, "\n");
|
|
|
|
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
2011-05-03 11:50:43 +00:00
|
|
|
{ret= 1; goto ex;};
|
2010-05-15 18:48:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
is_default= (bin_path[0] == 0) || (flag & 4);
|
|
|
|
sprintf(line, "-boot_image %s bin_path=", form);
|
|
|
|
Text_shellsafe(bin_path, line, 1);
|
|
|
|
strcat(line, "\n");
|
|
|
|
if(!(is_default && no_defaults))
|
|
|
|
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
2010-10-12 18:31:54 +00:00
|
|
|
|
|
|
|
is_default= (emul == 0);
|
|
|
|
sprintf(line, "-boot_image %s emul_type=%s\n",
|
|
|
|
form, emul == 2 ? "diskette" : emul == 1 ? "hard_disk" : "no_emulation");
|
|
|
|
if(!(is_default && no_defaults))
|
|
|
|
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
2010-05-15 18:48:10 +00:00
|
|
|
|
|
|
|
is_default= (platform_id == 0 || (flag & 4));
|
|
|
|
sprintf(line, "-boot_image %s platform_id=0x%-2.2x\n", form, platform_id);
|
|
|
|
if(!(is_default && no_defaults))
|
|
|
|
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
|
|
|
|
|
|
|
is_default= ((patch_isolinux & 1) == 0 || bin_path[0] == 0 || (flag & 4));
|
|
|
|
sprintf(line, "-boot_image %s boot_info_table=%s\n",
|
2013-04-13 07:42:18 +00:00
|
|
|
(patch_isolinux & 2) ? "grub" : form,
|
|
|
|
(patch_isolinux & 1) ? "on" : "off");
|
|
|
|
if(!(is_default && no_defaults))
|
|
|
|
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
|
|
|
|
|
|
|
is_default= ((patch_isolinux & 512) == 0 || bin_path[0] == 0 || (flag & 4));
|
|
|
|
sprintf(line, "-boot_image grub grub2_boot_info=%s\n",
|
|
|
|
(patch_isolinux & 512) ? "on" : "off");
|
2010-05-15 18:48:10 +00:00
|
|
|
if(!(is_default && no_defaults))
|
|
|
|
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
|
|
|
|
2016-11-13 10:13:33 +00:00
|
|
|
if(flag & 32) {
|
|
|
|
is_default= 0;
|
|
|
|
sprintf(line, "-boot_image %s load_size=full", form);
|
|
|
|
} else {
|
|
|
|
is_default= (load_size == 2048 || (flag & 4));
|
|
|
|
sprintf(line, "-boot_image %s load_size=%lu\n",
|
|
|
|
form, (unsigned long) load_size);
|
|
|
|
}
|
2010-05-15 18:48:10 +00:00
|
|
|
if(!(is_default && no_defaults))
|
|
|
|
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
|
|
|
|
|
|
|
is_default= 1;
|
|
|
|
if(!(flag & 4))
|
|
|
|
for(i= 0; i < 20; i++)
|
|
|
|
if(selection_crit[i])
|
|
|
|
is_default= 0;
|
|
|
|
sprintf(line, "-boot_image %s sel_crit=", form);
|
|
|
|
for(i= 0; i < 20; i++)
|
|
|
|
sprintf(line + strlen(line), "%-2.2X", (unsigned int) selection_crit[i]);
|
|
|
|
strcat(line, "\n");
|
|
|
|
if(!(is_default && no_defaults))
|
|
|
|
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
|
|
|
|
|
|
|
is_default= 1;
|
|
|
|
if(!(flag & 4))
|
|
|
|
for(i= 0; i < 28; i++)
|
|
|
|
if(id_string[i])
|
|
|
|
is_default= 0;
|
|
|
|
sprintf(line, "-boot_image %s id_string=", form);
|
|
|
|
for(i= 0; i < 28; i++)
|
|
|
|
sprintf(line + strlen(line), "%-2.2X", (unsigned int) id_string[i]);
|
|
|
|
strcat(line, "\n");
|
|
|
|
if(!(is_default && no_defaults))
|
|
|
|
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
2014-10-28 14:03:42 +00:00
|
|
|
|
|
|
|
is_default= 1;
|
|
|
|
partition_entry= "";
|
|
|
|
if((patch_isolinux & 0x0fc) == (1 << 2))
|
|
|
|
partition_entry= "gpt_basdat";
|
|
|
|
else if((patch_isolinux & 0x0fc) == (2 << 2))
|
|
|
|
partition_entry= "gpt_hfsplus";
|
|
|
|
if(partition_entry[0]) {
|
|
|
|
sprintf(line, "-boot_image isolinux partition_entry=%s\n", partition_entry);
|
|
|
|
Xorriso_status_result(xorriso, filter, fp, flag & 2);
|
|
|
|
is_default= 0;
|
|
|
|
}
|
|
|
|
if(patch_isolinux & (1 << 8)) {
|
|
|
|
sprintf(line, "-boot_image isolinux partition_entry=apm_hfsplus\n");
|
|
|
|
Xorriso_status_result(xorriso, filter, fp, flag & 2);
|
|
|
|
is_default= 0;
|
|
|
|
}
|
|
|
|
if(is_default && !no_defaults) {
|
|
|
|
sprintf(line, "-boot_image isolinux partition_entry=off\n");
|
|
|
|
Xorriso_status_result(xorriso, filter, fp, flag & 2);
|
|
|
|
}
|
2010-05-15 18:48:10 +00:00
|
|
|
|
2011-05-03 11:50:43 +00:00
|
|
|
ret= 1;
|
|
|
|
ex:;
|
|
|
|
Xorriso_free_meM(bspec);
|
|
|
|
return(ret);
|
2010-05-15 18:48:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-14 09:11:02 +00:00
|
|
|
int Xorriso_status_hppa(struct XorrisO *xorriso, char *what, char *value,
|
|
|
|
char *filter, FILE *fp, int flag)
|
|
|
|
{
|
|
|
|
char *line;
|
|
|
|
|
|
|
|
line= xorriso->result_line;
|
|
|
|
if(value == NULL)
|
|
|
|
return(1);
|
|
|
|
sprintf(line, "-boot_image any hppa_%s=", what);
|
|
|
|
Text_shellsafe(value, line, 1);
|
|
|
|
strcat(line, "\n");
|
|
|
|
Xorriso_status_result(xorriso, filter, fp, flag & 2);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-18 21:22:23 +00:00
|
|
|
/*
|
|
|
|
bit0= do only report non-default settings
|
|
|
|
bit1= do only report to fp
|
|
|
|
*/
|
2010-11-05 14:46:34 +00:00
|
|
|
int Xorriso_boot_status_non_mbr(struct XorrisO *xorriso, IsoImage *image,
|
|
|
|
char *filter, FILE *fp, int flag)
|
2010-10-13 17:07:05 +00:00
|
|
|
{
|
2014-03-03 20:28:36 +00:00
|
|
|
int i, num_boots, sa_type;
|
|
|
|
char *paths[15], *line;
|
|
|
|
int ret;
|
|
|
|
char num[4];
|
2014-01-14 09:11:02 +00:00
|
|
|
char *cmdline, *bootloader, *kernel_32, *kernel_64, *ramdisk;
|
2010-10-13 17:07:05 +00:00
|
|
|
|
|
|
|
line= xorriso->result_line;
|
|
|
|
|
2010-10-15 11:21:30 +00:00
|
|
|
sa_type= (xorriso->system_area_options & 0xfc) >> 2;
|
2010-11-05 14:46:34 +00:00
|
|
|
if(sa_type == 3) {
|
|
|
|
sprintf(line, "-boot_image any sparc_label=");
|
|
|
|
Text_shellsafe(xorriso->ascii_disc_label, line, 1);
|
|
|
|
strcat(line, "\n");
|
|
|
|
Xorriso_status_result(xorriso, filter, fp, flag & 2);
|
2013-04-13 20:54:04 +00:00
|
|
|
sprintf(line, "-boot_image grub grub2_sparc_core=");
|
|
|
|
Text_shellsafe(xorriso->grub2_sparc_core, line, 1);
|
|
|
|
strcat(line, "\n");
|
|
|
|
Xorriso_status_result(xorriso, filter, fp, flag & 2);
|
2010-11-05 14:46:34 +00:00
|
|
|
return(0);
|
2015-11-09 09:55:32 +00:00
|
|
|
} else if(sa_type == 1 || sa_type == 2) {
|
2014-01-14 09:11:02 +00:00
|
|
|
num_boots= iso_image_get_mips_boot_files(image, paths, 0);
|
|
|
|
Xorriso_process_msg_queues(xorriso, 0);
|
|
|
|
if(num_boots > 0) {
|
|
|
|
if(sa_type == 2)
|
|
|
|
num_boots= 1;
|
|
|
|
for(i= 0; i < num_boots; i++) {
|
|
|
|
sprintf(line, "-boot_image any mips%s_path=", sa_type ==2 ? "el" : "");
|
|
|
|
Text_shellsafe(paths[i], line, 1);
|
|
|
|
strcat(line, "\n");
|
|
|
|
Xorriso_status_result(xorriso, filter, fp, flag & 2);
|
|
|
|
}
|
|
|
|
}
|
2010-10-13 17:07:05 +00:00
|
|
|
return(num_boots);
|
2015-02-28 14:31:04 +00:00
|
|
|
} else if(sa_type == 4 || sa_type == 5) {
|
2014-01-14 09:11:02 +00:00
|
|
|
ret= iso_image_get_hppa_palo(image, &cmdline, &bootloader, &kernel_32,
|
|
|
|
&kernel_64, &ramdisk);
|
|
|
|
if(ret == 1) {
|
|
|
|
Xorriso_status_hppa(xorriso, "cmdline", cmdline, filter, fp, 0);
|
|
|
|
Xorriso_status_hppa(xorriso, "bootloader", bootloader, filter, fp, 0);
|
|
|
|
Xorriso_status_hppa(xorriso, "kernel_32", kernel_32, filter, fp, 0);
|
|
|
|
Xorriso_status_hppa(xorriso, "kernel_64", kernel_64, filter, fp, 0);
|
|
|
|
Xorriso_status_hppa(xorriso, "ramdisk", ramdisk, filter, fp, 0);
|
2014-01-16 11:34:11 +00:00
|
|
|
sprintf(num, "%d", sa_type);
|
|
|
|
Xorriso_status_hppa(xorriso, "hdrversion", num, filter, fp, 0);
|
2014-01-14 09:11:02 +00:00
|
|
|
}
|
|
|
|
return(0);
|
2015-02-28 14:31:04 +00:00
|
|
|
} else if(sa_type == 6) {
|
|
|
|
ret= iso_image_get_alpha_boot(image, &bootloader);
|
|
|
|
if (ret == 1 && bootloader != NULL) {
|
|
|
|
sprintf(line, "-boot_image any alpha_boot=");
|
|
|
|
Text_shellsafe(bootloader, line, 1);
|
|
|
|
strcat(line, "\n");
|
|
|
|
Xorriso_status_result(xorriso, filter, fp, flag & 2);
|
|
|
|
}
|
|
|
|
return(0);
|
2014-01-14 09:11:02 +00:00
|
|
|
}
|
|
|
|
return(0);
|
2010-10-13 17:07:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-18 21:22:23 +00:00
|
|
|
/*
|
|
|
|
bit0= do only report non-default settings
|
|
|
|
bit1= do only report to fp
|
|
|
|
*/
|
|
|
|
int Xorriso_append_part_status(struct XorrisO *xorriso, IsoImage *image,
|
|
|
|
char *filter, FILE *fp, int flag)
|
|
|
|
{
|
2019-02-18 12:19:32 +00:00
|
|
|
int i, l, is_default;
|
2010-10-18 21:22:23 +00:00
|
|
|
|
2015-02-06 11:56:31 +00:00
|
|
|
is_default= (xorriso->appended_as_gpt == 0);
|
|
|
|
sprintf(xorriso->result_line, "-boot_image any appended_part_as=%s\n",
|
|
|
|
xorriso->appended_as_gpt ? "gpt" : "mbr");
|
|
|
|
if(!(is_default && (flag & 1)))
|
|
|
|
Xorriso_status_result(xorriso, filter, fp, flag & 2);
|
2010-11-05 14:46:34 +00:00
|
|
|
for(i= 0; i < Xorriso_max_appended_partitionS; i++) {
|
|
|
|
if(xorriso->appended_partitions[i] == NULL)
|
2010-10-18 21:22:23 +00:00
|
|
|
continue;
|
2019-02-18 12:19:32 +00:00
|
|
|
sprintf(xorriso->result_line, "-append_partition %d ", i + 1);
|
|
|
|
l= strlen(xorriso->result_line);
|
|
|
|
if(xorriso->appended_part_gpt_flags[i] & 1) {
|
|
|
|
Xorriso__format_guid(xorriso->appended_part_type_guids[i],
|
|
|
|
xorriso->result_line + l, 0);
|
|
|
|
strcpy(xorriso->result_line + l + 32, " ");
|
|
|
|
} else {
|
|
|
|
sprintf(xorriso->result_line + l, "0x%2.2x ",
|
|
|
|
(unsigned int) xorriso->appended_part_types[i]);
|
|
|
|
}
|
2010-10-18 21:22:23 +00:00
|
|
|
Text_shellsafe(xorriso->appended_partitions[i], xorriso->result_line, 1);
|
|
|
|
strcat(xorriso->result_line, "\n");
|
|
|
|
Xorriso_status_result(xorriso, filter, fp, flag & 2);
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
/*
|
|
|
|
bit0= do only report non-default settings
|
|
|
|
bit1= do only report to fp
|
|
|
|
*/
|
|
|
|
int Xorriso_boot_image_status(struct XorrisO *xorriso, char *filter, FILE *fp,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
int ret, i, num_boots, hflag;
|
2014-04-03 19:48:20 +00:00
|
|
|
int is_default, no_defaults;
|
2011-05-03 11:50:43 +00:00
|
|
|
char *path= NULL, *form= "any", *line, *hpt;
|
2010-05-15 18:48:10 +00:00
|
|
|
struct burn_drive_info *dinfo;
|
|
|
|
struct burn_drive *drive;
|
|
|
|
IsoImage *image= NULL;
|
|
|
|
ElToritoBootImage **boots = NULL;
|
|
|
|
IsoFile **bootnodes = NULL;
|
|
|
|
int platform_id, patch, load_size;
|
|
|
|
enum eltorito_boot_media_type media_type;
|
|
|
|
unsigned char id_string[29], sel_crit[21];
|
|
|
|
|
2011-05-03 11:50:43 +00:00
|
|
|
Xorriso_alloc_meM(path, char, SfileadrL);
|
2010-05-15 18:48:10 +00:00
|
|
|
line= xorriso->result_line;
|
|
|
|
no_defaults= flag & 1;
|
|
|
|
|
2010-10-13 17:07:05 +00:00
|
|
|
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
|
|
|
"on attempt to print boot info", 2 | 16);
|
|
|
|
if(ret<=0)
|
|
|
|
goto no_image;
|
|
|
|
image= isoburn_get_attached_image(drive);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if(image == NULL)
|
|
|
|
goto no_image;
|
|
|
|
|
2010-11-05 14:46:34 +00:00
|
|
|
ret= Xorriso_boot_status_non_mbr(xorriso, image, filter, fp, flag & 3);
|
2010-10-13 17:07:05 +00:00
|
|
|
if(ret < 0) /* == 0 is normal */
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
if(xorriso->boot_count == 0 && xorriso->boot_image_bin_path[0] == 0) {
|
2010-10-13 17:07:05 +00:00
|
|
|
no_image:;
|
2010-05-15 18:48:10 +00:00
|
|
|
if(xorriso->patch_isolinux_image & 1) {
|
|
|
|
sprintf(line, "-boot_image %s patch\n",
|
|
|
|
xorriso->patch_isolinux_image & 2 ? "grub" : form);
|
|
|
|
is_default= 0;
|
|
|
|
} else if(xorriso->keep_boot_image) {
|
|
|
|
sprintf(line, "-boot_image %s keep\n", form);
|
|
|
|
is_default= 0;
|
|
|
|
} else {
|
|
|
|
sprintf(line, "-boot_image %s discard\n", form);
|
|
|
|
is_default= 1;
|
|
|
|
}
|
|
|
|
if(!(is_default && no_defaults))
|
|
|
|
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
2014-03-02 10:20:39 +00:00
|
|
|
goto report_open_item;
|
2010-05-15 18:48:10 +00:00
|
|
|
}
|
|
|
|
|
2014-03-02 10:20:39 +00:00
|
|
|
is_default= (xorriso->boot_image_cat_path[0] == 0);
|
|
|
|
sprintf(line,"-boot_image %s cat_path=", form);
|
|
|
|
Text_shellsafe(xorriso->boot_image_cat_path, line, 1);
|
|
|
|
strcat(line, "\n");
|
|
|
|
if(!(is_default && no_defaults))
|
|
|
|
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
|
|
|
|
|
|
|
is_default= !xorriso->boot_image_cat_hidden;
|
|
|
|
hpt= Xorriso__hide_mode_text(xorriso->boot_image_cat_hidden & 63, 0);
|
|
|
|
if(hpt != NULL)
|
|
|
|
sprintf(line, "-boot_image %s cat_hidden=%s\n", form, hpt);
|
|
|
|
Xorriso_free_meM(hpt);
|
|
|
|
if(!(is_default && no_defaults))
|
|
|
|
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
2010-05-15 18:48:10 +00:00
|
|
|
|
|
|
|
if(xorriso->boot_count > 0) {
|
|
|
|
|
|
|
|
/* show attached boot image info */;
|
|
|
|
|
|
|
|
ret= iso_image_get_all_boot_imgs(image, &num_boots, &boots, &bootnodes, 0);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if(ret == 1 && num_boots > 0) {
|
|
|
|
for(i= 0; i < num_boots; i++) {
|
|
|
|
ret= Xorriso_path_from_node(xorriso, (IsoNode *) bootnodes[i], path, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
continue;
|
|
|
|
platform_id= el_torito_get_boot_platform_id(boots[i]);
|
|
|
|
patch= el_torito_get_isolinux_options(boots[i], 0);
|
|
|
|
el_torito_get_boot_media_type(boots[i], &media_type);
|
|
|
|
load_size= el_torito_get_load_size(boots[i]) * 512;
|
|
|
|
el_torito_get_id_string(boots[i], id_string);
|
|
|
|
el_torito_get_selection_crit(boots[i], sel_crit);
|
2010-10-12 18:31:54 +00:00
|
|
|
if(media_type == ELTORITO_FLOPPY_EMUL)
|
|
|
|
media_type= 2;
|
|
|
|
else if(media_type == ELTORITO_HARD_DISC_EMUL)
|
|
|
|
media_type= 1;
|
|
|
|
else
|
|
|
|
media_type= 0;
|
2010-05-15 18:48:10 +00:00
|
|
|
ret= Xorriso_boot_item_status(xorriso, xorriso->boot_image_cat_path,
|
2013-04-13 07:42:18 +00:00
|
|
|
path, platform_id, patch, media_type,
|
2010-05-15 18:48:10 +00:00
|
|
|
load_size, id_string, sel_crit, "any",
|
|
|
|
filter, fp, 16 | (flag & 3));
|
|
|
|
if(ret <= 0)
|
|
|
|
continue;
|
|
|
|
sprintf(line,"-boot_image %s next\n", form);
|
|
|
|
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Show pending boot image info */
|
|
|
|
if(strcmp(xorriso->boot_image_bin_form, "isolinux") == 0 ||
|
|
|
|
strcmp(xorriso->boot_image_bin_form, "grub") == 0)
|
|
|
|
form= xorriso->boot_image_bin_form;
|
|
|
|
|
|
|
|
if(xorriso->boot_count > 0 &&
|
|
|
|
xorriso->boot_platform_id == 0 &&
|
|
|
|
xorriso->patch_isolinux_image == 0 &&
|
|
|
|
xorriso->boot_image_bin_path[0] == 0 &&
|
|
|
|
xorriso->boot_image_emul == 0 &&
|
|
|
|
xorriso->boot_image_load_size == 4 * 512) {
|
|
|
|
for(i= 0; i < 20; i++)
|
|
|
|
if(xorriso->boot_selection_crit[i])
|
|
|
|
break;
|
|
|
|
if(i >= 20)
|
|
|
|
for(i= 0; i < 28; i++)
|
|
|
|
if(xorriso->boot_id_string[i])
|
|
|
|
break;
|
|
|
|
if(i >= 28)
|
|
|
|
{ret= 1; goto ex;} /* Images registered, pending is still default */
|
|
|
|
}
|
2014-03-02 10:20:39 +00:00
|
|
|
|
|
|
|
report_open_item:;
|
2010-05-15 18:48:10 +00:00
|
|
|
hflag= 16;
|
|
|
|
if(xorriso->boot_platform_id == 0xef && !xorriso->boot_efi_default)
|
|
|
|
hflag= 0;
|
|
|
|
ret= Xorriso_boot_item_status(xorriso, xorriso->boot_image_cat_path,
|
|
|
|
xorriso->boot_image_bin_path, xorriso->boot_platform_id,
|
|
|
|
xorriso->patch_isolinux_image, xorriso->boot_image_emul,
|
|
|
|
xorriso->boot_image_load_size, xorriso->boot_id_string,
|
|
|
|
xorriso->boot_selection_crit, form,
|
|
|
|
filter, fp, hflag | (flag & 3));
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
|
2010-10-18 21:22:23 +00:00
|
|
|
ret = Xorriso_append_part_status(xorriso, image, filter, fp, flag & 3);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
ret= 1;
|
|
|
|
ex:
|
|
|
|
if(boots != NULL)
|
|
|
|
free(boots);
|
|
|
|
if(bootnodes != NULL)
|
|
|
|
free(bootnodes);
|
2011-05-05 10:52:52 +00:00
|
|
|
if(image != NULL)
|
|
|
|
iso_image_unref(image);
|
2011-05-03 11:50:43 +00:00
|
|
|
Xorriso_free_meM(path);
|
2010-05-15 18:48:10 +00:00
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso__append_boot_params(char *line, ElToritoBootImage *bootimg,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
unsigned int platform_id;
|
|
|
|
|
|
|
|
platform_id= el_torito_get_boot_platform_id(bootimg);
|
|
|
|
if(platform_id != 0)
|
|
|
|
sprintf(line + strlen(line),
|
|
|
|
" , platform_id=0x%-2.2X ", (unsigned int) platform_id);
|
|
|
|
if(el_torito_seems_boot_info_table(bootimg, 0))
|
|
|
|
sprintf(line + strlen(line), " , boot_info_table=on");
|
2013-04-13 07:42:18 +00:00
|
|
|
if(el_torito_seems_boot_info_table(bootimg, 1))
|
|
|
|
sprintf(line + strlen(line), " , grub2_boot_info=on");
|
2010-05-15 18:48:10 +00:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit0= no output if no boot record was found
|
|
|
|
bit1= short form
|
|
|
|
bit3= report to info channel (else to result channel)
|
|
|
|
*/
|
|
|
|
int Xorriso_show_boot_info(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
2014-04-25 06:45:30 +00:00
|
|
|
int ret, bin_path_valid= 0, i, num_boots, sa_count;
|
|
|
|
char *respt, *path= NULL, **sa_report= NULL, *sa_summary= NULL;
|
2011-05-08 17:47:43 +00:00
|
|
|
unsigned char *lb0= NULL;
|
2010-05-15 18:48:10 +00:00
|
|
|
struct burn_drive_info *dinfo;
|
|
|
|
struct burn_drive *drive;
|
|
|
|
IsoImage *image= NULL;
|
|
|
|
ElToritoBootImage *bootimg, **boots = NULL;
|
|
|
|
IsoFile *bootimg_node, **bootnodes = NULL;
|
|
|
|
IsoBoot *bootcat_node;
|
|
|
|
|
2011-05-03 11:50:43 +00:00
|
|
|
Xorriso_alloc_meM(path, char, SfileadrL);
|
2011-05-08 17:47:43 +00:00
|
|
|
Xorriso_alloc_meM(lb0, unsigned char, 2048);
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
respt= xorriso->result_line;
|
|
|
|
|
|
|
|
if(xorriso->boot_count > 0) {
|
|
|
|
if(!(flag & 1)) {
|
2014-04-25 06:45:30 +00:00
|
|
|
sprintf(respt, "Boot record : (overridden by -boot_image any next)\n");
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso_toc_line(xorriso, flag & 8);
|
|
|
|
}
|
|
|
|
ret= 1; goto ex;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
|
|
|
"on attempt to print boot info", 16);
|
|
|
|
if(ret<=0)
|
|
|
|
goto no_boot;
|
|
|
|
image= isoburn_get_attached_image(drive);
|
|
|
|
if(image == NULL) {
|
|
|
|
ret= 0;
|
|
|
|
no_boot:;
|
|
|
|
if(!(flag & 1)) {
|
|
|
|
sprintf(respt, "Boot record : none\n");
|
|
|
|
Xorriso_toc_line(xorriso, flag & 8);
|
|
|
|
}
|
|
|
|
goto ex;
|
|
|
|
}
|
|
|
|
|
2014-04-25 06:45:30 +00:00
|
|
|
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);
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
/* Using the nodes with extreme care . They might be deleted meanwhile. */
|
|
|
|
ret= iso_image_get_boot_image(image, &bootimg, &bootimg_node, &bootcat_node);
|
2014-04-25 06:45:30 +00:00
|
|
|
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;
|
|
|
|
}
|
2010-11-23 19:37:19 +00:00
|
|
|
ret= iso_image_get_all_boot_imgs(image, &num_boots, &boots, &bootnodes, 0);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if(ret != 1) {
|
|
|
|
num_boots= 0;
|
|
|
|
} else {
|
|
|
|
ret= Xorriso_path_from_node(xorriso, (IsoNode *) bootnodes[0], path, 0);
|
|
|
|
if(ret > 0)
|
|
|
|
bin_path_valid= 1;
|
|
|
|
}
|
2010-05-15 18:48:10 +00:00
|
|
|
sprintf(respt, "Boot record : El Torito");
|
2014-04-25 06:45:30 +00:00
|
|
|
if(sa_summary != NULL)
|
|
|
|
sprintf(respt + strlen(respt), " , %s", sa_summary);
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
strcat(respt, "\n");
|
|
|
|
Xorriso_toc_line(xorriso, flag & 8);
|
|
|
|
if(flag & 2)
|
|
|
|
{ret= 1; goto ex;}
|
|
|
|
|
2011-05-03 11:50:43 +00:00
|
|
|
if(xorriso->loaded_boot_cat_path[0]) {
|
|
|
|
sprintf(respt, "Boot catalog : ");
|
|
|
|
Text_shellsafe(xorriso->loaded_boot_cat_path, respt, 1);
|
|
|
|
strcat(respt, "\n");
|
|
|
|
} else {
|
2010-05-15 18:48:10 +00:00
|
|
|
sprintf(respt, "Boot catalog : -not-found-at-load-time-\n");
|
2011-05-03 11:50:43 +00:00
|
|
|
}
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso_toc_line(xorriso, flag & 8);
|
|
|
|
|
2011-05-03 11:50:43 +00:00
|
|
|
if(bin_path_valid) {
|
|
|
|
sprintf(respt, "Boot image : ");
|
|
|
|
Text_shellsafe(path, respt, 1);
|
|
|
|
} else if(xorriso->loaded_boot_bin_lba <= 0) {
|
2010-05-15 18:48:10 +00:00
|
|
|
sprintf(respt, "Boot image : -not-found-at-load-time-");
|
2011-05-03 11:50:43 +00:00
|
|
|
} else {
|
2010-05-15 18:48:10 +00:00
|
|
|
sprintf(respt, "Boot image : -not-found-any-more-by-lba=%d",
|
|
|
|
xorriso->loaded_boot_bin_lba);
|
2011-05-03 11:50:43 +00:00
|
|
|
}
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso__append_boot_params(respt, bootimg, 0);
|
|
|
|
strcat(respt, "\n");
|
|
|
|
Xorriso_toc_line(xorriso, flag & 8);
|
|
|
|
|
2010-11-23 19:37:19 +00:00
|
|
|
if(num_boots > 1) {
|
2010-05-15 18:48:10 +00:00
|
|
|
for(i= 1; i < num_boots; i++) {
|
|
|
|
ret= Xorriso_path_from_node(xorriso, (IsoNode *) bootnodes[i], path, 0);
|
2011-05-03 11:50:43 +00:00
|
|
|
if(ret > 0) {
|
|
|
|
sprintf(respt, "Boot image : ");
|
|
|
|
Text_shellsafe(path, respt, 1);
|
|
|
|
} else
|
2010-05-15 18:48:10 +00:00
|
|
|
sprintf(respt, "Boot image : -not-found-any-more-");
|
|
|
|
Xorriso__append_boot_params(respt, boots[i], 0);
|
|
|
|
strcat(respt, "\n");
|
|
|
|
Xorriso_toc_line(xorriso, flag & 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret= 1;
|
|
|
|
ex:;
|
|
|
|
if(boots != NULL)
|
|
|
|
free(boots);
|
2011-05-20 17:58:18 +00:00
|
|
|
if(bootnodes != NULL)
|
2010-05-15 18:48:10 +00:00
|
|
|
free(bootnodes);
|
|
|
|
if(image != NULL)
|
|
|
|
iso_image_unref(image); /* release obtained reference */
|
2011-05-03 11:50:43 +00:00
|
|
|
Xorriso_free_meM(path);
|
2011-05-08 17:47:43 +00:00
|
|
|
Xorriso_free_meM(lb0);
|
2014-04-25 06:45:30 +00:00
|
|
|
Xorriso_free_meM(sa_summary);
|
2010-05-15 18:48:10 +00:00
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit0=silently return 0 if no volume/image is present
|
|
|
|
*/
|
|
|
|
int Xorriso_get_volume(struct XorrisO *xorriso, IsoImage **volume,
|
|
|
|
int flag)
|
|
|
|
{
|
2015-12-26 09:06:28 +00:00
|
|
|
*volume= NULL;
|
2010-05-15 18:48:10 +00:00
|
|
|
if(xorriso->in_volset_handle==NULL) {
|
|
|
|
if(flag & 1)
|
|
|
|
return(0);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
sprintf(xorriso->info_text,"No ISO image present.");
|
|
|
|
if(xorriso->indev[0]==0 && xorriso->outdev[0]==0)
|
|
|
|
sprintf(xorriso->info_text+strlen(xorriso->info_text),
|
|
|
|
" No -dev, -indev, or -outdev selected.");
|
|
|
|
else
|
|
|
|
sprintf(xorriso->info_text+strlen(xorriso->info_text),
|
|
|
|
" Possible program error with drive '%s'.", xorriso->indev);
|
|
|
|
|
|
|
|
if(!xorriso->no_volset_present)
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
xorriso->no_volset_present= 1;
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
*volume= (IsoImage *) xorriso->in_volset_handle;
|
|
|
|
xorriso->no_volset_present= 0;
|
|
|
|
return(*volume != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-04 09:48:04 +00:00
|
|
|
/* @param flag bit0= do not return 1 on volset_change_pending != 1
|
|
|
|
*/
|
2010-05-15 18:48:10 +00:00
|
|
|
int Xorriso_change_is_pending(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
2010-12-02 06:32:31 +00:00
|
|
|
if(flag & 1)
|
|
|
|
return(xorriso->volset_change_pending == 1);
|
2010-05-15 18:48:10 +00:00
|
|
|
return(!!xorriso->volset_change_pending);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit0= do not set hln_change_pending */
|
|
|
|
int Xorriso_set_change_pending(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
IsoImage *image;
|
|
|
|
|
|
|
|
ret= Xorriso_get_volume(xorriso, &image, 1);
|
|
|
|
if(ret <= 0)
|
|
|
|
return ret;
|
2010-12-02 06:32:31 +00:00
|
|
|
/* Do not override mark of -as mkisofs -print-size */
|
|
|
|
if(xorriso->volset_change_pending != 2)
|
|
|
|
xorriso->volset_change_pending= 1;
|
2010-05-15 18:48:10 +00:00
|
|
|
if(!(flag & 1))
|
|
|
|
xorriso->hln_change_pending= 1;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@param flag bit0= print mount command to result channel rather than
|
|
|
|
performing it
|
|
|
|
bit1= do not allow prefixes with cmd
|
|
|
|
bit2= interpret unprefixed cmd as shell:
|
|
|
|
*/
|
|
|
|
int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode,
|
|
|
|
char *adr_value, char *cmd, int flag)
|
|
|
|
{
|
|
|
|
int ret, lba, track, session, params_flag= 0, is_safe= 0, is_extra_drive= 0;
|
2010-12-08 19:43:34 +00:00
|
|
|
int give_up= 0, mount_chardev= 0, status, aquire_flag= 0;
|
2011-05-03 11:50:43 +00:00
|
|
|
char volid[33], *devadr, *mount_command= NULL, *adr_data= NULL, *adr_pt;
|
|
|
|
char *dev_path, *libburn_adr= NULL;
|
|
|
|
char *dpt, *sysname= "";
|
2010-05-15 18:48:10 +00:00
|
|
|
struct stat stbuf;
|
|
|
|
struct burn_drive_info *dinfo= NULL;
|
|
|
|
struct burn_drive *drive= NULL;
|
|
|
|
|
2011-05-03 11:50:43 +00:00
|
|
|
Xorriso_alloc_meM(mount_command, char, SfileadrL);
|
|
|
|
Xorriso_alloc_meM(adr_data, char, 163);
|
|
|
|
Xorriso_alloc_meM(libburn_adr, char, BURN_DRIVE_ADR_LEN + SfileadrL);
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
devadr= dev;
|
|
|
|
adr_pt= adr_value;
|
|
|
|
if(strcmp(dev, "indev") == 0) {
|
|
|
|
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
|
|
|
"on attempt to perform -mount \"indev\"", 0);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
dev_path= devadr= xorriso->indev;
|
|
|
|
if(strncmp(dev_path, "stdio:", 6) == 0)
|
|
|
|
dev_path+= 6;
|
2011-05-07 10:51:35 +00:00
|
|
|
else if(strncmp(dev_path, "mmc:", 4) == 0)
|
|
|
|
dev_path+= 4;
|
2010-05-15 18:48:10 +00:00
|
|
|
if(xorriso->in_drive_handle == xorriso->out_drive_handle)
|
|
|
|
give_up= 3;
|
|
|
|
else
|
|
|
|
give_up= 1;
|
|
|
|
} else if(strcmp(dev, "outdev") == 0) {
|
|
|
|
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
|
|
|
"on attempt to perform -mount \"outdev\"",
|
|
|
|
2);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
dev_path= devadr= xorriso->outdev;
|
|
|
|
if(strncmp(dev_path, "stdio:", 6) == 0)
|
|
|
|
dev_path+= 6;
|
2011-05-07 10:51:35 +00:00
|
|
|
else if(strncmp(dev_path, "mmc:", 4) == 0)
|
|
|
|
dev_path+= 4;
|
2010-05-15 18:48:10 +00:00
|
|
|
if(xorriso->in_drive_handle == xorriso->out_drive_handle)
|
|
|
|
give_up= 3;
|
|
|
|
else
|
|
|
|
give_up= 2;
|
|
|
|
} else {
|
|
|
|
is_extra_drive= 1;
|
|
|
|
dev_path= dev;
|
|
|
|
if(strncmp(dev_path, "stdio:", 6) == 0)
|
|
|
|
dev_path+= 6;
|
2011-05-07 10:51:35 +00:00
|
|
|
else if(strncmp(dev_path, "mmc:", 4) == 0)
|
|
|
|
dev_path+= 4;
|
2010-05-15 18:48:10 +00:00
|
|
|
|
|
|
|
/* do only accept regular files and block devices */
|
|
|
|
ret= stat(dev_path, &stbuf);
|
|
|
|
if(ret == -1) {
|
2011-05-03 11:50:43 +00:00
|
|
|
sprintf(xorriso->info_text, "Cannot determine properties of file ");
|
|
|
|
Text_shellsafe(dev_path, xorriso->info_text, 1);
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
ret= 0; goto ex;
|
|
|
|
}
|
|
|
|
ret= System_uname(&sysname, NULL, NULL, NULL, 0);
|
|
|
|
if(ret > 0 && strcmp(sysname, "FreeBSD") == 0)
|
|
|
|
mount_chardev= 1;
|
|
|
|
if(!(S_ISREG(stbuf.st_mode) || (S_ISBLK(stbuf.st_mode) && !mount_chardev)
|
|
|
|
|| (S_ISCHR(stbuf.st_mode) && !mount_chardev))) {
|
|
|
|
sprintf(xorriso->info_text,
|
2011-05-03 11:50:43 +00:00
|
|
|
"File object is not suitable as mount device: ");
|
|
|
|
Text_shellsafe(dev_path, xorriso->info_text, 1);
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
ret= 0; goto ex;
|
|
|
|
}
|
|
|
|
|
2019-10-28 14:34:56 +00:00
|
|
|
/* Acquire drive as direct libburn address or via stdio: prefix */
|
2011-05-07 10:51:35 +00:00
|
|
|
if(strncmp(dev, "mmc:", 4) == 0)
|
|
|
|
ret= burn_drive_convert_fs_adr(dev + 4, libburn_adr);
|
|
|
|
else
|
|
|
|
ret= burn_drive_convert_fs_adr(dev, libburn_adr);
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if(ret < 0)
|
|
|
|
{ret= -1; goto ex;}
|
2011-05-07 10:51:35 +00:00
|
|
|
if(ret == 0 && strncmp(dev, "stdio:", 6) != 0 &&
|
|
|
|
strncmp(dev, "mmc:", 4) != 0)
|
2010-05-15 18:48:10 +00:00
|
|
|
sprintf(libburn_adr, "stdio:%s", dev);
|
2011-05-07 10:50:13 +00:00
|
|
|
burn_preset_device_open(
|
2016-03-18 13:55:09 +00:00
|
|
|
(xorriso->drives_exclusive && !(xorriso->mount_opts_flag & 1)) |
|
|
|
|
(xorriso->linux_scsi_dev_family << 2), 0, 0);
|
2010-12-07 17:49:29 +00:00
|
|
|
aquire_flag= 1;
|
|
|
|
if((xorriso->toc_emulation_flag & 2) && adr_mode == 3)
|
|
|
|
aquire_flag|= 16;
|
2012-08-14 10:32:35 +00:00
|
|
|
if(xorriso->toc_emulation_flag & 4)
|
|
|
|
aquire_flag|= 128;
|
|
|
|
if(xorriso->toc_emulation_flag & 8)
|
|
|
|
aquire_flag|= 512;
|
2010-12-07 17:49:29 +00:00
|
|
|
ret= isoburn_drive_aquire(&dinfo, libburn_adr, aquire_flag);
|
2016-03-18 13:55:09 +00:00
|
|
|
burn_preset_device_open(1 | (xorriso->linux_scsi_dev_family << 2), 0, 0);
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if(ret <= 0)
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
drive= dinfo[0].drive;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(adr_mode == 4 && strlen(adr_pt) <= 80) {
|
|
|
|
ret= Xorriso__bourne_to_reg(adr_pt, adr_data, 0);
|
|
|
|
if(ret == 1) {
|
|
|
|
params_flag|= 4;
|
|
|
|
adr_pt= adr_data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret= isoburn_get_mount_params(drive, adr_mode, adr_pt, &lba, &track,
|
|
|
|
&session, volid, params_flag);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
2010-12-07 17:49:29 +00:00
|
|
|
if(((session <= 0 || track <= 0) && !(aquire_flag & 16)) || ret == 2) {
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso_msgs_submit(xorriso, 0,
|
|
|
|
"-mount : Given address does not point to an ISO 9660 session",
|
|
|
|
0, "FAILURE", 0);
|
|
|
|
ret= 0; goto ex;
|
|
|
|
}
|
|
|
|
if(strstr(devadr, "stdio:") == devadr)
|
|
|
|
devadr+= 6;
|
2011-05-07 10:51:35 +00:00
|
|
|
if(strstr(devadr, "mmc:") == devadr)
|
|
|
|
devadr+= 4;
|
2010-05-15 18:48:10 +00:00
|
|
|
ret= Xorriso_make_mount_cmd(xorriso, cmd, lba, track, session, volid, devadr,
|
2014-05-28 12:57:48 +00:00
|
|
|
mount_command, (flag & (2 | 4)) | ((flag & 4) << 1));
|
2010-05-15 18:48:10 +00:00
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
if(ret == 2)
|
|
|
|
is_safe= 1;
|
|
|
|
|
|
|
|
if(is_extra_drive) {
|
|
|
|
isoburn_drive_release(drive, 0);
|
|
|
|
burn_drive_info_free(dinfo);
|
|
|
|
drive= NULL;
|
|
|
|
} else if(give_up > 0 && !((flag & 1) || (xorriso->mount_opts_flag & 1))) {
|
2015-11-08 20:30:26 +00:00
|
|
|
ret= Xorriso_give_up_drive(xorriso, give_up);
|
2010-05-15 18:48:10 +00:00
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
}
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
|
2011-05-03 11:50:43 +00:00
|
|
|
sprintf(xorriso->info_text, "Volume id : ");
|
|
|
|
Text_shellsafe(volid, xorriso->info_text, 1);
|
|
|
|
strcat(xorriso->info_text, "\n");
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso_info(xorriso, 0);
|
|
|
|
if(flag & 1) {
|
|
|
|
sprintf(xorriso->result_line, "%s\n", mount_command);
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
} else {
|
|
|
|
sprintf(xorriso->info_text, "Mount command: %s\n", mount_command);
|
|
|
|
Xorriso_info(xorriso, 0);
|
|
|
|
if(!is_safe) {
|
|
|
|
Xorriso_msgs_submit(xorriso, 0,
|
|
|
|
"-mount : Will not perform mount command which stems from command template.",
|
|
|
|
0, "SORRY", 0);
|
|
|
|
sprintf(xorriso->result_line, "%s\n", mount_command);
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
} else {
|
2014-04-21 13:18:38 +00:00
|
|
|
ret= Xorriso_execv(xorriso, mount_command, 0, NULL, "/bin:/sbin",
|
|
|
|
NULL, NULL, NULL, &status, 1);
|
2010-05-15 18:48:10 +00:00
|
|
|
if(WIFEXITED(status) && WEXITSTATUS(status) != 0) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"-mount : mount command failed with exit value %d",
|
2017-07-21 10:55:08 +00:00
|
|
|
(int) WEXITSTATUS(status));
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
ret= 0; goto ex;
|
|
|
|
}
|
2011-05-03 11:50:43 +00:00
|
|
|
sprintf(xorriso->info_text, "\nMounted session %d of device ", session);
|
|
|
|
Text_shellsafe(dev_path, xorriso->info_text, 1);
|
2010-05-15 18:48:10 +00:00
|
|
|
dpt= strchr(cmd, ':');
|
|
|
|
if(dpt == NULL)
|
|
|
|
dpt= cmd ;
|
|
|
|
else
|
|
|
|
dpt++;
|
2011-05-03 11:50:43 +00:00
|
|
|
sprintf(xorriso->info_text + strlen(xorriso->info_text), " as directory ");
|
|
|
|
Text_shellsafe(dpt, xorriso->info_text, 1);
|
|
|
|
strcat(xorriso->info_text, "\n");
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso_info(xorriso, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret= 1;
|
|
|
|
ex:;
|
|
|
|
if(is_extra_drive && drive != NULL) {
|
|
|
|
isoburn_drive_release(drive, 0);
|
|
|
|
burn_drive_info_free(dinfo);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
}
|
2011-05-03 11:50:43 +00:00
|
|
|
Xorriso_free_meM(mount_command);
|
|
|
|
Xorriso_free_meM(adr_data);
|
|
|
|
Xorriso_free_meM(libburn_adr);
|
2010-05-15 18:48:10 +00:00
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
2010-10-12 18:31:54 +00:00
|
|
|
|
2010-10-13 17:07:05 +00:00
|
|
|
/* @param flag bit0= give up all boot file paths
|
2010-10-15 11:21:30 +00:00
|
|
|
bit1= refuse if already a path is added
|
2010-10-13 17:07:05 +00:00
|
|
|
*/
|
2010-10-12 18:31:54 +00:00
|
|
|
int Xorriso_add_mips_boot_file(struct XorrisO *xorriso, char *path, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
IsoImage *image;
|
2010-10-15 11:21:30 +00:00
|
|
|
char *paths[15];
|
2010-10-12 18:31:54 +00:00
|
|
|
|
|
|
|
ret= Xorriso_get_volume(xorriso, &image, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
return ret;
|
2010-10-13 17:07:05 +00:00
|
|
|
if(flag & 1) {
|
2010-10-15 11:21:30 +00:00
|
|
|
iso_image_give_up_mips_boot(image, 0);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
if(flag & 2) {
|
|
|
|
ret= iso_image_get_mips_boot_files(image, paths, 0);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if(ret < 0)
|
|
|
|
goto report_error;
|
|
|
|
if(ret > 0) {
|
|
|
|
Xorriso_msgs_submit(xorriso, 0,
|
|
|
|
"There is already a boot image file registered.",
|
|
|
|
0, "FAILURE", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
2010-10-13 17:07:05 +00:00
|
|
|
}
|
2010-10-12 18:31:54 +00:00
|
|
|
ret = iso_image_add_mips_boot_file(image, path, 0);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if (ret < 0) {
|
2010-10-15 11:21:30 +00:00
|
|
|
report_error:;
|
2010-10-12 18:31:54 +00:00
|
|
|
Xorriso_report_iso_error(xorriso, "", ret,
|
|
|
|
"Error when adding MIPS boot file",
|
|
|
|
0, "FAILURE", 1);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-14 09:11:02 +00:00
|
|
|
/* @param flag bit0= Give up HP-PA boot parameters
|
|
|
|
*/
|
|
|
|
int Xorriso_set_hppa_boot_parm(struct XorrisO *xorriso, char *text, char *what,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
IsoImage *image;
|
|
|
|
char *par[5];
|
|
|
|
|
|
|
|
ret= Xorriso_get_volume(xorriso, &image, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
return(ret);
|
|
|
|
par[0]= par[1]= par[2]= par[3]= par[4]= NULL;
|
|
|
|
if(flag & 1) {
|
|
|
|
/* Give up HP-PA boot parameters */
|
|
|
|
iso_image_set_hppa_palo(image, par[0], par[1], par[2], par[3], par[4],
|
|
|
|
1);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
if(strcmp(what, "cmdline") == 0) {
|
|
|
|
par[0]= text;
|
|
|
|
} else if(strcmp(what, "bootloader") == 0) {
|
|
|
|
par[1]= text;
|
|
|
|
} else if(strcmp(what, "kernel_32") == 0 || strcmp(what, "kernel-32") == 0) {
|
|
|
|
par[2]= text;
|
|
|
|
} else if(strcmp(what, "kernel_64") == 0 || strcmp(what, "kernel-64") == 0) {
|
|
|
|
par[3]= text;
|
|
|
|
} else if(strcmp(what, "ramdisk") == 0) {
|
|
|
|
par[4]= text;
|
2014-01-16 11:34:11 +00:00
|
|
|
} else if(strcmp(what, "hdrversion") == 0) {
|
|
|
|
if(strcmp(text, "4") == 0) {
|
|
|
|
xorriso->system_area_options= (xorriso->system_area_options & ~0xfc) |
|
|
|
|
(4 << 2);
|
|
|
|
} else if(strcmp(text, "5") == 0) {
|
|
|
|
xorriso->system_area_options= (xorriso->system_area_options & ~0xfc) |
|
|
|
|
(5 << 2);
|
|
|
|
} else {
|
|
|
|
strcpy(xorriso->info_text, "Unsupported HP-PA PALO header version ");
|
|
|
|
Text_shellsafe(text, xorriso->info_text, 1);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
return(1);
|
2014-01-14 09:11:02 +00:00
|
|
|
} else {
|
|
|
|
strcpy(xorriso->info_text,
|
|
|
|
"HP-PA boot parameter name not recognized: hppa_");
|
|
|
|
Text_shellsafe(what, xorriso->info_text, 1);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
ret= iso_image_set_hppa_palo(image, par[0], par[1], par[2], par[3], par[4],
|
|
|
|
0);
|
|
|
|
if (ret < 0) {
|
|
|
|
Xorriso_report_iso_error(xorriso, "", ret,
|
|
|
|
"Error when adding HP-PA boot parameter",
|
|
|
|
0, "FAILURE", 1);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-28 14:31:04 +00:00
|
|
|
/* @param flag bit0= Give up DEC Alpha boot parameters
|
|
|
|
*/
|
|
|
|
int Xorriso_set_alpha_boot(struct XorrisO *xorriso, char *path, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
IsoImage *image;
|
|
|
|
|
|
|
|
ret= Xorriso_get_volume(xorriso, &image, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
return(ret);
|
|
|
|
if(flag & 1) {
|
|
|
|
/* Give up boot parameters */
|
|
|
|
iso_image_set_alpha_boot(image, NULL, 1);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
ret= iso_image_set_alpha_boot(image, path, 0);
|
|
|
|
if (ret < 0) {
|
|
|
|
Xorriso_report_iso_error(xorriso, "", ret,
|
|
|
|
"Error when adding DEC Alpha boot loader",
|
|
|
|
0, "FAILURE", 1);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-04 15:35:34 +00:00
|
|
|
/* @param flag bit0= do not set xorriso->system_area_options, just check
|
|
|
|
bit1= only check for grub2_mbr <-> isolinux partition_table
|
|
|
|
*/
|
2010-10-13 17:07:05 +00:00
|
|
|
int Xorriso_coordinate_system_area(struct XorrisO *xorriso, int sa_type,
|
|
|
|
int options, char *cmd, int flag)
|
|
|
|
{
|
2014-03-25 19:59:31 +00:00
|
|
|
int old_type, old_options, new_options;
|
2015-02-28 14:31:04 +00:00
|
|
|
static char *type_names[7] = {
|
2010-11-05 14:46:34 +00:00
|
|
|
"MBR", "MIPS Big Endian Volume Header", "MIPS Little Endian Boot Block",
|
2015-02-28 14:31:04 +00:00
|
|
|
"SUN Disk Label", "HP-PA PALO v4", "HP-PA PALO v5",
|
|
|
|
"DEC Alpha SRM Boot Block"};
|
|
|
|
static int num_names = 7;
|
2010-10-13 17:07:05 +00:00
|
|
|
|
|
|
|
old_type= (xorriso->system_area_options & 0xfc) >> 2;
|
2014-04-04 15:35:34 +00:00
|
|
|
old_options= xorriso->system_area_options & 0x3c03;
|
|
|
|
new_options= options & 0x3c03;
|
|
|
|
if(((options & (1 << 14)) && (xorriso->system_area_options & 2)) ||
|
|
|
|
((options & 2) && (xorriso->system_area_options & (1 << 14))))
|
|
|
|
goto reject;
|
|
|
|
if(flag & 2)
|
|
|
|
return(1);
|
2010-10-13 17:07:05 +00:00
|
|
|
if((old_type != 0 || old_options != 0) &&
|
2014-03-25 19:59:31 +00:00
|
|
|
(old_type != sa_type || (old_options != 0 && old_options != new_options))){
|
2014-04-04 15:35:34 +00:00
|
|
|
reject:;
|
2010-10-13 17:07:05 +00:00
|
|
|
sprintf(xorriso->info_text, "%s : First sector already occupied by %s",
|
2015-02-28 14:31:04 +00:00
|
|
|
cmd, old_type < num_names ?
|
|
|
|
type_names[old_type] : "other boot facility");
|
2014-03-25 19:59:31 +00:00
|
|
|
if(old_type == 0 && (old_options & 2))
|
2010-10-13 17:07:05 +00:00
|
|
|
strcat(xorriso->info_text, " for ISOLINUX isohybrid");
|
2014-04-04 15:35:34 +00:00
|
|
|
else if (old_type == 0 && (xorriso->system_area_options & (1 << 14))) {
|
|
|
|
strcat(xorriso->info_text, " for GRUB2 patching");
|
|
|
|
if(old_type == 0 && (old_options & 1))
|
|
|
|
strcat(xorriso->info_text, " with partition table");
|
|
|
|
} else if(old_type == 0 && (old_options & 1))
|
2010-10-13 17:07:05 +00:00
|
|
|
strcat(xorriso->info_text, " for partition table");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
goto hint_revoke;
|
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
if(!(flag & 1))
|
2014-04-04 15:35:34 +00:00
|
|
|
xorriso->system_area_options= (xorriso->system_area_options & ~0x3cff) |
|
|
|
|
((sa_type << 2) & 0xfc) | (options & 0x3c03);
|
2010-10-13 17:07:05 +00:00
|
|
|
return(1);
|
|
|
|
|
|
|
|
hint_revoke:;
|
|
|
|
if(old_type == 0)
|
|
|
|
sprintf(xorriso->info_text, "Revokable by -boot_image any discard");
|
2010-10-15 11:21:30 +00:00
|
|
|
else if(old_type == 1 || old_type == 2)
|
2010-10-13 17:07:05 +00:00
|
|
|
sprintf(xorriso->info_text, "Revokable by -boot_image any mips_discard");
|
2010-11-05 14:46:34 +00:00
|
|
|
else if(old_type == 3)
|
|
|
|
sprintf(xorriso->info_text, "Revokable by -boot_image any sparc_discard");
|
|
|
|
if(old_type < 4)
|
2010-10-13 17:07:05 +00:00
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2014-04-11 16:12:22 +00:00
|
|
|
|
2014-04-12 13:02:23 +00:00
|
|
|
int Xorriso_gpt_crc(struct XorrisO *xorriso, char *path, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
char *buf = NULL;
|
|
|
|
FILE *fp = NULL;
|
|
|
|
uint32_t crc;
|
|
|
|
|
|
|
|
Xorriso_alloc_meM(buf, char, 32 * 1024);
|
|
|
|
|
|
|
|
ret= Xorriso_afile_fopen(xorriso, path, "rb", &fp, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
ret= fread(buf, 1, 32 * 1024, fp);
|
|
|
|
if(ret == 0) {
|
|
|
|
strcpy(xorriso->info_text,
|
|
|
|
"No bytes readable for GPT CRC from ");
|
|
|
|
Text_shellsafe(path, xorriso->info_text, 1);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
|
|
|
|
ret= 0; goto ex;
|
|
|
|
}
|
|
|
|
crc= iso_crc32_gpt((unsigned char *) buf, ret, 0);
|
|
|
|
sprintf(xorriso->result_line, "0x%8.8x\n", (unsigned int) crc);
|
|
|
|
Xorriso_result(xorriso, 0);
|
|
|
|
ret= 1;
|
|
|
|
ex:;
|
|
|
|
if(fp != NULL && fp != stdin)
|
|
|
|
fclose(fp);
|
|
|
|
Xorriso_free_meM(buf);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
static int Xorriso_split_report_line(struct XorrisO *xorriso, char *line,
|
|
|
|
int num_limit,
|
|
|
|
char *name, char **contentpt,
|
|
|
|
double *num, int *num_count,
|
|
|
|
char **textpt, int flag)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char *spt, *ept, *cpt;
|
|
|
|
|
|
|
|
if(strlen(line) < 21) {
|
|
|
|
undigestible:
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Undigestible report line with -report_* mode cmd: '%s'", line);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
if(line[19] != ':')
|
|
|
|
goto undigestible;
|
|
|
|
strncpy(name, line, 20);
|
|
|
|
name[20]= 0;
|
|
|
|
|
|
|
|
for(spt= line + 20; *spt == ' '; spt++);
|
|
|
|
*textpt= *contentpt= spt;
|
|
|
|
*num_count= 0;
|
|
|
|
for(i= 0; i < num_limit; i++) {
|
|
|
|
/* Get word */
|
|
|
|
for(spt= *textpt; *spt == ' '; spt++);
|
|
|
|
if(*spt == 0) {
|
|
|
|
*textpt= spt;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
for(ept= spt + 1; *ept != ' ' && *ept != 0; ept++);
|
|
|
|
/* Look for decimal number */
|
|
|
|
if(ept - spt > 16)
|
|
|
|
break;
|
|
|
|
for(cpt= spt; cpt < ept; cpt++)
|
|
|
|
if(*cpt < '0' || *cpt > '9')
|
|
|
|
break;
|
|
|
|
if(cpt != ept)
|
|
|
|
break;
|
|
|
|
sscanf(spt, "%lf", num + *num_count);
|
|
|
|
(*num_count)++;
|
|
|
|
*textpt= ept;
|
|
|
|
}
|
|
|
|
/* Set *textpt to next non-blank */
|
|
|
|
for(; **textpt == ' '; (*textpt)++);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-14 10:08:32 +00:00
|
|
|
int Xorriso_record_cmd_line(struct XorrisO *xorriso, char *buf,
|
|
|
|
char **cmds, int *cmd_count, int flag)
|
2014-10-28 14:03:42 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if(flag & 1) {
|
|
|
|
(*cmd_count)++;
|
|
|
|
ret= 1; goto ex;
|
|
|
|
}
|
|
|
|
Xorriso_alloc_meM(cmds[*cmd_count], char, strlen(buf) + 1);
|
|
|
|
strcpy(cmds[*cmd_count], buf);
|
|
|
|
(*cmd_count)++;
|
|
|
|
ret= 1;
|
|
|
|
ex:;
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-07 07:54:16 +00:00
|
|
|
/* @param flag bit0= zeroize MBR partition table
|
|
|
|
bit1= zeroize GPT
|
|
|
|
bit2= zeroize APM
|
2015-05-10 09:34:30 +00:00
|
|
|
bit30= Source imported_iso rather than local_fs
|
2015-05-07 07:54:16 +00:00
|
|
|
*/
|
|
|
|
int Xorriso_add_intvl_adr(struct XorrisO *xorriso, char *buf,
|
|
|
|
uint64_t start_adr, uint64_t end_adr, char *suffix,
|
|
|
|
int flag)
|
|
|
|
{
|
2015-05-10 09:34:30 +00:00
|
|
|
char *path;
|
|
|
|
|
|
|
|
sprintf(buf + strlen(buf), "--interval:%s:%.f%s-%.f%s:",
|
|
|
|
((flag & (1 << 30)) ? "imported_iso" : "local_fs"),
|
2015-05-07 07:54:16 +00:00
|
|
|
(double) start_adr, suffix, (double) end_adr, suffix);
|
|
|
|
if(flag & 1)
|
|
|
|
strcat(buf, "zero_mbrpt,");
|
|
|
|
if(flag & 2)
|
|
|
|
strcat(buf, "zero_gpt,");
|
|
|
|
if(flag & 4)
|
|
|
|
strcat(buf, "zero_apm,");
|
|
|
|
if(buf[strlen(buf) - 1] == ',')
|
|
|
|
buf[strlen(buf) - 1] = 0;
|
|
|
|
strcat(buf, ":");
|
2015-05-10 09:34:30 +00:00
|
|
|
path= xorriso->indev;
|
|
|
|
if(strncmp(path, "stdio:", 6) == 0)
|
|
|
|
path+= 6;
|
|
|
|
Text_shellsafe(path, buf, 1);
|
2015-05-07 07:54:16 +00:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-05 08:53:59 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-11 16:04:21 +00:00
|
|
|
struct elto_img_par {
|
|
|
|
int n, ldsiz, boot_info_table, grub2_boot_info;
|
|
|
|
int do_gpt_basdat, do_gpt_hfsplus, do_apm_hfsplus;
|
|
|
|
unsigned int ld_seg, hdpt, platform_id;
|
2020-12-05 08:53:59 +00:00
|
|
|
unsigned long int lba, extract_size;
|
2015-05-11 16:04:21 +00:00
|
|
|
char pltf[8], b[8], emul[8], boot_image_type[16];
|
|
|
|
char *path, *id_string, *sel_crit;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-04-25 10:09:34 +00:00
|
|
|
/* @param ptype 0= unknown, 1= gpt-basdat, 2=gpt-hfsplus, 3=EFI
|
|
|
|
@param flag bit0= isohybrid
|
|
|
|
*/
|
|
|
|
static int Xorriso_register_eltorito_gpt(struct XorrisO *xorriso,
|
|
|
|
struct elto_img_par *et_img,
|
|
|
|
int ptype,
|
|
|
|
int *efi_boot_part, int *first_efi,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
if(flag & 1) {
|
|
|
|
if(ptype == 1 || ptype == 3)
|
2021-04-04 18:16:47 +00:00
|
|
|
et_img->do_gpt_basdat= ptype;
|
2016-04-25 10:09:34 +00:00
|
|
|
else if(ptype == 2)
|
|
|
|
et_img->do_gpt_hfsplus= 1;
|
|
|
|
return(1);
|
|
|
|
} else if(*first_efi && et_img->platform_id == 0xef) {
|
2022-04-22 11:32:25 +00:00
|
|
|
if(*efi_boot_part <= 0)
|
|
|
|
*efi_boot_part= 1;
|
2016-04-25 10:09:34 +00:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
if(et_img->platform_id == 0xef)
|
|
|
|
*first_efi= 0;
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-11 16:04:21 +00:00
|
|
|
/* @param ptype 0= unknown, 1= gpt-basdat, 2=gpt-hfsplus, 3=EFI
|
|
|
|
@param flag bit0= isohybrid
|
|
|
|
*/
|
|
|
|
static int Xorriso_search_eltorito_path(struct XorrisO *xorriso,
|
|
|
|
struct elto_img_par *et_imgs,
|
|
|
|
int elto_count, char *path, int ptype,
|
|
|
|
int *found, int *efi_boot_part,
|
|
|
|
int flag)
|
|
|
|
{
|
2016-04-25 10:09:34 +00:00
|
|
|
int first_efi= 1, et_idx, ret;
|
2015-05-11 16:04:21 +00:00
|
|
|
|
|
|
|
for(et_idx= 0; et_idx < elto_count; et_idx++) {
|
|
|
|
if(strcmp(et_imgs[et_idx].path, path) != 0)
|
|
|
|
continue;
|
2016-04-25 10:09:34 +00:00
|
|
|
ret= Xorriso_register_eltorito_gpt(xorriso, et_imgs + et_idx,
|
|
|
|
ptype, efi_boot_part, &first_efi, flag);
|
|
|
|
if(ret > 0)
|
2015-05-11 16:04:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
*found= et_idx;
|
|
|
|
if(et_idx < elto_count)
|
|
|
|
return(1);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-25 10:09:34 +00:00
|
|
|
static int Xorriso_search_eltorito_lba(struct XorrisO *xorriso,
|
|
|
|
struct elto_img_par *et_imgs,
|
|
|
|
int elto_count,
|
|
|
|
unsigned int lba,
|
|
|
|
int *found, int flag)
|
|
|
|
{
|
|
|
|
int et_idx;
|
|
|
|
|
|
|
|
for(et_idx= 0; et_idx < elto_count; et_idx++)
|
|
|
|
if(et_imgs[et_idx].lba == lba)
|
|
|
|
break;
|
|
|
|
*found= et_idx;
|
|
|
|
if(et_idx < elto_count)
|
|
|
|
return(1);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_highest_data_block(struct XorrisO *xorriso, uint32_t *high_block,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct FindjoB *job= NULL;
|
|
|
|
struct stat dir_stbuf;
|
|
|
|
|
|
|
|
*high_block= 0;
|
|
|
|
ret= Findjob_new(&job, "/", 0);
|
|
|
|
if(ret <= 0) {
|
|
|
|
Xorriso_no_findjob(xorriso, "[internal:last_data_file_block]", 0);
|
|
|
|
{ret= -1; goto ex;}
|
|
|
|
}
|
|
|
|
Findjob_set_action_type(job, 58, 0, 0);
|
|
|
|
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
|
|
|
|
NULL, "/", &dir_stbuf, 0, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
Findjob_get_last_data_file_block(job, high_block, 0);
|
|
|
|
ex:;
|
|
|
|
Findjob_destroy(&job, 0);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
/* @param flag bit0= do not record but only count
|
2016-04-25 10:09:34 +00:00
|
|
|
bit1= as_mkisofs
|
2020-12-05 08:53:59 +00:00
|
|
|
bit2= no sorry messages
|
2014-10-28 14:03:42 +00:00
|
|
|
*/
|
|
|
|
static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
char **et_lines, int et_line_count,
|
|
|
|
char **sa_lines, int sa_line_count,
|
2020-12-05 08:53:59 +00:00
|
|
|
char **cmds, int *cmd_count,
|
|
|
|
char **boot_imgs, int *boot_img_count,
|
|
|
|
int flag)
|
2014-10-28 14:03:42 +00:00
|
|
|
{
|
|
|
|
int ret= 0, i, num_count, mkisofs, line_count, idx, et_idx, isohybrid= 0;
|
2016-04-25 10:09:34 +00:00
|
|
|
int ptype, gpt_idx, j, pad, mbr_idx;
|
|
|
|
int efi_boot_part= 0, full_sparc_part= 0, have_sparc_part= 0, fe_dummy= 1;
|
2015-05-07 15:20:42 +00:00
|
|
|
int appended_as_gpt= 0, have_prep= 0, did_sysarea= 0, cared_for_apm= 0;
|
2015-05-14 10:08:32 +00:00
|
|
|
int cared_for_sparc= 0, have_hfsplus= 0;
|
2015-05-10 09:34:30 +00:00
|
|
|
int have_sysarea= 0, ptable_killer, imported_iso, have_alpha_ldr_path= 0;
|
2022-04-22 11:32:25 +00:00
|
|
|
int have_protective_msdos= 0, part_like_isohybrid= 0, fresh_efi_boot_part;
|
2018-09-09 12:59:47 +00:00
|
|
|
|
|
|
|
#ifdef Not_any_more_because_padding_is_now_after_partitions
|
|
|
|
int appended_partition= 0;
|
|
|
|
#endif
|
|
|
|
|
2019-02-18 12:19:32 +00:00
|
|
|
int iso_mbr_part_type= -1, iso_gpt_part_idx= -1;
|
2017-06-03 19:35:22 +00:00
|
|
|
unsigned int prev_pltf= 0;
|
2020-12-05 08:53:59 +00:00
|
|
|
unsigned long int sa_options= 0, partno, id_tag, perms, start_cyl;
|
|
|
|
unsigned long int part_status, part_type, mbr_start_block, mbr_num_blocks;
|
|
|
|
unsigned long int partition_offset= 0;
|
|
|
|
uint32_t high_block= 0, indev_blocks;
|
2019-02-18 12:19:32 +00:00
|
|
|
char name[24], *textpt, *contentpt, *buf= NULL, part_type_text[37];
|
2014-10-28 14:03:42 +00:00
|
|
|
char **lines= NULL;
|
|
|
|
double num[8];
|
|
|
|
char *cat_path= "";
|
|
|
|
struct elto_img_par *et_imgs= NULL;
|
|
|
|
int elto_count= 0;
|
2020-12-05 08:53:59 +00:00
|
|
|
uint32_t mbr_parts_end= 0, extract_size;
|
2015-05-14 10:08:32 +00:00
|
|
|
struct FindjoB *job= NULL;
|
|
|
|
struct stat dir_stbuf;
|
2015-05-14 13:12:44 +00:00
|
|
|
IsoImage *image;
|
2017-09-09 14:29:22 +00:00
|
|
|
char *volid, *crt, *mdt, *ext, *eft, uuid[17], *uuid_time;
|
2016-01-01 17:28:46 +00:00
|
|
|
char **app_pseudo_paths= NULL;
|
2017-09-09 14:29:22 +00:00
|
|
|
struct tm tm_erg;
|
2020-10-24 12:19:57 +00:00
|
|
|
int was_force_bootable= 0, have_mbr_force_bootable= 0;
|
2020-12-05 08:53:59 +00:00
|
|
|
uint64_t gpt_bheader_block= 0, start_block, num_blocks;
|
|
|
|
uint64_t img_blocks= 0, iso_part_blocks;
|
2022-10-07 09:55:10 +00:00
|
|
|
char *cpt, *npt, *ftext;
|
|
|
|
int ftext_l, l;
|
2021-05-25 19:18:48 +00:00
|
|
|
unsigned char bin_data[8];
|
|
|
|
uint64_t gpt_part_flags;
|
|
|
|
int was_gpt_iso_bootable= 0, was_gpt_iso_not_ro= 0, bin_count;
|
2014-10-28 14:03:42 +00:00
|
|
|
|
2015-05-10 09:34:30 +00:00
|
|
|
struct mbr_par {
|
|
|
|
uint8_t ptype;
|
2016-01-01 17:28:46 +00:00
|
|
|
uint64_t start_block;
|
|
|
|
uint64_t block_count;
|
|
|
|
int appended;
|
2016-04-25 10:09:34 +00:00
|
|
|
int has_path;
|
2015-05-10 09:34:30 +00:00
|
|
|
};
|
|
|
|
struct mbr_par *mbrpts= NULL;
|
2015-05-07 15:20:42 +00:00
|
|
|
int mbr_count= 0;
|
2015-05-10 09:34:30 +00:00
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
struct gpt_par {
|
2015-05-07 07:54:16 +00:00
|
|
|
int ptype; /* 0= unknown, 1= gpt-basdat, 2=gpt-hfsplus, 3=EFI */
|
2019-02-18 12:19:32 +00:00
|
|
|
uint8_t type_guid[16];
|
2016-04-25 10:09:34 +00:00
|
|
|
int is_gap;
|
2015-05-07 07:54:16 +00:00
|
|
|
int has_path;
|
2015-05-11 16:04:21 +00:00
|
|
|
char *path;
|
2016-04-25 10:09:34 +00:00
|
|
|
uint64_t start_block;
|
|
|
|
uint64_t block_count;
|
2014-10-28 14:03:42 +00:00
|
|
|
};
|
|
|
|
struct gpt_par *gpts= NULL;
|
|
|
|
int gpt_count= 0;
|
|
|
|
|
|
|
|
struct apm_par {
|
2015-05-14 10:08:32 +00:00
|
|
|
int ptype; /* bit0= type Apple_HFS , bit1= name HFSPLUS_Hybrid */
|
|
|
|
char *path;
|
2014-10-28 14:03:42 +00:00
|
|
|
};
|
|
|
|
struct apm_par *apms= NULL;
|
|
|
|
int apm_count= 0;
|
2015-05-07 07:54:16 +00:00
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
#define Xorriso_record_cmd_linE { \
|
|
|
|
ret= Xorriso_record_cmd_line(xorriso, buf, cmds, cmd_count, flag & 1); \
|
2020-12-05 08:53:59 +00:00
|
|
|
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; \
|
2014-10-28 14:03:42 +00:00
|
|
|
if(ret <= 0) \
|
|
|
|
goto ex; \
|
|
|
|
}
|
|
|
|
|
2020-12-05 08:53:59 +00:00
|
|
|
/* 2 exp 19 blocks = 1 GiB */
|
|
|
|
#define Xorriso_max_endless_uefi_sizE (1 << 19)
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
mkisofs= !!(flag & 2);
|
2015-05-10 09:34:30 +00:00
|
|
|
imported_iso= (!mkisofs) << 30;
|
2014-10-28 14:03:42 +00:00
|
|
|
|
|
|
|
*cmd_count= 0;
|
2020-12-05 08:53:59 +00:00
|
|
|
*boot_img_count= 0;
|
2014-10-28 14:03:42 +00:00
|
|
|
line_count= et_line_count + sa_line_count;
|
|
|
|
if(line_count <= 0)
|
|
|
|
{ret= 1; goto ex;}
|
|
|
|
|
|
|
|
Xorriso_alloc_meM(buf, char, 80 + SfileadrL);
|
|
|
|
Xorriso_alloc_meM(lines, char *, line_count);
|
|
|
|
for(i= 0; i < et_line_count; i++)
|
|
|
|
lines[i]= et_lines[i];
|
|
|
|
for(i= 0; i < sa_line_count; i++)
|
|
|
|
lines[i + et_line_count]= sa_lines[i];
|
|
|
|
|
|
|
|
/* Pre-scan to establish context */
|
|
|
|
for(i= 0; i < line_count; i++) {
|
|
|
|
ret= Xorriso_split_report_line(xorriso, lines[i], 8, name, &contentpt,
|
|
|
|
num, &num_count, &textpt, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
if(strcmp(name, "System area options:") == 0) {
|
|
|
|
sscanf(contentpt, "%lx", &sa_options);
|
|
|
|
|
|
|
|
} else if(strcmp(name, "System area summary:") == 0) {
|
2015-05-07 15:20:42 +00:00
|
|
|
have_sysarea= 1;
|
2014-10-28 14:03:42 +00:00
|
|
|
|
|
|
|
} else if(strcmp(name, "El Torito boot img :") == 0) {
|
|
|
|
if(num[0] > elto_count)
|
|
|
|
elto_count= num[0];
|
|
|
|
|
2015-05-07 07:54:16 +00:00
|
|
|
} else if(strcmp(name, "PReP boot partition:") == 0) {
|
|
|
|
have_prep= 1;
|
|
|
|
|
2015-05-07 15:20:42 +00:00
|
|
|
} else if(strcmp(name, "MBR partition :") == 0) {
|
|
|
|
if(num[0] > mbr_count)
|
|
|
|
mbr_count= num[0];
|
2020-10-24 12:19:57 +00:00
|
|
|
if(strcmp(textpt, "0x80 0x00 0 1") == 0)
|
|
|
|
have_mbr_force_bootable= 1;
|
2015-05-07 15:20:42 +00:00
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
} else if(strcmp(name, "GPT partition name :") == 0) {
|
|
|
|
if(num[0] > gpt_count)
|
|
|
|
gpt_count= num[0];
|
|
|
|
|
|
|
|
} else if(strcmp(name, "APM partition name :") == 0) {
|
|
|
|
if(num[0] > apm_count)
|
|
|
|
apm_count= num[0];
|
|
|
|
|
|
|
|
} else if(strcmp(name, "ISO image size/512 :") == 0) {
|
|
|
|
img_blocks= num[0];
|
|
|
|
|
2017-08-24 10:23:25 +00:00
|
|
|
} else if(strcmp(name, "Partition offset :") == 0 &&
|
|
|
|
(num[0] == 0 || num[0] == 16)) {
|
|
|
|
partition_offset= num[0];
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-25 10:09:34 +00:00
|
|
|
ret= Xorriso_highest_data_block(xorriso, &high_block, 0);
|
|
|
|
if(ret < 0)
|
|
|
|
goto ex;
|
|
|
|
if(ret == 0)
|
2020-12-05 08:53:59 +00:00
|
|
|
high_block = img_blocks / 4 - 1;
|
2016-04-25 10:09:34 +00:00
|
|
|
|
2015-05-11 16:04:21 +00:00
|
|
|
if(elto_count > 0) {
|
2014-10-28 14:03:42 +00:00
|
|
|
Xorriso_alloc_meM(et_imgs, struct elto_img_par, elto_count);
|
2015-12-24 08:02:02 +00:00
|
|
|
for(et_idx= 0; et_idx < elto_count; et_idx++) {
|
2015-05-11 16:04:21 +00:00
|
|
|
et_imgs[et_idx].path= NULL;
|
2015-12-24 08:02:02 +00:00
|
|
|
et_imgs[et_idx].ldsiz= -1;
|
|
|
|
}
|
2016-01-01 17:28:46 +00:00
|
|
|
Xorriso_alloc_meM(app_pseudo_paths, char *, elto_count);
|
|
|
|
for(i= 0; i < elto_count; i++)
|
|
|
|
app_pseudo_paths[i]= NULL;
|
|
|
|
for(i= 0; i < elto_count; i++) {
|
|
|
|
Xorriso_alloc_meM(app_pseudo_paths[i], char, 80);
|
|
|
|
app_pseudo_paths[i][0]= 0;
|
|
|
|
}
|
2015-05-11 16:04:21 +00:00
|
|
|
}
|
2015-05-10 09:34:30 +00:00
|
|
|
if(mbr_count > 0)
|
|
|
|
Xorriso_alloc_meM(mbrpts, struct mbr_par, mbr_count);
|
2015-05-11 16:04:21 +00:00
|
|
|
if(gpt_count > 0) {
|
2014-10-28 14:03:42 +00:00
|
|
|
Xorriso_alloc_meM(gpts, struct gpt_par, gpt_count);
|
2015-05-11 16:04:21 +00:00
|
|
|
for(gpt_idx= 0; gpt_idx < gpt_count; gpt_idx++)
|
|
|
|
gpts[gpt_idx].path= NULL;
|
|
|
|
}
|
2015-05-14 10:08:32 +00:00
|
|
|
if(apm_count > 0) {
|
2014-10-28 14:03:42 +00:00
|
|
|
Xorriso_alloc_meM(apms, struct apm_par, apm_count);
|
2015-05-14 10:08:32 +00:00
|
|
|
for(i= 0; i < apm_count; i++)
|
|
|
|
apms[i].path= NULL;
|
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
|
2015-05-07 15:20:42 +00:00
|
|
|
ptable_killer= (mbr_count > 0) | ((gpt_count > 0) << 1) |
|
|
|
|
((apm_count > 0) << 2);
|
|
|
|
|
2015-05-14 13:12:44 +00:00
|
|
|
/* Report volume id and GRUB2 modification date */;
|
|
|
|
ret= Xorriso_get_volume(xorriso, &image, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-V ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-volid ");
|
|
|
|
volid= (char *) un0(iso_image_get_volume_id(image));
|
|
|
|
Text_shellsafe(volid, buf, 1);
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
ret= iso_image_get_pvd_times(image, &crt, &mdt, &ext, &eft);
|
|
|
|
if(ret == ISO_SUCCESS) {
|
2017-09-09 14:29:22 +00:00
|
|
|
uuid_time= crt;
|
|
|
|
/* If Creation Time is bad and Modification Time is ok: use the latter */
|
|
|
|
ret= Decode_ecma119_format(&tm_erg, crt, 0);
|
|
|
|
if(ret <= 0 || strlen(crt) != 16) {
|
|
|
|
ret= Decode_ecma119_format(&tm_erg, mdt, 0);
|
|
|
|
if(!(ret <= 0 || strlen(mdt) != 16))
|
|
|
|
uuid_time= mdt;
|
|
|
|
}
|
2015-08-12 09:12:04 +00:00
|
|
|
pad= 0;
|
|
|
|
for(j= 0; j < 16; j++) {
|
|
|
|
if(pad) {
|
|
|
|
uuid[j]= '0';
|
2017-09-09 14:29:22 +00:00
|
|
|
} else if(uuid_time[j] == 0) {
|
2015-08-12 09:12:04 +00:00
|
|
|
pad= 1;
|
|
|
|
uuid[j]= '0';
|
2017-09-09 14:29:22 +00:00
|
|
|
} else if(uuid_time[j] < '0' || uuid_time[j] > '9') {
|
2015-08-12 09:12:04 +00:00
|
|
|
uuid[j]= '0';
|
|
|
|
} else {
|
2017-09-09 14:29:22 +00:00
|
|
|
uuid[j]= uuid_time[j];
|
2015-08-12 09:12:04 +00:00
|
|
|
}
|
|
|
|
}
|
2015-05-14 13:12:44 +00:00
|
|
|
uuid[16]= 0;
|
2017-09-09 14:29:22 +00:00
|
|
|
ret= Decode_ecma119_format(&tm_erg, uuid, 0);
|
|
|
|
if(!(ret <= 0 || strlen(uuid) != 16)) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "--modification-date=");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-volume_date uuid ");
|
|
|
|
Text_shellsafe(uuid, buf, 1);
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
2015-05-14 13:12:44 +00:00
|
|
|
}
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
/* First pass: set up objects, record El Torito and info needed in 2nd pass */
|
|
|
|
for(i= 0; i < line_count; i++) {
|
|
|
|
buf[0]= 0;
|
|
|
|
ret= Xorriso_split_report_line(xorriso, lines[i], 8, name, &contentpt,
|
|
|
|
num, &num_count, &textpt, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
|
|
|
|
if(strcmp(name, "El Torito cat path :") == 0) {
|
|
|
|
cat_path= textpt;
|
|
|
|
|
2020-12-05 08:53:59 +00:00
|
|
|
} 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
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
} else if(strcmp(name, "El Torito boot img :") == 0) {
|
|
|
|
/* Platform Id, bootability, emulation, load segment,
|
|
|
|
Hard disk emulation partition type, Load size
|
|
|
|
*/
|
|
|
|
idx= num[0] - 1;
|
|
|
|
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].emul, &(et_imgs[idx].ld_seg), &(et_imgs[idx].hdpt),
|
|
|
|
&(et_imgs[idx].ldsiz), &(et_imgs[idx].lba));
|
|
|
|
if(strcmp(et_imgs[idx].pltf, "BIOS") == 0)
|
|
|
|
et_imgs[idx].platform_id= 0;
|
|
|
|
else if(strcmp(et_imgs[idx].pltf, "PPC") == 0)
|
|
|
|
et_imgs[idx].platform_id= 1;
|
|
|
|
else if(strcmp(et_imgs[idx].pltf, "Mac") == 0)
|
|
|
|
et_imgs[idx].platform_id= 2;
|
|
|
|
else if(strcmp(et_imgs[idx].pltf, "UEFI") == 0)
|
|
|
|
et_imgs[idx].platform_id= 0xef;
|
|
|
|
else
|
|
|
|
sscanf(et_imgs[idx].pltf, "%x", &(et_imgs[idx].platform_id));
|
|
|
|
|
|
|
|
strcpy(et_imgs[idx].boot_image_type, "any");
|
|
|
|
et_imgs[idx].boot_info_table= 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].do_gpt_basdat= et_imgs[idx].do_gpt_hfsplus= 0;
|
|
|
|
et_imgs[idx].do_apm_hfsplus= 0;
|
2020-12-05 08:53:59 +00:00
|
|
|
et_imgs[idx].extract_size= (et_imgs[idx].ldsiz + 3) / 4;
|
2014-10-28 14:03:42 +00:00
|
|
|
|
|
|
|
} else if(strcmp(name, "El Torito img path :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
|
|
|
et_imgs[idx].path= textpt;
|
2020-12-05 08:53:59 +00:00
|
|
|
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];
|
2014-10-28 14:03:42 +00:00
|
|
|
|
|
|
|
} else if(strcmp(name, "El Torito img opts :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
|
|
|
if(strstr(textpt, "boot-info-table") != NULL)
|
|
|
|
et_imgs[idx].boot_info_table= 1;
|
|
|
|
if(strstr(textpt, "isohybrid-suitable") != NULL)
|
|
|
|
strcpy(et_imgs[idx].boot_image_type, "isolinux");
|
|
|
|
if(strstr(textpt, "grub2-boot-info") != NULL) {
|
|
|
|
strcpy(et_imgs[idx].boot_image_type, "grub");
|
|
|
|
et_imgs[idx].grub2_boot_info= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if(strcmp(name, "El Torito id string:") == 0) {
|
|
|
|
idx= num[0] - 1;
|
|
|
|
et_imgs[idx].id_string= textpt;
|
|
|
|
|
|
|
|
} else if(strcmp(name, "El Torito sel crit :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
|
|
|
et_imgs[idx].sel_crit= textpt;
|
|
|
|
|
2016-01-01 17:28:46 +00:00
|
|
|
} else if(strcmp(name, "System area summary:") == 0) {
|
|
|
|
if(strstr(textpt, "protective-msdos-label") != NULL)
|
|
|
|
have_protective_msdos= 1;
|
|
|
|
|
2015-05-10 09:34:30 +00:00
|
|
|
} else if(strcmp(name, "MBR partition :") == 0) {
|
|
|
|
sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu",
|
2020-12-05 08:53:59 +00:00
|
|
|
&partno, &part_status, &part_type, &mbr_start_block,
|
|
|
|
&mbr_num_blocks);
|
2015-05-10 09:34:30 +00:00
|
|
|
idx= partno - 1;
|
|
|
|
mbrpts[idx].ptype= part_type;
|
2020-12-05 08:53:59 +00:00
|
|
|
mbrpts[idx].start_block= mbr_start_block;
|
|
|
|
mbrpts[idx].block_count= mbr_num_blocks;
|
|
|
|
if(mbr_num_blocks > 0 && mbr_start_block + mbr_num_blocks > mbr_parts_end)
|
|
|
|
mbr_parts_end= mbr_start_block + mbr_num_blocks;
|
|
|
|
if(mbr_start_block == partition_offset * 4 &&
|
|
|
|
(mbr_start_block + mbr_num_blocks) >= high_block * 4 &&
|
|
|
|
iso_mbr_part_type < 0)
|
2017-08-24 10:23:25 +00:00
|
|
|
iso_mbr_part_type = part_type;
|
2015-05-10 09:34:30 +00:00
|
|
|
|
2016-04-25 10:09:34 +00:00
|
|
|
} else if(strcmp(name, "MBR partition path :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
|
|
|
mbrpts[idx].has_path= 1;
|
|
|
|
|
2018-09-12 11:33:20 +00:00
|
|
|
} else if(strcmp(name, "GPT lba range :") == 0) {
|
|
|
|
gpt_bheader_block= num[2];
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
} else if(strcmp(name, "GPT type GUID :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
|
|
|
if(strcmp(textpt, "a2a0d0ebe5b9334487c068b6b72699c7") == 0)
|
|
|
|
gpts[idx].ptype= 1; /* Basic data */
|
|
|
|
else if(strcmp(textpt, "005346480000aa11aa1100306543ecac") == 0)
|
|
|
|
gpts[idx].ptype= 2; /* HFS+ */
|
2015-05-07 07:54:16 +00:00
|
|
|
else if(strcmp(textpt, "28732ac11ff8d211ba4b00a0c93ec93b") == 0)
|
|
|
|
gpts[idx].ptype= 3; /* EFI System Partition */
|
2014-10-28 14:03:42 +00:00
|
|
|
else
|
|
|
|
gpts[idx].ptype= 0;
|
2019-02-18 12:19:32 +00:00
|
|
|
Xorriso_parse_guid(xorriso, textpt, gpts[idx].type_guid, 1);
|
2014-10-28 14:03:42 +00:00
|
|
|
|
2015-05-07 07:54:16 +00:00
|
|
|
} else if(strcmp(name, "GPT start and size :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
2017-04-09 17:52:54 +00:00
|
|
|
if(num[2] > 0)
|
2015-05-07 07:54:16 +00:00
|
|
|
appended_as_gpt= 1;
|
2019-02-18 12:19:32 +00:00
|
|
|
start_block= gpts[idx].start_block= num[1];
|
|
|
|
num_blocks= gpts[idx].block_count= num[2];
|
|
|
|
if(start_block == partition_offset * 4 &&
|
|
|
|
(start_block + num_blocks) >= high_block * 4 &&
|
|
|
|
iso_gpt_part_idx < 0)
|
|
|
|
iso_gpt_part_idx= idx;
|
2015-05-07 07:54:16 +00:00
|
|
|
|
|
|
|
} else if(strcmp(name, "GPT partition path :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
|
|
|
gpts[idx].has_path= 1;
|
2015-05-11 16:04:21 +00:00
|
|
|
gpts[idx].path= textpt;
|
2015-05-07 07:54:16 +00:00
|
|
|
|
2016-04-25 10:09:34 +00:00
|
|
|
} else if(strcmp(name, "GPT partition name :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
|
|
|
if(strstr(contentpt, " 470061007000") != NULL) /* "Gap"... */
|
|
|
|
gpts[idx].is_gap= 1;
|
|
|
|
|
2015-05-14 10:08:32 +00:00
|
|
|
} else if(strcmp(name, "APM partition name :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
|
|
|
if(strcmp(textpt, "HFSPLUS_Hybrid") == 0)
|
|
|
|
apms[idx].ptype|= 2;
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
} else if(strcmp(name, "APM partition type :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
|
|
|
if(strcmp(textpt, "Apple_HFS") == 0)
|
2015-05-14 10:08:32 +00:00
|
|
|
apms[idx].ptype|= 1;
|
|
|
|
|
|
|
|
} else if(strcmp(name, "APM partition path :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
|
|
|
apms[idx].path= textpt;
|
2014-10-28 14:03:42 +00:00
|
|
|
|
2015-05-07 15:20:42 +00:00
|
|
|
} else if(strcmp(name, "DEC Alpha ldr path :") == 0) {
|
|
|
|
have_alpha_ldr_path= 1;
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-12 11:33:20 +00:00
|
|
|
if(appended_as_gpt && !have_protective_msdos) {
|
2022-04-22 11:33:52 +00:00
|
|
|
/* Check if really a pure GPT or a nearly pure mbr-force-bootable GPT */
|
|
|
|
if(mbr_count != 1 && !(mbr_count == 2 && have_mbr_force_bootable)) {
|
2018-09-12 11:33:20 +00:00
|
|
|
appended_as_gpt= 0;
|
|
|
|
} else if(mbrpts[0].ptype != 0xee || mbrpts[0].start_block != 1) {
|
|
|
|
appended_as_gpt= 0;
|
|
|
|
} else if(gpt_bheader_block != mbrpts[0].block_count) {
|
|
|
|
appended_as_gpt= 0;
|
|
|
|
}
|
|
|
|
}
|
2016-04-25 10:09:34 +00:00
|
|
|
|
2017-11-25 10:00:29 +00:00
|
|
|
iso_part_blocks= img_blocks;
|
|
|
|
for(mbr_idx = 0; mbr_idx < mbr_count; mbr_idx++) {
|
|
|
|
if(mbrpts[mbr_idx].start_block == partition_offset * 4) {
|
|
|
|
iso_part_blocks= mbrpts[mbr_idx].block_count + partition_offset * 4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
/* Second pass: scan for System Area info */
|
|
|
|
for(i= 0; i < line_count; i++) {
|
|
|
|
buf[0]= 0;
|
|
|
|
ret= Xorriso_split_report_line(xorriso, lines[i], 8, name, &contentpt,
|
|
|
|
num, &num_count, &textpt, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
|
|
|
|
if(strcmp(name, "System area options:") == 0) {
|
|
|
|
if((sa_options & 0x3c00) == 0x0400) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-chrp-boot-part ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any chrp_boot_part=on ");
|
2022-10-07 09:55:10 +00:00
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
buf[0]= 0;
|
|
|
|
ret= Xorriso_assess_written_features(xorriso,
|
|
|
|
mkisofs ? "as_mkisofs" : "cmd", 1);
|
|
|
|
if(ret > 0) {
|
|
|
|
ftext= xorriso->result_line;
|
|
|
|
ftext_l= strlen(ftext);
|
|
|
|
for(cpt= ftext ; cpt - ftext < ftext_l ; cpt+= l + 1) {
|
|
|
|
npt= strchr(cpt, '\n');
|
|
|
|
if(npt == NULL)
|
|
|
|
l= strlen(cpt);
|
|
|
|
else
|
|
|
|
l= npt - cpt;
|
|
|
|
cpt[l]= 0;
|
|
|
|
/* Only forward relaxations of ISO 9660 defaults, plus no RR */
|
|
|
|
if(mkisofs) {
|
|
|
|
if(strcmp(cpt, "-iso-level 2") != 0 &&
|
|
|
|
strcmp(cpt, "-iso-level 3") != 0 &&
|
|
|
|
strcmp(cpt, "--norock") != 0 &&
|
|
|
|
strncmp(cpt, "-untranslated_name_len", 22) != 0 &&
|
|
|
|
strcmp(cpt, "-N") != 0 &&
|
|
|
|
strcmp(cpt, "-D") != 0 &&
|
|
|
|
strcmp(cpt, "-U") != 0 &&
|
|
|
|
strcmp(cpt, "-max-iso9660-filenames") != 0 &&
|
|
|
|
strcmp(cpt, "-d") != 0 &&
|
|
|
|
strcmp(cpt, "-allow-lowercase") != 0)
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
/* (Do not forward iso_9660_level because 3 is default and the
|
|
|
|
user possibly had reasons to lower it) */
|
|
|
|
if(strcmp(cpt, "-rockridge off") != 0 &&
|
|
|
|
strncmp(cpt, "-compliance untranslated_name_len=", 34) != 0 &&
|
|
|
|
strcmp(cpt, "-compliance omit_version_off:only_iso_version")
|
|
|
|
!= 0 &&
|
|
|
|
strcmp(cpt, "-compliance omit_version:only_iso_version_off")
|
|
|
|
!= 0 &&
|
|
|
|
strcmp(cpt, "-compliance deep_paths") != 0 &&
|
|
|
|
strcmp(cpt, "-compliance long_paths") != 0 &&
|
|
|
|
strcmp(cpt, "-compliance full_ascii") != 0 &&
|
|
|
|
strcmp(cpt, "-compliance long_names") != 0 &&
|
|
|
|
strncmp(cpt, "-compliance no_force_dots:", 26) != 0 &&
|
|
|
|
strcmp(cpt, "-compliance lowercase") != 0)
|
|
|
|
continue;
|
|
|
|
if(strcmp(cpt, "-compliance untranslated_name_len=0") == 0)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(strncmp(cpt, "-compliance untranslated_name_len=", 34) == 0) {
|
|
|
|
/* Better allow the maximum if it is reported as non-0 */
|
|
|
|
strcpy(buf, "-compliance untranslated_name_len=96");
|
|
|
|
} else {
|
|
|
|
strcpy(buf, cpt);
|
|
|
|
}
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if(strcmp(name, "System area summary:") == 0) {
|
|
|
|
if(strstr(textpt, "isohybrid") != NULL) {
|
|
|
|
isohybrid= 1;
|
|
|
|
if(mkisofs)
|
2015-05-07 07:54:16 +00:00
|
|
|
sprintf(buf, "-isohybrid-mbr ");
|
2014-10-28 14:03:42 +00:00
|
|
|
else
|
2015-05-07 07:54:16 +00:00
|
|
|
sprintf(buf, "-boot_image isolinux system_area=");
|
2015-05-07 15:20:42 +00:00
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
|
2015-05-10 09:34:30 +00:00
|
|
|
imported_iso | ptable_killer);
|
2014-10-28 14:03:42 +00:00
|
|
|
Xorriso_record_cmd_linE
|
2020-12-05 08:53:59 +00:00
|
|
|
strcpy(buf, "mbr_code_isohybrid.img/");
|
|
|
|
Xorriso_add_offset_size(xorriso, buf, (off_t) 0, (off_t) 446, 0);
|
|
|
|
Xorriso_record_boot_imglinE
|
2015-05-07 15:20:42 +00:00
|
|
|
did_sysarea= 1;
|
2014-10-28 14:03:42 +00:00
|
|
|
}
|
|
|
|
if(strstr(textpt, "grub2-mbr") != NULL) {
|
|
|
|
if(mkisofs)
|
2015-05-07 07:54:16 +00:00
|
|
|
sprintf(buf, "--grub2-mbr ");
|
2014-10-28 14:03:42 +00:00
|
|
|
else
|
2015-05-07 07:54:16 +00:00
|
|
|
sprintf(buf, "-boot_image grub grub2_mbr=");
|
2015-05-07 15:20:42 +00:00
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
|
2015-05-10 09:34:30 +00:00
|
|
|
imported_iso | ptable_killer);
|
2014-10-28 14:03:42 +00:00
|
|
|
Xorriso_record_cmd_linE
|
2020-12-05 08:53:59 +00:00
|
|
|
strcpy(buf, "mbr_code_grub2.img/");
|
|
|
|
Xorriso_add_offset_size(xorriso, buf, (off_t) 0, (off_t) 446, 0);
|
|
|
|
Xorriso_record_boot_imglinE
|
2015-05-07 15:20:42 +00:00
|
|
|
did_sysarea= 1;
|
2014-10-28 14:03:42 +00:00
|
|
|
}
|
|
|
|
if(strstr(textpt, "protective-msdos-label") != NULL) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "--protective-msdos-label");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any partition_table=on");
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
if(strstr(textpt, "cyl-align-off") != NULL) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-partition_cyl_align off");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any partition_cyl_align=off");
|
|
|
|
} else if(strstr(textpt, "cyl-align-all") != NULL) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-partition_cyl_align all");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any partition_cyl_align=all");
|
|
|
|
} else if(strstr(textpt, "cyl-align-") != NULL) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-partition_cyl_align on");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any partition_cyl_align=on");
|
|
|
|
} else
|
|
|
|
buf[0]= 0;
|
|
|
|
|
|
|
|
} else if(strcmp(name, "Partition offset :") == 0 &&
|
|
|
|
(num[0] == 0 || num[0] == 16)) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-partition_offset %.f", num[0]);
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any partition_offset=%.f", num[0]);
|
|
|
|
|
|
|
|
} else if(strcmp(name, "MBR heads per cyl :") == 0 &&
|
|
|
|
(num[0] > 0 && num[0] <= 255)) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-partition_hd_cyl %.f", num[0]);
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any partition_hd_cyl=%.f", num[0]);
|
|
|
|
|
|
|
|
} else if(strcmp(name, "MBR secs per head :") == 0 &&
|
|
|
|
(num[0] > 0 && num[0] <= 63)) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-partition_sec_hd %.f", num[0]);
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any partition_sec_hd=%.f", num[0]);
|
|
|
|
|
|
|
|
} else if(strcmp(name, "MBR partition :") == 0) {
|
2015-05-07 07:54:16 +00:00
|
|
|
sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu",
|
2020-12-05 08:53:59 +00:00
|
|
|
&partno, &part_status, &part_type, &mbr_start_block,
|
|
|
|
&mbr_num_blocks);
|
|
|
|
if(mbr_num_blocks > 0 && part_type != 0x00 && part_type != 0xee &&
|
|
|
|
(iso_part_blocks <= mbr_start_block ||
|
2016-01-01 17:28:46 +00:00
|
|
|
(have_protective_msdos && img_blocks == mbr_parts_end &&
|
|
|
|
partno > 1))) {
|
2015-05-07 07:54:16 +00:00
|
|
|
if(!appended_as_gpt) {
|
|
|
|
sprintf(buf, "-append_partition %lu 0x%lx ", partno, part_type);
|
2020-12-05 08:53:59 +00:00
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) mbr_start_block,
|
|
|
|
((uint64_t) mbr_start_block) + mbr_num_blocks - 1,
|
|
|
|
"d", imported_iso);
|
|
|
|
Xorriso_record_cmd_linE
|
2016-01-01 17:28:46 +00:00
|
|
|
if(partno >= 1 && (int) partno <= mbr_count)
|
|
|
|
mbrpts[partno - 1].appended= 1;
|
2018-09-09 12:59:47 +00:00
|
|
|
|
|
|
|
#ifdef Not_any_more_because_padding_is_now_after_partitions
|
2016-04-25 10:09:34 +00:00
|
|
|
appended_partition= 1;
|
2018-09-09 12:59:47 +00:00
|
|
|
#endif
|
|
|
|
|
2015-05-07 07:54:16 +00:00
|
|
|
}
|
2020-12-05 08:53:59 +00:00
|
|
|
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
|
|
|
|
}
|
2015-05-07 07:54:16 +00:00
|
|
|
} else if(part_type == 0x41 && have_prep) {
|
|
|
|
if(mkisofs) {
|
|
|
|
sprintf(buf, "-prep-boot-part ");
|
|
|
|
} else {
|
|
|
|
sprintf(buf, "-boot_image any prep_boot_part=");
|
|
|
|
}
|
2020-12-05 08:53:59 +00:00
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) mbr_start_block,
|
|
|
|
((uint64_t) mbr_start_block) + mbr_num_blocks - 1,
|
|
|
|
"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
|
2018-09-09 13:04:05 +00:00
|
|
|
}
|
|
|
|
if((part_status & 0x80) && !was_force_bootable) {
|
|
|
|
was_force_bootable= 1;
|
|
|
|
if(buf[0]) {
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
2016-01-01 17:28:46 +00:00
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "--mbr-force-bootable");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any mbr_force_bootable=on");
|
2015-05-07 07:54:16 +00:00
|
|
|
}
|
2015-05-10 09:34:30 +00:00
|
|
|
} else if(strcmp(name, "MBR partition path :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
2015-05-14 10:08:32 +00:00
|
|
|
if(mbrpts[idx].ptype == 0x41) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Cannot make proposal to mark PReP partition by data file: ");
|
|
|
|
Text_shellsafe(textpt, xorriso->info_text, 1);
|
2020-12-05 08:53:59 +00:00
|
|
|
if(!(flag & 5))
|
2015-05-14 10:08:32 +00:00
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
2015-05-11 16:04:21 +00:00
|
|
|
continue;
|
2015-05-14 10:08:32 +00:00
|
|
|
}
|
|
|
|
ptype= 0;
|
|
|
|
if(mbrpts[idx].ptype == 0xef)
|
|
|
|
ptype= 3;
|
|
|
|
ret= Xorriso_search_eltorito_path(xorriso, et_imgs, elto_count,
|
|
|
|
textpt, ptype,
|
|
|
|
&et_idx, &efi_boot_part, !!isohybrid);
|
|
|
|
if(ret <= 0) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Cannot make proposal to mark data file as MBR partition without being an El Torito boot image : ");
|
|
|
|
Text_shellsafe(textpt, xorriso->info_text, 1);
|
2020-12-05 08:53:59 +00:00
|
|
|
if(!(flag & 5))
|
2015-05-14 10:08:32 +00:00
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
} else {
|
|
|
|
for(gpt_idx= 0; gpt_idx < gpt_count; gpt_idx++) {
|
|
|
|
if(gpts[gpt_idx].path != NULL)
|
|
|
|
if(strcmp(gpts[gpt_idx].path, textpt) == 0)
|
|
|
|
break;
|
2015-05-11 16:04:21 +00:00
|
|
|
}
|
2015-05-14 10:08:32 +00:00
|
|
|
if(gpt_idx >= gpt_count) {
|
2015-05-11 16:04:21 +00:00
|
|
|
sprintf(xorriso->info_text,
|
2015-05-14 10:08:32 +00:00
|
|
|
"Cannot make proposal to mark data file as MBR partition without being in GPT : ");
|
2015-05-10 09:34:30 +00:00
|
|
|
Text_shellsafe(textpt, xorriso->info_text, 1);
|
2020-12-05 08:53:59 +00:00
|
|
|
if(!(flag & 5))
|
2015-05-11 16:04:21 +00:00
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
}
|
2015-05-10 09:34:30 +00:00
|
|
|
}
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
} else if(strcmp(name, "GPT disk GUID :") == 0) {
|
|
|
|
|
|
|
|
/* >>> ??? need command to set disk GUID */;
|
|
|
|
|
|
|
|
} else if(strcmp(name, "GPT partition name :") == 0) {
|
|
|
|
|
|
|
|
/* >>> ??? need command to set partition name for partition number */;
|
|
|
|
|
|
|
|
} else if(strcmp(name, "GPT partition GUID :") == 0) {
|
|
|
|
|
|
|
|
/* >>> ??? need command to set partition GUID for partition number */;
|
|
|
|
|
|
|
|
} else if(strcmp(name, "GPT partition flags:") == 0) {
|
|
|
|
|
2021-05-25 19:18:48 +00:00
|
|
|
/* >>> check whether 0x100000000000000[15] . Else: complain */;
|
|
|
|
|
|
|
|
cpt= strstr(contentpt, "0x");
|
|
|
|
if(cpt != NULL) {
|
|
|
|
ret= Hex_to_bin(cpt + 2, 8, &bin_count, bin_data, 0);
|
|
|
|
if(ret > 0) {
|
|
|
|
/* convert big-endian bin_data to local endianness */
|
|
|
|
gpt_part_flags= 0;
|
|
|
|
for(gpt_idx= 0; gpt_idx < bin_count; gpt_idx++)
|
|
|
|
gpt_part_flags|= (((uint64_t) bin_data[gpt_idx]) <<
|
|
|
|
(8 * (bin_count - 1 - gpt_idx)));
|
|
|
|
|
|
|
|
if((gpt_part_flags & 4) && !was_gpt_iso_bootable) {
|
|
|
|
was_gpt_iso_bootable= 1;
|
|
|
|
if(buf[0]) {
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "--gpt-iso-bootable");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any gpt_iso_bootable=on");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(num_count > 0 && num[0] == 1 &&
|
|
|
|
(!(gpt_part_flags & (((uint64_t) 1) << 60))) &&
|
|
|
|
!was_gpt_iso_not_ro) {
|
|
|
|
was_gpt_iso_not_ro= 1;
|
|
|
|
if(buf[0]) {
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "--gpt-iso-not-ro");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any gpt_iso_not_ro=on");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
|
|
|
|
} else if(strcmp(name, "GPT partition path :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
2015-05-11 16:04:21 +00:00
|
|
|
ret= Xorriso_search_eltorito_path(xorriso, et_imgs, elto_count,
|
|
|
|
textpt, gpts[idx].ptype,
|
|
|
|
&et_idx, &efi_boot_part, !!isohybrid);
|
|
|
|
if(ret <= 0) {
|
2015-05-10 09:34:30 +00:00
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Cannot make proposal to mark data file as GPT partition : ");
|
|
|
|
Text_shellsafe(textpt, xorriso->info_text, 1);
|
2020-12-05 08:53:59 +00:00
|
|
|
if(!(flag & 5))
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
2015-05-10 09:34:30 +00:00
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
|
2015-05-07 07:54:16 +00:00
|
|
|
} else if(strcmp(name, "GPT start and size :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
|
|
|
if(gpts[idx].ptype == 3)
|
|
|
|
part_type= 0xef;
|
|
|
|
else
|
|
|
|
part_type= 0xcd;
|
2016-04-25 10:09:34 +00:00
|
|
|
|
2022-04-22 11:32:25 +00:00
|
|
|
fresh_efi_boot_part= 0;
|
2018-09-12 11:33:20 +00:00
|
|
|
if(high_block * 4 < num[1] && num[2] > 0 && !gpts[idx].is_gap) {
|
2016-04-25 10:09:34 +00:00
|
|
|
for(mbr_idx = 0; mbr_idx < mbr_count; mbr_idx++) {
|
2017-04-09 17:54:12 +00:00
|
|
|
if(mbrpts[mbr_idx].start_block == num[1]) {
|
|
|
|
if(mbrpts[mbr_idx].block_count != num[2] && !(flag & 1)) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"GPT partition %d has same start block as MBR partition %d but different block count (%.f <> %.f)",
|
|
|
|
idx + 1, mbr_idx + 1, num[2],
|
|
|
|
(double) mbrpts[mbr_idx].block_count);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING",
|
|
|
|
0);
|
|
|
|
}
|
2016-04-25 10:09:34 +00:00
|
|
|
break;
|
2017-04-09 17:54:12 +00:00
|
|
|
}
|
2016-04-25 10:09:34 +00:00
|
|
|
}
|
|
|
|
if(mbr_idx >= mbr_count) {
|
2019-02-18 12:19:32 +00:00
|
|
|
if(appended_as_gpt == 1) {
|
2016-04-25 10:09:34 +00:00
|
|
|
appended_as_gpt= 2;
|
2019-02-18 12:19:32 +00:00
|
|
|
Xorriso__format_guid(gpts[idx].type_guid, part_type_text, 0);
|
|
|
|
} else {
|
|
|
|
sprintf(part_type_text, "0x%lx", part_type);
|
|
|
|
}
|
|
|
|
sprintf(buf, "-append_partition %d %s ", idx + 1, part_type_text);
|
2016-04-25 10:09:34 +00:00
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) num[1],
|
|
|
|
(uint64_t) (num[1] + num[2] - 1.0), "d",
|
|
|
|
imported_iso);
|
2017-04-09 17:52:54 +00:00
|
|
|
Xorriso_record_cmd_linE
|
2018-09-09 12:59:47 +00:00
|
|
|
|
|
|
|
#ifdef Not_any_more_because_padding_is_now_after_partitions
|
2016-04-25 10:09:34 +00:00
|
|
|
appended_partition= 1;
|
2018-09-09 12:59:47 +00:00
|
|
|
#endif
|
|
|
|
|
2016-04-25 10:09:34 +00:00
|
|
|
}
|
|
|
|
|
2022-04-22 11:32:25 +00:00
|
|
|
} else if(gpts[idx].ptype == 3 && gpts[idx].has_path == 0 &&
|
|
|
|
img_blocks >= num[1] + num[2] && !efi_boot_part) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-efi-boot-part ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any efi_boot_part=");
|
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) num[1],
|
|
|
|
(uint64_t) (num[1] + num[2] - 1.0), "d",
|
|
|
|
imported_iso);
|
|
|
|
efi_boot_part= 2;
|
|
|
|
fresh_efi_boot_part= 1;
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!fresh_efi_boot_part) {
|
2017-04-09 17:52:54 +00:00
|
|
|
/* Check for isohybri-ish MBR and GPT mix */
|
2020-10-24 12:19:57 +00:00
|
|
|
if((mbr_count == 1 || (mbr_count == 2 && have_mbr_force_bootable)) &&
|
|
|
|
mbrpts[0].ptype == 0xee && have_protective_msdos) {
|
|
|
|
/* real GPT (+/- mbr_force_bootable) is not -part_like_isohybrid */
|
2017-04-09 17:52:54 +00:00
|
|
|
ret= 0;
|
|
|
|
} else {
|
|
|
|
ret= Xorriso_search_eltorito_lba(xorriso, et_imgs, elto_count,
|
|
|
|
(unsigned int) (num[1] / 4.0),
|
|
|
|
&et_idx, 0);
|
|
|
|
}
|
2016-04-25 10:09:34 +00:00
|
|
|
if(ret > 0) {
|
2022-04-22 11:33:52 +00:00
|
|
|
if(!(isohybrid ||
|
|
|
|
et_imgs[et_idx].do_gpt_basdat ||
|
2016-04-25 10:09:34 +00:00
|
|
|
et_imgs[et_idx].do_gpt_hfsplus ||
|
|
|
|
part_like_isohybrid)) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-part_like_isohybrid");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any part_like_isohybrid=on");
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
part_like_isohybrid= 1;
|
2017-09-10 16:50:19 +00:00
|
|
|
appended_as_gpt= 0;
|
2016-04-25 10:09:34 +00:00
|
|
|
}
|
|
|
|
/* mark el torito for -isohybrid-gpt-... */
|
|
|
|
Xorriso_register_eltorito_gpt(xorriso, et_imgs + et_idx,
|
|
|
|
gpts[idx].ptype, &efi_boot_part,
|
|
|
|
&fe_dummy, 1);
|
2022-04-22 11:32:25 +00:00
|
|
|
if(efi_boot_part == 1) {
|
|
|
|
/* -isohybrid-gpt- substitutes for -efi-boot-part --efi-boot-image */
|
|
|
|
efi_boot_part= 2;
|
|
|
|
}
|
2015-05-07 07:54:16 +00:00
|
|
|
}
|
2020-12-05 08:53:59 +00:00
|
|
|
}
|
2015-05-07 07:54:16 +00:00
|
|
|
|
2020-12-05 08:53:59 +00:00
|
|
|
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
|
2015-05-07 07:54:16 +00:00
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
|
|
|
|
} else if(strcmp(name, "APM block size :") == 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-apm-block-size %.f", num[0]);
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any apm_block_size=%.f", num[0]);
|
|
|
|
|
|
|
|
} else if(strcmp(name, "APM partition name :") == 0) {
|
|
|
|
|
|
|
|
/* >>> ??? need command to set APM partition name for partition number */;
|
|
|
|
|
|
|
|
} else if(strcmp(name, "APM partition path :") == 0) {
|
|
|
|
idx= num[0] - 1;
|
|
|
|
/* Check El Torito EFI boot images for same path */
|
|
|
|
for(et_idx= 0; isohybrid && et_idx < elto_count; et_idx++)
|
|
|
|
if(strcmp(et_imgs[et_idx].path, textpt) == 0) {
|
2015-11-10 10:49:41 +00:00
|
|
|
if(apms[idx].ptype == 1) {
|
2014-10-28 14:03:42 +00:00
|
|
|
et_imgs[et_idx].do_apm_hfsplus= 1;
|
2015-05-07 15:20:42 +00:00
|
|
|
cared_for_apm= 1;
|
2015-11-10 10:49:41 +00:00
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-05-07 07:54:16 +00:00
|
|
|
} else if(strcmp(name, "APM start and size :") == 0) {
|
2015-05-14 10:08:32 +00:00
|
|
|
idx= num[0] - 1;
|
|
|
|
|
|
|
|
if(num[1] + num[2] <= img_blocks && apms[idx].ptype == 3 &&
|
|
|
|
apms[idx].path == NULL && !have_hfsplus) {
|
|
|
|
|
|
|
|
/* >>> HFS+ magic number */;
|
|
|
|
/* >>> Read byte 1024 and 1025 after partition start
|
|
|
|
Must be {'H', '+'} (0x482b big endian)
|
|
|
|
*/;
|
|
|
|
/* ??? >>> Do this recognition in libisofs ? */
|
2015-05-07 07:54:16 +00:00
|
|
|
|
2015-05-14 10:08:32 +00:00
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-hfsplus");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-hfsplus on");
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
|
|
|
/* Report commands for blessings and creator-type */
|
|
|
|
ret= Findjob_new(&job, "/", 0);
|
|
|
|
if(ret <= 0) {
|
|
|
|
Xorriso_no_findjob(xorriso, "xorriso", 0);
|
|
|
|
{ret= -1; goto ex;}
|
|
|
|
}
|
|
|
|
Findjob_set_action_target(job, 53, NULL, 0);
|
|
|
|
xorriso->show_hfs_cmd_count= *cmd_count;
|
|
|
|
xorriso->show_hfs_cmds= cmds;
|
|
|
|
xorriso->show_hfs_cmd_flag= (flag & 1) | ((!!mkisofs) << 1);
|
|
|
|
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, NULL, "/",
|
|
|
|
&dir_stbuf, 0, 0);
|
|
|
|
*cmd_count= xorriso->show_hfs_cmd_count;
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
have_hfsplus= 1;
|
|
|
|
cared_for_apm= 1;
|
|
|
|
}
|
2015-05-07 07:54:16 +00:00
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
} else if(strcmp(name, "MIPS-BE boot path :") == 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-mips-boot ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any mips_path=");
|
|
|
|
Text_shellsafe(textpt, buf, 1);
|
|
|
|
|
|
|
|
} else if(strcmp(name, "MIPS-LE boot path :") == 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-mipsel-boot ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any mipsel_path=");
|
|
|
|
Text_shellsafe(textpt, buf, 1);
|
|
|
|
|
|
|
|
} else if(strcmp(name, "SUN SPARC disklabel:") == 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-sparc-label ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any sparc_label=");
|
|
|
|
Text_shellsafe(textpt, buf, 1);
|
|
|
|
|
|
|
|
} else if(strcmp(name, "SPARC GRUB2 path :") == 0) {
|
2014-11-13 18:04:24 +00:00
|
|
|
if(mkisofs) {
|
|
|
|
sprintf(buf, "-B ,");
|
|
|
|
Xorriso_record_cmd_linE
|
2014-10-28 14:03:42 +00:00
|
|
|
sprintf(buf, "--grub2-sparc-core ");
|
2014-11-13 18:04:24 +00:00
|
|
|
} else
|
2014-10-28 14:03:42 +00:00
|
|
|
sprintf(buf, "-boot_image grub grub2_sparc_core=");
|
|
|
|
Text_shellsafe(textpt, buf, 1);
|
2015-05-10 09:34:30 +00:00
|
|
|
cared_for_sparc= 1;
|
2014-10-28 14:03:42 +00:00
|
|
|
|
|
|
|
} else if(strcmp(name, "SUN SPARC partition:") == 0) {
|
|
|
|
have_sparc_part= 1;
|
|
|
|
partno= id_tag= perms= num_blocks= 0;
|
|
|
|
start_cyl= 0xffffffff;
|
|
|
|
sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu",
|
2020-12-05 08:53:59 +00:00
|
|
|
&partno, &id_tag, &perms, &start_cyl, &mbr_num_blocks);
|
2016-02-27 17:00:24 +00:00
|
|
|
if(partno > 0 && partno < 9 && start_cyl == 0 &&
|
2020-12-05 08:53:59 +00:00
|
|
|
mbr_num_blocks >= img_blocks - 600 && mbr_num_blocks <= img_blocks &&
|
2016-02-27 17:00:24 +00:00
|
|
|
((partno == 1 && id_tag == 4) || (partno > 1 && id_tag == 2)))
|
2014-10-28 14:03:42 +00:00
|
|
|
full_sparc_part|= (1 << (partno - 1));
|
|
|
|
|
|
|
|
} else if(strcmp(name, "PALO header version:") == 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-hppa-hdrversion %.f", num[0]);
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any hppa_hdrversion=%.f", num[0]);
|
|
|
|
|
|
|
|
} else if(strcmp(name, "HP-PA cmdline :") == 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-hppa-cmdline ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any hppa_cmdline=");
|
|
|
|
Text_shellsafe(textpt, buf, 1);
|
|
|
|
|
|
|
|
} else if(strcmp(name, "HP-PA 32-bit kernel:") == 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-hppa-kernel-32 ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any hppa_kernel_32=");
|
|
|
|
Text_shellsafe(textpt, buf, 1);
|
|
|
|
|
|
|
|
} else if(strcmp(name, "HP-PA 64-bit kernel:") == 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-hppa-kernel-64 ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any hppa_kernel_64=");
|
|
|
|
Text_shellsafe(textpt, buf, 1);
|
|
|
|
|
|
|
|
} else if(strcmp(name, "HP-PA ramdisk :") == 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-hppa-ramdisk ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any hppa_ramdisk=");
|
|
|
|
Text_shellsafe(textpt, buf, 1);
|
|
|
|
|
|
|
|
} else if(strcmp(name, "HP-PA bootloader :") == 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-hppa-bootloader ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any hppa_bootloader=");
|
|
|
|
Text_shellsafe(textpt, buf, 1);
|
|
|
|
|
2015-05-07 15:20:42 +00:00
|
|
|
} else if(strcmp(name, "DEC Alpha ldr adr :") == 0) {
|
|
|
|
if(!have_alpha_ldr_path) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Cannot enable DEC Alpha boot loader because it is not a data file in the ISO filesystem");
|
2020-12-05 08:53:59 +00:00
|
|
|
if(!(flag & 5))
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
2015-05-07 15:20:42 +00:00
|
|
|
}
|
|
|
|
|
2015-02-28 14:31:04 +00:00
|
|
|
} else if(strcmp(name, "DEC Alpha ldr path :") == 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-alpha-boot ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any alpha_boot=");
|
|
|
|
Text_shellsafe(textpt, buf, 1);
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(buf[0])
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:50:19 +00:00
|
|
|
if(appended_as_gpt == 2) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-appended_part_as_gpt");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any appended_part_as=gpt");
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
if(have_sparc_part) {
|
|
|
|
if(full_sparc_part == 255) {
|
|
|
|
if(mkisofs) {
|
2015-05-07 07:54:16 +00:00
|
|
|
sprintf(buf, "-G ");
|
2015-05-10 09:34:30 +00:00
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
|
|
|
|
imported_iso);
|
2014-10-28 14:03:42 +00:00
|
|
|
Xorriso_record_cmd_linE
|
2015-05-07 15:20:42 +00:00
|
|
|
did_sysarea= 1;
|
2014-10-28 14:03:42 +00:00
|
|
|
sprintf(buf, "-B ...");
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
} else {
|
2015-05-07 07:54:16 +00:00
|
|
|
sprintf(buf, "-boot_image any system_area=");
|
2015-05-10 09:34:30 +00:00
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
|
|
|
|
imported_iso);
|
2014-10-28 14:03:42 +00:00
|
|
|
Xorriso_record_cmd_linE
|
2015-05-07 15:20:42 +00:00
|
|
|
did_sysarea= 1;
|
2014-10-28 14:03:42 +00:00
|
|
|
for(i= 2; i <= 8; i++) {
|
|
|
|
sprintf(buf, "-append_partition %d 0x00 .", i);
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
}
|
2015-05-10 09:34:30 +00:00
|
|
|
cared_for_sparc= 1;
|
|
|
|
} else if(!cared_for_sparc) {
|
2015-05-07 15:20:42 +00:00
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Cannot enable SUN Disk Label because of non-trivial partition layout");
|
2020-12-05 08:53:59 +00:00
|
|
|
if(!(flag & 5))
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
2014-10-28 14:03:42 +00:00
|
|
|
}
|
|
|
|
}
|
2015-05-07 15:20:42 +00:00
|
|
|
if(have_sysarea && !did_sysarea) {
|
|
|
|
/* Zeroize old partition tables from -indev */
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-G ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any system_area=");
|
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
|
2015-05-10 09:34:30 +00:00
|
|
|
imported_iso | ptable_killer);
|
2015-05-07 15:20:42 +00:00
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
did_sysarea= 1;
|
|
|
|
}
|
2020-12-05 08:53:59 +00:00
|
|
|
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
|
|
|
|
}
|
2019-07-22 18:14:53 +00:00
|
|
|
if(iso_mbr_part_type >= 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-iso_mbr_part_type 0x%2.2x",
|
|
|
|
(unsigned int) iso_mbr_part_type);
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any iso_mbr_part_type=0x%2.2x",
|
|
|
|
(unsigned int) iso_mbr_part_type);
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
|
|
|
} else if(iso_gpt_part_idx >= 0) {
|
2019-02-18 12:19:32 +00:00
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-iso_mbr_part_type ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any iso_mbr_part_type=");
|
|
|
|
Xorriso__format_guid(gpts[iso_gpt_part_idx].type_guid, buf + strlen(buf),
|
|
|
|
0);
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
2017-08-24 10:23:25 +00:00
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
|
2015-05-07 15:20:42 +00:00
|
|
|
/* Issue commands related to El Torito */
|
2014-10-28 14:03:42 +00:00
|
|
|
if(elto_count <= 0)
|
|
|
|
goto after_el_torito;
|
|
|
|
|
2019-09-29 20:54:19 +00:00
|
|
|
if(efi_boot_part == 1) {
|
2014-10-28 14:03:42 +00:00
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-efi-boot-part --efi-boot-image");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any efi_boot_part=--efi-boot-image");
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
if(cat_path[0]) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-c ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any cat_path=");
|
|
|
|
Text_shellsafe(cat_path, buf, 1);
|
|
|
|
} else {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "--boot-catalog-hide");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any cat_hidden=on");
|
|
|
|
}
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
for(idx= 0; idx < elto_count; idx++) {
|
2020-12-05 08:53:59 +00:00
|
|
|
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
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
if(et_imgs[idx].ld_seg != 0 && et_imgs[idx].ld_seg != 0x07c0) {
|
2020-12-05 08:53:59 +00:00
|
|
|
if(!(flag & 5)) {
|
2015-05-07 15:20:42 +00:00
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Cannot enable EL Torito boot image #%d because its Load Segment is neither 0x0 nor 0x7c0",
|
|
|
|
idx + 1);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(idx > 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-eltorito-alt-boot");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any next");
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
if(et_imgs[idx].path[0] == 0) {
|
2016-01-01 17:28:46 +00:00
|
|
|
/* Check whether appended partition */;
|
|
|
|
for(i= 0; i < mbr_count; i++)
|
2016-04-25 10:09:34 +00:00
|
|
|
if((mbrpts[i].appended || !mbrpts[i].has_path) &&
|
2016-01-01 17:28:46 +00:00
|
|
|
mbrpts[i].start_block == ((uint64_t) et_imgs[idx].lba) * 4 &&
|
|
|
|
(mbrpts[i].block_count == (uint64_t) et_imgs[idx].ldsiz ||
|
|
|
|
et_imgs[idx].ldsiz == 0 || et_imgs[idx].ldsiz == 1))
|
|
|
|
break;
|
|
|
|
if (i < mbr_count) {
|
2016-04-25 10:09:34 +00:00
|
|
|
if(!mbrpts[i].appended) {
|
|
|
|
mbrpts[i].appended= 1;
|
|
|
|
if(!appended_as_gpt) {
|
|
|
|
sprintf(buf, "-append_partition %lu 0x%lx ", (unsigned long) i + 1,
|
|
|
|
(unsigned long) mbrpts[i].ptype);
|
|
|
|
Xorriso_add_intvl_adr(xorriso, buf,
|
|
|
|
(uint64_t) mbrpts[i].start_block,
|
|
|
|
((uint64_t) mbrpts[i].start_block) +
|
|
|
|
mbrpts[i].block_count - 1,
|
|
|
|
"d", imported_iso);
|
|
|
|
Xorriso_record_cmd_linE
|
2018-09-09 12:59:47 +00:00
|
|
|
|
|
|
|
#ifdef Not_any_more_because_padding_is_now_after_partitions
|
2016-04-25 10:09:34 +00:00
|
|
|
appended_partition= 1;
|
2018-09-09 12:59:47 +00:00
|
|
|
#endif
|
|
|
|
|
2016-04-25 10:09:34 +00:00
|
|
|
buf[0]= 0;
|
|
|
|
}
|
|
|
|
}
|
2016-01-01 17:28:46 +00:00
|
|
|
sprintf(app_pseudo_paths[idx],
|
2016-01-20 10:43:13 +00:00
|
|
|
"--interval:appended_partition_%d_start_%lus_size_%lud:all::",
|
2016-01-01 17:28:46 +00:00
|
|
|
i + 1,
|
2016-01-20 10:43:13 +00:00
|
|
|
(unsigned long) et_imgs[idx].lba,
|
2016-01-01 17:28:46 +00:00
|
|
|
(unsigned long) mbrpts[i].block_count);
|
|
|
|
et_imgs[idx].path= app_pseudo_paths[idx];
|
2016-04-25 10:09:34 +00:00
|
|
|
}
|
2019-09-29 20:54:19 +00:00
|
|
|
if (et_imgs[idx].path[0] == 0 && efi_boot_part != 2) {
|
2016-04-25 10:09:34 +00:00
|
|
|
for(i= 0; i < gpt_count; i++) {
|
2022-04-22 11:33:52 +00:00
|
|
|
if((have_protective_msdos || appended_as_gpt) && (
|
2016-04-25 10:09:34 +00:00
|
|
|
gpts[i].start_block == ((uint64_t) et_imgs[idx].lba) * 4 &&
|
|
|
|
(gpts[i].block_count == (uint64_t) et_imgs[idx].ldsiz ||
|
|
|
|
et_imgs[idx].ldsiz == 0 || et_imgs[idx].ldsiz == 1)))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i < gpt_count) {
|
|
|
|
sprintf(app_pseudo_paths[idx],
|
|
|
|
"--interval:appended_partition_%d_start_%lus_size_%lud:all::",
|
|
|
|
i + 1,
|
|
|
|
(unsigned long) et_imgs[idx].lba,
|
|
|
|
(unsigned long) gpts[i].block_count);
|
|
|
|
et_imgs[idx].path= app_pseudo_paths[idx];
|
|
|
|
}
|
|
|
|
}
|
2020-12-05 08:53:59 +00:00
|
|
|
|
2016-04-25 10:09:34 +00:00
|
|
|
if (et_imgs[idx].path[0] == 0) {
|
2020-12-05 08:53:59 +00:00
|
|
|
|
|
|
|
/* >>> need way to exploit .extract_size by cutting out from ISO */;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (et_imgs[idx].path[0] == 0) {
|
|
|
|
if(!(flag & 5)) {
|
2016-01-01 17:28:46 +00:00
|
|
|
sprintf(xorriso->info_text,
|
2015-05-07 15:20:42 +00:00
|
|
|
"Cannot enable EL Torito boot image #%d because it is not a data file in the ISO filesystem",
|
|
|
|
idx + 1);
|
2016-01-01 17:28:46 +00:00
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
}
|
|
|
|
buf[0]= 0;
|
2016-04-25 10:09:34 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2017-06-03 19:35:22 +00:00
|
|
|
if(et_imgs[idx].platform_id != 0xef) {
|
|
|
|
if(mkisofs) {
|
|
|
|
if(prev_pltf != et_imgs[idx].platform_id) {
|
|
|
|
sprintf(buf, "-eltorito-platform 0x%2.2x", et_imgs[idx].platform_id);
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
prev_pltf= et_imgs[idx].platform_id;
|
2016-04-25 10:09:34 +00:00
|
|
|
sprintf(buf, "-b ");
|
2017-06-03 19:35:22 +00:00
|
|
|
} else {
|
2016-04-25 10:09:34 +00:00
|
|
|
sprintf(buf, "-boot_image %s bin_path=", et_imgs[idx].boot_image_type);
|
2017-06-03 19:35:22 +00:00
|
|
|
}
|
|
|
|
} else {
|
2016-04-25 10:09:34 +00:00
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-e ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image %s efi_path=", et_imgs[idx].boot_image_type);
|
2014-10-28 14:03:42 +00:00
|
|
|
}
|
|
|
|
Text_shellsafe(et_imgs[idx].path, buf, 1);
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
if(!mkisofs) {
|
|
|
|
sprintf(buf, "-boot_image any platform_id=0x%2.2x",
|
|
|
|
et_imgs[idx].platform_id);
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
if(strcmp(et_imgs[idx].emul, "none") == 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-no-emul-boot");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any emul_type=no_emulation");
|
|
|
|
} else if(strcmp(et_imgs[idx].emul, "hd") == 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-hard-disk-boot");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any emul_type=hard_disk");
|
|
|
|
} else {
|
|
|
|
if(mkisofs)
|
|
|
|
buf[0]= 0;
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any emul_type=diskette");
|
|
|
|
}
|
|
|
|
if(buf[0])
|
|
|
|
Xorriso_record_cmd_linE
|
2015-12-24 08:02:02 +00:00
|
|
|
if(et_imgs[idx].ldsiz >= 0) {
|
2014-10-28 14:03:42 +00:00
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-boot-load-size %d", et_imgs[idx].ldsiz);
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any load_size=%d", et_imgs[idx].ldsiz * 512);
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
if(et_imgs[idx].boot_info_table) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-boot-info-table");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any boot_info_table=on");
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
if(et_imgs[idx].grub2_boot_info) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "--grub2-boot-info");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image grub grub2_boot_info=on");
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
if(et_imgs[idx].id_string[0] != 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-eltorito-id ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any id_string=");
|
|
|
|
Text_shellsafe(et_imgs[idx].id_string, buf, 1);
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
if(et_imgs[idx].sel_crit[0] != 0) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-eltorito-selcrit ");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image any sel_crit=");
|
|
|
|
Text_shellsafe(et_imgs[idx].sel_crit, buf, 1);
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
2021-04-04 18:16:47 +00:00
|
|
|
if(et_imgs[idx].do_gpt_basdat &&
|
|
|
|
!(et_imgs[idx].do_gpt_basdat == 3 &&
|
|
|
|
strstr(et_imgs[idx].path, "--interval:appended_partition_") ==
|
|
|
|
et_imgs[idx].path)) { /* (not with appended EFI partition) */
|
2014-10-28 14:03:42 +00:00
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-isohybrid-gpt-basdat");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image isolinux partition_entry=gpt_basdat");
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
if(et_imgs[idx].do_gpt_hfsplus) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-isohybrid-gpt-hfsplus");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image isolinux partition_entry=gpt_hfsplus");
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
if(et_imgs[idx].do_apm_hfsplus) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-isohybrid-apm-hfsplus");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-boot_image isolinux partition_entry=apm_hfsplus");
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
}
|
|
|
|
after_el_torito:
|
|
|
|
|
2020-12-05 08:53:59 +00:00
|
|
|
if((apm_count > 0 && !cared_for_apm) && !(flag & 5)) {
|
2015-05-07 15:20:42 +00:00
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Cannot make proposal to produce APM of loaded image");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
}
|
|
|
|
|
2018-09-09 12:59:47 +00:00
|
|
|
#ifdef Not_any_more_because_padding_is_now_after_partitions
|
|
|
|
|
2016-04-25 10:09:34 +00:00
|
|
|
if(appended_partition) {
|
|
|
|
if(mkisofs)
|
|
|
|
sprintf(buf, "-no-pad");
|
|
|
|
else
|
|
|
|
sprintf(buf, "-padding 0");
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
}
|
|
|
|
|
2018-09-09 12:59:47 +00:00
|
|
|
#endif /* Not_any_more_because_padding_is_now_after_partitions */
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
ret= 1;
|
|
|
|
ex:
|
2015-05-14 10:08:32 +00:00
|
|
|
xorriso->show_hfs_cmds= NULL;
|
|
|
|
Findjob_destroy(&job, 0);
|
2014-10-28 14:03:42 +00:00
|
|
|
Xorriso_free_meM(apms);
|
|
|
|
Xorriso_free_meM(gpts);
|
2015-05-10 09:34:30 +00:00
|
|
|
Xorriso_free_meM(mbrpts);
|
2016-01-01 17:28:46 +00:00
|
|
|
if(app_pseudo_paths != NULL) {
|
|
|
|
for(i= 0; i < elto_count; i++)
|
|
|
|
if(app_pseudo_paths[i] != NULL)
|
|
|
|
Xorriso_free_meM(app_pseudo_paths[i]);
|
|
|
|
Xorriso_free_meM(app_pseudo_paths);
|
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
Xorriso_free_meM(et_imgs);
|
|
|
|
Xorriso_free_meM(lines);
|
|
|
|
Xorriso_free_meM(buf);
|
|
|
|
return(ret);
|
|
|
|
|
|
|
|
#undef Xorriso_record_cmd_linE
|
2020-12-05 08:53:59 +00:00
|
|
|
#undef Xorriso_record_boot_imglinE
|
|
|
|
#undef Xorriso_max_endless_uefi_sizE
|
2014-10-28 14:03:42 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit0= currently not significant:
|
|
|
|
report is about El Torito rather than System Area
|
2020-12-05 08:53:59 +00:00
|
|
|
bit1= report -as mkisofs options in cmds
|
|
|
|
bit2= no sorry messages
|
|
|
|
bit15= dispose cmds and boot_imgs
|
2014-10-28 14:03:42 +00:00
|
|
|
*/
|
|
|
|
static int Xorriso_report_to_cmd(struct XorrisO *xorriso,
|
|
|
|
char **et_lines, int et_line_count,
|
|
|
|
char **sa_lines, int sa_line_count,
|
2020-12-05 08:53:59 +00:00
|
|
|
char ***cmds, int *cmd_count,
|
|
|
|
char ***boot_imgs, int *boot_img_count,
|
|
|
|
int flag)
|
2014-10-28 14:03:42 +00:00
|
|
|
{
|
|
|
|
int ret= 0, i;
|
|
|
|
|
|
|
|
if(flag & (1 << 15))
|
|
|
|
{ret= 1; goto ex;}
|
|
|
|
*cmds= NULL;
|
|
|
|
*cmd_count= 0;
|
|
|
|
|
|
|
|
/* Count commands */
|
|
|
|
ret= Xorriso_scan_report_lines(xorriso, et_lines, et_line_count,
|
|
|
|
sa_lines, sa_line_count, *cmds, cmd_count,
|
2020-12-05 08:53:59 +00:00
|
|
|
*boot_imgs, boot_img_count,
|
|
|
|
1 | (flag & 6));
|
2014-10-28 14:03:42 +00:00
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
|
2020-12-05 08:53:59 +00:00
|
|
|
if(*cmd_count <= 0 && *boot_img_count <= 0)
|
2014-10-28 14:03:42 +00:00
|
|
|
{ret= 2; goto ex;}
|
2020-12-05 08:53:59 +00:00
|
|
|
if(*cmd_count > 0) {
|
|
|
|
Xorriso_alloc_meM(*cmds, char *, *cmd_count);
|
|
|
|
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;
|
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
|
|
|
|
/* Record commands */
|
|
|
|
ret= Xorriso_scan_report_lines(xorriso, et_lines, et_line_count,
|
|
|
|
sa_lines, sa_line_count, *cmds, cmd_count,
|
2020-12-05 08:53:59 +00:00
|
|
|
*boot_imgs, boot_img_count,
|
|
|
|
flag & 6);
|
2014-10-28 14:03:42 +00:00
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
|
|
|
|
ret= 1;
|
|
|
|
ex:
|
|
|
|
if(ret <= 0 || (flag & (1 << 15))) {
|
|
|
|
if(*cmds != NULL) {
|
|
|
|
for(i= 0; i < *cmd_count; i++)
|
|
|
|
if((*cmds)[i] != NULL)
|
|
|
|
Xorriso_free_meM((*cmds)[i]);
|
|
|
|
Xorriso_free_meM(*cmds);
|
|
|
|
*cmds= NULL;
|
|
|
|
}
|
2020-12-05 08:53:59 +00:00
|
|
|
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;
|
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
}
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-24 08:41:28 +00:00
|
|
|
static void Xorriso_report_lines(struct XorrisO *xorriso,
|
|
|
|
char **lines, int line_count)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < line_count ; i++) {
|
|
|
|
sprintf(xorriso->result_line, "%s\n", lines[i]);
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit0= report El Torito rather than System Area
|
2015-09-06 19:43:08 +00:00
|
|
|
bit1= with form "cmd" do not report but rather execute
|
2014-04-24 08:41:28 +00:00
|
|
|
*/
|
2014-04-11 16:12:22 +00:00
|
|
|
int Xorriso_report_system_area(struct XorrisO *xorriso, char *form, int flag)
|
|
|
|
{
|
2015-07-04 09:48:41 +00:00
|
|
|
int ret, line_count, cmd_count= 0, et_line_count= 0, sa_line_count= 0;
|
2020-12-05 08:53:59 +00:00
|
|
|
int do_cmd= 0, as_mkisofs= 0, i, bin_count, boot_img_count= 0;
|
2014-10-28 14:03:42 +00:00
|
|
|
char **lines = NULL, **et_lines= NULL, **sa_lines= NULL, **cmds= NULL;
|
2020-12-05 08:53:59 +00:00
|
|
|
char **boot_imgs= NULL;
|
2016-08-15 17:48:42 +00:00
|
|
|
uint8_t guid[16];
|
2014-04-11 16:12:22 +00:00
|
|
|
IsoImage *image;
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
if(strcmp(form, "cmd") == 0 || strcmp(form, "as_mkisofs") == 0 || (flag & 2))
|
|
|
|
do_cmd= 1;
|
|
|
|
if(strcmp(form, "as_mkisofs") == 0)
|
|
|
|
as_mkisofs= 1;
|
|
|
|
|
2014-04-11 16:12:22 +00:00
|
|
|
if(strcmp(form, "help") == 0) {
|
2014-04-29 17:49:08 +00:00
|
|
|
if(flag & 1)
|
2014-10-28 14:03:42 +00:00
|
|
|
ret= iso_image_report_el_torito(NULL, &et_lines, &et_line_count, 1);
|
2014-04-29 17:49:08 +00:00
|
|
|
else
|
2014-10-28 14:03:42 +00:00
|
|
|
ret= iso_image_report_system_area(NULL, &sa_lines, &sa_line_count, 1);
|
2014-04-24 08:41:28 +00:00
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
sprintf(xorriso->result_line,
|
|
|
|
"------------------------------------------------------------------------------\n");
|
|
|
|
Xorriso_result(xorriso, 0);
|
2014-04-29 17:49:08 +00:00
|
|
|
if(flag & 1)
|
|
|
|
sprintf(xorriso->result_line, "With -report_el_torito \"plain\":\n");
|
|
|
|
else
|
|
|
|
sprintf(xorriso->result_line, "With -report_system_area \"plain\":\n");
|
2014-04-24 08:41:28 +00:00
|
|
|
Xorriso_result(xorriso, 0);
|
|
|
|
sprintf(xorriso->result_line,
|
|
|
|
"------------------------------------------------------------------------------\n");
|
|
|
|
Xorriso_result(xorriso, 0);
|
|
|
|
sprintf(xorriso->result_line, "\n");
|
|
|
|
Xorriso_result(xorriso, 0);
|
|
|
|
|
2014-10-28 14:03:42 +00:00
|
|
|
} else if(strcmp(form, "") == 0 || strcmp(form, "plain") == 0 || do_cmd) {
|
2014-04-11 16:12:22 +00:00
|
|
|
ret= Xorriso_get_volume(xorriso, &image, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
2014-10-28 14:03:42 +00:00
|
|
|
if(do_cmd || (flag & 1))
|
|
|
|
ret= iso_image_report_el_torito(image, &et_lines, &et_line_count, 0);
|
|
|
|
if(ret < 0)
|
|
|
|
goto ex;
|
|
|
|
if(do_cmd || !(flag & 1))
|
|
|
|
ret= iso_image_report_system_area(image, &sa_lines, &sa_line_count, 0);
|
|
|
|
if(ret < 0)
|
|
|
|
goto ex;
|
|
|
|
if(do_cmd) {
|
|
|
|
ret= Xorriso_report_to_cmd(xorriso, et_lines, et_line_count,
|
|
|
|
sa_lines, sa_line_count, &cmds, &cmd_count,
|
2020-12-05 08:53:59 +00:00
|
|
|
&boot_imgs, &boot_img_count,
|
2014-10-28 14:03:42 +00:00
|
|
|
(flag & 1) | (as_mkisofs << 1));
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
}
|
2020-12-05 08:53:59 +00:00
|
|
|
|
2014-04-29 17:49:08 +00:00
|
|
|
} else if(strncmp(form, "gpt_crc_of:", 11) == 0 && !(flag & 1)) {
|
2014-04-12 13:02:23 +00:00
|
|
|
ret = Xorriso_gpt_crc(xorriso, form + 11, 0);
|
|
|
|
goto ex;
|
2014-04-24 08:41:28 +00:00
|
|
|
|
2016-08-12 18:57:21 +00:00
|
|
|
} else if(strcmp(form, "make_guid") == 0 && !(flag & 1)) {
|
|
|
|
ret= Xorriso_make_guid(xorriso, xorriso->result_line, 0);
|
|
|
|
if(ret < 0)
|
|
|
|
goto ex;
|
|
|
|
strcat(xorriso->result_line, "\n");
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
goto ex;
|
|
|
|
|
2016-08-15 17:48:42 +00:00
|
|
|
} else if(strcmp(form, "gpt_disk_guid") == 0 && !(flag & 1)) {
|
|
|
|
ret= Xorriso_get_volume(xorriso, &image, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
ret= iso_image_report_system_area(image, &sa_lines, &sa_line_count, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
for(i= 0; i < sa_line_count; i++) {
|
|
|
|
if(strncmp(sa_lines[i], "GPT disk GUID : ", 26) == 0) {
|
|
|
|
ret= Hex_to_bin(sa_lines[i] + 26, 16, &bin_count, guid, 0);
|
|
|
|
if(ret < 0 || bin_count != 16)
|
|
|
|
break;
|
|
|
|
Xorriso_format_guid(xorriso, guid, xorriso->result_line, 0);
|
|
|
|
strcat(xorriso->result_line, "\n");
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
ret= 1;
|
|
|
|
goto ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret= 1;
|
|
|
|
goto ex;
|
|
|
|
|
2014-04-11 16:12:22 +00:00
|
|
|
} else {
|
2014-04-29 17:49:08 +00:00
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"%s form parameter not recognized: ",
|
|
|
|
flag & 1 ? "-report_el_torito" : "-report_system_area");
|
2014-04-11 16:12:22 +00:00
|
|
|
Text_shellsafe(form, xorriso->info_text, 1);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
ret= 0; goto ex;
|
|
|
|
}
|
|
|
|
if(ret < 0)
|
|
|
|
goto ex;
|
2014-10-28 14:03:42 +00:00
|
|
|
if(flag & 1) {
|
|
|
|
lines= et_lines;
|
|
|
|
line_count= et_line_count;
|
|
|
|
} else {
|
|
|
|
lines= sa_lines;
|
|
|
|
line_count= sa_line_count;
|
2014-04-11 16:12:22 +00:00
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
if(!do_cmd) {
|
|
|
|
if(lines == NULL || ret == 0) {
|
|
|
|
if(flag & 1)
|
|
|
|
strcpy(xorriso->info_text, "No El Torito information was loaded");
|
|
|
|
else
|
|
|
|
strcpy(xorriso->info_text, "No System Area was loaded");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
|
|
|
ret= 2; goto ex;
|
|
|
|
}
|
|
|
|
if(line_count == 0) {
|
|
|
|
if(flag & 1)
|
|
|
|
strcpy(xorriso->info_text, "No El Torito information available");
|
|
|
|
else
|
|
|
|
strcpy(xorriso->info_text, "System Area only contains 0-bytes");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
|
|
|
ret= 2; goto ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(flag & 2) {
|
2015-09-06 19:43:08 +00:00
|
|
|
if(cmd_count > 0) {
|
|
|
|
ret= Xorriso_execute_option(xorriso,
|
|
|
|
"-boot_image any discard -boot_image any system_area=/dev/zero",
|
|
|
|
1 | 16);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
for(i= 0; i < cmd_count; i++) {
|
|
|
|
ret= Xorriso_execute_option(xorriso, cmds[i], 1 | 16);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
}
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Replayed %d boot related commands", cmd_count);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
|
|
|
} else {
|
|
|
|
Xorriso_msgs_submit(xorriso, 0,
|
|
|
|
"No proposals available for boot related commands",
|
|
|
|
0, "NOTE", 0);
|
|
|
|
ret= 2; goto ex;
|
|
|
|
}
|
2014-10-28 14:03:42 +00:00
|
|
|
} else if(do_cmd) {
|
|
|
|
Xorriso_report_lines(xorriso, cmds, cmd_count);
|
|
|
|
} else {
|
|
|
|
Xorriso_report_lines(xorriso, lines, line_count);
|
2014-04-11 16:12:22 +00:00
|
|
|
}
|
|
|
|
ret= 1;
|
|
|
|
ex:;
|
2020-12-05 08:53:59 +00:00
|
|
|
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);
|
2014-10-28 14:03:42 +00:00
|
|
|
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);
|
2014-04-11 16:12:22 +00:00
|
|
|
return(ret);
|
|
|
|
}
|
2014-04-12 13:02:23 +00:00
|
|
|
|