New API call iso_file_source_get_aa_string()

and IsoFileSource_Iface.version == 1 with ifs_class
Now libisofs is able to load AA strings from images and to store them again.
This commit is contained in:
Thomas Schmitt 2009-01-15 21:58:48 +01:00
parent de99f93640
commit 9dc56426c0
5 changed files with 101 additions and 7 deletions

View File

@ -19,6 +19,10 @@
#include "tree.h" #include "tree.h"
#include "eltorito.h" #include "eltorito.h"
#ifdef Libisofs_with_aaiP
#include "aaip_0_2.h"
#endif
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <locale.h> #include <locale.h>
@ -936,15 +940,38 @@ void ifs_free(IsoFileSource *src)
#ifdef Libisofs_with_aaiP #ifdef Libisofs_with_aaiP
/* >>> unsigned char *(*get_aa_string)(IsoFileSource *src, static
unsigned char **aa_string, int flag); 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 */ #endif /* Libisofs_with_aaiP */
IsoFileSourceIface ifs_class = { IsoFileSourceIface ifs_class = {
#ifdef Libisofs_with_aaiP
1, /* version */
#else
0, /* version */ 0, /* version */
#endif
ifs_get_path, ifs_get_path,
ifs_get_name, ifs_get_name,
ifs_lstat, ifs_lstat,
@ -958,6 +985,12 @@ IsoFileSourceIface ifs_class = {
ifs_get_filesystem, ifs_get_filesystem,
ifs_free, ifs_free,
ifs_lseek 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; char *name;
ImageFileSourceData *data; ImageFileSourceData *data;
#ifdef Libisofs_with_aaiP
unsigned char *aa_string;
#endif /* Libisofs_with_aaiP */
if (builder == NULL || src == NULL || node == NULL || src->data == NULL) { if (builder == NULL || src == NULL || node == NULL || src->data == NULL) {
return ISO_NULL_POINTER; return ISO_NULL_POINTER;
} }
@ -2493,8 +2530,21 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
new->parent = NULL; new->parent = NULL;
new->next = NULL; new->next = NULL;
*node = new; *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; return ISO_SUCCESS;
} }

View File

@ -115,3 +115,17 @@ IsoFilesystem* iso_file_source_get_filesystem(IsoFileSource *src)
{ {
return src->class->get_filesystem(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);
}

View File

@ -463,7 +463,9 @@ struct IsoFileSource_Iface
/** /**
* Tells the version of the interface: * Tells the version of the interface:
* Version 0 provides functions up to (*lseek)(). * Version 0 provides functions up to (*lseek)().
* @since 0.6.2
* Version 1 additionally provides function *(get_aa_string)(). * Version 1 additionally provides function *(get_aa_string)().
* @since 0.6.14
*/ */
int version; int version;
@ -688,7 +690,7 @@ struct IsoFileSource_Iface
* (e.g. ISO_FILE_ERROR if no better one can be found). * (e.g. ISO_FILE_ERROR if no better one can be found).
* @since 0.6.14 * @since 0.6.14
*/ */
unsigned char *(*get_aa_string)(IsoFileSource *src, int (*get_aa_string)(IsoFileSource *src,
unsigned char **aa_string, int flag); 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); 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 * Get the filesystem for this source. No extra ref is added, so you
* musn't unref the IsoFilesystem. * musn't unref the IsoFilesystem.

View File

@ -666,7 +666,6 @@ int susp_add_SP(Ecma119Image *t, struct susp_info *susp)
#ifdef Libisofs_with_aaiP #ifdef Libisofs_with_aaiP
/* ts A90114 */ /* ts A90114 */
static
int aaip_xinfo_func(void *data, int flag) int aaip_xinfo_func(void *data, int flag)
{ {
if (flag & 1) { if (flag & 1) {

View File

@ -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, unsigned char **aa_string, size_t *aa_size, size_t *aa_len,
size_t *prev_field, int *is_done, int flag); 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 */ #endif /* LIBISO_ROCKRIDGE_H */