diff options
author | Darrick J. Wong <djwong@us.ibm.com> | 2011-09-30 12:41:26 -0700 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-09-30 21:28:30 -0400 |
commit | 9026b3db3af838983ed81aad2b4d5e09df1013e3 (patch) | |
tree | 381c2052c6660113358e6c8e5c47fe072ceb7aaf /lib/ext2fs | |
parent | 1660034c0a0c7199b0843909c756f8f9e42b85f5 (diff) | |
download | e2fsprogs-9026b3db3af838983ed81aad2b4d5e09df1013e3.tar.gz |
libext2fs: Always swab the MMP block on big-endian systems machines
The MMP code in libext2fs tries to gate MMP block swab'ing with this
test:
if (fs->super->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
However, EXT2FS_ENABLE_SWAPFS never seems to be defined anywhere (all
possible existed, the field fs->super->s_magic is always in host
byteorder, so the test always fails. So, we can change the #ifdef to
WORDS_BIGENDIAN (which is conditionally defined on BE platforms) and
get rid of the broken if test.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib/ext2fs')
-rw-r--r-- | lib/ext2fs/mmp.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c index ed6ee425..91f4fb28 100644 --- a/lib/ext2fs/mmp.c +++ b/lib/ext2fs/mmp.c @@ -91,9 +91,8 @@ errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf) } mmp_cmp = fs->mmp_cmp; -#ifdef EXT2FS_ENABLE_SWAPFS - if (fs->flags & EXT2_FLAG_SWAP_BYTES) - ext2fs_swap_mmp(mmp_cmp); +#ifdef WORDS_BIGENDIAN + ext2fs_swap_mmp(mmp_cmp); #endif if (buf != NULL && buf != fs->mmp_cmp) @@ -122,18 +121,16 @@ errcode_t ext2fs_mmp_write(ext2_filsys fs, blk64_t mmp_blk, void *buf) fs->super->s_mmp_block > ext2fs_blocks_count(fs->super)) return EXT2_ET_MMP_BAD_BLOCK; -#ifdef EXT2FS_ENABLE_SWAPFS - if (fs->super->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) - ext2fs_swap_mmp(mmp_s); +#ifdef WORDS_BIGENDIAN + ext2fs_swap_mmp(mmp_s); #endif /* I was tempted to make this use O_DIRECT and the mmp_fd, but * this caused no end of grief, while leaving it as-is works. */ retval = io_channel_write_blk64(fs->io, mmp_blk, -fs->blocksize, buf); -#ifdef EXT2FS_ENABLE_SWAPFS - if (fs->super->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) - ext2fs_swap_mmp(mmp_s); +#ifdef WORDS_BIGENDIAN + ext2fs_swap_mmp(mmp_s); #endif /* Make sure the block gets to disk quickly */ |