Changeset fe27eb4 in mainline


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

Location:
uspace/lib/ext4
Files:
9 edited

Legend:

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

    rae3d4f8 rfe27eb4  
    9696        }
    9797
    98         uint32_t bitmap_block_addr = ext4_block_group_get_block_bitmap(bg_ref->block_group);
     98        uint32_t bitmap_block_addr = ext4_block_group_get_block_bitmap(
     99                        bg_ref->block_group, fs->superblock);
    99100        block_t *bitmap_block;
    100101        rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0);
     
    129130
    130131        // Update block group free blocks count
    131         uint32_t free_blocks = ext4_block_group_get_free_blocks_count(bg_ref->block_group);
     132        uint32_t free_blocks = ext4_block_group_get_free_blocks_count(
     133                        bg_ref->block_group, fs->superblock);
    132134        free_blocks++;
    133         ext4_block_group_set_free_blocks_count(bg_ref->block_group, free_blocks);
     135        ext4_block_group_set_free_blocks_count(bg_ref->block_group,
     136                        fs->superblock, free_blocks);
    134137        bg_ref->dirty = true;
    135138
     
    148151{
    149152        uint32_t block_group_count = ext4_superblock_get_block_group_count(sb);
    150         uint32_t inode_table_first_block = ext4_block_group_get_inode_table_first_block(bg);
     153        uint32_t inode_table_first_block = ext4_block_group_get_inode_table_first_block(
     154                        bg, sb);
    151155        uint16_t inode_table_item_size = ext4_superblock_get_inode_size(sb);
    152156        uint32_t inodes_per_group = ext4_superblock_get_inodes_per_group(sb);
     
    210214
    211215        uint32_t block_group_count = ext4_superblock_get_block_group_count(fs->superblock);
    212         uint32_t inode_table_first_block = ext4_block_group_get_inode_table_first_block(bg_ref->block_group);
     216        uint32_t inode_table_first_block = ext4_block_group_get_inode_table_first_block(
     217                        bg_ref->block_group, fs->superblock);
    213218        uint16_t inode_table_item_size = ext4_superblock_get_inode_size(fs->superblock);
    214219        uint32_t inode_table_bytes;
     
    278283
    279284        // Load bitmap
    280         bitmap_block_addr = ext4_block_group_get_block_bitmap(bg_ref->block_group);
     285        bitmap_block_addr = ext4_block_group_get_block_bitmap(bg_ref->block_group,
     286                        fs->superblock);
    281287
    282288        rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0);
     
    380386
    381387                // Load bitmap
    382                 bitmap_block_addr = ext4_block_group_get_block_bitmap(bg_ref->block_group);
     388                bitmap_block_addr = ext4_block_group_get_block_bitmap(
     389                                bg_ref->block_group, fs->superblock);
    383390
    384391                rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0);
     
    461468
    462469        // Update block group free blocks count
    463         uint32_t bg_free_blocks = ext4_block_group_get_free_blocks_count(bg_ref->block_group);
     470        uint32_t bg_free_blocks = ext4_block_group_get_free_blocks_count(
     471                        bg_ref->block_group, fs->superblock);
    464472        bg_free_blocks--;
    465         ext4_block_group_set_free_blocks_count(bg_ref->block_group, bg_free_blocks);
     473        ext4_block_group_set_free_blocks_count(bg_ref->block_group,
     474                        fs->superblock, bg_free_blocks);
    466475        bg_ref->dirty = true;
    467476
  • uspace/lib/ext4/libext4_block_group.c

    rae3d4f8 rfe27eb4  
    3939#include "libext4.h"
    4040
    41 uint64_t ext4_block_group_get_block_bitmap(ext4_block_group_t *bg)
    42 {
    43         return ((uint64_t)uint32_t_le2host(bg->block_bitmap_hi) << 32) |
    44                 uint32_t_le2host(bg->block_bitmap_lo);
    45 }
    46 
    47 uint64_t ext4_block_group_get_inode_bitmap(ext4_block_group_t *bg)
    48 {
    49         return ((uint64_t)uint32_t_le2host(bg->inode_bitmap_hi) << 32) |
    50                 uint32_t_le2host(bg->inode_bitmap_lo);
    51 }
    52 
    53 uint64_t ext4_block_group_get_inode_table_first_block(ext4_block_group_t *bg)
    54 {
    55         return ((uint64_t)uint32_t_le2host(bg->inode_table_first_block_hi) << 32) |
    56                 uint32_t_le2host(bg->inode_table_first_block_lo);
    57 }
    58 
    59 uint32_t ext4_block_group_get_free_blocks_count(ext4_block_group_t *bg)
    60 {
    61         return ((uint32_t)uint16_t_le2host(bg->free_blocks_count_hi) << 16) |
    62                 uint16_t_le2host(bg->free_blocks_count_lo);
    63 }
    64 
    65 void ext4_block_group_set_free_blocks_count(ext4_block_group_t *bg, uint32_t value) {
     41uint64_t ext4_block_group_get_block_bitmap(ext4_block_group_t *bg,
     42                ext4_superblock_t *sb)
     43{
     44        if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     45                return ((uint64_t)uint32_t_le2host(bg->block_bitmap_hi) << 32) |
     46                        uint32_t_le2host(bg->block_bitmap_lo);
     47        } else {
     48                return uint32_t_le2host(bg->block_bitmap_lo);
     49        }
     50}
     51
     52void ext4_block_group_set_block_bitmap(ext4_block_group_t *bg,
     53                ext4_superblock_t *sb, uint64_t block_bitmap)
     54{
     55        bg->block_bitmap_lo = host2uint32_t_le((block_bitmap << 32) >> 32);
     56
     57        if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     58                bg->block_bitmap_hi = host2uint32_t_le(block_bitmap >> 32);
     59        }
     60}
     61
     62uint64_t ext4_block_group_get_inode_bitmap(ext4_block_group_t *bg,
     63                ext4_superblock_t *sb)
     64{
     65        if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     66                return ((uint64_t)uint32_t_le2host(bg->inode_bitmap_hi) << 32) |
     67                        uint32_t_le2host(bg->inode_bitmap_lo);
     68        } else {
     69                return uint32_t_le2host(bg->inode_bitmap_lo);
     70        }
     71
     72}
     73
     74void ext4_block_group_set_inode_bitmap(ext4_block_group_t *bg,
     75                ext4_superblock_t *sb, uint64_t inode_bitmap)
     76{
     77        bg->inode_bitmap_lo = host2uint32_t_le((inode_bitmap << 32) >> 32);
     78
     79        if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     80                bg->inode_bitmap_hi = host2uint32_t_le(inode_bitmap >> 32);
     81        }
     82}
     83
     84uint64_t ext4_block_group_get_inode_table_first_block(ext4_block_group_t *bg,
     85                ext4_superblock_t *sb)
     86{
     87        if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     88                return ((uint64_t)uint32_t_le2host(bg->inode_table_first_block_hi) << 32) |
     89                        uint32_t_le2host(bg->inode_table_first_block_lo);
     90        } else {
     91                return uint32_t_le2host(bg->inode_table_first_block_lo);
     92        }
     93}
     94
     95void 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
     105uint32_t ext4_block_group_get_free_blocks_count(ext4_block_group_t *bg,
     106                ext4_superblock_t *sb)
     107{
     108        if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     109                return ((uint32_t)uint16_t_le2host(bg->free_blocks_count_hi) << 16) |
     110                        uint16_t_le2host(bg->free_blocks_count_lo);
     111        } else {
     112                return uint16_t_le2host(bg->free_blocks_count_lo);
     113        }
     114}
     115
     116void ext4_block_group_set_free_blocks_count(ext4_block_group_t *bg,
     117                ext4_superblock_t *sb, uint32_t value)
     118{
    66119        bg->free_blocks_count_lo = host2uint16_t_le((value << 16) >> 16);
    67         bg->free_blocks_count_hi = host2uint16_t_le(value >> 16);
    68 }
    69 
    70 uint32_t ext4_block_group_get_free_inodes_count(ext4_block_group_t *bg)
    71 {
    72         return ((uint32_t)uint16_t_le2host(bg->free_inodes_count_hi) << 16) |
    73                 uint16_t_le2host(bg->free_inodes_count_lo);
    74 }
    75 
    76 uint32_t ext4_block_group_get_used_dirs_count(ext4_block_group_t *bg)
    77 {
    78         return ((uint32_t)uint16_t_le2host(bg->used_dirs_count_hi) << 16) |
    79                 uint16_t_le2host(bg->used_dirs_count_lo);
     120        if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     121                bg->free_blocks_count_hi = host2uint16_t_le(value >> 16);
     122        }
     123}
     124
     125uint32_t ext4_block_group_get_free_inodes_count(ext4_block_group_t *bg,
     126                ext4_superblock_t *sb)
     127{
     128        if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     129                return ((uint32_t)uint16_t_le2host(bg->free_inodes_count_hi) << 16) |
     130                        uint16_t_le2host(bg->free_inodes_count_lo);
     131        } else {
     132                return uint16_t_le2host(bg->free_inodes_count_lo);
     133        }
     134}
     135
     136void ext4_block_group_set_free_inodes_count(ext4_block_group_t *bg,
     137                ext4_superblock_t *sb, uint32_t value)
     138{
     139        bg->free_inodes_count_lo = host2uint16_t_le((value << 16) >> 16);
     140        if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     141                bg->free_inodes_count_hi = host2uint16_t_le(value >> 16);
     142        }
     143}
     144
     145
     146uint32_t ext4_block_group_get_used_dirs_count(ext4_block_group_t *bg,
     147                ext4_superblock_t *sb)
     148{
     149        if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     150                return ((uint32_t)uint16_t_le2host(bg->used_dirs_count_hi) << 16) |
     151                        uint16_t_le2host(bg->used_dirs_count_lo);
     152        } else {
     153                return uint16_t_le2host(bg->used_dirs_count_lo);
     154        }
     155}
     156
     157void ext4_block_group_set_used_dirs_count(ext4_block_group_t *bg,
     158                ext4_superblock_t *sb, uint32_t count)
     159{
     160        bg->used_dirs_count_lo = host2uint16_t_le((count << 16) >> 16);
     161        if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     162                bg->used_dirs_count_hi = host2uint16_t_le(count >> 16);
     163        }
    80164}
    81165
     
    85169}
    86170
    87 uint32_t ext4_block_group_get_itable_unused(ext4_block_group_t *bg)
    88 {
    89         return ((uint32_t)uint16_t_le2host(bg->itable_unused_hi) << 16) |
    90                 uint16_t_le2host(bg->itable_unused_lo);
     171uint32_t ext4_block_group_get_itable_unused(ext4_block_group_t *bg,
     172                ext4_superblock_t *sb)
     173{
     174        if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     175                return ((uint32_t)uint16_t_le2host(bg->itable_unused_hi) << 16) |
     176                        uint16_t_le2host(bg->itable_unused_lo);
     177        } else {
     178                return uint16_t_le2host(bg->itable_unused_lo);
     179        }
     180}
     181
     182void ext4_block_group_set_itable_unused(ext4_block_group_t *bg,
     183                ext4_superblock_t *sb, uint32_t value)
     184{
     185        bg->itable_unused_lo = host2uint16_t_le((value << 16) >> 16);
     186        if (ext4_superblock_get_desc_size(sb) > EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE) {
     187                bg->itable_unused_hi = host2uint16_t_le(value >> 16);
     188        }
     189
    91190}
    92191
     
    94193{
    95194        return uint16_t_le2host(bg->checksum);
     195}
     196
     197void ext4_block_group_set_checksum(ext4_block_group_t *bg, uint16_t checksum)
     198{
     199        bg->checksum = host2uint16_t_le(checksum);
    96200}
    97201
  • uspace/lib/ext4/libext4_block_group.h

    rae3d4f8 rfe27eb4  
    3737#include <sys/types.h>
    3838#include "libext4_block_group.h"
     39#include "libext4_superblock.h"
    3940/*
    4041 * Structure of a blocks group descriptor
     
    6970
    7071#define EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE 32
     72#define EXT4_BLOCK_MAX_GROUP_DESCRIPTOR_SIZE 64
    7173
    72 extern uint64_t ext4_block_group_get_block_bitmap(ext4_block_group_t *);
    73 extern uint64_t ext4_block_group_get_inode_bitmap(ext4_block_group_t *);
    74 extern uint64_t ext4_block_group_get_inode_table_first_block(ext4_block_group_t *);
    75 extern uint32_t ext4_block_group_get_free_blocks_count(ext4_block_group_t *);
    76 extern void ext4_block_group_set_free_blocks_count(ext4_block_group_t *, uint32_t);
    77 extern uint32_t ext4_block_group_get_free_inodes_count(ext4_block_group_t *);
    78 extern uint32_t ext4_block_group_get_used_dirs_count(ext4_block_group_t *);
     74extern uint64_t ext4_block_group_get_block_bitmap(ext4_block_group_t *,
     75                ext4_superblock_t *);
     76extern void ext4_block_group_set_block_bitmap(ext4_block_group_t *,
     77                ext4_superblock_t *, uint64_t);
     78extern uint64_t ext4_block_group_get_inode_bitmap(ext4_block_group_t *,
     79                ext4_superblock_t *);
     80extern void ext4_block_group_set_inode_bitmap(ext4_block_group_t *,
     81                ext4_superblock_t *, uint64_t);
     82extern uint64_t ext4_block_group_get_inode_table_first_block(
     83                ext4_block_group_t *, ext4_superblock_t *);
     84extern void ext4_block_group_set_inode_table_first_block(
     85                ext4_block_group_t *, ext4_superblock_t *, uint64_t);
     86extern uint32_t ext4_block_group_get_free_blocks_count(ext4_block_group_t *,
     87                ext4_superblock_t *);
     88extern void ext4_block_group_set_free_blocks_count(ext4_block_group_t *,
     89                ext4_superblock_t *, uint32_t);
     90extern uint32_t ext4_block_group_get_free_inodes_count(ext4_block_group_t *,
     91                ext4_superblock_t *);
     92extern void ext4_block_group_set_free_inodes_count(ext4_block_group_t *,
     93                ext4_superblock_t *, uint32_t);
     94extern void ext4_block_group_set_free_inodes_count(ext4_block_group_t *,
     95                ext4_superblock_t *, uint32_t);
     96extern uint32_t ext4_block_group_get_used_dirs_count(ext4_block_group_t *,
     97                ext4_superblock_t *);
     98extern void ext4_block_group_set_used_dirs_count(ext4_block_group_t *,
     99                ext4_superblock_t *, uint32_t);
    79100extern uint16_t ext4_block_group_get_flags(ext4_block_group_t *);
    80 extern uint32_t ext4_block_group_get_itable_unused(ext4_block_group_t *);
     101extern void ext4_block_group_set_flags(ext4_block_group_t *, uint16_t);
     102extern uint32_t ext4_block_group_get_itable_unused(ext4_block_group_t *,
     103                ext4_superblock_t *);
     104extern void ext4_block_group_set_itable_unused(ext4_block_group_t *,
     105                ext4_superblock_t *, uint32_t);
    81106extern uint16_t ext4_block_group_get_checksum(ext4_block_group_t *);
     107extern void ext4_block_group_set_checksum(ext4_block_group_t *, uint16_t);
    82108
    83109#endif
  • uspace/lib/ext4/libext4_filesystem.c

    rae3d4f8 rfe27eb4  
    234234
    235235        inode_table_start = ext4_block_group_get_inode_table_first_block(
    236             bg_ref->block_group);
     236            bg_ref->block_group, fs->superblock);
    237237
    238238        rc = ext4_filesystem_put_block_group_ref(bg_ref);
  • uspace/lib/ext4/libext4_filesystem.h

    rae3d4f8 rfe27eb4  
    4646} ext4_filesystem_t;
    4747
     48#define EXT4_MIN_BLOCK_SIZE             1024  //1 KiB
    4849#define EXT4_MAX_BLOCK_SIZE     65536 //64 KiB
    4950#define EXT4_REV0_INODE_SIZE    128
  • uspace/lib/ext4/libext4_inode.c

    rae3d4f8 rfe27eb4  
    6363}
    6464
    65 bool ext4_inode_is_type(ext4_superblock_t *sb, ext4_inode_t *inode, uint32_t type)
    66 {
    67         uint32_t mode = ext4_inode_get_mode(sb, inode);
    68         return (mode & EXT4_INODE_MODE_TYPE_MASK) == type;
    69 }
    70 
    71 /*
     65void ext4_inode_set_mode(ext4_superblock_t *sb, ext4_inode_t *inode, uint32_t mode)
     66{
     67        inode->mode = host2uint16_t_le((mode << 16) >> 16);
     68
     69        if (ext4_superblock_get_creator_os(sb) == EXT4_SUPERBLOCK_OS_HURD) {
     70                inode->osd2.hurd2.mode_high = host2uint16_t_le(mode >> 16);
     71        }
     72}
     73
    7274uint32_t ext4_inode_get_uid(ext4_inode_t *inode)
    73 */
     75{
     76        return uint32_t_le2host(inode->uid);
     77}
     78
     79void ext4_inode_set_uid(ext4_inode_t *inode, uint32_t uid)
     80{
     81        inode->uid = host2uint32_t_le(uid);
     82}
    7483
    7584uint64_t ext4_inode_get_size(ext4_superblock_t *sb, ext4_inode_t *inode)
     
    8998}
    9099
    91 /*
    92 extern uint32_t ext4_inode_get_access_time(ext4_inode_t *);
    93 extern uint32_t ext4_inode_get_change_inode_time(ext4_inode_t *);
    94 extern uint32_t ext4_inode_get_modification_time(ext4_inode_t *);
    95 extern uint32_t ext4_inode_get_deletion_time(ext4_inode_t *);
    96 extern uint32_t ext4_inode_get_gid(ext4_inode_t *);
    97 */
     100uint32_t ext4_inode_get_access_time(ext4_inode_t *inode)
     101{
     102        return uint32_t_le2host(inode->access_time);
     103}
     104
     105void ext4_inode_set_access_time(ext4_inode_t *inode, uint32_t time)
     106{
     107        inode->access_time = host2uint32_t_le(time);
     108}
     109
     110uint32_t ext4_inode_get_change_inode_time(ext4_inode_t *inode)
     111{
     112        return uint32_t_le2host(inode->change_inode_time);
     113}
     114
     115void ext4_inode_set_change_inode_time(ext4_inode_t *inode, uint32_t time)
     116{
     117        inode->change_inode_time = host2uint32_t_le(time);
     118}
     119
     120uint32_t ext4_inode_get_modification_time(ext4_inode_t *inode)
     121{
     122        return uint32_t_le2host(inode->modification_time);
     123}
     124
     125void ext4_inode_set_modification_time(ext4_inode_t *inode, uint32_t time)
     126{
     127        inode->modification_time = host2uint32_t_le(time);
     128}
     129
     130uint32_t ext4_inode_get_deletion_time(ext4_inode_t *inode)
     131{
     132        return uint32_t_le2host(inode->deletion_time);
     133}
     134
     135void ext4_inode_set_deletion_time(ext4_inode_t *inode, uint32_t time)
     136{
     137        inode->deletion_time = host2uint32_t_le(time);
     138}
     139
     140uint32_t ext4_inode_get_gid(ext4_inode_t *inode)
     141{
     142        return uint32_t_le2host(inode->gid);
     143}
     144
     145void ext4_inode_set_gid(ext4_inode_t *inode, uint32_t gid)
     146{
     147        inode->gid = host2uint32_t_le(gid);
     148}
    98149
    99150uint16_t ext4_inode_get_links_count(ext4_inode_t *inode)
     
    102153}
    103154
     155void ext4_inode_set_links_count(ext4_inode_t *inode, uint16_t count)
     156{
     157        inode->links_count = host2uint16_t_le(count);
     158}
    104159
    105160uint64_t ext4_inode_get_blocks_count(ext4_superblock_t *sb, ext4_inode_t *inode)
     
    161216    }
    162217    return EOK;
    163 
    164 
    165218}
    166219
     
    172225        inode->flags = host2uint32_t_le(flags);
    173226}
     227
     228uint32_t ext4_inode_get_generation(ext4_inode_t *inode)
     229{
     230        return uint32_t_le2host(inode->generation);
     231}
     232
     233void ext4_inode_set_generation(ext4_inode_t *inode, uint32_t generation)
     234{
     235        inode->generation = host2uint32_t_le(generation);
     236}
     237
     238/***********************************************************************/
    174239
    175240uint32_t ext4_inode_get_direct_block(ext4_inode_t *inode, uint32_t idx)
     
    260325}
    261326
     327bool ext4_inode_is_type(ext4_superblock_t *sb, ext4_inode_t *inode, uint32_t type)
     328{
     329        uint32_t mode = ext4_inode_get_mode(sb, inode);
     330        return (mode & EXT4_INODE_MODE_TYPE_MASK) == type;
     331}
     332
     333
    262334ext4_extent_header_t * ext4_inode_get_extent_header(ext4_inode_t *inode)
    263335{
  • uspace/lib/ext4/libext4_inode.h

    rae3d4f8 rfe27eb4  
    5555        uint16_t uid; // Low 16 bits of owner uid
    5656        uint32_t size_lo; // Size in bytes
    57         uint32_t acess_time; // Access time
     57        uint32_t access_time; // Access time
    5858        uint32_t change_inode_time; // Inode change time
    5959        uint32_t modification_time; // Modification time
     
    150150
    151151extern uint32_t ext4_inode_get_mode(ext4_superblock_t *, ext4_inode_t *);
    152 extern bool ext4_inode_is_type(ext4_superblock_t *, ext4_inode_t *, uint32_t);
    153 /*
     152extern void ext4_inode_set_mode(ext4_superblock_t *, ext4_inode_t *, uint32_t);
    154153extern uint32_t ext4_inode_get_uid(ext4_inode_t *);
    155 */
     154extern void ext4_inode_set_uid(ext4_inode_t *, uint32_t);
    156155extern uint64_t ext4_inode_get_size(ext4_superblock_t *, ext4_inode_t *);
    157156extern void ext4_inode_set_size(ext4_inode_t *, uint64_t);
    158 /*
    159157extern uint32_t ext4_inode_get_access_time(ext4_inode_t *);
     158extern void ext4_inode_set_access_time(ext4_inode_t *, uint32_t);
    160159extern uint32_t ext4_inode_get_change_inode_time(ext4_inode_t *);
     160extern void ext4_inode_set_change_inode_time(ext4_inode_t *, uint32_t);
    161161extern uint32_t ext4_inode_get_modification_time(ext4_inode_t *);
     162extern void ext4_inode_set_modification_time(ext4_inode_t *, uint32_t);
    162163extern uint32_t ext4_inode_get_deletion_time(ext4_inode_t *);
     164extern void ext4_inode_set_deletion_time(ext4_inode_t *, uint32_t);
    163165extern uint32_t ext4_inode_get_gid(ext4_inode_t *);
    164 */
     166extern void ext4_inode_set_gid(ext4_inode_t *, uint32_t);
    165167extern uint16_t ext4_inode_get_links_count(ext4_inode_t *);
     168extern void ext4_inode_set_links_count(ext4_inode_t *, uint16_t);
    166169extern uint64_t ext4_inode_get_blocks_count(ext4_superblock_t *, ext4_inode_t *);
    167170extern int ext4_inode_set_blocks_count(ext4_superblock_t *, ext4_inode_t *, uint64_t);
    168171extern uint32_t ext4_inode_get_flags(ext4_inode_t *);
    169 void ext4_inode_set_flags(ext4_inode_t *, uint32_t);
    170 extern uint32_t ext4_inode_get_direct_block(ext4_inode_t *, uint32_t);
    171 extern void ext4_inode_set_direct_block(ext4_inode_t *, uint32_t, uint32_t);
    172 extern uint32_t ext4_inode_get_indirect_block(ext4_inode_t *, uint32_t);
    173 extern void ext4_inode_set_indirect_block(ext4_inode_t *, uint32_t, uint32_t);
    174 extern uint32_t ext4_inode_get_extent_block(ext4_inode_t *, uint64_t, service_id_t);
    175 /*
    176 uint32_t blocks[EXT4_INODE_BLOCKS]; // Pointers to blocks
    177 uint32_t generation;
     172extern void ext4_inode_set_flags(ext4_inode_t *, uint32_t);
     173extern uint32_t ext4_inode_get_generation(ext4_inode_t *);
     174extern void ext4_inode_set_generation(ext4_inode_t *, uint32_t);
     175/*
    178176uint32_t file_acl_lo; // File ACL
    179177uint16_t extra_isize;
     
    186184*/
    187185
     186/******************************************/
     187
     188extern uint32_t ext4_inode_get_direct_block(ext4_inode_t *, uint32_t);
     189extern void ext4_inode_set_direct_block(ext4_inode_t *, uint32_t, uint32_t);
     190extern uint32_t ext4_inode_get_indirect_block(ext4_inode_t *, uint32_t);
     191extern void ext4_inode_set_indirect_block(ext4_inode_t *, uint32_t, uint32_t);
     192extern uint32_t ext4_inode_get_extent_block(ext4_inode_t *, uint64_t, service_id_t);
    188193extern ext4_extent_header_t * ext4_inode_get_extent_header(ext4_inode_t *);
     194extern bool ext4_inode_is_type(ext4_superblock_t *, ext4_inode_t *, uint32_t);
    189195extern bool ext4_inode_has_flag(ext4_inode_t *, uint32_t);
    190196extern void ext4_inode_clear_flag(ext4_inode_t *, uint32_t);
  • 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
  • uspace/lib/ext4/libext4_superblock.h

    rae3d4f8 rfe27eb4  
    202202
    203203extern uint32_t ext4_superblock_get_inodes_count(ext4_superblock_t *);
     204extern void ext4_superblock_set_inodes_count(ext4_superblock_t *, uint32_t);
    204205extern uint64_t ext4_superblock_get_blocks_count(ext4_superblock_t *);
     206extern void ext4_superblock_set_blocks_count(ext4_superblock_t *, uint64_t);
    205207extern uint64_t ext4_superblock_get_reserved_blocks_count(ext4_superblock_t *);
     208extern void ext4_superblock_set_reserved_blocks_count(ext4_superblock_t *, uint64_t);
    206209extern uint64_t ext4_superblock_get_free_blocks_count(ext4_superblock_t *);
    207210extern void ext4_superblock_set_free_blocks_count(ext4_superblock_t *, uint64_t);
    208211extern uint32_t ext4_superblock_get_free_inodes_count(ext4_superblock_t *);
     212extern void ext4_superblock_set_free_inodes_count(ext4_superblock_t *, uint32_t);
    209213extern uint32_t ext4_superblock_get_first_data_block(ext4_superblock_t *);
     214extern void ext4_superblock_set_first_data_block(ext4_superblock_t *, uint32_t);
    210215extern uint32_t ext4_superblock_get_log_block_size(ext4_superblock_t *);
     216extern void ext4_superblock_set_log_block_size(ext4_superblock_t *, uint32_t);
    211217extern uint32_t ext4_superblock_get_block_size(ext4_superblock_t *);
     218extern void ext4_superblock_set_block_size(ext4_superblock_t *, uint32_t);
    212219extern uint32_t ext4_superblock_get_blocks_per_group(ext4_superblock_t *);
     220extern void ext4_superblock_set_blocks_per_group(ext4_superblock_t *, uint32_t);
    213221extern uint32_t ext4_superblock_get_inodes_per_group(ext4_superblock_t *);
     222extern void ext4_superblock_set_inodes_per_group(ext4_superblock_t *, uint32_t);
    214223extern uint32_t ext4_superblock_get_mount_time(ext4_superblock_t *);
     224extern void ext4_superblock_set_mount_time(ext4_superblock_t *, uint32_t);
    215225extern uint32_t ext4_superblock_get_write_time(ext4_superblock_t *);
     226extern void ext4_superblock_set_write_time(ext4_superblock_t *, uint32_t);
    216227extern uint16_t ext4_superblock_get_mount_count(ext4_superblock_t *);
     228extern void ext4_superblock_set_mount_count(ext4_superblock_t *, uint16_t);
    217229extern uint16_t ext4_superblock_get_max_mount_count(ext4_superblock_t *);
     230extern void ext4_superblock_set_max_mount_count(ext4_superblock_t *, uint16_t);
    218231extern uint16_t ext4_superblock_get_magic(ext4_superblock_t *);
    219232extern uint16_t ext4_superblock_get_state(ext4_superblock_t *);
     233extern void ext4_superblock_set_state(ext4_superblock_t *, uint16_t);
    220234extern uint16_t ext4_superblock_get_errors(ext4_superblock_t *);
     235extern void ext4_superblock_set_errors(ext4_superblock_t *, uint16_t);
    221236extern uint16_t ext4_superblock_get_minor_rev_level(ext4_superblock_t *);
     237extern void ext4_superblock_set_minor_rev_level(ext4_superblock_t *, uint16_t);
    222238extern uint32_t ext4_superblock_get_last_check_time(ext4_superblock_t *);
     239extern void ext4_superblock_set_last_check_time(ext4_superblock_t *, uint32_t);
    223240extern uint32_t ext4_superblock_get_check_interval(ext4_superblock_t *);
     241extern void ext4_superblock_set_check_interval(ext4_superblock_t *, uint32_t);
    224242extern uint32_t ext4_superblock_get_creator_os(ext4_superblock_t *);
     243extern void ext4_superblock_set_creator_os(ext4_superblock_t *, uint32_t);
    225244extern uint32_t ext4_superblock_get_rev_level(ext4_superblock_t *);
    226 
    227 /*
    228 uint16_t s_def_resuid; // Default uid for reserved blocks
    229 uint16_t s_def_resgid; // Default gid for reserved blocks
    230 */
    231 
     245extern void ext4_superblock_set_rev_level(ext4_superblock_t *, uint32_t);
     246extern uint16_t ext4_superblock_get_def_resuid(ext4_superblock_t *);
     247extern void ext4_superblock_set_def_resuid(ext4_superblock_t *, uint16_t);
     248extern uint16_t ext4_superblock_get_def_resgid(ext4_superblock_t *);
     249extern void ext4_superblock_set_def_resgid(ext4_superblock_t *, uint16_t);
    232250extern uint32_t ext4_superblock_get_first_inode(ext4_superblock_t *);
     251extern void ext4_superblock_set_first_inode(ext4_superblock_t *, uint32_t);
    233252extern uint16_t ext4_superblock_get_inode_size(ext4_superblock_t *);
     253extern void ext4_superblock_set_inode_size(ext4_superblock_t *, uint16_t);
    234254extern uint16_t ext4_superblock_get_block_group_number(ext4_superblock_t *);
     255extern void ext4_superblock_set_block_group_number(ext4_superblock_t *, uint16_t);
    235256extern uint32_t ext4_superblock_get_features_compatible(ext4_superblock_t *);
     257extern void     ext4_superblock_set_features_compatible(ext4_superblock_t *, uint32_t);
    236258extern uint32_t ext4_superblock_get_features_incompatible(ext4_superblock_t *);
     259extern void     ext4_superblock_set_features_incompatible(ext4_superblock_t *, uint32_t);
    237260extern uint32_t ext4_superblock_get_features_read_only(ext4_superblock_t *);
     261extern void     ext4_superblock_set_features_read_only(ext4_superblock_t *, uint32_t);
    238262
    239263/*
     
    251275*/
    252276extern uint32_t* ext4_superblock_get_hash_seed(ext4_superblock_t *);
    253 
    254277/*
    255278uint8_t s_def_hash_version; // Default hash version to use
     
    258281
    259282extern uint16_t ext4_superblock_get_desc_size(ext4_superblock_t *);
     283extern void ext4_superblock_set_desc_size(ext4_superblock_t *, uint16_t);
    260284
    261285/*
     
    268292*/
    269293extern uint32_t ext4_superblock_get_flags(ext4_superblock_t *);
     294extern void ext4_superblock_set_flags(ext4_superblock_t *, uint32_t);
    270295/*
    271296uint16_t s_raid_stride; // RAID stride
Note: See TracChangeset for help on using the changeset viewer.