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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



sequence, transid and reserved field of inode was write to disk
with uninitizlized value, this patch fixed it.

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

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,
-- 
1.8.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux