Browse Source

FIX: checksum is not calculated for just-initialized bitmap.

pull/11/head
ngkaho1234 9 years ago
parent
commit
e40f01af4e
  1. 6
      lwext4/ext4_balloc.c
  2. 9
      lwext4/ext4_balloc.h
  3. 10
      lwext4/ext4_fs.c
  4. 6
      lwext4/ext4_ialloc.c
  5. 9
      lwext4/ext4_ialloc.h

6
lwext4/ext4_balloc.c

@ -101,9 +101,9 @@ static uint32_t ext4_balloc_bitmap_csum(struct ext4_sblock *sb,
* Currently we do not verify the checksum of bitmaps.
*/
static void ext4_balloc_set_bitmap_csum(struct ext4_sblock *sb,
struct ext4_bgroup *bg,
void *bitmap)
void ext4_balloc_set_bitmap_csum(struct ext4_sblock *sb,
struct ext4_bgroup *bg,
void *bitmap)
{
int desc_size = ext4_sb_get_desc_size(sb);
uint32_t checksum = ext4_balloc_bitmap_csum(sb, bitmap);

9
lwext4/ext4_balloc.h

@ -64,6 +64,15 @@ uint32_t ext4_balloc_get_bgid_of_block(struct ext4_sblock *s,
ext4_fsblk_t ext4_balloc_get_block_of_bgid(struct ext4_sblock *s,
uint32_t bgid);
/**@brief Calculate and set checksum of block bitmap.
* @param sb superblock pointer.
* @param bg block group
* @param bitmap bitmap buffer
*/
void ext4_balloc_set_bitmap_csum(struct ext4_sblock *sb,
struct ext4_bgroup *bg,
void *bitmap);
/**@brief Free block from inode.
* @param inode_ref inode reference
* @param baddr block address

10
lwext4/ext4_fs.c

@ -374,6 +374,11 @@ static int ext4_fs_init_block_bitmap(struct ext4_block_group_ref *bg_ref)
ext4_fs_mark_bitmap_end(group_blocks, block_size * 8, block_bitmap.data);
block_bitmap.dirty = true;
ext4_balloc_set_bitmap_csum(&bg_ref->fs->sb,
bg_ref->block_group,
block_bitmap.data);
bg_ref->dirty = true;
/* Save bitmap */
return ext4_block_set(bg_ref->fs->bdev, &block_bitmap);
}
@ -413,6 +418,11 @@ static int ext4_fs_init_inode_bitmap(struct ext4_block_group_ref *bg_ref)
block_bitmap.dirty = true;
ext4_ialloc_set_bitmap_csum(&bg_ref->fs->sb,
bg_ref->block_group,
block_bitmap.data);
bg_ref->dirty = true;
/* Save bitmap */
return ext4_block_set(bg_ref->fs->bdev, &block_bitmap);
}

6
lwext4/ext4_ialloc.c

@ -109,9 +109,9 @@ static uint32_t ext4_ialloc_bitmap_csum(struct ext4_sblock *sb,
* Currently we do not verify the checksum of bitmaps.
*/
static void ext4_ialloc_set_bitmap_csum(struct ext4_sblock *sb,
struct ext4_bgroup *bg,
void *bitmap)
void ext4_ialloc_set_bitmap_csum(struct ext4_sblock *sb,
struct ext4_bgroup *bg,
void *bitmap)
{
int desc_size = ext4_sb_get_desc_size(sb);
uint32_t checksum = ext4_ialloc_bitmap_csum(sb, bitmap);

9
lwext4/ext4_ialloc.h

@ -49,6 +49,15 @@ extern "C" {
#include "ext4_config.h"
#include "ext4_types.h"
/**@brief Calculate and set checksum of inode bitmap.
* @param sb superblock pointer.
* @param bg block group
* @param bitmap bitmap buffer
*/
void ext4_ialloc_set_bitmap_csum(struct ext4_sblock *sb,
struct ext4_bgroup *bg,
void *bitmap);
/**@brief Free i-node number and modify filesystem data structers.
* @param fs Filesystem, where the i-node is located
* @param index Index of i-node to be release

Loading…
Cancel
Save