Introduced into AAIP a short notation for name spaces "system.", "user.",

and "isofs.".
This commit is contained in:
Thomas Schmitt 2009-02-10 20:36:34 +01:00
parent 2633aab967
commit 699866f984
2 changed files with 136 additions and 28 deletions

View File

@ -3,7 +3,7 @@
Arbitrary Attribute Interchange Protocol
Draft version 0.2
Jan 30 2008
Feb 10 2009
Interchange of Persistent File Attributes
@ -46,11 +46,12 @@ The reader shall be prepared to detect and handle oversized data.
One or more AA entries form the Attribute List of a file object with
an even number of components. Each two consequtive components form a pair of
Name and Value.
Names which do not contain a perisod character "." are reserved for
registration at libburnia.org. The meaning of any other names is not
specified by this document.
For now only one name is registered:
The empty name indicates that the value is a compact representation of ALCs.
The empty name indicates that the value is a compact representation of ACLs.
Names must not contain byte value 0x00. Names which begin by bytes 0x01 to 0x1f
represent names in particular name spaces. See below: Name Spaces.
The meaning of any other names or name parts is not specified by this document.
All AA entries except the last one shall have the CONTINUE flag set. An AA
entry with CONTINUE set to 0 indicates the end of the Attribute List.
@ -136,6 +137,50 @@ Example: Two pairs of "name"="long...content" and "one"="more" encoded as
-------------------------------------------------------------------------------
Name Spaces
AAIP provides a short notation for namespaces which uses a single non-printable
byte at the start of the name.
Reserved start bytes of names are
0x01 to 0x1F
The names of extended file attributes are traditionally organized in name
spaces, which get expressed as first part of an attribute name up to a
period "." character. It is also tradition that names are printable text,
single words and especially contain no 0-bytes.
AAIP does not enforce the use of any name space but it urges that names in the
following registered name spaces are used according to traditions.
The name spaces "system." and "user." are available with many file system
types. "system." is file system dependent and often restricted in the
choice of names. "user." is portable and allows to choose about any name.
Name space "isofs." is defined for internal use of AAIP enhanced ISO 9660
file systems. Names in this name space should be registered at libburnia.org.
Further name spaces may be registered at libburnia.org.
The reserved start bytes of names have the following meaning
0x01 escape reserved character at start of name
0x02 namespace "system."
0x03 namespace "user."
0x04 namespace "isofs."
0x05 to 0x1F shall not be used yet.
If encountered then they map to name space "user." and the name gets
prefixed "aaipXY_" with XY being two hex digits [0-9A-F] describing
the encountered short indicator value.
Examples:
Name "user.abc"
0, 4, 0x03, 'a', 'b', 'c'
Name "\003abc" (if really desired)
0, 5, 0x01, 0x03, 'a', 'b', 'c'
Default mapping of AAIP name component record {0, 4, 0x0f, 'a', 'b', 'c'}
"user.aaip0F_abc"
-------------------------------------------------------------------------------
Specification of binary ACL representation as special Arbitrary Attribute
The Name component of a binary ACL shall be of length 0.
@ -345,6 +390,10 @@ Revoked drafts:
There was a draft AAIP 0.0 with ER signature "AAIP_2008A". It did not resemble
the existing entry SL and therefore shall not be used by writers of ISO images.
AAIP 0.2 once allowed to announce and use a different signature than "AA".
This has been revoked because ES entries serve the purpose to distinguish
AAIP entries from eventual "AA" entries of any other extension.
-------------------------------------------------------------------------------
References:
@ -361,17 +410,3 @@ Pending considerations:
- shall the tag types ACL_USER and ACL_GROUP with non-numeric qualifier be
revoked ?
- define short indicators for namespaces "user" and "system".
Idea:
Reserved start bytes of name
0x00 to 0x1F
have a meaning
0x00 builtin ACL
0x01 escape reserved character at start of name
0x02 namespace "system"
0x03 namespace "user"
0x04 namespace "libisofs"
0x05 to 0x1F shall not be used yet. If encountered then they map to name
space "user" and the name gets prefixed "aaipXY_" with XY being two hex
digits describint the encountered short indicator value.

View File

@ -41,6 +41,21 @@
#define Aaip_ACL_GROUP_N 12
#define Aaip_FUTURE_VERSION 15
#define Aaip_with_short_namespaceS yes
#define Aaip_max_named_spacE 0x04
#define Aaip_min_named_spacE 0x02
#define Aaip_maxdef_namespacE 0x1f
#define Aaip_namespace_literaL 0x01
#define Aaip_namespace_systeM 0x02
#define Aaip_namespace_useR 0x03
#define Aaip_namespace_isofS 0x04
static char Aaip_namespace_textS[][8]= {"", "", "system.", "user.", "isofs."};
/* maximum expansion: "user.aaipXY_" */
#define Aaip_max_name_expansioN 12
/* --------------------------------- Encoder ---------------------------- */
@ -151,22 +166,27 @@ static void aaip_encode_byte(unsigned char *result, size_t *result_fill,
static int aaip_encode_comp(unsigned char *result, size_t *result_fill,
char *data, size_t l, int flag)
int prefix, char *data, size_t l, int flag)
{
size_t todo;
char *rpt, *comp_start;
if(l == 0) {
if(l == 0 && prefix <= 0) {
aaip_encode_byte(result, result_fill, 0);
aaip_encode_byte(result, result_fill, 0);
return(1);
}
for(rpt= data; rpt - data < l;) {
todo= l - (rpt - data);
todo= l - (rpt - data) + (prefix > 0);
aaip_encode_byte(result, result_fill, (todo > 255));
if(todo > 255)
todo= 255;
aaip_encode_byte(result, result_fill, todo);
if(prefix > 0) {
aaip_encode_byte(result, result_fill, prefix);
todo--;
prefix= 0;
}
for(comp_start= rpt; rpt - comp_start < todo; rpt++)
aaip_encode_byte(result, result_fill, *((unsigned char *) rpt));
}
@ -184,8 +204,24 @@ static int aaip_encode_pair(char *name, size_t attr_length, char *attr,
int flag)
{
size_t l;
int i, prefix= 0;
l= strlen(name);
#ifdef Aaip_with_short_namespaceS
/* translate name into eventual short form */
for(i= Aaip_min_named_spacE; i <= Aaip_max_named_spacE; i++)
if(strncmp(name, Aaip_namespace_textS[i], strlen(Aaip_namespace_textS[i]))
== 0) {
name+= strlen(Aaip_namespace_textS[i]);
prefix= i;
}
/* Eventually prepend escape marker for strange names */
if(prefix <= 0 && name[0] > 0 && name[0] <= Aaip_maxdef_namespacE)
prefix= Aaip_namespace_literaL;
#endif /* Aaip_with_short_namespaceS */
l= strlen(name) + (prefix > 0);
*num_recs= l / 255 + (!!(l % 255)) + (l == 0) +
attr_length / 255 + (!!(attr_length % 255)) + (attr_length == 0);
*comp_size= l + attr_length + 2 * *num_recs;
@ -193,8 +229,8 @@ static int aaip_encode_pair(char *name, size_t attr_length, char *attr,
if(flag & 1)
return(1);
aaip_encode_comp(result, &result_fill, name, l, 0);
aaip_encode_comp(result, &result_fill, attr, attr_length, 0);
aaip_encode_comp(result, &result_fill, prefix, name, l - (prefix > 0), 0);
aaip_encode_comp(result, &result_fill, 0, attr, attr_length, 0);
return(1);
}
@ -1482,6 +1518,11 @@ int aaip_decode_pair(struct aaip_state *aaip,
int ret;
size_t ready_bytes;
#ifdef Aaip_with_short_namespaceS
char prefix[Aaip_max_name_expansioN + 1];
size_t nl, pl;
#endif
*consumed= 0;
if((aaip->pair_status < 0 && aaip->pair_status != -2) ||
aaip->pair_status == 4 ||
@ -1524,8 +1565,8 @@ int aaip_decode_pair(struct aaip_state *aaip,
{ret= -1; goto ex;} /* unknown reply from aaip_submit_data() */
*consumed= num_data;
ret= aaip_advance_pair(aaip, name, name_size, name_fill,
value, value_size, value_fill, flag & 1);
ret= aaip_advance_pair(aaip, name, name_size - Aaip_max_name_expansioN,
name_fill, value, value_size, value_fill, flag & 1);
if(aaip->aa_ends == 3) {
if(ret >= 2 && ret <= 4)
ret= 4;
@ -1533,6 +1574,38 @@ int aaip_decode_pair(struct aaip_state *aaip,
ret= 5;
}
ex:;
#ifdef Aaip_with_short_namespaceS
if(ret >= 2 && ret <= 4 && *name_fill > 0) {
/* Translate name from eventual short form */
nl= *name_fill;
if(name[0] > 0 && name[0] <= Aaip_maxdef_namespacE) {
prefix[0]= 0;
if(name[0] == Aaip_namespace_literaL) {
if(nl > 1) {
/* Remove first character of name */
memmove(name, name + 1, nl - 1);
(*name_fill)--;
}
} else if(name[0] == Aaip_namespace_systeM ||
name[0] == Aaip_namespace_useR ||
name[0] == Aaip_namespace_isofS) {
strcpy(prefix, Aaip_namespace_textS[(int) name[0]]);
} else {
sprintf(prefix, "user.aaip%2.2X_", (unsigned int) name[0]);
}
pl= strlen(prefix);
if(pl > 0) {
memmove(name + pl, name + 1, nl - 1);
memcpy(name, prefix, pl);
*name_fill= pl + nl - 1;
}
}
}
#endif /* Aaip_with_short_namespaceS */
aaip->pair_status= ret;
return(ret);
}