ext4_mkfs: use EXT4_SUPERBLOCK_SIZE instead of sizeof op.
[lwext4.git] / lwext4 / ext4_block_group.h
index 92333331fb094bf0ef0e0f14e4ca8bc61ae1ddc6..7d91ad5a5e286e711e8ebb8050a1c5fe4053b33a 100644 (file)
  * @return Address of block with block bitmap
  */
 static inline uint64_t ext4_bg_get_block_bitmap(struct ext4_bgroup *bg,
-                                                struct ext4_sblock *s)
+                                               struct ext4_sblock *s)
 {
-    uint64_t v = to_le32(bg->block_bitmap_lo);
+       uint64_t v = to_le32(bg->block_bitmap_lo);
 
-    if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
-        v |= (uint64_t)to_le32(bg->block_bitmap_hi) << 32;
+       if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
+               v |= (uint64_t)to_le32(bg->block_bitmap_hi) << 32;
 
-    return v;
+       return v;
 }
 
 /**@brief Get address of block with i-node bitmap.
@@ -71,15 +71,15 @@ static inline uint64_t ext4_bg_get_block_bitmap(struct ext4_bgroup *bg,
  * @return Address of block with i-node bitmap
  */
 static inline uint64_t ext4_bg_get_inode_bitmap(struct ext4_bgroup *bg,
-                                                struct ext4_sblock *s)
+                                               struct ext4_sblock *s)
 {
 
-    uint64_t v = to_le32(bg->inode_bitmap_lo);
+       uint64_t v = to_le32(bg->inode_bitmap_lo);
 
-    if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
-        v |= (uint64_t)to_le32(bg->inode_bitmap_hi) << 32;
+       if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
+               v |= (uint64_t)to_le32(bg->inode_bitmap_hi) << 32;
 
-    return v;
+       return v;
 }
 
 /**@brief Get address of the first block of the i-node table.
@@ -89,14 +89,14 @@ static inline uint64_t ext4_bg_get_inode_bitmap(struct ext4_bgroup *bg,
  */
 static inline uint64_t
 ext4_bg_get_inode_table_first_block(struct ext4_bgroup *bg,
-                                    struct ext4_sblock *s)
+                                   struct ext4_sblock *s)
 {
-    uint64_t v = to_le32(bg->inode_table_first_block_lo);
+       uint64_t v = to_le32(bg->inode_table_first_block_lo);
 
-    if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
-        v |= (uint64_t)to_le32(bg->inode_table_first_block_hi) << 32;
+       if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
+               v |= (uint64_t)to_le32(bg->inode_table_first_block_hi) << 32;
 
-    return v;
+       return v;
 }
 
 /**@brief Get number of free blocks in block group.
@@ -105,14 +105,14 @@ ext4_bg_get_inode_table_first_block(struct ext4_bgroup *bg,
  * @return Number of free blocks in block group
  */
 static inline uint32_t ext4_bg_get_free_blocks_count(struct ext4_bgroup *bg,
-                                                     struct ext4_sblock *s)
+                                                    struct ext4_sblock *s)
 {
-    uint32_t v = to_le16(bg->free_blocks_count_lo);
+       uint32_t v = to_le16(bg->free_blocks_count_lo);
 
-    if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
-        v |= (uint32_t)to_le16(bg->free_blocks_count_hi) << 16;
+       if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
+               v |= (uint32_t)to_le16(bg->free_blocks_count_hi) << 16;
 
-    return v;
+       return v;
 }
 
 /**@brief Set number of free blocks in block group.
@@ -121,12 +121,12 @@ static inline uint32_t ext4_bg_get_free_blocks_count(struct ext4_bgroup *bg,
  * @param cnt Number of free blocks in block group
  */
 static inline void ext4_bg_set_free_blocks_count(struct ext4_bgroup *bg,
-                                                 struct ext4_sblock *s,
-                                                 uint32_t cnt)
+                                                struct ext4_sblock *s,
+                                                uint32_t cnt)
 {
-    bg->free_blocks_count_lo = to_le16((cnt << 16) >> 16);
-    if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
-        bg->free_blocks_count_hi = to_le16(cnt >> 16);
+       bg->free_blocks_count_lo = to_le16((cnt << 16) >> 16);
+       if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
+               bg->free_blocks_count_hi = to_le16(cnt >> 16);
 }
 
 /**@brief Get number of free i-nodes in block group.
@@ -135,14 +135,14 @@ static inline void ext4_bg_set_free_blocks_count(struct ext4_bgroup *bg,
  * @return Number of free i-nodes in block group
  */
 static inline uint32_t ext4_bg_get_free_inodes_count(struct ext4_bgroup *bg,
-                                                     struct ext4_sblock *s)
+                                                    struct ext4_sblock *s)
 {
-    uint32_t v = to_le16(bg->free_inodes_count_lo);
+       uint32_t v = to_le16(bg->free_inodes_count_lo);
 
-    if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
-        v |= (uint32_t)to_le16(bg->free_inodes_count_hi) << 16;
+       if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
+               v |= (uint32_t)to_le16(bg->free_inodes_count_hi) << 16;
 
-    return v;
+       return v;
 }
 
 /**@brief Set number of free i-nodes in block group.
@@ -151,12 +151,12 @@ static inline uint32_t ext4_bg_get_free_inodes_count(struct ext4_bgroup *bg,
  * @param cnt Number of free i-nodes in block group
  */
 static inline void ext4_bg_set_free_inodes_count(struct ext4_bgroup *bg,
-                                                 struct ext4_sblock *s,
-                                                 uint32_t cnt)
+                                                struct ext4_sblock *s,
+                                                uint32_t cnt)
 {
-    bg->free_inodes_count_lo = to_le16((cnt << 16) >> 16);
-    if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
-        bg->free_inodes_count_hi = to_le16(cnt >> 16);
+       bg->free_inodes_count_lo = to_le16((cnt << 16) >> 16);
+       if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
+               bg->free_inodes_count_hi = to_le16(cnt >> 16);
 }
 
 /**@brief Get number of used directories in block group.
@@ -165,14 +165,14 @@ static inline void ext4_bg_set_free_inodes_count(struct ext4_bgroup *bg,
  * @return Number of used directories in block group
  */
 static inline uint32_t ext4_bg_get_used_dirs_count(struct ext4_bgroup *bg,
-                                                   struct ext4_sblock *s)
+                                                  struct ext4_sblock *s)
 {
-    uint32_t v = to_le16(bg->used_dirs_count_lo);
+       uint32_t v = to_le16(bg->used_dirs_count_lo);
 
-    if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
-        v |= (uint32_t)to_le16(bg->used_dirs_count_hi) << 16;
+       if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
+               v |= (uint32_t)to_le16(bg->used_dirs_count_hi) << 16;
 
-    return v;
+       return v;
 }
 
 /**@brief Set number of used directories in block group.
@@ -181,12 +181,12 @@ static inline uint32_t ext4_bg_get_used_dirs_count(struct ext4_bgroup *bg,
  * @param cnt Number of used directories in block group
  */
 static inline void ext4_bg_set_used_dirs_count(struct ext4_bgroup *bg,
-                                               struct ext4_sblock *s,
-                                               uint32_t cnt)
+                                              struct ext4_sblock *s,
+                                              uint32_t cnt)
 {
-    bg->used_dirs_count_lo = to_le16((cnt << 16) >> 16);
-    if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
-        bg->used_dirs_count_hi = to_le16(cnt >> 16);
+       bg->used_dirs_count_lo = to_le16((cnt << 16) >> 16);
+       if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
+               bg->used_dirs_count_hi = to_le16(cnt >> 16);
 }
 
 /**@brief Get number of unused i-nodes.
@@ -195,15 +195,15 @@ static inline void ext4_bg_set_used_dirs_count(struct ext4_bgroup *bg,
  * @return Number of unused i-nodes
  */
 static inline uint32_t ext4_bg_get_itable_unused(struct ext4_bgroup *bg,
-                                                 struct ext4_sblock *s)
+                                                struct ext4_sblock *s)
 {
 
-    uint32_t v = to_le16(bg->itable_unused_lo);
+       uint32_t v = to_le16(bg->itable_unused_lo);
 
-    if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
-        v |= (uint32_t)to_le16(bg->itable_unused_hi) << 16;
+       if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
+               v |= (uint32_t)to_le16(bg->itable_unused_hi) << 16;
 
-    return v;
+       return v;
 }
 
 /**@brief Set number of unused i-nodes.
@@ -212,12 +212,12 @@ static inline uint32_t ext4_bg_get_itable_unused(struct ext4_bgroup *bg,
  * @param cnt Number of unused i-nodes
  */
 static inline void ext4_bg_set_itable_unused(struct ext4_bgroup *bg,
-                                             struct ext4_sblock *s,
-                                             uint32_t cnt)
+                                            struct ext4_sblock *s,
+                                            uint32_t cnt)
 {
-    bg->itable_unused_lo = to_le16((cnt << 16) >> 16);
-    if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
-        bg->itable_unused_hi = to_le16(cnt >> 16);
+       bg->itable_unused_lo = to_le16((cnt << 16) >> 16);
+       if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
+               bg->itable_unused_hi = to_le16(cnt >> 16);
 }
 
 /**@brief  Set checksum of block group.
@@ -226,7 +226,7 @@ static inline void ext4_bg_set_itable_unused(struct ext4_bgroup *bg,
  */
 static inline void ext4_bg_set_checksum(struct ext4_bgroup *bg, uint16_t crc)
 {
-    bg->checksum = to_le16(crc);
+       bg->checksum = to_le16(crc);
 }
 
 /**@brief Check if block group has a flag.
@@ -236,7 +236,7 @@ static inline void ext4_bg_set_checksum(struct ext4_bgroup *bg, uint16_t crc)
  */
 static inline bool ext4_bg_has_flag(struct ext4_bgroup *bg, uint32_t f)
 {
-    return to_le16(bg->flags) & f;
+       return to_le16(bg->flags) & f;
 }
 
 /**@brief Set flag of block group.
@@ -245,9 +245,9 @@ static inline bool ext4_bg_has_flag(struct ext4_bgroup *bg, uint32_t f)
  */
 static inline void ext4_bg_set_flag(struct ext4_bgroup *bg, uint32_t f)
 {
-    uint16_t flags = to_le16(bg->flags);
-    flags |= f;
-    bg->flags = to_le16(flags);
+       uint16_t flags = to_le16(bg->flags);
+       flags |= f;
+       bg->flags = to_le16(flags);
 }
 
 /**@brief Clear flag of block group.
@@ -256,9 +256,9 @@ static inline void ext4_bg_set_flag(struct ext4_bgroup *bg, uint32_t f)
  */
 static inline void ext4_bg_clear_flag(struct ext4_bgroup *bg, uint32_t f)
 {
-    uint16_t flags = to_le16(bg->flags);
-    flags &= ~f;
-    bg->flags = to_le16(flags);
+       uint16_t flags = to_le16(bg->flags);
+       flags &= ~f;
+       bg->flags = to_le16(flags);
 }
 
 /**@brief Calculate CRC16 of the block group.