Commit d561d4dd authored by Chengguang Xu's avatar Chengguang Xu Committed by Jan Kara

ext2: introduce new helper for xattr entry comparison

Introduce new helper ext2_xattr_cmp_entry() for xattr
entry comparison.
Signed-off-by: default avatarChengguang Xu <cgxu519@zoho.com.cn>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 9bb1d7a6
...@@ -166,6 +166,21 @@ ext2_xattr_entry_valid(struct ext2_xattr_entry *entry, ...@@ -166,6 +166,21 @@ ext2_xattr_entry_valid(struct ext2_xattr_entry *entry,
return true; return true;
} }
static int
ext2_xattr_cmp_entry(int name_index, size_t name_len, const char *name,
struct ext2_xattr_entry *entry)
{
int cmp;
cmp = name_index - entry->e_name_index;
if (!cmp)
cmp = name_len - entry->e_name_len;
if (!cmp)
cmp = memcmp(name, entry->e_name, name_len);
return cmp;
}
/* /*
* ext2_xattr_get() * ext2_xattr_get()
* *
...@@ -452,13 +467,9 @@ ext2_xattr_set(struct inode *inode, int name_index, const char *name, ...@@ -452,13 +467,9 @@ ext2_xattr_set(struct inode *inode, int name_index, const char *name,
min_offs = offs; min_offs = offs;
} }
if (not_found > 0) { if (not_found > 0) {
not_found = name_index - last->e_name_index; not_found = ext2_xattr_cmp_entry(name_index,
if (!not_found) name_len,
not_found = name_len - last->e_name_len; name, last);
if (!not_found) {
not_found = memcmp(name, last->e_name,
name_len);
}
if (not_found <= 0) if (not_found <= 0)
here = last; here = last;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment