Enabled output of HFS+ proposal with report_system_area cmd and as_mkisofs

This commit is contained in:
Thomas Schmitt 2015-05-14 10:08:32 +00:00
parent d8da5a00dd
commit 376b450694
7 changed files with 172 additions and 52 deletions

View File

@ -428,6 +428,10 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->update_flags= 0;
m->show_hfs_cmd_flag= 0;
m->show_hfs_cmd_count= 0;
m->show_hfs_cmds= NULL;
m->result_line[0]= 0;
m->result_line_counter= 0;
m->result_page_counter= 0;

View File

@ -173,6 +173,7 @@ struct FindjoB {
50= print_outname namespace
51= report_sections
52= show_stream_id
53= internal: show_hfs_cmd , controlled by xorriso->show_hfs_cmd*
*/
int action;
int prune;

View File

@ -1467,8 +1467,8 @@ undigestible:
}
static int Xorriso_record_cmd_line(struct XorrisO *xorriso, char *buf,
char **cmds, int *cmd_count, int flag)
int Xorriso_record_cmd_line(struct XorrisO *xorriso, char *buf,
char **cmds, int *cmd_count, int flag)
{
int ret;
@ -1571,7 +1571,7 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
int ptype, gpt_idx;
int efi_boot_part= 0, full_sparc_part= 0, have_sparc_part= 0;
int appended_as_gpt= 0, have_prep= 0, did_sysarea= 0, cared_for_apm= 0;
int cared_for_sparc= 0;
int cared_for_sparc= 0, have_hfsplus= 0;
int have_sysarea= 0, ptable_killer, imported_iso, have_alpha_ldr_path= 0;
unsigned long int sa_options= 0, partno, id_tag, perms, start_cyl, num_blocks;
unsigned long int part_status, part_type, start_block;
@ -1582,6 +1582,8 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
struct elto_img_par *et_imgs= NULL;
int elto_count= 0;
uint32_t img_blocks= 0;
struct FindjoB *job= NULL;
struct stat dir_stbuf;
struct mbr_par {
uint8_t ptype;
@ -1598,7 +1600,8 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
int gpt_count= 0;
struct apm_par {
int ptype; /* 0= unknown, 1= Apple_HFS */
int ptype; /* bit0= type Apple_HFS , bit1= name HFSPLUS_Hybrid */
char *path;
};
struct apm_par *apms= NULL;
int apm_count= 0;
@ -1674,8 +1677,11 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
for(gpt_idx= 0; gpt_idx < gpt_count; gpt_idx++)
gpts[gpt_idx].path= NULL;
}
if(apm_count > 0)
if(apm_count > 0) {
Xorriso_alloc_meM(apms, struct apm_par, apm_count);
for(i= 0; i < apm_count; i++)
apms[i].path= NULL;
}
ptable_killer= (mbr_count > 0) | ((gpt_count > 0) << 1) |
((apm_count > 0) << 2);
@ -1770,12 +1776,19 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
gpts[idx].has_path= 1;
gpts[idx].path= textpt;
} else if(strcmp(name, "APM partition name :") == 0) {
idx= num[0] - 1;
if(strcmp(textpt, "HFSPLUS_Hybrid") == 0)
apms[idx].ptype|= 2;
} else if(strcmp(name, "APM partition type :") == 0) {
idx= num[0] - 1;
if(strcmp(textpt, "Apple_HFS") == 0)
apms[idx].ptype= 1;
else
apms[idx].ptype= 0;
apms[idx].ptype|= 1;
} else if(strcmp(name, "APM partition path :") == 0) {
idx= num[0] - 1;
apms[idx].path= textpt;
} else if(strcmp(name, "DEC Alpha ldr path :") == 0) {
have_alpha_ldr_path= 1;
@ -1890,37 +1903,38 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
} else if(strcmp(name, "MBR partition path :") == 0) {
idx= num[0] - 1;
if(!(flag & 1)) {
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);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
continue;
}
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);
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);
if(!(flag & 1))
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;
}
if(gpt_idx >= gpt_count) {
sprintf(xorriso->info_text,
"Cannot make proposal to mark data file as MBR partition without being in GPT : ");
Text_shellsafe(textpt, xorriso->info_text, 1);
continue;
}
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);
if(!(flag & 1))
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;
}
if(gpt_idx >= gpt_count) {
sprintf(xorriso->info_text,
"Cannot make proposal to mark data file as MBR partition without being in GPT : ");
Text_shellsafe(textpt, xorriso->info_text, 1);
if(!(flag & 1))
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
}
}
}
@ -2007,11 +2021,42 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
}
} else if(strcmp(name, "APM start and size :") == 0) {
idx= num[0] - 1;
/* >>> check for -hfsplus : APM inside ISO, type Apple_HFS,
no path, isofs.hb and isofs.hx in image
>>> HFS+ magic number ?
*/;
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 ? */
if(mkisofs)
sprintf(buf, "-hfsplus");
else
sprintf(buf, "-hfsplus on");
Xorriso_record_cmd_linE
buf[0]= 0;
/* 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;
}
} else if(strcmp(name, "MIPS-BE boot path :") == 0) {
if(mkisofs)
@ -2322,6 +2367,8 @@ after_el_torito:
ret= 1;
ex:
xorriso->show_hfs_cmds= NULL;
Findjob_destroy(&job, 0);
Xorriso_free_meM(apms);
Xorriso_free_meM(gpts);
Xorriso_free_meM(mbrpts);

View File

@ -36,8 +36,8 @@ int Xorriso__append_boot_params(char *line, ElToritoBootImage *bootimg,
int Xorriso_get_volume(struct XorrisO *xorriso, IsoImage **volume,
int flag);
int Xorriso_record_cmd_line(struct XorrisO *xorriso, char *buf,
char **cmds, int *cmd_count, int flag);
#endif /* ! Xorriso_pvt_iso_img_includeD */

View File

@ -31,6 +31,7 @@
#include "lib_mgt.h"
#include "iso_img.h"
#include "iso_tree.h"
#include "iso_img.h"
#include "iso_manip.h"
#include "sort_cmp.h"
#include "parse_exec.h"
@ -2533,6 +2534,7 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
time_t date= 0;
mode_t mode_or= 0, mode_and= ~1;
char *target, *text_2, *iso_prefix, md5[16], *basename, bless_code[17];
char crtp[10];
struct FindjoB *subjob;
struct stat dir_stbuf, stbuf;
void *xinfo;
@ -2741,9 +2743,13 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
&value_length, &value, 0);
if(ret < 0)
return(ret);
if(ret > 0 && value_length >= 10) {
ret= Xorriso_hfsplus_file_creator_type(xorriso, show_path, (void *) node,
value + 2, value + 6, 4);
if(ret > 0) {
if(value_length >= 10) {
ret= Xorriso_hfsplus_file_creator_type(xorriso, show_path,
(void *) node,
value + 2, value + 6, 4);
} else
ret= 1;
free(value);
if(ret <= 0)
return(ret);
@ -2752,11 +2758,15 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
&value_length, &value, 0);
if(ret < 0)
return(ret);
if(ret > 0 && value_length >= 1) {
bless_code[0]= value[0];
bless_code[1]= 0;
ret= Xorriso_hfsplus_bless(xorriso, show_path, (void *) node,
bless_code, 0);
if(ret > 0) {
if(value_length >= 1) {
bless_code[0]= value[0];
bless_code[1]= 0;
ret= Xorriso_hfsplus_bless(xorriso, show_path, (void *) node,
bless_code, 0);
} else
ret= 1;
free(value);
if(ret <= 0)
return(ret);
}
@ -2770,6 +2780,55 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
} else if(action == 51) { /* report_sections */
ret= Xorriso_report_lba(xorriso, show_path, node, 1);
} else if(action == 53) { /* internal: show_hfs_cmd */
ret= Xorriso_get_blessing(xorriso, node, &bless_idx, bless_code, 0);
if (ret > 0) {
if(xorriso->show_hfs_cmd_flag & 2) {
sprintf(xorriso->result_line, "-hfs-bless-by %s ", bless_code);
Text_shellsafe(show_path, xorriso->result_line, 1);
} else {
sprintf(xorriso->result_line, "-find ");
Text_shellsafe(show_path, xorriso->result_line, 1);
sprintf(xorriso->result_line + strlen(xorriso->result_line),
" -exec set_hfs_bless %s --", bless_code);
}
ret= Xorriso_record_cmd_line(xorriso, xorriso->result_line,
xorriso->show_hfs_cmds,
&xorriso->show_hfs_cmd_count,
(xorriso->show_hfs_cmd_flag & 1));
if(ret <= 0)
return(ret);
}
ret= iso_node_get_xinfo(node, iso_hfsplus_xinfo_func, &xinfo);
if(ret < 0) {
Xorriso_process_msg_queues(xorriso, 0);
ret= 0;
} else if(ret == 1) {
hfsplus_xinfo= (struct iso_hfsplus_xinfo_data *) xinfo;
for(i= 0; i < 4; i++)
crtp[i]= hfsplus_xinfo->creator_code[i];
crtp[4]= ' ';
for(i= 0; i < 4; i++)
crtp[5 + i]= hfsplus_xinfo->type_code[i];
crtp[9]= 0;
if(xorriso->show_hfs_cmd_flag & 2) {
sprintf(xorriso->result_line, "-hfsplus-file-creator-type %s ", crtp);
Text_shellsafe(show_path, xorriso->result_line, 1);
} else {
sprintf(xorriso->result_line, "-find ");
Text_shellsafe(show_path, xorriso->result_line, 1);
sprintf(xorriso->result_line + strlen(xorriso->result_line),
" -exec set_hfs_crtp %s --", crtp);
}
ret= Xorriso_record_cmd_line(xorriso, xorriso->result_line,
xorriso->show_hfs_cmds,
&xorriso->show_hfs_cmd_count,
(xorriso->show_hfs_cmd_flag & 1));
if(ret <= 0)
return(ret);
}
ret= 1;
} else { /* includes : 15 in_iso */
Xorriso_esc_filepath(xorriso, show_path, xorriso->result_line, 0);
strcat(xorriso->result_line, "\n");

View File

@ -758,6 +758,15 @@ struct XorrisO { /* the global context of xorriso */
*/
int update_flags;
/* For find jobs show_hfs_cmd , show_hfs_as_mkisofs
*/
/* bit0= do not record but only count
bit1= as_mkisofs mode
*/
int show_hfs_cmd_flag;
int show_hfs_cmd_count;
char **show_hfs_cmds;
/* result (stdout, R: ) */
char result_line[10*SfileadrL];
int result_line_counter;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2015.05.11.160333"
#define Xorriso_timestamP "2015.05.14.100737"