Changeset 5352d72 in mainline for uspace/lib
- Timestamp:
- 2011-02-16T16:47:18Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a2a1792
- Parents:
- ce13577
- Location:
- uspace/lib/ext2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext2/libext2_filesystem.c
rce13577 r5352d72 225 225 } 226 226 227 newref->inode = newref->block->data + offset_in_group;227 newref->inode = newref->block->data + (offset_in_group*inode_size); 228 228 229 229 *ref = newref; -
uspace/lib/ext2/libext2_inode.c
rce13577 r5352d72 38 38 #include <byteorder.h> 39 39 40 /** 41 * Get mode stored in the inode 42 * 43 * @param inode pointer to inode 44 */ 45 inline uint16_t ext2_inode_get_mode(ext2_inode_t *inode) 46 { 47 return uint16_t_le2host(inode->mode); 48 } 49 50 /** 51 * Get uid this inode is belonging to 52 * 53 * @param inode pointer to inode 54 */ 55 inline uint32_t ext2_inode_get_user_id(ext2_inode_t *inode) 56 { 57 // TODO: use additional OS specific bits 58 return uint16_t_le2host(inode->user_id); 59 } 60 61 /** 62 * Get size of file 63 * 64 * @param inode pointer to inode 65 */ 66 inline uint32_t ext2_inode_get_size(ext2_inode_t *inode) 67 { 68 // TODO: Directory ACLS! 69 return uint16_t_le2host(inode->size); 70 } 71 72 /** 73 * Get gid this inode belongs to 74 * 75 * @param inode pointer to inode 76 */ 77 inline uint32_t ext2_inode_get_group_id(ext2_inode_t *inode) 78 { 79 // TODO: use additional OS specific bits 80 return uint16_t_le2host(inode->group_id); 81 } 82 83 /** 84 * Get usage count (i.e. hard link count) 85 * A value of 1 is common, while 0 means that the inode should be freed 86 * 87 * @param inode pointer to inode 88 */ 89 inline uint16_t ext2_inode_get_usage_count(ext2_inode_t *inode) 90 { 91 return uint16_t_le2host(inode->usage_count); 92 } 93 94 /** 95 * Get size of inode in 512 byte blocks 96 * TODO: clarify this 97 * 98 * @param inode pointer to inode 99 */ 100 inline uint32_t ext2_inode_get_reserved_512_blocks(ext2_inode_t *inode) 101 { 102 return uint32_t_le2host(inode->reserved_512_blocks); 103 } 104 105 /** 106 * Get inode flags 107 * 108 * @param inode pointer to inode 109 */ 110 111 inline uint32_t ext2_inode_get_flags(ext2_inode_t *inode) { 112 return uint32_t_le2host(inode->flags); 113 } 114 115 /** 116 * Get direct block ID 117 * 118 * @param inode pointer to inode 119 * @param idx Index to block. Valid values are 0 <= idx < 12 120 */ 121 inline uint32_t ext2_inode_get_direct_block(ext2_inode_t *inode, uint8_t idx) 122 { 123 return uint32_t_le2host(inode->direct_blocks[idx]); 124 } 125 126 /** 127 * Get indirect block ID 128 * 129 * @param inode pointer to inode 130 */ 131 inline uint32_t ext2_inode_get_single_indirect_block(ext2_inode_t *inode) 132 { 133 return uint32_t_le2host(inode->single_indirect_block); 134 } 135 136 /** 137 * Get double indirect block ID 138 * 139 * @param inode pointer to inode 140 */ 141 inline uint32_t ext2_inode_get_double_indirect_block(ext2_inode_t *inode) 142 { 143 return uint32_t_le2host(inode->double_indirect_block); 144 } 145 146 /** 147 * Get triple indirect block ID 148 * 149 * @param inode pointer to inode 150 */ 151 inline uint32_t ext2_inode_get_triple_indirect_block(ext2_inode_t *inode) 152 { 153 return uint32_t_le2host(inode->triple_indirect_block); 154 } 40 155 41 156 -
uspace/lib/ext2/libext2_inode.h
rce13577 r5352d72 55 55 } ext2_inode_t; 56 56 57 #define EXT2_INODE_MODE_FIFO 0x1000 58 #define EXT2_INODE_MODE_CHARDEV 0x2000 59 #define EXT2_INODE_MODE_DIRECTORY 0x4000 60 #define EXT2_INODE_MODE_BLOCKDEV 0x6000 61 #define EXT2_INODE_MODE_FILE 0x8000 62 #define EXT2_INODE_MODE_SOFTLINK 0xA000 63 #define EXT2_INODE_MODE_SOCKET 0xC000 64 #define EXT2_INODE_MODE_ACCESS_MASK 0x0FFF 65 57 66 typedef struct ext2_inode_ref { 58 67 block_t *block; // Reference to a block containing this inode 59 68 ext2_inode_t *inode; 60 69 } ext2_inode_ref_t; 70 71 inline uint16_t ext2_inode_get_mode(ext2_inode_t *); 72 inline uint32_t ext2_inode_get_user_id(ext2_inode_t *); 73 inline uint32_t ext2_inode_get_size(ext2_inode_t *); 74 inline uint32_t ext2_inode_get_group_id(ext2_inode_t *); 75 inline uint16_t ext2_inode_get_usage_count(ext2_inode_t *); 76 inline uint32_t ext2_inode_get_reserved_512_blocks(ext2_inode_t *); 77 inline uint32_t ext2_inode_get_flags(ext2_inode_t *); 78 inline uint32_t ext2_inode_get_direct_block(ext2_inode_t *, uint8_t); 79 inline uint32_t ext2_inode_get_single_indirect_block(ext2_inode_t *); 80 inline uint32_t ext2_inode_get_double_indirect_block(ext2_inode_t *); 81 inline uint32_t ext2_inode_get_triple_indirect_block(ext2_inode_t *); 61 82 62 83
Note:
See TracChangeset
for help on using the changeset viewer.