Made preservation of ACL in iso_node_set_attrs() more efficient
This commit is contained in:
parent
22e45ed489
commit
49821f6962
@ -4433,7 +4433,7 @@ int iso_node_get_attrs(IsoNode *node, size_t *num_attrs,
|
|||||||
* bit1= Do not clear the existing attribute list but merge it with
|
* bit1= Do not clear the existing attribute list but merge it with
|
||||||
* the list given by this call
|
* the list given by this call
|
||||||
* bit2= Delete the attributes with the given names
|
* bit2= Delete the attributes with the given names
|
||||||
* bit3= Allow non-user attribute.
|
* bit3= Allow non-user attributes.
|
||||||
* I.e. those with a non-empty name which does not begin by "user."
|
* I.e. those with a non-empty name which does not begin by "user."
|
||||||
* (The empty name is always allowed and governed by bit0.) This
|
* (The empty name is always allowed and governed by bit0.) This
|
||||||
* deletes all previously existing attributes if not bit1 is set.
|
* deletes all previously existing attributes if not bit1 is set.
|
||||||
|
@ -1528,6 +1528,7 @@ int attr_enlarge_list(char ***names, size_t **value_lengths, char ***values,
|
|||||||
(but not if bit2 is set)
|
(but not if bit2 is set)
|
||||||
bit2= delete the given names rather than overwrite
|
bit2= delete the given names rather than overwrite
|
||||||
their content
|
their content
|
||||||
|
bit4= do not overwrite value of empty name
|
||||||
bit15= release memory and return 1
|
bit15= release memory and return 1
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
@ -1546,7 +1547,7 @@ int iso_node_merge_xattr(IsoNode *node, size_t num_attrs, char **names,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = iso_node_get_attrs(node, m_num_attrs, m_names, m_value_lengths,
|
ret = iso_node_get_attrs(node, m_num_attrs, m_names, m_value_lengths,
|
||||||
m_values, 0);
|
m_values, 1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -1572,8 +1573,12 @@ int iso_node_merge_xattr(IsoNode *node, size_t num_attrs, char **names,
|
|||||||
|
|
||||||
/* Handle existing names, count non-existing names */
|
/* Handle existing names, count non-existing names */
|
||||||
for (i = 0; i < num_attrs; i++) {
|
for (i = 0; i < num_attrs; i++) {
|
||||||
|
if (names[i] == NULL)
|
||||||
|
continue;
|
||||||
|
if (names[i][0] == 0 && (flag & 16))
|
||||||
|
continue;
|
||||||
for (j = 0; j < *m_num_attrs; j++) {
|
for (j = 0; j < *m_num_attrs; j++) {
|
||||||
if (names[i] == NULL || (*m_names)[j] == NULL)
|
if ((*m_names)[j] == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(names[i], (*m_names)[j]) == 0) {
|
if (strcmp(names[i], (*m_names)[j]) == 0) {
|
||||||
if ((*m_values)[j] != NULL)
|
if ((*m_values)[j] != NULL)
|
||||||
@ -1613,8 +1618,12 @@ int iso_node_merge_xattr(IsoNode *node, size_t num_attrs, char **names,
|
|||||||
/* Set new pairs */;
|
/* Set new pairs */;
|
||||||
w = *m_num_attrs;
|
w = *m_num_attrs;
|
||||||
for (i = 0; i < num_attrs; i++) {
|
for (i = 0; i < num_attrs; i++) {
|
||||||
|
if (names[i] == NULL)
|
||||||
|
continue;
|
||||||
|
if (names[i][0] == 0 && (flag & 16))
|
||||||
|
continue;
|
||||||
for (j = 0; j < *m_num_attrs; j++) {
|
for (j = 0; j < *m_num_attrs; j++) {
|
||||||
if (names[i] == NULL || (*m_names)[j] == NULL)
|
if ((*m_names)[j] == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(names[i], (*m_names)[j]) == 0)
|
if (strcmp(names[i], (*m_names)[j]) == 0)
|
||||||
continue;
|
continue;
|
||||||
@ -1658,7 +1667,7 @@ int iso_node_set_attrs(IsoNode *node, size_t num_attrs, char **names,
|
|||||||
|
|
||||||
#ifdef Libisofs_with_aaiP
|
#ifdef Libisofs_with_aaiP
|
||||||
|
|
||||||
int ret;
|
int ret, acl_saved = 0;
|
||||||
size_t sret, result_len, m_num = 0, *m_value_lengths = NULL, i;
|
size_t sret, result_len, m_num = 0, *m_value_lengths = NULL, i;
|
||||||
unsigned char *result;
|
unsigned char *result;
|
||||||
char *a_acl = NULL, *d_acl = NULL, **m_names = NULL, **m_values = NULL;
|
char *a_acl = NULL, *d_acl = NULL, **m_names = NULL, **m_values = NULL;
|
||||||
@ -1668,28 +1677,28 @@ int iso_node_set_attrs(IsoNode *node, size_t num_attrs, char **names,
|
|||||||
if (strncmp(names[i], "user.", 5) != 0 && names[i][0] != 0)
|
if (strncmp(names[i], "user.", 5) != 0 && names[i][0] != 0)
|
||||||
return ISO_AAIP_NON_USER_NAME;
|
return ISO_AAIP_NON_USER_NAME;
|
||||||
|
|
||||||
if (!(flag & 1))
|
|
||||||
iso_node_get_acl_text(node, &a_acl, &d_acl, 16);
|
|
||||||
|
|
||||||
if ((flag & (2 | 4)) || !(flag & 8)) {
|
if ((flag & (2 | 4)) || !(flag & 8)) {
|
||||||
/* Merge old and new lists */
|
/* Merge old and new lists */
|
||||||
ret = iso_node_merge_xattr(
|
ret = iso_node_merge_xattr(
|
||||||
node, num_attrs, names, value_lengths, values,
|
node, num_attrs, names, value_lengths, values,
|
||||||
&m_num, &m_names, &m_value_lengths, &m_values,
|
&m_num, &m_names, &m_value_lengths, &m_values,
|
||||||
(flag & 4) | !(flag & 2));
|
(flag & 4) | (!(flag & 2)) | ((!(flag & 1)) << 4));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto ex;
|
goto ex;
|
||||||
num_attrs = m_num;
|
num_attrs = m_num;
|
||||||
names = m_names;
|
names = m_names;
|
||||||
value_lengths = m_value_lengths;
|
value_lengths = m_value_lengths;
|
||||||
values = m_values;
|
values = m_values;
|
||||||
|
} else if (!(flag & 1)) {
|
||||||
|
iso_node_get_acl_text(node, &a_acl, &d_acl, 16);
|
||||||
|
acl_saved = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_attrs == 0) {
|
if (num_attrs == 0) {
|
||||||
ret = iso_node_remove_xinfo(node, aaip_xinfo_func);
|
ret = iso_node_remove_xinfo(node, aaip_xinfo_func);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto ex;
|
goto ex;
|
||||||
if (!(flag & 1)) {
|
if (acl_saved && (a_acl != NULL || d_acl != NULL)) {
|
||||||
ret = iso_node_set_acl_text(node, a_acl, d_acl, 0);
|
ret = iso_node_set_acl_text(node, a_acl, d_acl, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto ex;
|
goto ex;
|
||||||
@ -1712,12 +1721,12 @@ int iso_node_set_attrs(IsoNode *node, size_t num_attrs, char **names,
|
|||||||
goto ex;
|
goto ex;
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
|
||||||
/* >>> something is messed up with xinfo */;
|
/* >>> something is messed up with xinfo: an aa_string still exists */;
|
||||||
|
|
||||||
ret = ISO_ERROR;
|
ret = ISO_ERROR;
|
||||||
goto ex;
|
goto ex;
|
||||||
}
|
}
|
||||||
if (!(flag & 1)) {
|
if (acl_saved) {
|
||||||
ret = iso_node_set_acl_text(node, a_acl, d_acl, 0);
|
ret = iso_node_set_acl_text(node, a_acl, d_acl, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto ex;
|
goto ex;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user