return NULL;
}
-static int find_ea_index(const char *fullname, char **name, int *index)
+static int find_ea_index(const char *fullname, const char **name, int *index)
{
struct ea_name_index *e;
for (e = ea_names; e->name; e++) {
if (strncmp(fullname, e->name, strlen(e->name)) == 0) {
- *name = (char *)fullname + strlen(e->name);
+ *name = fullname + strlen(e->name);
*index = e->index;
return 1;
}
static errcode_t convert_posix_acl_to_disk_buffer(const void *value, size_t size,
void *out_buf, size_t *size_out)
{
- posix_acl_xattr_header *header = (posix_acl_xattr_header*) value;
- posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
+ const posix_acl_xattr_header *header =
+ (const posix_acl_xattr_header*) value;
+ const posix_acl_xattr_entry *end, *entry =
+ (const posix_acl_xattr_entry *)(header+1);
ext4_acl_header *ext_acl;
size_t s;
- void *e;
+ char *e;
int count;
{
posix_acl_xattr_header *header;
posix_acl_xattr_entry *entry;
- ext4_acl_header *ext_acl = (ext4_acl_header *) value;
+ const ext4_acl_header *ext_acl = (const ext4_acl_header *) value;
errcode_t err;
const char *cp;
char *out;
header->a_version = ext2fs_cpu_to_le32(POSIX_ACL_XATTR_VERSION);
entry = (posix_acl_xattr_entry *) (out + sizeof(posix_acl_xattr_header));
- cp = value + sizeof(ext4_acl_header);
+ cp = (const char *) value + sizeof(ext4_acl_header);
size -= sizeof(ext4_acl_header);
while (size > 0) {
{
struct ext2_xattr *x;
struct ext2_ext_attr_entry *e = entries_start;
- void *end = entries_start + storage_size;
- char *shortname;
- unsigned int entry_size, value_size;
+ char *end = (char *) entries_start + storage_size;
+ const char *shortname;
+ unsigned int value_size;
int idx, ret;
errcode_t err;
shortname = x->name;
ret = find_ea_index(x->name, &shortname, &idx);
- /* Calculate entry and value size */
- entry_size = (sizeof(*e) + strlen(shortname) +
- EXT2_EXT_ATTR_PAD - 1) &
- ~(EXT2_EXT_ATTR_PAD - 1);
value_size = ((x->value_len + EXT2_EXT_ATTR_PAD - 1) /
EXT2_EXT_ATTR_PAD) * EXT2_EXT_ATTR_PAD;
e->e_value_offs = 0;
} else {
end -= value_size;
- e->e_value_offs = end - entries_start +
- value_offset_correction;
+ e->e_value_offs = end - (char *) entries_start +
+ value_offset_correction;
memcpy(end, x->value, e->e_value_size);
}
errcode_t ext2fs_xattrs_write(struct ext2_xattr_handle *handle)
{
ext2_filsys fs = handle->fs;
- const int inode_size = EXT2_INODE_SIZE(fs->super);
+ const unsigned int inode_size = EXT2_INODE_SIZE(fs->super);
struct ext2_inode_large *inode;
char *start, *block_buf = NULL;
struct ext2_ext_attr_header *header;
static void xattrs_free_keys(struct ext2_xattr_handle *h)
{
struct ext2_xattr *a = h->attrs;
- size_t i;
+ int i;
for (i = 0; i < h->capacity; i++) {
if (a[i].name)
{
struct ext2_xattr *x;
int i;
- char *shortname, *x_shortname;
+ const char *shortname, *x_shortname;
int name_idx, x_name_idx;
int shortname_len, x_shortname_len;
int add_to_ibody;
int needed;
int name_len, name_idx;
- char *shortname;
+ const char *shortname;
int new_idx;
int ret;
{
int total = 0;
struct ext2_xattr *x;
- char *shortname;
+ const char *shortname;
int i, len, name_idx;
for (i = 0, x = attrs; i < count; i++, x++) {
ret = EXT2_ET_FILESYSTEM_CORRUPTED;
goto out;
}
- ret = xattr_array_update(h, name, value, value_len, ibody_free,
+ ret = xattr_array_update(h, name, new_value, value_len,
+ ibody_free,
0 /* block_free */, old_idx,
0 /* in_inode */);
if (ret)
value_len > EXT4_XATTR_MIN_LARGE_EA_SIZE(fs->blocksize))
in_inode = 1;
- ret = xattr_array_update(h, name, value, value_len, ibody_free,
+ ret = xattr_array_update(h, name, new_value, value_len, ibody_free,
block_free, old_idx, in_inode);
if (ret == EXT2_ET_EA_NO_SPACE && !in_inode &&
ext2fs_has_feature_ea_inode(fs->super))
- ret = xattr_array_update(h, name, value, value_len, ibody_free,
- block_free, old_idx, 1 /* in_inode */);
+ ret = xattr_array_update(h, name, new_value, value_len,
+ ibody_free, block_free, old_idx, 1 /* in_inode */);
if (ret)
goto out;