Implemented generation of AA strings from local filesystem

and upgraded IsoFileSourceIface lfs_class to version 1
release-1.5.4.branch
Thomas Schmitt 14 years ago
parent 9dc56426c0
commit d01b3cc6cc
  1. 16
      libisofs/aaip_0_2.c
  2. 20
      libisofs/aaip_0_2.h
  3. 25
      libisofs/builder.c
  4. 7
      libisofs/fs_image.c
  5. 65
      libisofs/fs_local.c
  6. 32
      libisofs/libisofs.h
  7. 7
      libisofs/rockridge.c
  8. 10
      libisofs/rockridge.h

@ -478,7 +478,7 @@ struct aaip_state {
/* ------- functions ------ */
size_t aaip_count_bytes(char aa_name[2], unsigned char *data, int flag)
size_t aaip_count_bytes(unsigned char *data, int flag)
{
int done = 0;
unsigned char *aapt;
@ -489,6 +489,20 @@ size_t aaip_count_bytes(char aa_name[2], unsigned char *data, int flag)
}
int aaip_set_signature(char aa_name[2], unsigned char *data, int flag)
{
int done = 0;
unsigned char *aapt;
for(aapt= data; !done; aapt += aapt[2]) {
done = !(aapt[4] & 1);
aapt[0] = aa_name[0];
aapt[1] = aa_name[1];
}
return(1);
}
size_t aaip_sizeof_aaip_state(void)
{
return((size_t) sizeof(struct aaip_state));

@ -116,16 +116,28 @@ int aaip_get_attr_list(char *path, size_t *num_attrs, char ***names,
attribute lists but may also be used as alternative to Pair Level.
*/
/* Operations on complete AA field strings which need no decoder context.
These function expect to get submitted a complete chain of AA fields.
*/
/* This function expects to get submitted a complete chain of AA fields and
determines its size by interpeting the SUSP structure.
@param aa_name The Signature Word (advised is "AA") to be looked for
/* Determine the size of the AA string by interpreting the SUSP structure.
@param data An arbitrary number of bytes beginning with the
complete chain of AA fields. Trailing trash is ignored.
@param flag Unused yet. Submit 0.
@return The number of bytes of the AA field chain.
*/
size_t aaip_count_bytes(char aa_name[2], unsigned char *data, int flag);
size_t aaip_count_bytes(unsigned char *data, int flag);
/* Set the Signature Words of all fields in the AA string to the given
two byte values.
@param aa_name The Signature Word to be set (advised is "AA").
@param data An arbitrary number of bytes beginning with the
complete chain of AA fields. Trailing trash is ignored.
@param flag Unused yet. Submit 0.
@return 1 means succes, <=0 means error
*/
int aaip_set_signature(char aa_name[2], unsigned char *data, int flag);
/* The AAIP decoder context.

@ -6,6 +6,9 @@
* published by the Free Software Foundation. See COPYING file for details.
*/
/* ts A90116 : libisofs.h eventually defines aaip_xinfo_func */
#include "libisofs.h"
#include "builder.h"
#include "node.h"
#include "fsource.h"
@ -86,6 +89,10 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
IsoNode *new;
char *name;
#ifdef Libisofs_with_aaiP
unsigned char *aa_string;
#endif /* Libisofs_with_aaiP */
if (builder == NULL || src == NULL || node == NULL) {
return ISO_NULL_POINTER;
}
@ -175,6 +182,24 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
iso_node_set_uid(new, info.st_uid);
*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) {
/* >>> change field signatures to eventual libisofs non-"AA" setting */;
/* (for now everything is "AA" anyway) */
ret = iso_node_add_xinfo(new, aaip_xinfo_func, aa_string);
if (ret < 0)
return ret;
}
#endif /* Libisofs_with_aaiP */
return ISO_SUCCESS;
}

@ -952,11 +952,12 @@ int ifs_get_aa_string(IsoFileSource *src, unsigned char **aa_string, int flag)
*aa_string = data->aa_string;
data->aa_string = NULL;
} else {
len = aaip_count_bytes((char *) data->aa_string, data->aa_string, 0);
len = aaip_count_bytes(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);
aaip_set_signature("AA", *aa_string, 0); /* libisofs.h demands so */
}
return 1;
}
@ -2538,6 +2539,10 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
/* obtain ownership of eventual AA string */
ret = iso_file_source_get_aa_string(src, &aa_string, 1);
if (ret == 1 && aa_string != NULL) {
/* >>> change field signatures to eventual libisofs non-"AA" setting */;
/* (for now everything is "AA" anyway) */
ret = iso_node_add_xinfo(new, aaip_xinfo_func, aa_string);
if (ret < 0)
return ret;

@ -10,9 +10,16 @@
* Filesystem/FileSource implementation to access the local filesystem.
*/
/* ts A90116 : libisofs.h eventually defines Libisofs_with_aaiP */
#include "libisofs.h"
#include "fsource.h"
#include "util.h"
#ifdef Libisofs_with_aaiP
#include "aaip_0_2.h"
#endif
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -466,8 +473,59 @@ void lfs_free(IsoFileSource *src)
iso_filesystem_unref(lfs);
}
#ifdef Libisofs_with_aaiP
/* ts A90116 */
static
int lfs_get_aa_string(IsoFileSource *src, unsigned char **aa_string, int flag)
{
unsigned int uret;
int ret;
size_t num_attrs = 0, *value_lengths = NULL, result_len;
char *path = NULL, **names = NULL, **values = NULL;
unsigned char *result = NULL;
*aa_string = NULL;
/* Obtain EAs and ACLs ("access" and "default"). ACLs encoded according
to AAIP ACL representation.
*/
path = iso_file_source_get_path(src);
ret = aaip_get_attr_list(path, &num_attrs, &names,
&value_lengths, &values, 1 | 2);
if (ret <= 0) {
ret = ISO_FILE_ERROR;
goto ex;
}
uret = aaip_encode("AA", (unsigned int) num_attrs, names,
value_lengths, values, &result_len, &result, 0);
if (uret == 0) {
ret = ISO_OUT_OF_MEM;
goto ex;
}
*aa_string = result;
ret = 1;
ex:;
if (path != NULL)
free(path);
if (names != NULL || value_lengths != NULL || values != NULL)
aaip_get_attr_list(path, &num_attrs, &names, &value_lengths, &values,
1 << 15); /* free memory */
return ret;
}
#endif /* Libisofs_with_aaiP */
IsoFileSourceIface lfs_class = {
#ifdef Libisofs_with_aaiP
1, /* version */
#else
0, /* version */
#endif
lfs_get_path,
lfs_get_name,
lfs_lstat,
@ -481,8 +539,15 @@ IsoFileSourceIface lfs_class = {
lfs_get_filesystem,
lfs_free,
lfs_lseek
#ifdef Libisofs_with_aaiP
,
lfs_get_aa_string
#endif
};
/**
*
* @return

@ -681,10 +681,11 @@ struct IsoFileSource_Iface
* not be able to produce it again.
* @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.
* Field signature will be "AA".
* (See doc/susp_aaip_0_2.txt for the meaning of AA and
* libisofs/aaip_0_2.h for encoding and decoding.)
* The caller is responsible for finally calling free()
* on non-NULL results.
* @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).
@ -3659,10 +3660,11 @@ int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz);
* @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.
* Field signature will be "AA".
* (See doc/susp_aaip_0_2.txt for the meaning of AA and
* libisofs/aaip_0_2.h for encoding and decoding.)
* The caller is responsible for finally calling free()
* on non-NULL results.
* @param flag Bitfield for control purposes
* bit0= Transfer ownership of AA string data.
* src will free the eventual cached data and might
@ -4103,4 +4105,26 @@ void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
/** Read error occured with IsoDataSource (FATAL,HIGH, -513) */
#define ISO_DATA_SOURCE_FATAL 0xF030FCFF
/* --------------------------------- AAIP --------------------------------- */
/* ts A90112 : Enable experiments about EA and ACL */
#define Libisofs_with_aaiP yes
/* ts A90112
<<< write dummy AAIP fields with any node
# define Libisofs_with_aaip_dummY yes
*/
#ifdef Libisofs_with_aaiP
/**
* Function to identify and manage AA strings as xinfo of IsoNode
*/
int aaip_xinfo_func(void *data, int flag);
#endif /* Libisofs_with_aaiP */
#endif /*LIBISO_LIBISOFS_H_*/

@ -7,6 +7,9 @@
* published by the Free Software Foundation. See COPYING file for details.
*/
/* ts A90116 : libisofs.h eventually defines Libisofs_with_aaiP */
#include "libisofs.h"
#include "rockridge.h"
#include "node.h"
#include "ecma119_tree.h"
@ -883,7 +886,7 @@ size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type, size_t space,
ret = iso_node_get_xinfo(n->node, aaip_xinfo_func, &xipt);
if (ret == 1) {
num_aapt = aaip_count_bytes("AA", (unsigned char *) xipt, 0);
num_aapt = aaip_count_bytes((unsigned char *) xipt, 0);
}
}
@ -1353,7 +1356,7 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
ret = iso_node_get_xinfo(n->node, aaip_xinfo_func, &xipt);
if (ret == 1) {
num_aapt = aaip_count_bytes("AA", (unsigned char *) xipt, 0);
num_aapt = aaip_count_bytes((unsigned char *) xipt, 0);
if (num_aapt > 0) {
aapt = malloc(num_aapt);
if (aapt == NULL) {

@ -29,16 +29,6 @@
#include "ecma119.h"
/* ts A90112 : Enable experiments about EA and ACL
*/
#define Libisofs_with_aaiP yes
/* ts A90112
<<< write dummy AAIP fields with any node
# define Libisofs_with_aaip_dummY yes
*/
#define SUSP_SIG(entry, a, b) ((entry->sig[0] == a) && (entry->sig[1] == b))
/**

Loading…
Cancel
Save