[Ocfs2-tools-devel] [PATCH] dirblock.c: Fix byte swapping of dir block trailer

y at suse.cz y at suse.cz
Wed Sep 8 09:14:41 PDT 2010


From: Jan Kara <jack at suse.cz>

ocfs2_swap_dir_trailer() was always nop as it didn't store swapped values thus
leading to corrupted dir block trailer on big endian machines. Fix the problem
by storing the values properly.

Signed-off-by: Jan Kara <jack at suse.cz>
---
 libocfs2/dirblock.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

 Sunil, would you include this fix please? Thanks.

diff --git a/libocfs2/dirblock.c b/libocfs2/dirblock.c
index bd65119..24afd8c 100644
--- a/libocfs2/dirblock.c
+++ b/libocfs2/dirblock.c
@@ -157,12 +157,12 @@ void ocfs2_swap_dir_trailer(struct ocfs2_dir_block_trailer *trailer)
 	if (cpu_is_little_endian)
 		return;
 
-	bswap_64(trailer->db_compat_inode);
-	bswap_64(trailer->db_compat_rec_len);
-	bswap_64(trailer->db_blkno);
-	bswap_64(trailer->db_parent_dinode);
-	bswap_16(trailer->db_free_rec_len);
-	bswap_64(trailer->db_free_next);
+	trailer->db_compat_inode = bswap_64(trailer->db_compat_inode);
+	trailer->db_compat_rec_len = bswap_64(trailer->db_compat_rec_len);
+	trailer->db_blkno = bswap_64(trailer->db_blkno);
+	trailer->db_parent_dinode = bswap_64(trailer->db_parent_dinode);
+	trailer->db_free_rec_len = bswap_16(trailer->db_free_rec_len);
+	trailer->db_free_next = bswap_64(trailer->db_free_next);
 }
 
 errcode_t ocfs2_read_dir_block(ocfs2_filesys *fs, struct ocfs2_dinode *di,
-- 
1.6.4.2




More information about the Ocfs2-tools-devel mailing list