Changeset fe27eb4 in mainline for uspace/lib/ext4/libext4_superblock.c


Ignore:
Timestamp:
2011-11-20T12:07:50Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
343ccfd
Parents:
ae3d4f8
Message:

added many getters and setters

File:
1 edited

Legend:

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

    rae3d4f8 rfe27eb4  
    4747}
    4848
     49void ext4_superblock_set_inodes_count(ext4_superblock_t *sb, uint32_t count)
     50{
     51        sb->inodes_count = host2uint32_t_le(count);
     52}
     53
    4954uint64_t ext4_superblock_get_blocks_count(ext4_superblock_t *sb)
    5055{
     
    5358}
    5459
     60void ext4_superblock_set_blocks_count(ext4_superblock_t *sb, uint64_t count)
     61{
     62        sb->blocks_count_lo = host2uint32_t_le((count << 32) >> 32);
     63        sb->blocks_count_hi = host2uint32_t_le(count >> 32);
     64}
     65
    5566uint64_t ext4_superblock_get_reserved_blocks_count(ext4_superblock_t *sb)
    5667{
     
    5970}
    6071
     72void ext4_superblock_set_reserved_blocks_count(ext4_superblock_t *sb, uint64_t count)
     73{
     74        sb->reserved_blocks_count_lo = host2uint32_t_le((count << 32) >> 32);
     75        sb->reserved_blocks_count_hi = host2uint32_t_le(count >> 32);
     76}
     77
    6178uint64_t ext4_superblock_get_free_blocks_count(ext4_superblock_t *sb)
    6279{
     
    7693}
    7794
     95void ext4_superblock_set_free_inodes_count(ext4_superblock_t *sb, uint32_t count)
     96{
     97        sb->free_inodes_count = host2uint32_t_le(count);
     98}
     99
    78100uint32_t ext4_superblock_get_first_data_block(ext4_superblock_t *sb)
    79101{
     
    81103}
    82104
     105void ext4_superblock_set_first_data_block(ext4_superblock_t *sb, uint32_t first)
     106{
     107        sb->first_data_block = host2uint32_t_le(first);
     108}
     109
    83110uint32_t ext4_superblock_get_log_block_size(ext4_superblock_t *sb)
    84111{
     
    86113}
    87114
     115void ext4_superblock_set_log_block_size(ext4_superblock_t *sb, uint32_t log_size)
     116{
     117        sb->log_block_size = host2uint32_t_le(log_size);
     118}
     119
    88120uint32_t ext4_superblock_get_block_size(ext4_superblock_t *sb)
    89121{
     
    91123}
    92124
     125void ext4_superblock_set_block_size(ext4_superblock_t *sb, uint32_t size)
     126{
     127        uint32_t log = 0;
     128        uint32_t tmp = size / EXT4_MIN_BLOCK_SIZE;
     129
     130        tmp >>= 1;
     131        while (tmp) {
     132                log++;
     133                tmp >>= 1;
     134        }
     135
     136        ext4_superblock_set_log_block_size(sb, log);
     137}
    93138
    94139uint32_t ext4_superblock_get_blocks_per_group(ext4_superblock_t *sb)
     
    97142}
    98143
     144void ext4_superblock_set_blocks_per_group(ext4_superblock_t *sb, uint32_t blocks)
     145{
     146        sb->blocks_per_group = host2uint32_t_le(blocks);
     147}
     148
    99149uint32_t ext4_superblock_get_inodes_per_group(ext4_superblock_t *sb)
    100150{
     
    102152}
    103153
     154void ext4_superblock_set_inodes_per_group(ext4_superblock_t *sb, uint32_t inodes)
     155{
     156        sb->inodes_per_group = host2uint32_t_le(inodes);
     157}
     158
    104159uint32_t ext4_superblock_get_mount_time(ext4_superblock_t *sb)
    105160{
     
    107162}
    108163
     164void ext4_superblock_set_mount_time(ext4_superblock_t *sb, uint32_t time)
     165{
     166        sb->mount_time = host2uint32_t_le(time);
     167}
     168
    109169uint32_t ext4_superblock_get_write_time(ext4_superblock_t *sb)
    110170{
     
    112172}
    113173
     174void ext4_superblock_set_write_time(ext4_superblock_t *sb, uint32_t time)
     175{
     176        sb->write_time = host2uint32_t_le(time);
     177}
     178
    114179uint16_t ext4_superblock_get_mount_count(ext4_superblock_t *sb)
    115180{
     
    117182}
    118183
     184void ext4_superblock_set_mount_count(ext4_superblock_t *sb, uint16_t count)
     185{
     186        sb->mount_count = host2uint16_t_le(count);
     187}
     188
    119189uint16_t ext4_superblock_get_max_mount_count(ext4_superblock_t *sb)
    120190{
     
    122192}
    123193
     194void ext4_superblock_set_max_mount_count(ext4_superblock_t *sb, uint16_t count)
     195{
     196        sb->max_mount_count = host2uint16_t_le(count);
     197}
     198
    124199uint16_t ext4_superblock_get_magic(ext4_superblock_t *sb)
    125200{
     
    132207}
    133208
     209void ext4_superblock_set_state(ext4_superblock_t *sb, uint16_t state)
     210{
     211        sb->state = host2uint16_t_le(state);
     212}
     213
    134214uint16_t ext4_superblock_get_errors(ext4_superblock_t *sb)
    135215{
     
    137217}
    138218
     219void ext4_superblock_set_errors(ext4_superblock_t *sb, uint16_t errors)
     220{
     221        sb->errors = host2uint16_t_le(errors);
     222}
    139223
    140224uint16_t ext4_superblock_get_minor_rev_level(ext4_superblock_t *sb)
     
    143227}
    144228
     229void ext4_superblock_set_minor_rev_level(ext4_superblock_t *sb, uint16_t level)
     230{
     231        sb->minor_rev_level = host2uint16_t_le(level);
     232}
     233
    145234uint32_t ext4_superblock_get_last_check_time(ext4_superblock_t *sb)
    146235{
    147236        return uint32_t_le2host(sb->last_check_time);
     237}
     238
     239void ext4_superblock_set_last_check_time(ext4_superblock_t *sb, uint32_t time)
     240{
     241        sb->state = host2uint32_t_le(time);
    148242}
    149243
     
    152246}
    153247
     248void ext4_superblock_set_check_interval(ext4_superblock_t *sb, uint32_t interval)
     249{
     250        sb->check_interval = host2uint32_t_le(interval);
     251}
     252
    154253uint32_t ext4_superblock_get_creator_os(ext4_superblock_t *sb)
    155254{
     
    157256}
    158257
     258void ext4_superblock_set_creator_os(ext4_superblock_t *sb, uint32_t os)
     259{
     260        sb->creator_os = host2uint32_t_le(os);
     261}
     262
    159263uint32_t ext4_superblock_get_rev_level(ext4_superblock_t *sb)
    160264{
    161265        return uint32_t_le2host(sb->rev_level);
     266}
     267
     268void ext4_superblock_set_rev_level(ext4_superblock_t *sb, uint32_t level)
     269{
     270        sb->rev_level = host2uint32_t_le(level);
     271}
     272
     273uint16_t ext4_superblock_get_def_resuid(ext4_superblock_t *sb)
     274{
     275        return uint16_t_le2host(sb->def_resuid);
     276}
     277
     278void ext4_superblock_set_def_resuid(ext4_superblock_t *sb, uint16_t uid)
     279{
     280        sb->def_resuid = host2uint16_t_le(uid);
     281}
     282
     283uint16_t ext4_superblock_get_def_resgid(ext4_superblock_t *sb)
     284{
     285        return uint16_t_le2host(sb->def_resgid);
     286}
     287
     288void ext4_superblock_set_def_resgid(ext4_superblock_t *sb, uint16_t gid)
     289{
     290        sb->def_resgid = host2uint16_t_le(gid);
     291}
     292
     293uint32_t ext4_superblock_get_first_inode(ext4_superblock_t *sb)
     294{
     295        return uint32_t_le2host(sb->first_inode);
     296}
     297
     298void ext4_superblock_set_first_inode(ext4_superblock_t *sb, uint32_t first_inode)
     299{
     300        sb->first_inode = host2uint32_t_le(first_inode);
    162301}
    163302
     
    170309}
    171310
     311void ext4_superblock_set_inode_size(ext4_superblock_t *sb, uint16_t size)
     312{
     313        sb->inode_size = host2uint16_t_le(size);
     314}
     315
    172316uint16_t ext4_superblock_get_block_group_number(ext4_superblock_t *sb)
    173317{
     
    175319}
    176320
     321void ext4_superblock_set_block_group_number(ext4_superblock_t *sb, uint16_t bg)
     322{
     323        sb->block_group_number = host2uint16_t_le(bg);
     324}
     325
    177326uint32_t ext4_superblock_get_features_compatible(ext4_superblock_t *sb)
    178327{
     
    180329}
    181330
     331void ext4_superblock_set_features_compatible(ext4_superblock_t *sb, uint32_t features)
     332{
     333        sb->features_compatible = host2uint32_t_le(features);
     334}
     335
    182336uint32_t ext4_superblock_get_features_incompatible(ext4_superblock_t *sb)
    183337{
     
    185339}
    186340
     341void ext4_superblock_set_features_incompatible(ext4_superblock_t *sb, uint32_t features)
     342{
     343        sb->features_incompatible = host2uint32_t_le(features);
     344}
     345
    187346uint32_t ext4_superblock_get_features_read_only(ext4_superblock_t *sb)
    188347{
     
    190349}
    191350
     351void ext4_superblock_set_features_read_only(ext4_superblock_t *sb, uint32_t features)
     352{
     353        sb->features_read_only = host2uint32_t_le(features);
     354}
    192355
    193356uint32_t* ext4_superblock_get_hash_seed(ext4_superblock_t *sb)
     
    207370}
    208371
     372void ext4_superblock_set_desc_size(ext4_superblock_t *sb, uint16_t size)
     373{
     374        sb->desc_size = host2uint16_t_le(size);
     375}
     376
    209377uint32_t ext4_superblock_get_flags(ext4_superblock_t *sb)
    210378{
    211379        return uint32_t_le2host(sb->flags);
     380}
     381
     382void ext4_superblock_set_flags(ext4_superblock_t *sb, uint32_t flags)
     383{
     384        sb->flags = host2uint32_t_le(flags);
    212385}
    213386
     
    307480        }
    308481
     482        // block size
     483        // desc size
     484
     485
    309486        // TODO more checks !!!
    310487
Note: See TracChangeset for help on using the changeset viewer.