Browse Source

Add ext4_sb_is_super_in_bg

pull/1/head
gkostka 10 years ago
parent
commit
e957027243
  1. 36
      lwext4/ext4_super.c
  2. 5
      lwext4/ext4_super.h

36
lwext4/ext4_super.c

@ -126,6 +126,42 @@ bool ext4_sb_check(struct ext4_sblock *s)
return true;
}
static inline int is_multiple(uint32_t a, uint32_t b)
{
while (1) {
if (a < b)
return 0;
if (a == b)
return 1;
if ((a % b) != 0)
return 0;
a = a / b;
}
}
static int ext4_sb_sparse(uint32_t group)
{
if (group <= 1)
return 1;
if (!(group & 1))
return 0;
return (is_multiple(group, 7) || is_multiple(group, 5) ||
is_multiple(group, 3));
}
bool ext4_sb_is_super_in_bg(struct ext4_sblock *s, uint32_t group)
{
if (ext4_sb_check_read_only(s,
EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
!ext4_sb_sparse(group))
return false;
return true;
}
/**
* @}
*/

5
lwext4/ext4_super.h

@ -177,6 +177,11 @@ int ext4_sb_read(struct ext4_blockdev *bdev, struct ext4_sblock *s);
* @return true if OK*/
bool ext4_sb_check(struct ext4_sblock *s);
/**@brief Superblock presence in block group.
* @param s superblock dsecriptor
* @param block_group block group id
* @return true if block group has superblock*/
bool ext4_sb_is_super_in_bg(struct ext4_sblock *s, uint32_t block_group);
#endif /* EXT4_SUPER_H_ */

Loading…
Cancel
Save