am 32243fad: Fix a few bugs in rand_emmc_perf
* commit '32243fadeab8cf244861e3df89744b78ba3eff92':
Fix a few bugs in rand_emmc_perf
diff --git a/ext4_utils/contents.c b/ext4_utils/contents.c
index de38bb0..345ab1e 100644
--- a/ext4_utils/contents.c
+++ b/ext4_utils/contents.c
@@ -263,7 +263,7 @@
u32 *hdr;
struct ext4_xattr_entry *entry;
size_t name_len = strlen(XATTR_SELINUX_SUFFIX);
- size_t value_len = strlen(secon)+1;
+ size_t value_len;
size_t size, min_offs;
char *val;
@@ -280,6 +280,7 @@
entry->e_name_index = EXT4_XATTR_INDEX_SECURITY;
entry->e_name_len = name_len;
memcpy(entry->e_name, XATTR_SELINUX_SUFFIX, name_len);
+ value_len = strlen(secon)+1;
entry->e_value_size = cpu_to_le32(value_len);
min_offs = (char *)inode + info.inode_size - (char*) entry;
size = EXT4_XATTR_SIZE(value_len);
diff --git a/ext4_utils/indirect.c b/ext4_utils/indirect.c
index 4e768a1..70f04d6 100644
--- a/ext4_utils/indirect.c
+++ b/ext4_utils/indirect.c
@@ -484,9 +484,10 @@
unsigned long backing_len)
{
struct block_allocation *alloc;
+ u32 block_len = DIV_ROUND_UP(len, info.block_size);
u8 *data = NULL;
- alloc = do_inode_allocate_indirect(inode, len);
+ alloc = do_inode_allocate_indirect(inode, block_len);
if (alloc == NULL) {
error("failed to allocate extents for %lu bytes", len);
return NULL;
@@ -498,6 +499,10 @@
error("failed to create backing for %lu bytes", backing_len);
}
+ rewind_alloc(alloc);
+ if (do_inode_attach_indirect(inode, alloc, block_len))
+ error("failed to attach blocks to indirect inode");
+
free_alloc(alloc);
return data;