Changeset ad34feb in mainline for uspace/lib/ext2/libext2_inode.c


Ignore:
Timestamp:
2011-02-23T23:07:28Z (14 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
102d400
Parents:
a54af66
Message:

Implement reading of blocks from inode in libext2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext2/libext2_inode.c

    ra54af66 rad34feb  
    3838#include "libext2_superblock.h"
    3939#include <byteorder.h>
     40#include <assert.h>
    4041
    4142/**
     
    142143
    143144/**
     145 * Get number of blocks allocated for contents of the file
     146 * represented by this inode.
     147 *
     148 * @param inode pointer to inode
     149 */
     150inline uint32_t ext2_inode_get_reserved_blocks(ext2_superblock_t *sb,
     151    ext2_inode_t *inode)
     152{
     153        return ext2_inode_get_reserved_512_blocks(inode) /
     154            (ext2_superblock_get_block_size(sb) / 512);
     155}
     156
     157/**
    144158 * Get inode flags
    145159 *
     
    158172inline uint32_t ext2_inode_get_direct_block(ext2_inode_t *inode, uint8_t idx)
    159173{
     174        assert(idx < EXT2_INODE_DIRECT_BLOCKS);
    160175        return uint32_t_le2host(inode->direct_blocks[idx]);
    161176}
     
    165180 *
    166181 * @param inode pointer to inode
     182 * @param idx Indirection level. Valid values are 0 <= idx < 3, where 0 is
     183 *            singly-indirect block and 2 is triply-indirect-block
    167184 */
    168 inline uint32_t ext2_inode_get_single_indirect_block(ext2_inode_t *inode)
     185inline uint32_t ext2_inode_get_indirect_block(ext2_inode_t *inode, uint8_t idx)
    169186{
    170         return uint32_t_le2host(inode->single_indirect_block);
     187        assert(idx < 3);
     188        return uint32_t_le2host(inode->indirect_blocks[idx]);
    171189}
    172 
    173 /**
    174  * Get double indirect block ID
    175  *
    176  * @param inode pointer to inode
    177  */
    178 inline uint32_t ext2_inode_get_double_indirect_block(ext2_inode_t *inode)
    179 {
    180         return uint32_t_le2host(inode->double_indirect_block);
    181 }
    182 
    183 /**
    184  * Get triple indirect block ID
    185  *
    186  * @param inode pointer to inode
    187  */
    188 inline uint32_t ext2_inode_get_triple_indirect_block(ext2_inode_t *inode)
    189 {
    190         return uint32_t_le2host(inode->triple_indirect_block);
    191 }
    192 
    193 
    194190
    195191/** @}
Note: See TracChangeset for help on using the changeset viewer.