Changeset 343ccfd in mainline


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

next bunch of getters and setters added

Location:
uspace/lib/ext4
Files:
8 edited

Legend:

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

    rfe27eb4 r343ccfd  
    4949}
    5050
     51void ext4_directory_entry_ll_set_inode(ext4_directory_entry_ll_t *de,
     52                uint32_t inode)
     53{
     54        de->inode = host2uint32_t_le(inode);
     55}
     56
    5157uint16_t ext4_directory_entry_ll_get_entry_length(
    52     ext4_directory_entry_ll_t *de)
     58                ext4_directory_entry_ll_t *de)
    5359{
    5460        return uint16_t_le2host(de->entry_length);
     61}
     62
     63void ext4_directory_entry_ll_set_entry_length(ext4_directory_entry_ll_t *de,
     64                uint16_t length)
     65{
     66        de->entry_length = host2uint16_t_le(length);
    5567}
    5668
     
    6072        if (ext4_superblock_get_rev_level(sb) == 0 &&
    6173            ext4_superblock_get_minor_rev_level(sb) < 5) {
    62                 return ((uint16_t)de->name_length_high) << 8 |
    63                     ((uint16_t)de->name_length);
    64         }
    65         return de->name_length;
    66 }
    67 
    68 uint8_t ext4_directory_dx_root_info_get_hash_version(ext4_directory_dx_root_info_t *root_info)
    69 {
    70         return root_info->hash_version;
    71 }
    72 
    73 uint8_t ext4_directory_dx_root_info_get_info_length(ext4_directory_dx_root_info_t *root_info)
    74 {
    75         return root_info->info_length;
    76 }
    77 
    78 uint8_t ext4_directory_dx_root_info_get_indirect_levels(ext4_directory_dx_root_info_t *root_info)
    79 {
    80         return root_info->indirect_levels;
    81 }
    82 
    83 uint16_t ext4_directory_dx_countlimit_get_limit(ext4_directory_dx_countlimit_t *countlimit)
    84 {
    85         return uint16_t_le2host(countlimit->limit);
    86 }
    87 uint16_t ext4_directory_dx_countlimit_get_count(ext4_directory_dx_countlimit_t *countlimit)
    88 {
    89         return uint16_t_le2host(countlimit->count);
    90 }
    91 
    92 uint32_t ext4_directory_dx_entry_get_hash(ext4_directory_dx_entry_t *entry)
    93 {
    94         return uint32_t_le2host(entry->hash);
    95 }
    96 
    97 uint32_t ext4_directory_dx_entry_get_block(ext4_directory_dx_entry_t *entry)
    98 {
    99         return uint32_t_le2host(entry->block);
    100 }
    101 
     74
     75                return de->name_length;
     76        }
     77
     78        return ((uint16_t)de->name_length_high) << 8 |
     79            ((uint16_t)de->name_length);
     80
     81
     82}
     83
     84void ext4_directory_entry_ll_set_name_length(ext4_superblock_t *sb,
     85                ext4_directory_entry_ll_t *de, uint16_t length)
     86{
     87
     88        de->name_length = (length << 8) >> 8;
     89
     90        if (ext4_superblock_get_rev_level(sb) > 0 ||
     91                    ext4_superblock_get_minor_rev_level(sb) >= 5) {
     92
     93                de->name_length_high = length >> 8;
     94        }
     95
     96}
    10297
    10398
  • uspace/lib/ext4/libext4_directory.h

    rfe27eb4 r343ccfd  
    6363
    6464extern uint32_t ext4_directory_entry_ll_get_inode(ext4_directory_entry_ll_t *);
     65extern void ext4_directory_entry_ll_set_inode(ext4_directory_entry_ll_t *,
     66                uint32_t);
    6567extern uint16_t ext4_directory_entry_ll_get_entry_length(
    6668    ext4_directory_entry_ll_t *);
     69extern void ext4_directory_entry_ll_set_entry_length(
     70                ext4_directory_entry_ll_t *, uint16_t);
    6771extern uint16_t ext4_directory_entry_ll_get_name_length(
    6872    ext4_superblock_t *, ext4_directory_entry_ll_t *);
     73extern void ext4_directory_entry_ll_set_name_length(ext4_superblock_t *,
     74                ext4_directory_entry_ll_t *, uint16_t);
    6975
    7076extern int ext4_directory_iterator_init(ext4_directory_iterator_t *,
  • uspace/lib/ext4/libext4_directory_index.c

    rfe27eb4 r343ccfd  
    3636 */
    3737
     38#include <byteorder.h>
    3839#include <errno.h>
    3940#include "libext4.h"
     41
     42
     43uint8_t ext4_directory_dx_root_info_get_hash_version(
     44                ext4_directory_dx_root_info_t *root_info)
     45{
     46        return root_info->hash_version;
     47}
     48
     49void ext4_directory_dx_root_info_set_hash_version(
     50                ext4_directory_dx_root_info_t *root_info, uint8_t version)
     51{
     52        root_info->hash_version = version;
     53}
     54
     55uint8_t ext4_directory_dx_root_info_get_info_length(
     56                ext4_directory_dx_root_info_t *root_info)
     57{
     58        return root_info->info_length;
     59}
     60
     61void ext4_directory_dx_root_info_set_info_length(
     62                ext4_directory_dx_root_info_t *root_info, uint8_t info_length)
     63{
     64        root_info->info_length = info_length;
     65}
     66
     67uint8_t ext4_directory_dx_root_info_get_indirect_levels(
     68                ext4_directory_dx_root_info_t *root_info)
     69{
     70        return root_info->indirect_levels;
     71}
     72
     73void ext4_directory_dx_root_info_set_indirect_levels(
     74                ext4_directory_dx_root_info_t *root_info, uint8_t levels)
     75{
     76        root_info->indirect_levels = levels;
     77}
     78
     79uint16_t ext4_directory_dx_countlimit_get_limit(
     80                ext4_directory_dx_countlimit_t *countlimit)
     81{
     82        return uint16_t_le2host(countlimit->limit);
     83}
     84
     85void ext4_directory_dx_countlimit_set_limit(
     86                ext4_directory_dx_countlimit_t *countlimit, uint16_t limit)
     87{
     88        countlimit->limit = host2uint16_t_le(limit);
     89}
     90
     91uint16_t ext4_directory_dx_countlimit_get_count(
     92                ext4_directory_dx_countlimit_t *countlimit)
     93{
     94        return uint16_t_le2host(countlimit->count);
     95}
     96
     97void ext4_directory_dx_countlimit_set_count(
     98                ext4_directory_dx_countlimit_t *countlimit, uint16_t count)
     99{
     100        countlimit->count = host2uint16_t_le(count);
     101}
     102
     103uint32_t ext4_directory_dx_entry_get_hash(ext4_directory_dx_entry_t *entry)
     104{
     105        return uint32_t_le2host(entry->hash);
     106}
     107
     108void ext4_directory_dx_entry_set_hash(ext4_directory_dx_entry_t *entry,
     109                uint32_t hash)
     110{
     111        entry->hash = host2uint32_t_le(hash);
     112}
     113
     114uint32_t ext4_directory_dx_entry_get_block(ext4_directory_dx_entry_t *entry)
     115{
     116        return uint32_t_le2host(entry->block);
     117}
     118
     119void ext4_directory_dx_entry_set_block(ext4_directory_dx_entry_t *entry,
     120                uint32_t block)
     121{
     122        entry->block = host2uint32_t_le(block);
     123}
     124
     125
     126/**************************************************************************/
     127
    40128
    41129static int ext4_directory_hinfo_init(ext4_hash_info_t *hinfo, block_t *root_block,
  • uspace/lib/ext4/libext4_directory_index.h

    rfe27eb4 r343ccfd  
    9191
    9292
    93 extern uint8_t ext4_directory_dx_root_info_get_hash_version(ext4_directory_dx_root_info_t *);
    94 extern uint8_t ext4_directory_dx_root_info_get_info_length(ext4_directory_dx_root_info_t *);
    95 extern uint8_t ext4_directory_dx_root_info_get_indirect_levels(ext4_directory_dx_root_info_t *);
     93extern uint8_t ext4_directory_dx_root_info_get_hash_version(
     94                ext4_directory_dx_root_info_t *);
     95extern void ext4_directory_dx_root_info_set_hash_version(
     96                ext4_directory_dx_root_info_t *, uint8_t);
     97extern uint8_t ext4_directory_dx_root_info_get_info_length(
     98                ext4_directory_dx_root_info_t *);
     99extern void ext4_directory_dx_root_info_set_info_length(
     100                ext4_directory_dx_root_info_t *, uint8_t);
     101extern uint8_t ext4_directory_dx_root_info_get_indirect_levels(
     102                ext4_directory_dx_root_info_t *);
     103extern void ext4_directory_dx_root_info_set_indirect_levels(
     104                ext4_directory_dx_root_info_t *, uint8_t);
    96105
    97 extern uint16_t ext4_directory_dx_countlimit_get_limit(ext4_directory_dx_countlimit_t *);
    98 extern uint16_t ext4_directory_dx_countlimit_get_count(ext4_directory_dx_countlimit_t *);
     106extern uint16_t ext4_directory_dx_countlimit_get_limit(
     107                ext4_directory_dx_countlimit_t *);
     108extern void ext4_directory_dx_countlimit_set_limit(
     109                ext4_directory_dx_countlimit_t *, uint16_t);
     110extern uint16_t ext4_directory_dx_countlimit_get_count(
     111                ext4_directory_dx_countlimit_t *);
     112extern void ext4_directory_dx_countlimit_set_count(
     113                ext4_directory_dx_countlimit_t *, uint16_t);
    99114
    100115extern uint32_t ext4_directory_dx_entry_get_hash(ext4_directory_dx_entry_t *);
     116extern void ext4_directory_dx_entry_set_hash(ext4_directory_dx_entry_t *,
     117                uint32_t);
    101118extern uint32_t ext4_directory_dx_entry_get_block(ext4_directory_dx_entry_t *);
     119void ext4_directory_dx_entry_set_block(ext4_directory_dx_entry_t *, uint32_t);
     120
     121/*********************************************************************************/
    102122
    103123extern int ext4_directory_dx_find_entry(ext4_directory_iterator_t *,
  • uspace/lib/ext4/libext4_extent.c

    rfe27eb4 r343ccfd  
    4444}
    4545
     46void ext4_extent_set_first_block(ext4_extent_t *extent, uint32_t first_block)
     47{
     48        extent->first_block = host2uint32_t_le(first_block);
     49}
     50
    4651uint16_t ext4_extent_get_block_count(ext4_extent_t *extent)
    4752{
    4853        return uint16_t_le2host(extent->block_count);
     54}
     55
     56void ext4_extent_set_block_count(ext4_extent_t *extent, uint16_t block_count)
     57{
     58        extent->block_count = host2uint16_t_le(block_count);
    4959}
    5060
     
    5363        return ((uint64_t)uint16_t_le2host(extent->start_hi)) << 32 |
    5464                        ((uint64_t)uint32_t_le2host(extent->start_lo));
     65}
    5566
     67void ext4_extent_set_start(ext4_extent_t *extent, uint64_t start)
     68{
     69        extent->start_lo = host2uint32_t_le((start << 32) >> 32);
     70        extent->start_hi = host2uint16_t_le((uint16_t)(start >> 32));
    5671}
    5772
     
    6176}
    6277
     78void ext4_extent_index_set_first_block(ext4_extent_index_t *index,
     79                uint32_t first)
     80{
     81        index->first_block = host2uint32_t_le(first);
     82}
     83
    6384uint64_t ext4_extent_index_get_leaf(ext4_extent_index_t *index)
    6485{
    6586        return ((uint64_t)uint16_t_le2host(index->leaf_hi)) << 32 |
    66                                 ((uint64_t)uint32_t_le2host(index->leaf_lo));
     87                ((uint64_t)uint32_t_le2host(index->leaf_lo));
     88}
     89
     90void ext4_extent_index_set_leaf(ext4_extent_index_t *index, uint64_t leaf)
     91{
     92        index->leaf_lo = host2uint32_t_le((leaf << 32) >> 32);
     93        index->leaf_hi = host2uint16_t_le((uint16_t)(leaf >> 32));
    6794}
    6895
     
    7299}
    73100
     101void ext4_extent_header_set_magic(ext4_extent_header_t *header, uint16_t magic)
     102{
     103        header->magic = host2uint16_t_le(magic);
     104}
     105
    74106uint16_t ext4_extent_header_get_entries_count(ext4_extent_header_t *header)
    75107{
    76108        return uint16_t_le2host(header->entries_count);
     109}
     110
     111void ext4_extent_header_set_entries_count(ext4_extent_header_t *header,
     112                uint16_t count)
     113{
     114        header->entries_count = host2uint16_t_le(count);
    77115}
    78116
     
    82120}
    83121
     122void ext4_extent_header_set_max_entries_count(ext4_extent_header_t *header,
     123                uint16_t max_count)
     124{
     125        header->max_entries_count = host2uint16_t_le(max_count);
     126}
     127
    84128uint16_t ext4_extent_header_get_depth(ext4_extent_header_t *header)
    85129{
    86130        return uint16_t_le2host(header->depth);
     131}
     132
     133void ext4_extent_header_set_depth(ext4_extent_header_t *header, uint16_t depth)
     134{
     135        header->depth = host2uint16_t_le(depth);
    87136}
    88137
     
    92141}
    93142
     143void ext4_extent_header_set_generation(ext4_extent_header_t *header,
     144                uint32_t generation)
     145{
     146        header->generation = host2uint32_t_le(generation);
     147}
     148
    94149/**
    95150 * @}
  • uspace/lib/ext4/libext4_extent.h

    rfe27eb4 r343ccfd  
    7575
    7676extern uint32_t ext4_extent_get_first_block(ext4_extent_t *);
     77extern void ext4_extent_set_first_block(ext4_extent_t *, uint32_t);
    7778extern uint16_t ext4_extent_get_block_count(ext4_extent_t *);
     79extern void ext4_extent_set_block_count(ext4_extent_t *, uint16_t);
    7880extern uint64_t ext4_extent_get_start(ext4_extent_t *);
     81extern void ext4_extent_set_start(ext4_extent_t *, uint64_t);
    7982
    8083extern uint32_t ext4_extent_index_get_first_block(ext4_extent_index_t *);
     84extern void ext4_extent_index_set_first_block(ext4_extent_index_t *, uint32_t);
    8185extern uint64_t ext4_extent_index_get_leaf(ext4_extent_index_t *);
     86extern void ext4_extent_index_set_leaf(ext4_extent_index_t *, uint64_t);
    8287
    8388extern uint16_t ext4_extent_header_get_magic(ext4_extent_header_t *);
     89extern void ext4_extent_header_set_magic(ext4_extent_header_t *, uint16_t);
    8490extern uint16_t ext4_extent_header_get_entries_count(ext4_extent_header_t *);
     91extern void ext4_extent_header_set_entries_count(ext4_extent_header_t *,
     92                uint16_t);
    8593extern uint16_t ext4_extent_header_get_max_entries_count(ext4_extent_header_t *);
     94extern void ext4_extent_header_set_max_entries_count(ext4_extent_header_t *,
     95                uint16_t);
    8696extern uint16_t ext4_extent_header_get_depth(ext4_extent_header_t *);
     97extern void ext4_extent_header_set_depth(ext4_extent_header_t *, uint16_t);
    8798extern uint32_t ext4_extent_header_get_generation(ext4_extent_header_t *);
     99extern void ext4_extent_header_set_generation(ext4_extent_header_t *, uint32_t);
    88100
    89101#endif
  • uspace/lib/ext4/libext4_inode.c

    rfe27eb4 r343ccfd  
    236236}
    237237
     238uint64_t ext4_get_inode_file_acl(ext4_inode_t *inode, ext4_superblock_t *sb)
     239{
     240        if (ext4_superblock_get_creator_os(sb) == EXT4_SUPERBLOCK_OS_LINUX) {
     241                return ((uint32_t)uint16_t_le2host(inode->osd2.linux2.file_acl_high)) << 16 |
     242                    (uint32_t_le2host(inode->file_acl_lo));
     243        }
     244
     245        return uint32_t_le2host(inode->file_acl_lo);
     246}
     247
     248void ext4_set_inode_file_acl(ext4_inode_t *inode, ext4_superblock_t *sb,
     249                uint64_t file_acl)
     250{
     251        inode->file_acl_lo = host2uint32_t_le((file_acl << 32) >> 32);
     252
     253        if (ext4_superblock_get_creator_os(sb) == EXT4_SUPERBLOCK_OS_LINUX) {
     254                inode->osd2.linux2.file_acl_high = host2uint16_t_le(file_acl >> 32);
     255        }
     256}
     257
    238258/***********************************************************************/
    239259
  • uspace/lib/ext4/libext4_inode.h

    rfe27eb4 r343ccfd  
    8484                uint32_t author;
    8585        } hurd2;
    86         struct {
    87                 uint16_t reserved1;  /* Obsoleted fragment number/size which are removed in ext4 */
    88                 uint16_t file_acl_high;
    89                 uint32_t reserved2[2];
    90         } masix2;
    9186    } __attribute__ ((packed)) osd2;
    9287
     
    173168extern uint32_t ext4_inode_get_generation(ext4_inode_t *);
    174169extern void ext4_inode_set_generation(ext4_inode_t *, uint32_t);
    175 /*
    176 uint32_t file_acl_lo; // File ACL
     170extern uint64_t ext4_get_inode_file_acl(ext4_inode_t *, ext4_superblock_t *);
     171extern void ext4_set_inode_file_acl(ext4_inode_t *, ext4_superblock_t *, uint64_t);
     172/*
    177173uint16_t extra_isize;
    178174uint32_t ctime_extra; // Extra change time (nsec << 2 | epoch)
Note: See TracChangeset for help on using the changeset viewer.