[U-Boot] [PATCH v3 3/4] ext4: fix endianess problems in ext4 write support

Stefan Bruens stefan.bruens at rwth-aachen.de
Thu Sep 1 02:38:51 CEST 2016


Hi Michael,

found two more errors, see below.

Kind regards,

Stefan

On Montag, 29. August 2016 10:46:45 CEST Michael Walle wrote:
> All fields were accessed directly instead of using the proper byte swap
> functions. Thus, ext4 write support was only usable on little-endian
> architectures. Fix this.
> 
> Signed-off-by: Michael Walle <michael at walle.cc>
> Reviewed-by: Stefan Brüns <stefan.bruens at rwth-aachen.de>
> Tested-by: Stefan Brüns <stefan.bruens at rwth-aachen.de>
> ---
>  fs/ext4/ext4_common.c  | 277
> +++++++++++++++++++++++++++---------------------- fs/ext4/ext4_common.h  | 
>  4 +-
>  fs/ext4/ext4_journal.c |  15 +--
>  fs/ext4/ext4_journal.h |   4 +-
>  fs/ext4/ext4_write.c   | 212 ++++++++++++++++++++-----------------
>  include/ext_common.h   |   2 +-
>  6 files changed, 285 insertions(+), 229 deletions(-)
> 
> diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
> index e8ed30a..567350f 100644
> --- a/fs/ext4/ext4_common.c
> +++ b/fs/ext4/ext4_common.c
> @@ -33,20 +33,40 @@
...
> @@ -879,17 +907,17 @@ long int ext4fs_get_new_blk_no(void)
>  				fs->curr_blkno = fs->curr_blkno +
>  						(i * fs->blksz * 8);
>  				fs->first_pass_bbmap++;
> -				bgd[i].free_blocks--;
> -				fs->sb->free_blocks--;
> -				status = ext4fs_devread((lbaint_t)
> -							bgd[i].block_id *
> +				ext4fs_bg_free_blocks_dec(&bgd[i]);
> +				ext4fs_sb_free_inodes_dec(fs->sb);
Thats obviously wrong, should be ext4fs_sb_free_*blocks*_dec ...

> +				status = ext4fs_devread(
> +							(lbaint_t)le32_to_cpu(bgd[i].block_id) *
>  							fs->sect_perblk, 0,
>  							fs->blksz,
>  							journal_buffer);
>  				if (status == 0)
>  					goto fail;
>  				if (ext4fs_log_journal(journal_buffer,
> -							bgd[i].block_id))
> +							le32_to_cpu(bgd[i].block_id)))
>  					goto fail;
>  				goto success;
>  			} else {
> @@ -923,13 +951,14 @@ restart:
...
> @@ -942,19 +971,20 @@ restart:
>  		/* journal backup */
>  		if (prev_bg_bitmap_index != bg_idx) {
>  			memset(journal_buffer, '\0', fs->blksz);
> -			status = ext4fs_devread((lbaint_t)bgd[bg_idx].block_id
> +			status = ext4fs_devread(
> +						(lbaint_t)le32_to_cpu(bgd[bg_idx].block_id)
>  						* fs->sect_perblk,
>  						0, fs->blksz, journal_buffer);
>  			if (status == 0)
>  				goto fail;
>  			if (ext4fs_log_journal(journal_buffer,
> -						bgd[bg_idx].block_id))
> +						le32_to_cpu(bgd[bg_idx].block_id)))
>  				goto fail;
> 
>  			prev_bg_bitmap_index = bg_idx;
>  		}
> -		bgd[bg_idx].free_blocks--;
> -		fs->sb->free_blocks--;
> +		ext4fs_bg_free_blocks_dec(&bgd[bg_idx]);
> +		ext4fs_sb_free_inodes_dec(fs->sb);
Same ...

>  		goto success;
>  	}
>  success:
> @@ -975,7 +1005,7 @@ int ext4fs_get_new_inode_no(void)
...



-- 
Stefan Brüns  /  Bergstraße 21  /  52062 Aachen
home: +49 241 53809034     mobile: +49 151 50412019
work: +49 2405 49936-424


More information about the U-Boot mailing list