ref: f4737bfd38c5a2bd7d1cd8da7f1a6e9cd2680b2a
parent: 08dc4abdfdb49ad8a92d2eafed1adccc206abfe5
author: ngkaho1234 <[email protected]>
date: Thu Nov 5 04:41:01 EST 2015
EA: ea entries with name "system.data" should be preferentially stored in inode body.
--- a/lwext4/ext4_types.h
+++ b/lwext4/ext4_types.h
@@ -823,6 +823,9 @@
} __attribute__((packed));
struct ext4_xattr_item {
+ /* This attribute should be stored in inode body */
+ bool in_inode;
+
uint8_t name_index;
char *name;
size_t name_len;
--- a/lwext4/ext4_xattr.c
+++ b/lwext4/ext4_xattr.c
@@ -163,6 +163,12 @@
struct ext4_xattr_item *b)
{
int result;
+ if (a->in_inode && !b->in_inode)
+ return -1;
+
+ if (!a->in_inode && b->in_inode)
+ return 1;
+
result = a->name_index - b->name_index;
if (result)
return result;
@@ -194,6 +200,11 @@
memset(&item->node, 0, sizeof(item->node));
memcpy(item->name, name, name_len);
+ if (name_index == EXT4_XATTR_INDEX_SYSTEM &&
+ name_len == 4 &&
+ !memcmp(name, "data", 4))
+ item->in_inode = true;
+
return item;
}
@@ -404,6 +415,10 @@
.name = (char *)name, /*RB_FIND - won't touch this string*/
.name_len = name_len,
};
+ if (name_index == EXT4_XATTR_INDEX_SYSTEM &&
+ name_len == 4 &&
+ !memcmp(name, "data", 4))
+ tmp.in_inode = true;
return RB_FIND(ext4_xattr_tree, &xattr_ref->root, &tmp);
}