diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index f1e3f68..f90f5d2 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -19,6 +19,10 @@ #include "tree.h" #include "eltorito.h" +#ifdef Libisofs_with_aaiP +#include "aaip_0_2.h" +#endif + #include #include #include @@ -936,15 +940,38 @@ void ifs_free(IsoFileSource *src) #ifdef Libisofs_with_aaiP -/* >>> unsigned char *(*get_aa_string)(IsoFileSource *src, - unsigned char **aa_string, int flag); -*/ +static +int ifs_get_aa_string(IsoFileSource *src, unsigned char **aa_string, int flag) +{ + size_t len; + ImageFileSourceData *data; + + data = src->data; + + if ((flag & 1) || data->aa_string == NULL) { + *aa_string = data->aa_string; + data->aa_string = NULL; + } else { + len = aaip_count_bytes((char *) data->aa_string, data->aa_string, 0); + *aa_string = calloc(len, 1); + if (*aa_string == NULL) + return ISO_OUT_OF_MEM; + memcpy(*aa_string, data->aa_string, len); + } + return 1; +} #endif /* Libisofs_with_aaiP */ IsoFileSourceIface ifs_class = { + +#ifdef Libisofs_with_aaiP + 1, /* version */ +#else 0, /* version */ +#endif + ifs_get_path, ifs_get_name, ifs_lstat, @@ -958,6 +985,12 @@ IsoFileSourceIface ifs_class = { ifs_get_filesystem, ifs_free, ifs_lseek + +#ifdef Libisofs_with_aaiP + , + ifs_get_aa_string +#endif + }; /** @@ -2325,6 +2358,10 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image, char *name; ImageFileSourceData *data; +#ifdef Libisofs_with_aaiP + unsigned char *aa_string; +#endif /* Libisofs_with_aaiP */ + if (builder == NULL || src == NULL || node == NULL || src->data == NULL) { return ISO_NULL_POINTER; } @@ -2493,8 +2530,21 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image, new->parent = NULL; new->next = NULL; - *node = new; + +#ifdef Libisofs_with_aaiP + /* ts A90115 */ + + /* obtain ownership of eventual AA string */ + ret = iso_file_source_get_aa_string(src, &aa_string, 1); + if (ret == 1 && aa_string != NULL) { + ret = iso_node_add_xinfo(new, aaip_xinfo_func, aa_string); + if (ret < 0) + return ret; + } + +#endif /* Libisofs_with_aaiP */ + return ISO_SUCCESS; } diff --git a/libisofs/fsource.c b/libisofs/fsource.c index 4b74350..603e66f 100644 --- a/libisofs/fsource.c +++ b/libisofs/fsource.c @@ -115,3 +115,17 @@ IsoFilesystem* iso_file_source_get_filesystem(IsoFileSource *src) { return src->class->get_filesystem(src); } + + +/* ts A90115 */ +inline +int iso_file_source_get_aa_string(IsoFileSource *src, + unsigned char **aa_string, int flag) +{ + if (src->class->version < 1) { + *aa_string = NULL; + return 1; + } + return src->class->get_aa_string(src, aa_string, flag); +} + diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 3beff48..d91ff42 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -463,7 +463,9 @@ struct IsoFileSource_Iface /** * Tells the version of the interface: * Version 0 provides functions up to (*lseek)(). + * @since 0.6.2 * Version 1 additionally provides function *(get_aa_string)(). + * @since 0.6.14 */ int version; @@ -688,7 +690,7 @@ struct IsoFileSource_Iface * (e.g. ISO_FILE_ERROR if no better one can be found). * @since 0.6.14 */ - unsigned char *(*get_aa_string)(IsoFileSource *src, + int (*get_aa_string)(IsoFileSource *src, unsigned char **aa_string, int flag); /* @@ -3650,6 +3652,29 @@ int iso_file_source_readdir(IsoFileSource *src, IsoFileSource **child); */ int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz); + +/** + * Get the AA string with encoded ACL and/or POSIX Extended Attributes. + * (Not to be confused with ECMA-119 Extended Attributes). + * @param src The file source object to be inquired. + * @param aa_string Returns a pointer to the AA string data. If no AA + * string is available, *aa_string becomes NULL. + * The caller is responsible for finally calling free() + * on non-NULL results. + * (See doc/susp_aaip_0_2.txt for the meaning of AA and + * libisofs/aaip_0_2.h for encoding and decoding.) + * @param flag Bitfield for control purposes + * bit0= Transfer ownership of AA string data. + * src will free the eventual cached data and might + * not be able to produce it again. + * @return 1 means success (*aa_string == NULL is possible) + * <0 means failure and must b a valid libisofs error code + * (e.g. ISO_FILE_ERROR if no better one can be found). + * @since 0.6.14 + */ +int iso_file_source_get_aa_string(IsoFileSource *src, + unsigned char **aa_string, int flag); + /** * Get the filesystem for this source. No extra ref is added, so you * musn't unref the IsoFilesystem. diff --git a/libisofs/rockridge.c b/libisofs/rockridge.c index dfe747c..c8f26bd 100644 --- a/libisofs/rockridge.c +++ b/libisofs/rockridge.c @@ -666,7 +666,6 @@ int susp_add_SP(Ecma119Image *t, struct susp_info *susp) #ifdef Libisofs_with_aaiP /* ts A90114 */ -static int aaip_xinfo_func(void *data, int flag) { if (flag & 1) { diff --git a/libisofs/rockridge.h b/libisofs/rockridge.h index e72376d..38b4811 100644 --- a/libisofs/rockridge.h +++ b/libisofs/rockridge.h @@ -318,7 +318,13 @@ int read_aaip_AA(struct susp_sys_user_entry *sue, char aa[2], unsigned char **aa_string, size_t *aa_size, size_t *aa_len, size_t *prev_field, int *is_done, int flag); -#endif +/** + * Function to identify and manage AA strings as xinfo of IsoNode + * See libisofs.h iso_node_xinfo_func + */ +int aaip_xinfo_func(void *data, int flag); + +#endif /* Libisofs_with_aaiP */ #endif /* LIBISO_ROCKRIDGE_H */