Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 3d93289a in mainline


Ignore:
Timestamp:
2012-04-18T07:18:56Z (10 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master
Children:
0c37135
Parents:
7b16549
Message:

comments for block group functions

Location:
uspace/lib/ext4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/libext4_block_group.c

    r7b16549 r3d93289a  
    3939#include "libext4.h"
    4040
     41/** Get address of block with data block bitmap.
     42 *
     43 * @param bg    pointer to block group
     44 * @param sb    pointer to superblock
     45 * @return              address of block with block bitmap
     46 */
    4147uint64_t ext4_block_group_get_block_bitmap(ext4_block_group_t *bg,
    4248                ext4_superblock_t *sb)
     
    5056}
    5157
     58/** Set address of block with data block bitmap.
     59 *
     60 * @param bg                    pointer to block group
     61 * @param sb                    pointer to superblock
     62 * @param block_bitmap  address of block with block bitmap
     63 */
    5264void ext4_block_group_set_block_bitmap(ext4_block_group_t *bg,
    5365                ext4_superblock_t *sb, uint64_t block_bitmap)
     
    6072}
    6173
     74/** Get address of block with i-node bitmap.
     75 *
     76 * @param bg    pointer to block group
     77 * @param sb    pointer to superblock
     78 * @return              address of block with i-node bitmap
     79 */
    6280uint64_t ext4_block_group_get_inode_bitmap(ext4_block_group_t *bg,
    6381                ext4_superblock_t *sb)
     
    7290}
    7391
     92/** Set address of block with i-node bitmap.
     93 *
     94 * @param bg                    pointer to block group
     95 * @param sb                    pointer to superblock
     96 * @param inode_bitmap  address of block with i-node bitmap
     97 */
    7498void ext4_block_group_set_inode_bitmap(ext4_block_group_t *bg,
    7599                ext4_superblock_t *sb, uint64_t inode_bitmap)
     
    82106}
    83107
     108/** Get address of the first block of the i-node table.
     109 *
     110 * @param bg    pointer to block group
     111 * @param sb    pointer to superblock
     112 * @return              address of first block of i-node table
     113 */
    84114uint64_t ext4_block_group_get_inode_table_first_block(ext4_block_group_t *bg,
    85115                ext4_superblock_t *sb)
     
    93123}
    94124
     125/** Set address of the first block of the i-node table.
     126 *
     127 * @param bg    pointer to block group
     128 * @param sb    pointer to superblock
     129 * @param inode_table_first address of first block of i-node table
     130 */
    95131void ext4_block_group_set_inode_table_first_block(ext4_block_group_t *bg,
    96                 ext4_superblock_t *sb, uint64_t ino_tbl_first)
    97 {
    98         bg->inode_table_first_block_lo = host2uint32_t_le((ino_tbl_first << 32) >> 32);
    99 
    100         if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
    101                 bg->inode_table_first_block_hi = host2uint32_t_le(ino_tbl_first >> 32);
    102         }
    103 }
    104 
     132                ext4_superblock_t *sb, uint64_t inode_table_first)
     133{
     134        bg->inode_table_first_block_lo =
     135                        host2uint32_t_le((inode_table_first << 32) >> 32);
     136
     137        if (ext4_superblock_get_desc_size(sb) >
     138                        EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     139
     140                bg->inode_table_first_block_hi =
     141                                host2uint32_t_le(inode_table_first >> 32);
     142        }
     143}
     144
     145/** Get number of free blocks in block group.
     146 *
     147 * @param bg    pointer to block group
     148 * @param sb    pointer to superblock
     149 * @return              number of free blocks in block group
     150 */
    105151uint32_t ext4_block_group_get_free_blocks_count(ext4_block_group_t *bg,
    106152                ext4_superblock_t *sb)
    107153{
    108         if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     154        if (ext4_superblock_get_desc_size(sb) >
     155                        EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     156
    109157                return ((uint32_t)uint16_t_le2host(bg->free_blocks_count_hi) << 16) |
    110158                        uint16_t_le2host(bg->free_blocks_count_lo);
     
    114162}
    115163
     164/** Set number of free blocks in block group.
     165 *
     166 * @param bg    pointer to block group
     167 * @param sb    pointer to superblock
     168 * @param value number of free blocks in block group
     169 */
    116170void ext4_block_group_set_free_blocks_count(ext4_block_group_t *bg,
    117171                ext4_superblock_t *sb, uint32_t value)
     
    123177}
    124178
     179/** Get number of free i-nodes in block group.
     180 *
     181 * @param bg    pointer to block group
     182 * @param sb    pointer to superblock
     183 * @return              number of free i-nodes in block group
     184 */
    125185uint32_t ext4_block_group_get_free_inodes_count(ext4_block_group_t *bg,
    126186                ext4_superblock_t *sb)
     
    134194}
    135195
     196/** Set number of free i-nodes in block group.
     197 *
     198 * @param bg    pointer to block group
     199 * @param sb    pointer to superblock
     200 * @param value number of free i-nodes in block group
     201 */
    136202void ext4_block_group_set_free_inodes_count(ext4_block_group_t *bg,
    137203                ext4_superblock_t *sb, uint32_t value)
     
    143209}
    144210
    145 
     211/** Get number of used directories in block group.
     212 *
     213 * @param bg    pointer to block group
     214 * @param sb    pointer to superblock
     215 * @return              number of used directories in block group
     216 */
    146217uint32_t ext4_block_group_get_used_dirs_count(ext4_block_group_t *bg,
    147218                ext4_superblock_t *sb)
     
    155226}
    156227
     228/** Set number of used directories in block group.
     229 *
     230 * @param bg    pointer to block group
     231 * @param sb    pointer to superblock
     232 * @param value number of used directories in block group
     233 */
    157234void ext4_block_group_set_used_dirs_count(ext4_block_group_t *bg,
    158235                ext4_superblock_t *sb, uint32_t count)
     
    164241}
    165242
     243/** Get flags of block group.
     244 *
     245 * @param bg    pointer to block group
     246 * @return              flags of block group
     247 */
    166248uint16_t ext4_block_group_get_flags(ext4_block_group_t *bg)
    167249{
     
    169251}
    170252
     253/** Set flags for block group.
     254 *
     255 * @param bg    pointer to block group
     256 * @param flags flags for block group
     257 */
    171258void ext4_block_group_set_flags(ext4_block_group_t *bg, uint16_t flags)
    172259{
     
    174261}
    175262
     263/** Get number of unused i-nodes.
     264 *
     265 * @param bg    pointer to block group
     266 * @param sb    pointer to superblock
     267 * @return              number of unused i-nodes
     268 */
    176269uint32_t ext4_block_group_get_itable_unused(ext4_block_group_t *bg,
    177270                ext4_superblock_t *sb)
     
    185278}
    186279
     280/** Set number of unused i-nodes.
     281 *
     282 * @param bg    pointer to block group
     283 * @param sb    pointer to superblock
     284 * @param value number of unused i-nodes
     285 */
    187286void ext4_block_group_set_itable_unused(ext4_block_group_t *bg,
    188287                ext4_superblock_t *sb, uint32_t value)
     
    195294}
    196295
     296/** Get checksum of block group.
     297 *
     298 * @param bg    pointer to block group
     299 * @return              checksum of block group
     300 */
    197301uint16_t ext4_block_group_get_checksum(ext4_block_group_t *bg)
    198302{
     
    200304}
    201305
     306/** Set checksum of block group.
     307 *
     308 * @param bg            pointer to block group
     309 * @param checksum      cheksum of block group
     310 */
    202311void ext4_block_group_set_checksum(ext4_block_group_t *bg, uint16_t checksum)
    203312{
     
    205314}
    206315
    207 // Flags operations
     316/** Check if block group has a flag.
     317 *
     318 * @param bg    pointer to block group
     319 * @param flag  flag to be checked
     320 * @return              true if flag is set to 1
     321 */
    208322bool ext4_block_group_has_flag(ext4_block_group_t *bg, uint32_t flag)
    209323{
     
    214328}
    215329
     330/** Set (add) flag of block group.
     331 *
     332 * @param bg    pointer to block group
     333 * @param flag  flag to be set
     334 */
     335void ext4_block_group_set_flag(ext4_block_group_t *bg, uint32_t set_flag)
     336{
     337        uint32_t flags = ext4_block_group_get_flags(bg);
     338        flags = flags | set_flag;
     339        ext4_block_group_set_flags(bg, flags);
     340}
     341
     342/** Clear (remove) flag of block group.
     343 *
     344 * @param bg    pointer to block group
     345 * @param flag  flag to be cleared
     346 */
    216347void ext4_block_group_clear_flag(ext4_block_group_t *bg, uint32_t clear_flag)
    217348{
  • uspace/lib/ext4/libext4_block_group.h

    r7b16549 r3d93289a  
    7474
    7575extern bool ext4_block_group_has_flag(ext4_block_group_t *, uint32_t);
     76extern void ext4_block_group_set_flag(ext4_block_group_t *, uint32_t);
    7677extern void ext4_block_group_clear_flag(ext4_block_group_t *, uint32_t);
    7778
Note: See TracChangeset for help on using the changeset viewer.