From 135721a8687017fd4be3984c362a73e2613f0a8a Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Fri, 25 May 2012 19:01:39 +0000 Subject: [PATCH] New (yet inofficial) -as mkisofs options -hfs-bless and -hfs-bless-by --- xorriso/emulators.c | 37 +++++++++++++----- xorriso/iso_manip.c | 76 +++++++++++++++++++++++++++++++++++++ xorriso/xorriso_timestamp.h | 2 +- xorriso/xorrisoburn.h | 3 ++ 4 files changed, 108 insertions(+), 10 deletions(-) diff --git a/xorriso/emulators.c b/xorriso/emulators.c index 2aa5cbdf..c65d5cae 100644 --- a/xorriso/emulators.c +++ b/xorriso/emulators.c @@ -612,7 +612,7 @@ int Xorriso_genisofs_count_args(struct XorrisO *xorriso, int argc, char **argv, "" }; static char arg2_options[][41]= { - "--scdbackup_tag", "--sort-weight", + "-hfs-bless-by", "--scdbackup_tag", "--sort-weight", "" }; static char arg3_options[][41]= { @@ -733,7 +733,10 @@ int Xorriso_genisofs_help(struct XorrisO *xorriso, int flag) " -hide-hfsplus-list FILE File with list of HFS+ files to hide", " -hfsplus Generate HFS+ filesystem", " -hfsplus-file-creator-type CREATOR TYPE iso_rr_path", -" Attach creator and type to a File.", +" Attach creator and type to a File", +" -hfs-bless FOLDER_NAME Name of Folder to be blessed", +" -hfs-bless-by BLESS_TYPE ISO_RR_PATH", +" Bless ISO_RR_PATH by BLESS_TYPE {p,i,s,9,x}", #endif @@ -1080,7 +1083,7 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom, int do_print_size= 0, fd, idx, iso_level= 1, emul_boot= 2; int option_b= 0, was_failure= 0, fret, lower_r= 0, zero= 0; int dir_mode= -1, file_mode= -1, count, partition_number, allow_dir_id_ext= 1; - int root_seen= 0, do_md5_mem, option_d= 0; + int root_seen= 0, do_md5_mem, option_d= 0, arg_count; mode_t mode_and, mode_or; int with_boot_image= 0, with_cat_path= 0, with_emul_toc= 0; int old_root_md5= 1, old_root_dev= 0, old_root_ino= 1; @@ -1506,17 +1509,23 @@ illegal_c:; } else if(strcmp(argpt, "-joliet-long")==0) { Xorriso_relax_compliance(xorriso, "joliet_long_paths:joliet_long_names", 0); - } else if(strcmp(argpt, "-hfsplus") == 0) { - xorriso->do_hfsplus= 1; - } else if(strcmp(argpt, "-hfsplus-file-creator-type") == 0) { - if(i + 3 >= argc) + } else if(strcmp(argpt, "-hfs-bless") == 0 || + strcmp(argpt, "-hfs-bless-by") == 0 || + strcmp(argpt, "-hfsplus-file-creator-type") == 0) { + arg_count= 1; + if(strcmp(argpt, "-hfs-bless-by") == 0) + arg_count= 2; + else if(strcmp(argpt, "-hfsplus-file-creator-type") == 0) + arg_count= 3; + if(i + arg_count >= argc) goto not_enough_args; /* Memorize command until all pathspecs are processed */ delay_opt_list[delay_opt_count++]= i; if(argv[i] != argpt) delay_opt_list[delay_opt_count - 1]|= 1<<31; - i+= 3; - + i+= arg_count; + } else if(strcmp(argpt, "-hfsplus") == 0) { + xorriso->do_hfsplus= 1; } else if(strcmp(argpt, "-graft-points")==0) { xorriso->allow_graft_points= 1; } else if(strcmp(argpt, "-path-list")==0 || @@ -2210,6 +2219,16 @@ problem_handler_2:; if(ret <= 0) goto problem_handler_boot; + } else if(strcmp(argpt, "-hfs-bless") == 0) { + ret= Xorriso_hfsplus_bless(xorriso, argv[i + 1], NULL, "ppc_bootdir", 0); + if(ret <= 0) + goto problem_handler_boot; + + } else if(strcmp(argpt, "-hfs-bless-by") == 0) { + ret= Xorriso_hfsplus_bless(xorriso, argv[i + 2], NULL, argv[i + 1], 0); + if(ret <= 0) + goto problem_handler_boot; + } else if(strcmp(argpt, "-hfsplus-file-creator-type") == 0) { ret= Xorriso_hfsplus_file_creator_type(xorriso, argv[i + 3], NULL, argv[i + 1], argv[i + 2], 0); diff --git a/xorriso/iso_manip.c b/xorriso/iso_manip.c index e03972c9..e11253a4 100644 --- a/xorriso/iso_manip.c +++ b/xorriso/iso_manip.c @@ -3518,3 +3518,79 @@ failure: return(0); } +/* + @param node + If node is NULL and path is empty, then the blessing will be + revoked from any node which bears it. + @param flag + Bitfield for control purposes. + bit0= Revoke blessing if node != NULL bears it. + bit1= Revoke any blessing of the node, regardless of parameter + blessing. If node is NULL, then revoke all blessings in opts. +*/ +int Xorriso_hfsplus_bless(struct XorrisO *xorriso, char *path, + void *in_node, char *blessing, int flag) +{ + int ret; + IsoNode *node; + IsoImage *volume= NULL; + enum IsoHfsplusBlessings bless_code = ISO_HFSPLUS_BLESS_MAX; /* = invalid */ + + if(in_node == NULL && path[0]) { + ret= Xorriso_node_from_path(xorriso, NULL, path, &node, 0); + if(ret <= 0) + return(ret); + } else + node= (IsoNode *) in_node; + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret <= 0) + return(ret); + + if(strcmp(blessing, "ppc_bootdir") == 0 || + strcmp(blessing, "p") == 0 || strcmp(blessing, "P") == 0) + bless_code= ISO_HFSPLUS_BLESS_PPC_BOOTDIR; + else if(strcmp(blessing, "intel_bootfile") == 0 || + strcmp(blessing, "i") == 0 || strcmp(blessing, "I") == 0) + bless_code= ISO_HFSPLUS_BLESS_INTEL_BOOTFILE; + else if(strcmp(blessing, "show_folder") == 0 || + strcmp(blessing, "s") == 0 || strcmp(blessing, "S") == 0) + bless_code= ISO_HFSPLUS_BLESS_SHOWFOLDER; + else if(strcmp(blessing, "os9_folder") == 0 || + strcmp(blessing, "9") == 0) + bless_code= ISO_HFSPLUS_BLESS_OS9_FOLDER; + else if(strcmp(blessing, "osx_folder") == 0 || + strcmp(blessing, "x") == 0 || strcmp(blessing, "X") == 0) + bless_code= ISO_HFSPLUS_BLESS_OSX_FOLDER; + else { + sprintf(xorriso->info_text, "Unknown blessing type "); + Text_shellsafe(blessing, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + + ret= iso_image_hfsplus_bless(volume, bless_code, node, flag & 3); + Xorriso_process_msg_queues(xorriso, 0); + if(ret == 0 && path[0]) { + if((flag & 3)) { + sprintf(xorriso->info_text, + "Attempt to revoke blessing of unblessed file"); + } else { + sprintf(xorriso->info_text, + "Multiple blessing to same file or inappropriate file type"); + } + if(path[0]) { + strcat(xorriso->info_text, ": "); + Text_shellsafe(path, xorriso->info_text, 1); + } + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } else if (ret < 0) { + Xorriso_report_iso_error(xorriso, "", ret, + "Error when trying to bless a file", + 0, "FAILURE", 1); + return(0); + } + Xorriso_set_change_pending(xorriso, 0); + return(1); +} + diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 5cce40b3..a5400014 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2012.05.25.084641" +#define Xorriso_timestamP "2012.05.25.190220" diff --git a/xorriso/xorrisoburn.h b/xorriso/xorrisoburn.h index dce046e2..ad002a34 100644 --- a/xorriso/xorrisoburn.h +++ b/xorriso/xorrisoburn.h @@ -602,5 +602,8 @@ int Xorriso_hfsplus_file_creator_type(struct XorrisO *xorriso, char *path, void *in_node, char *creator, char *hfs_type, int flag); +int Xorriso_hfsplus_bless(struct XorrisO *xorriso, char *path, + void *in_node, char *blessing, int flag); + #endif /* Xorrisoburn_includeD */