diff mbox

libext2fs: Fix various errors result from crc32c/metadata checksum integration

Message ID 20110930193843.GS12086@tux1.beaverton.ibm.com
State Accepted, archived
Headers show

Commit Message

Darrick J. Wong Sept. 30, 2011, 7:38 p.m. UTC
Fix several minor errors in structure definitions, the byteswap code, and
Makefiles that result from merging the crc32c and initial parts of the metadata
checksumming patchset.

(This fix is required by the metadata checksumming patchset)

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---

 lib/ext2fs/Makefile.in |    2 +-
 lib/ext2fs/ext2fs.h    |    4 ++--
 lib/ext2fs/swapfs.c    |   18 ++++++++----------
 3 files changed, 11 insertions(+), 13 deletions(-)

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

Comments

Andreas Dilger Sept. 30, 2011, 9:08 p.m. UTC | #1
On 2011-09-30, at 1:38 PM, Darrick J. Wong wrote:
> Fix several minor errors in structure definitions, the byteswap code,
> and Makefiles that result from merging the crc32c and initial parts
> of the metadata checksumming patchset.
> 
> (This fix is required by the metadata checksumming patchset)

Yay, someone who can and does actually test on a big-endian system. :-)

> Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
> ---
> 
> lib/ext2fs/Makefile.in |    2 +-
> lib/ext2fs/ext2fs.h    |    4 ++--
> lib/ext2fs/swapfs.c    |   18 ++++++++----------
> 3 files changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/lib/ext2fs/Makefile.in b/lib/ext2fs/Makefile.in
> index c2bfb70..3de9f87 100644
> --- a/lib/ext2fs/Makefile.in
> +++ b/lib/ext2fs/Makefile.in
> @@ -398,7 +398,7 @@ clean::
> 		tst_bitops tst_types tst_icount tst_super_size tst_csum \
> 		ext2_tdbtool mkjournal debug_cmds.c \
> 		../libext2fs.a ../libext2fs_p.a ../libext2fs_chk.a \
> -		crc32c_table.h
> +		crc32c_table.h gen_crc32ctable tst_crc32c
> 
> mostlyclean:: clean
> distclean:: clean
> diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
> index 203d222..357bf60 100644
> --- a/lib/ext2fs/ext2fs.h
> +++ b/lib/ext2fs/ext2fs.h
> @@ -916,8 +916,8 @@ extern int ext2fs_super_and_bgd_loc(ext2_filsys fs,
> extern void ext2fs_update_dynamic_rev(ext2_filsys fs);
> 
> /* crc32c.c */
> -extern __u32 crc32c_be(__u32 crc, unsigned char const *p, size_t len);
> -extern __u32 crc32c_le(__u32 crc, unsigned char const *p, size_t len);
> +extern __u32 ext2fs_crc32c_be(__u32 crc, unsigned char const *p, size_t len);
> +extern __u32 ext2fs_crc32c_le(__u32 crc, unsigned char const *p, size_t len);
> 
> /* csum.c */
> extern void ext2fs_group_desc_csum_set(ext2_filsys fs, dgrp_t group);
> diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c
> index 7962472..7c99373 100644
> --- a/lib/ext2fs/swapfs.c
> +++ b/lib/ext2fs/swapfs.c
> @@ -260,7 +260,7 @@ void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t,
> 		t->osd2.linux2.l_i_gid_high =
> 		  ext2fs_swab16 (f->osd2.linux2.l_i_gid_high);
> 		t->osd2.linux2.l_i_checksum_lo =
> -			ext2fs_swab32(f->osd2.linux2.l_i_checksum_lo);
> +			ext2fs_swab16(f->osd2.linux2.l_i_checksum_lo);
> 		break;
> 	case EXT2_OS_HURD:
> 		t->osd1.hurd1.h_i_translator =
> @@ -294,21 +294,19 @@ void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t,
> 		return;
> 	}
> 
> -	if (extra_isize >= 2)
> +	if (extra_isize >= 4)
> 		t->i_checksum_hi = ext2fs_swab16(f->i_checksum_hi);
> -	if (extra_isize >= 6)
> -		t->i_checksum_hi = ext2fs_swab32(f->i_checksum_hi);
> -	if (extra_isize >= 10)
> +	if (extra_isize >= 8)
> 		t->i_ctime_extra = ext2fs_swab32(f->i_ctime_extra);
> -	if (extra_isize >= 14)
> +	if (extra_isize >= 12)
> 		t->i_mtime_extra = ext2fs_swab32(f->i_mtime_extra);
> -	if (extra_isize >= 18)
> +	if (extra_isize >= 16)
> 		t->i_atime_extra = ext2fs_swab32(f->i_atime_extra);
> -	if (extra_isize >= 22)
> +	if (extra_isize >= 20)
> 		t->i_crtime = ext2fs_swab32(f->i_crtime);
> -	if (extra_isize >= 26)
> +	if (extra_isize >= 24)
> 		t->i_crtime_extra = ext2fs_swab32(f->i_crtime_extra);
> -	if (extra_isize >= 30)
> +	if (extra_isize >= 28)
> 		t->i_version_hi = ext2fs_swab32(f->i_version_hi);
> 
> 	i = sizeof(struct ext2_inode) + extra_isize + sizeof(__u32);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Cheers, Andreas





--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o Sept. 30, 2011, 9:12 p.m. UTC | #2
On Fri, Sep 30, 2011 at 12:38:43PM -0700, Darrick J. Wong wrote:
> Fix several minor errors in structure definitions, the byteswap code, and
> Makefiles that result from merging the crc32c and initial parts of the metadata
> checksumming patchset.
> 
> (This fix is required by the metadata checksumming patchset)
> 
> Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>

Oops, thanks for catching these.  I've applied this patch to the next
branch of e2fsprogs.

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

Patch

diff --git a/lib/ext2fs/Makefile.in b/lib/ext2fs/Makefile.in
index c2bfb70..3de9f87 100644
--- a/lib/ext2fs/Makefile.in
+++ b/lib/ext2fs/Makefile.in
@@ -398,7 +398,7 @@  clean::
 		tst_bitops tst_types tst_icount tst_super_size tst_csum \
 		ext2_tdbtool mkjournal debug_cmds.c \
 		../libext2fs.a ../libext2fs_p.a ../libext2fs_chk.a \
-		crc32c_table.h
+		crc32c_table.h gen_crc32ctable tst_crc32c
 
 mostlyclean:: clean
 distclean:: clean
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 203d222..357bf60 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -916,8 +916,8 @@  extern int ext2fs_super_and_bgd_loc(ext2_filsys fs,
 extern void ext2fs_update_dynamic_rev(ext2_filsys fs);
 
 /* crc32c.c */
-extern __u32 crc32c_be(__u32 crc, unsigned char const *p, size_t len);
-extern __u32 crc32c_le(__u32 crc, unsigned char const *p, size_t len);
+extern __u32 ext2fs_crc32c_be(__u32 crc, unsigned char const *p, size_t len);
+extern __u32 ext2fs_crc32c_le(__u32 crc, unsigned char const *p, size_t len);
 
 /* csum.c */
 extern void ext2fs_group_desc_csum_set(ext2_filsys fs, dgrp_t group);
diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c
index 7962472..7c99373 100644
--- a/lib/ext2fs/swapfs.c
+++ b/lib/ext2fs/swapfs.c
@@ -260,7 +260,7 @@  void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t,
 		t->osd2.linux2.l_i_gid_high =
 		  ext2fs_swab16 (f->osd2.linux2.l_i_gid_high);
 		t->osd2.linux2.l_i_checksum_lo =
-			ext2fs_swab32(f->osd2.linux2.l_i_checksum_lo);
+			ext2fs_swab16(f->osd2.linux2.l_i_checksum_lo);
 		break;
 	case EXT2_OS_HURD:
 		t->osd1.hurd1.h_i_translator =
@@ -294,21 +294,19 @@  void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t,
 		return;
 	}
 
-	if (extra_isize >= 2)
+	if (extra_isize >= 4)
 		t->i_checksum_hi = ext2fs_swab16(f->i_checksum_hi);
-	if (extra_isize >= 6)
-		t->i_checksum_hi = ext2fs_swab32(f->i_checksum_hi);
-	if (extra_isize >= 10)
+	if (extra_isize >= 8)
 		t->i_ctime_extra = ext2fs_swab32(f->i_ctime_extra);
-	if (extra_isize >= 14)
+	if (extra_isize >= 12)
 		t->i_mtime_extra = ext2fs_swab32(f->i_mtime_extra);
-	if (extra_isize >= 18)
+	if (extra_isize >= 16)
 		t->i_atime_extra = ext2fs_swab32(f->i_atime_extra);
-	if (extra_isize >= 22)
+	if (extra_isize >= 20)
 		t->i_crtime = ext2fs_swab32(f->i_crtime);
-	if (extra_isize >= 26)
+	if (extra_isize >= 24)
 		t->i_crtime_extra = ext2fs_swab32(f->i_crtime_extra);
-	if (extra_isize >= 30)
+	if (extra_isize >= 28)
 		t->i_version_hi = ext2fs_swab32(f->i_version_hi);
 
 	i = sizeof(struct ext2_inode) + extra_isize + sizeof(__u32);