diff mbox

[2/3] btrfs-progs: Avoid uninitialized data in output of btrfs-convert

Message ID 950a8539e7a587f55d34820049d6ed46aa4acdc8.1441718128.git.zhaolei@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Zhaolei Sept. 8, 2015, 1:16 p.m. UTC
sequence, transid and reserved field of inode was write to disk
with uninitizlized value, this patch fixed it.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
---
 btrfs-convert.c | 4 ++++
 ctree.h         | 2 ++
 2 files changed, 6 insertions(+)
diff mbox

Patch

diff --git a/btrfs-convert.c b/btrfs-convert.c
index f4fc650..934f4dc 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -1016,6 +1016,8 @@  static int copy_inode_item(struct btrfs_inode_item *dst,
 			   struct ext2_inode *src, u32 blocksize)
 {
 	btrfs_set_stack_inode_generation(dst, 1);
+	btrfs_set_stack_inode_sequence(dst, 0);
+	btrfs_set_stack_inode_transid(dst, 1);
 	btrfs_set_stack_inode_size(dst, src->i_size);
 	btrfs_set_stack_inode_nbytes(dst, 0);
 	btrfs_set_stack_inode_block_group(dst, 0);
@@ -1052,6 +1054,8 @@  static int copy_inode_item(struct btrfs_inode_item *dst,
 				new_decode_dev(src->i_block[1]));
 		}
 	}
+	memset(&dst->reserved, 0, sizeof(dst->reserved));
+
 	return 0;
 }
 
diff --git a/ctree.h b/ctree.h
index 2061e1e..c57f9ca 100644
--- a/ctree.h
+++ b/ctree.h
@@ -1424,6 +1424,8 @@  BTRFS_SETGET_STACK_FUNCS(stack_inode_generation,
 			 struct btrfs_inode_item, generation, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_inode_sequence,
 			 struct btrfs_inode_item, sequence, 64);
+BTRFS_SETGET_STACK_FUNCS(stack_inode_transid,
+			 struct btrfs_inode_item, transid, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_inode_size,
 			 struct btrfs_inode_item, size, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_inode_nbytes,