From ab11c954d9ae442f623dc9e1e0bf288f84e2a5ce Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Fri, 25 May 2012 14:40:06 +0200 Subject: [PATCH] Created API and hfsplus interface of HFS+ blessing. But iso_write_opts_bless() is still a dummy. --- libisofs/ecma119.c | 22 ++++++++++++++++++ libisofs/ecma119.h | 9 ++++++++ libisofs/libisofs.h | 54 +++++++++++++++++++++++++++++++++++++++++++ libisofs/libisofs.ver | 1 + libisofs/util.c | 2 ++ 5 files changed, 88 insertions(+) diff --git a/libisofs/ecma119.c b/libisofs/ecma119.c index 74a3948..2d5c061 100644 --- a/libisofs/ecma119.c +++ b/libisofs/ecma119.c @@ -119,6 +119,9 @@ void ecma119_image_free(Ecma119Image *t) for (i = 0; i < ISO_MAX_PARTITIONS; i++) if (t->appended_partitions[i] != NULL) free(t->appended_partitions[i]); + for (i = 0; i < ISO_HFSPLUS_BLESS_MAX; i++) + if (t->hfsplus_blessed[i] != NULL) + iso_node_unref(t->hfsplus_blessed[i]); free(t); } @@ -1868,6 +1871,11 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img) target->appended_part_start[i] = target->appended_part_size[i] = 0; } strcpy(target->ascii_disc_label, opts->ascii_disc_label); + for (i = 0; i < ISO_HFSPLUS_BLESS_MAX; i++) { + target->hfsplus_blessed[i] = opts->hfsplus_blessed[i]; + if (target->hfsplus_blessed[i] != NULL) + iso_node_ref(target->hfsplus_blessed[i]); + } /* * 2. Based on those options, create needed writers: iso, joliet... @@ -2599,6 +2607,8 @@ int iso_write_opts_new(IsoWriteOpts **opts, int profile) wopts->allow_dir_id_ext = 0; wopts->old_empty = 0; wopts->untranslated_name_len = 0; + for (i = 0; i < ISO_HFSPLUS_BLESS_MAX; i++) + wopts->hfsplus_blessed[i] = NULL; *opts = wopts; return ISO_SUCCESS; @@ -2625,6 +2635,9 @@ void iso_write_opts_free(IsoWriteOpts *opts) for (i = 0; i < ISO_MAX_PARTITIONS; i++) if (opts->appended_partitions[i] != NULL) free(opts->appended_partitions[i]); + for (i = 0; i < ISO_HFSPLUS_BLESS_MAX; i++) + if (opts->hfsplus_blessed[i] != NULL) + iso_node_unref(opts->hfsplus_blessed[i]); free(opts); } @@ -3218,3 +3231,12 @@ int iso_write_opts_set_disc_label(IsoWriteOpts *opts, char *label) return ISO_SUCCESS; } +/* API */ +int iso_write_opts_bless(IsoWriteOpts *opts, enum IsoHfsplusBlessings blessing, + IsoNode *node, int flag) +{ + /* >>> */; + + return 0; +} + diff --git a/libisofs/ecma119.h b/libisofs/ecma119.h index 5de4354..f58651c 100644 --- a/libisofs/ecma119.h +++ b/libisofs/ecma119.h @@ -443,6 +443,14 @@ struct iso_write_opts { /* Eventual name of the non-ISO aspect of the image. E.g. SUN ASCII label. */ char ascii_disc_label[ISO_DISC_LABEL_SIZE]; + + /* Pointers to directories or files which shall be get a HFS+ blessing. + libisofs/hfsplus.c et.al. will compare these pointers + with the ->node pointer of Ecma119Nodes. + See libisofs.h + */ + IsoNode *hfsplus_blessed[ISO_HFSPLUS_BLESS_MAX]; + }; typedef struct ecma119_image Ecma119Image; @@ -774,6 +782,7 @@ struct ecma119_image char ascii_disc_label[ISO_DISC_LABEL_SIZE]; + IsoNode *hfsplus_blessed[ISO_HFSPLUS_BLESS_MAX]; }; #define BP(a,b) [(b) - (a) + 1] diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 97473c1..1863dce 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -6694,6 +6694,60 @@ int iso_hfsplus_xinfo_func(void *data, int flag); struct iso_hfsplus_xinfo_data *iso_hfsplus_xinfo_new(int flag); +/** + * HFS+ blessings are relationships between HFS+ enhanced ISO images and + * particular files in such images. Except for ISO_HFSPLUS_BLESS_INTEL_BOOTFILE + * and ISO_HFSPLUS_BLESS_MAX, these files have to be directories. + * No file may have more than one blessing. Each blessing can only be issued + * to one file. + * + * @since 1.2.4 + */ +enum IsoHfsplusBlessings { + /* The blessing that is issued by mkisofs option -hfs-bless. */ + ISO_HFSPLUS_BLESS_PPC_BOOTDIR, + + /* To be applied to a data file */ + ISO_HFSPLUS_BLESS_INTEL_BOOTFILE, + + /* Further blessings for directories */ + ISO_HFSPLUS_BLESS_SHOWFOLDER, + ISO_HFSPLUS_BLESS_OS9_FOLDER, + ISO_HFSPLUS_BLESS_OSX_FOLDER, + + /* Not a blessing, but telling the number of blessings in this list */ + ISO_HFSPLUS_BLESS_MAX +}; + +/** + * Issue a blessing to a particular IsoNode. If the blessing is already issued + * to some file, then it gets revoked from that one. + * + * @param opts + * The option set to be manipulated. + * @param blessing + * The kind of blessing to be issued. Use + * @param node + * The file that shall be blessed. It must actually be an IsoDir or + * IsoFile as is appropriate for the kind of blessing. (See above enum.) + * The node may not yet bear a blessing other than the desired one. + * @param flag + * Bitfield for control purposes. + * bit0= Revoke blessing rather than issue it + * bit1= Revoke any blessing of the node, + * regardless of parameter blessing + * @return + * 1 means successful blessing or revokation of an existing blessing + * 0 means that the blessing could not be issued, + * or that the node was not blessed and revokation was desired + * <0 is one of the listed error codes + * + * @since 1.2.4 + */ +int iso_write_opts_bless(IsoWriteOpts *opts, enum IsoHfsplusBlessings blessing, + IsoNode *node, int flag); + + /************ Error codes and return values for libisofs ********************/ /** successfully execution */ diff --git a/libisofs/libisofs.ver b/libisofs/libisofs.ver index 85d79b8..0cad54c 100644 --- a/libisofs/libisofs.ver +++ b/libisofs/libisofs.ver @@ -262,6 +262,7 @@ iso_tree_set_replace_mode; iso_tree_set_report_callback; iso_util_decode_md5_tag; iso_write_opts_attach_jte; +iso_write_opts_bless; iso_write_opts_detach_jte; iso_write_opts_free; iso_write_opts_get_data_start; diff --git a/libisofs/util.c b/libisofs/util.c index 8754177..3176a82 100644 --- a/libisofs/util.c +++ b/libisofs/util.c @@ -2066,6 +2066,7 @@ void *iso_alloc_mem(size_t size, size_t count, int flag) } +/* API, >>> ts B20525 : should finally go to hfplus.c */ int iso_hfsplus_xinfo_func(void *data, int flag) { if (flag == 1 && data != NULL) @@ -2074,6 +2075,7 @@ int iso_hfsplus_xinfo_func(void *data, int flag) } +/* API, >>> ts B20525 : should finally go to hfplus.c */ struct iso_hfsplus_xinfo_data *iso_hfsplus_xinfo_new(int flag) { struct iso_hfsplus_xinfo_data *o;