Changeset fe27eb4 in mainline
- Timestamp:
- 2011-11-20T12:07:50Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 343ccfd
- Parents:
- ae3d4f8
- Location:
- uspace/lib/ext4
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_balloc.c
rae3d4f8 rfe27eb4 96 96 } 97 97 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); 99 100 block_t *bitmap_block; 100 101 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0); … … 129 130 130 131 // 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); 132 134 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); 134 137 bg_ref->dirty = true; 135 138 … … 148 151 { 149 152 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); 151 155 uint16_t inode_table_item_size = ext4_superblock_get_inode_size(sb); 152 156 uint32_t inodes_per_group = ext4_superblock_get_inodes_per_group(sb); … … 210 214 211 215 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); 213 218 uint16_t inode_table_item_size = ext4_superblock_get_inode_size(fs->superblock); 214 219 uint32_t inode_table_bytes; … … 278 283 279 284 // 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); 281 287 282 288 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0); … … 380 386 381 387 // 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); 383 390 384 391 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0); … … 461 468 462 469 // 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); 464 472 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); 466 475 bg_ref->dirty = true; 467 476 -
uspace/lib/ext4/libext4_block_group.c
rae3d4f8 rfe27eb4 39 39 #include "libext4.h" 40 40 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) { 41 uint64_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 52 void 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 62 uint64_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 74 void 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 84 uint64_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 95 void 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 105 uint32_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 116 void ext4_block_group_set_free_blocks_count(ext4_block_group_t *bg, 117 ext4_superblock_t *sb, uint32_t value) 118 { 66 119 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 125 uint32_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 136 void 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 146 uint32_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 157 void 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 } 80 164 } 81 165 … … 85 169 } 86 170 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); 171 uint32_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 182 void 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 91 190 } 92 191 … … 94 193 { 95 194 return uint16_t_le2host(bg->checksum); 195 } 196 197 void ext4_block_group_set_checksum(ext4_block_group_t *bg, uint16_t checksum) 198 { 199 bg->checksum = host2uint16_t_le(checksum); 96 200 } 97 201 -
uspace/lib/ext4/libext4_block_group.h
rae3d4f8 rfe27eb4 37 37 #include <sys/types.h> 38 38 #include "libext4_block_group.h" 39 #include "libext4_superblock.h" 39 40 /* 40 41 * Structure of a blocks group descriptor … … 69 70 70 71 #define EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE 32 72 #define EXT4_BLOCK_MAX_GROUP_DESCRIPTOR_SIZE 64 71 73 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 *); 74 extern uint64_t ext4_block_group_get_block_bitmap(ext4_block_group_t *, 75 ext4_superblock_t *); 76 extern void ext4_block_group_set_block_bitmap(ext4_block_group_t *, 77 ext4_superblock_t *, uint64_t); 78 extern uint64_t ext4_block_group_get_inode_bitmap(ext4_block_group_t *, 79 ext4_superblock_t *); 80 extern void ext4_block_group_set_inode_bitmap(ext4_block_group_t *, 81 ext4_superblock_t *, uint64_t); 82 extern uint64_t ext4_block_group_get_inode_table_first_block( 83 ext4_block_group_t *, ext4_superblock_t *); 84 extern void ext4_block_group_set_inode_table_first_block( 85 ext4_block_group_t *, ext4_superblock_t *, uint64_t); 86 extern uint32_t ext4_block_group_get_free_blocks_count(ext4_block_group_t *, 87 ext4_superblock_t *); 88 extern void ext4_block_group_set_free_blocks_count(ext4_block_group_t *, 89 ext4_superblock_t *, uint32_t); 90 extern uint32_t ext4_block_group_get_free_inodes_count(ext4_block_group_t *, 91 ext4_superblock_t *); 92 extern void ext4_block_group_set_free_inodes_count(ext4_block_group_t *, 93 ext4_superblock_t *, uint32_t); 94 extern void ext4_block_group_set_free_inodes_count(ext4_block_group_t *, 95 ext4_superblock_t *, uint32_t); 96 extern uint32_t ext4_block_group_get_used_dirs_count(ext4_block_group_t *, 97 ext4_superblock_t *); 98 extern void ext4_block_group_set_used_dirs_count(ext4_block_group_t *, 99 ext4_superblock_t *, uint32_t); 79 100 extern 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 *); 101 extern void ext4_block_group_set_flags(ext4_block_group_t *, uint16_t); 102 extern uint32_t ext4_block_group_get_itable_unused(ext4_block_group_t *, 103 ext4_superblock_t *); 104 extern void ext4_block_group_set_itable_unused(ext4_block_group_t *, 105 ext4_superblock_t *, uint32_t); 81 106 extern uint16_t ext4_block_group_get_checksum(ext4_block_group_t *); 107 extern void ext4_block_group_set_checksum(ext4_block_group_t *, uint16_t); 82 108 83 109 #endif -
uspace/lib/ext4/libext4_filesystem.c
rae3d4f8 rfe27eb4 234 234 235 235 inode_table_start = ext4_block_group_get_inode_table_first_block( 236 bg_ref->block_group );236 bg_ref->block_group, fs->superblock); 237 237 238 238 rc = ext4_filesystem_put_block_group_ref(bg_ref); -
uspace/lib/ext4/libext4_filesystem.h
rae3d4f8 rfe27eb4 46 46 } ext4_filesystem_t; 47 47 48 #define EXT4_MIN_BLOCK_SIZE 1024 //1 KiB 48 49 #define EXT4_MAX_BLOCK_SIZE 65536 //64 KiB 49 50 #define EXT4_REV0_INODE_SIZE 128 -
uspace/lib/ext4/libext4_inode.c
rae3d4f8 rfe27eb4 63 63 } 64 64 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 /* 65 void 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 72 74 uint32_t ext4_inode_get_uid(ext4_inode_t *inode) 73 */ 75 { 76 return uint32_t_le2host(inode->uid); 77 } 78 79 void ext4_inode_set_uid(ext4_inode_t *inode, uint32_t uid) 80 { 81 inode->uid = host2uint32_t_le(uid); 82 } 74 83 75 84 uint64_t ext4_inode_get_size(ext4_superblock_t *sb, ext4_inode_t *inode) … … 89 98 } 90 99 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 */ 100 uint32_t ext4_inode_get_access_time(ext4_inode_t *inode) 101 { 102 return uint32_t_le2host(inode->access_time); 103 } 104 105 void ext4_inode_set_access_time(ext4_inode_t *inode, uint32_t time) 106 { 107 inode->access_time = host2uint32_t_le(time); 108 } 109 110 uint32_t ext4_inode_get_change_inode_time(ext4_inode_t *inode) 111 { 112 return uint32_t_le2host(inode->change_inode_time); 113 } 114 115 void 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 120 uint32_t ext4_inode_get_modification_time(ext4_inode_t *inode) 121 { 122 return uint32_t_le2host(inode->modification_time); 123 } 124 125 void ext4_inode_set_modification_time(ext4_inode_t *inode, uint32_t time) 126 { 127 inode->modification_time = host2uint32_t_le(time); 128 } 129 130 uint32_t ext4_inode_get_deletion_time(ext4_inode_t *inode) 131 { 132 return uint32_t_le2host(inode->deletion_time); 133 } 134 135 void ext4_inode_set_deletion_time(ext4_inode_t *inode, uint32_t time) 136 { 137 inode->deletion_time = host2uint32_t_le(time); 138 } 139 140 uint32_t ext4_inode_get_gid(ext4_inode_t *inode) 141 { 142 return uint32_t_le2host(inode->gid); 143 } 144 145 void ext4_inode_set_gid(ext4_inode_t *inode, uint32_t gid) 146 { 147 inode->gid = host2uint32_t_le(gid); 148 } 98 149 99 150 uint16_t ext4_inode_get_links_count(ext4_inode_t *inode) … … 102 153 } 103 154 155 void ext4_inode_set_links_count(ext4_inode_t *inode, uint16_t count) 156 { 157 inode->links_count = host2uint16_t_le(count); 158 } 104 159 105 160 uint64_t ext4_inode_get_blocks_count(ext4_superblock_t *sb, ext4_inode_t *inode) … … 161 216 } 162 217 return EOK; 163 164 165 218 } 166 219 … … 172 225 inode->flags = host2uint32_t_le(flags); 173 226 } 227 228 uint32_t ext4_inode_get_generation(ext4_inode_t *inode) 229 { 230 return uint32_t_le2host(inode->generation); 231 } 232 233 void ext4_inode_set_generation(ext4_inode_t *inode, uint32_t generation) 234 { 235 inode->generation = host2uint32_t_le(generation); 236 } 237 238 /***********************************************************************/ 174 239 175 240 uint32_t ext4_inode_get_direct_block(ext4_inode_t *inode, uint32_t idx) … … 260 325 } 261 326 327 bool 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 262 334 ext4_extent_header_t * ext4_inode_get_extent_header(ext4_inode_t *inode) 263 335 { -
uspace/lib/ext4/libext4_inode.h
rae3d4f8 rfe27eb4 55 55 uint16_t uid; // Low 16 bits of owner uid 56 56 uint32_t size_lo; // Size in bytes 57 uint32_t ac ess_time; // Access time57 uint32_t access_time; // Access time 58 58 uint32_t change_inode_time; // Inode change time 59 59 uint32_t modification_time; // Modification time … … 150 150 151 151 extern 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 /* 152 extern void ext4_inode_set_mode(ext4_superblock_t *, ext4_inode_t *, uint32_t); 154 153 extern uint32_t ext4_inode_get_uid(ext4_inode_t *); 155 */ 154 extern void ext4_inode_set_uid(ext4_inode_t *, uint32_t); 156 155 extern uint64_t ext4_inode_get_size(ext4_superblock_t *, ext4_inode_t *); 157 156 extern void ext4_inode_set_size(ext4_inode_t *, uint64_t); 158 /*159 157 extern uint32_t ext4_inode_get_access_time(ext4_inode_t *); 158 extern void ext4_inode_set_access_time(ext4_inode_t *, uint32_t); 160 159 extern uint32_t ext4_inode_get_change_inode_time(ext4_inode_t *); 160 extern void ext4_inode_set_change_inode_time(ext4_inode_t *, uint32_t); 161 161 extern uint32_t ext4_inode_get_modification_time(ext4_inode_t *); 162 extern void ext4_inode_set_modification_time(ext4_inode_t *, uint32_t); 162 163 extern uint32_t ext4_inode_get_deletion_time(ext4_inode_t *); 164 extern void ext4_inode_set_deletion_time(ext4_inode_t *, uint32_t); 163 165 extern uint32_t ext4_inode_get_gid(ext4_inode_t *); 164 */ 166 extern void ext4_inode_set_gid(ext4_inode_t *, uint32_t); 165 167 extern uint16_t ext4_inode_get_links_count(ext4_inode_t *); 168 extern void ext4_inode_set_links_count(ext4_inode_t *, uint16_t); 166 169 extern uint64_t ext4_inode_get_blocks_count(ext4_superblock_t *, ext4_inode_t *); 167 170 extern int ext4_inode_set_blocks_count(ext4_superblock_t *, ext4_inode_t *, uint64_t); 168 171 extern 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; 172 extern void ext4_inode_set_flags(ext4_inode_t *, uint32_t); 173 extern uint32_t ext4_inode_get_generation(ext4_inode_t *); 174 extern void ext4_inode_set_generation(ext4_inode_t *, uint32_t); 175 /* 178 176 uint32_t file_acl_lo; // File ACL 179 177 uint16_t extra_isize; … … 186 184 */ 187 185 186 /******************************************/ 187 188 extern uint32_t ext4_inode_get_direct_block(ext4_inode_t *, uint32_t); 189 extern void ext4_inode_set_direct_block(ext4_inode_t *, uint32_t, uint32_t); 190 extern uint32_t ext4_inode_get_indirect_block(ext4_inode_t *, uint32_t); 191 extern void ext4_inode_set_indirect_block(ext4_inode_t *, uint32_t, uint32_t); 192 extern uint32_t ext4_inode_get_extent_block(ext4_inode_t *, uint64_t, service_id_t); 188 193 extern ext4_extent_header_t * ext4_inode_get_extent_header(ext4_inode_t *); 194 extern bool ext4_inode_is_type(ext4_superblock_t *, ext4_inode_t *, uint32_t); 189 195 extern bool ext4_inode_has_flag(ext4_inode_t *, uint32_t); 190 196 extern void ext4_inode_clear_flag(ext4_inode_t *, uint32_t); -
uspace/lib/ext4/libext4_superblock.c
rae3d4f8 rfe27eb4 47 47 } 48 48 49 void ext4_superblock_set_inodes_count(ext4_superblock_t *sb, uint32_t count) 50 { 51 sb->inodes_count = host2uint32_t_le(count); 52 } 53 49 54 uint64_t ext4_superblock_get_blocks_count(ext4_superblock_t *sb) 50 55 { … … 53 58 } 54 59 60 void 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 55 66 uint64_t ext4_superblock_get_reserved_blocks_count(ext4_superblock_t *sb) 56 67 { … … 59 70 } 60 71 72 void 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 61 78 uint64_t ext4_superblock_get_free_blocks_count(ext4_superblock_t *sb) 62 79 { … … 76 93 } 77 94 95 void 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 78 100 uint32_t ext4_superblock_get_first_data_block(ext4_superblock_t *sb) 79 101 { … … 81 103 } 82 104 105 void 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 83 110 uint32_t ext4_superblock_get_log_block_size(ext4_superblock_t *sb) 84 111 { … … 86 113 } 87 114 115 void 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 88 120 uint32_t ext4_superblock_get_block_size(ext4_superblock_t *sb) 89 121 { … … 91 123 } 92 124 125 void 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 } 93 138 94 139 uint32_t ext4_superblock_get_blocks_per_group(ext4_superblock_t *sb) … … 97 142 } 98 143 144 void 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 99 149 uint32_t ext4_superblock_get_inodes_per_group(ext4_superblock_t *sb) 100 150 { … … 102 152 } 103 153 154 void 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 104 159 uint32_t ext4_superblock_get_mount_time(ext4_superblock_t *sb) 105 160 { … … 107 162 } 108 163 164 void ext4_superblock_set_mount_time(ext4_superblock_t *sb, uint32_t time) 165 { 166 sb->mount_time = host2uint32_t_le(time); 167 } 168 109 169 uint32_t ext4_superblock_get_write_time(ext4_superblock_t *sb) 110 170 { … … 112 172 } 113 173 174 void ext4_superblock_set_write_time(ext4_superblock_t *sb, uint32_t time) 175 { 176 sb->write_time = host2uint32_t_le(time); 177 } 178 114 179 uint16_t ext4_superblock_get_mount_count(ext4_superblock_t *sb) 115 180 { … … 117 182 } 118 183 184 void ext4_superblock_set_mount_count(ext4_superblock_t *sb, uint16_t count) 185 { 186 sb->mount_count = host2uint16_t_le(count); 187 } 188 119 189 uint16_t ext4_superblock_get_max_mount_count(ext4_superblock_t *sb) 120 190 { … … 122 192 } 123 193 194 void 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 124 199 uint16_t ext4_superblock_get_magic(ext4_superblock_t *sb) 125 200 { … … 132 207 } 133 208 209 void ext4_superblock_set_state(ext4_superblock_t *sb, uint16_t state) 210 { 211 sb->state = host2uint16_t_le(state); 212 } 213 134 214 uint16_t ext4_superblock_get_errors(ext4_superblock_t *sb) 135 215 { … … 137 217 } 138 218 219 void ext4_superblock_set_errors(ext4_superblock_t *sb, uint16_t errors) 220 { 221 sb->errors = host2uint16_t_le(errors); 222 } 139 223 140 224 uint16_t ext4_superblock_get_minor_rev_level(ext4_superblock_t *sb) … … 143 227 } 144 228 229 void 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 145 234 uint32_t ext4_superblock_get_last_check_time(ext4_superblock_t *sb) 146 235 { 147 236 return uint32_t_le2host(sb->last_check_time); 237 } 238 239 void ext4_superblock_set_last_check_time(ext4_superblock_t *sb, uint32_t time) 240 { 241 sb->state = host2uint32_t_le(time); 148 242 } 149 243 … … 152 246 } 153 247 248 void ext4_superblock_set_check_interval(ext4_superblock_t *sb, uint32_t interval) 249 { 250 sb->check_interval = host2uint32_t_le(interval); 251 } 252 154 253 uint32_t ext4_superblock_get_creator_os(ext4_superblock_t *sb) 155 254 { … … 157 256 } 158 257 258 void ext4_superblock_set_creator_os(ext4_superblock_t *sb, uint32_t os) 259 { 260 sb->creator_os = host2uint32_t_le(os); 261 } 262 159 263 uint32_t ext4_superblock_get_rev_level(ext4_superblock_t *sb) 160 264 { 161 265 return uint32_t_le2host(sb->rev_level); 266 } 267 268 void ext4_superblock_set_rev_level(ext4_superblock_t *sb, uint32_t level) 269 { 270 sb->rev_level = host2uint32_t_le(level); 271 } 272 273 uint16_t ext4_superblock_get_def_resuid(ext4_superblock_t *sb) 274 { 275 return uint16_t_le2host(sb->def_resuid); 276 } 277 278 void ext4_superblock_set_def_resuid(ext4_superblock_t *sb, uint16_t uid) 279 { 280 sb->def_resuid = host2uint16_t_le(uid); 281 } 282 283 uint16_t ext4_superblock_get_def_resgid(ext4_superblock_t *sb) 284 { 285 return uint16_t_le2host(sb->def_resgid); 286 } 287 288 void ext4_superblock_set_def_resgid(ext4_superblock_t *sb, uint16_t gid) 289 { 290 sb->def_resgid = host2uint16_t_le(gid); 291 } 292 293 uint32_t ext4_superblock_get_first_inode(ext4_superblock_t *sb) 294 { 295 return uint32_t_le2host(sb->first_inode); 296 } 297 298 void ext4_superblock_set_first_inode(ext4_superblock_t *sb, uint32_t first_inode) 299 { 300 sb->first_inode = host2uint32_t_le(first_inode); 162 301 } 163 302 … … 170 309 } 171 310 311 void ext4_superblock_set_inode_size(ext4_superblock_t *sb, uint16_t size) 312 { 313 sb->inode_size = host2uint16_t_le(size); 314 } 315 172 316 uint16_t ext4_superblock_get_block_group_number(ext4_superblock_t *sb) 173 317 { … … 175 319 } 176 320 321 void 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 177 326 uint32_t ext4_superblock_get_features_compatible(ext4_superblock_t *sb) 178 327 { … … 180 329 } 181 330 331 void ext4_superblock_set_features_compatible(ext4_superblock_t *sb, uint32_t features) 332 { 333 sb->features_compatible = host2uint32_t_le(features); 334 } 335 182 336 uint32_t ext4_superblock_get_features_incompatible(ext4_superblock_t *sb) 183 337 { … … 185 339 } 186 340 341 void ext4_superblock_set_features_incompatible(ext4_superblock_t *sb, uint32_t features) 342 { 343 sb->features_incompatible = host2uint32_t_le(features); 344 } 345 187 346 uint32_t ext4_superblock_get_features_read_only(ext4_superblock_t *sb) 188 347 { … … 190 349 } 191 350 351 void ext4_superblock_set_features_read_only(ext4_superblock_t *sb, uint32_t features) 352 { 353 sb->features_read_only = host2uint32_t_le(features); 354 } 192 355 193 356 uint32_t* ext4_superblock_get_hash_seed(ext4_superblock_t *sb) … … 207 370 } 208 371 372 void ext4_superblock_set_desc_size(ext4_superblock_t *sb, uint16_t size) 373 { 374 sb->desc_size = host2uint16_t_le(size); 375 } 376 209 377 uint32_t ext4_superblock_get_flags(ext4_superblock_t *sb) 210 378 { 211 379 return uint32_t_le2host(sb->flags); 380 } 381 382 void ext4_superblock_set_flags(ext4_superblock_t *sb, uint32_t flags) 383 { 384 sb->flags = host2uint32_t_le(flags); 212 385 } 213 386 … … 307 480 } 308 481 482 // block size 483 // desc size 484 485 309 486 // TODO more checks !!! 310 487 -
uspace/lib/ext4/libext4_superblock.h
rae3d4f8 rfe27eb4 202 202 203 203 extern uint32_t ext4_superblock_get_inodes_count(ext4_superblock_t *); 204 extern void ext4_superblock_set_inodes_count(ext4_superblock_t *, uint32_t); 204 205 extern uint64_t ext4_superblock_get_blocks_count(ext4_superblock_t *); 206 extern void ext4_superblock_set_blocks_count(ext4_superblock_t *, uint64_t); 205 207 extern uint64_t ext4_superblock_get_reserved_blocks_count(ext4_superblock_t *); 208 extern void ext4_superblock_set_reserved_blocks_count(ext4_superblock_t *, uint64_t); 206 209 extern uint64_t ext4_superblock_get_free_blocks_count(ext4_superblock_t *); 207 210 extern void ext4_superblock_set_free_blocks_count(ext4_superblock_t *, uint64_t); 208 211 extern uint32_t ext4_superblock_get_free_inodes_count(ext4_superblock_t *); 212 extern void ext4_superblock_set_free_inodes_count(ext4_superblock_t *, uint32_t); 209 213 extern uint32_t ext4_superblock_get_first_data_block(ext4_superblock_t *); 214 extern void ext4_superblock_set_first_data_block(ext4_superblock_t *, uint32_t); 210 215 extern uint32_t ext4_superblock_get_log_block_size(ext4_superblock_t *); 216 extern void ext4_superblock_set_log_block_size(ext4_superblock_t *, uint32_t); 211 217 extern uint32_t ext4_superblock_get_block_size(ext4_superblock_t *); 218 extern void ext4_superblock_set_block_size(ext4_superblock_t *, uint32_t); 212 219 extern uint32_t ext4_superblock_get_blocks_per_group(ext4_superblock_t *); 220 extern void ext4_superblock_set_blocks_per_group(ext4_superblock_t *, uint32_t); 213 221 extern uint32_t ext4_superblock_get_inodes_per_group(ext4_superblock_t *); 222 extern void ext4_superblock_set_inodes_per_group(ext4_superblock_t *, uint32_t); 214 223 extern uint32_t ext4_superblock_get_mount_time(ext4_superblock_t *); 224 extern void ext4_superblock_set_mount_time(ext4_superblock_t *, uint32_t); 215 225 extern uint32_t ext4_superblock_get_write_time(ext4_superblock_t *); 226 extern void ext4_superblock_set_write_time(ext4_superblock_t *, uint32_t); 216 227 extern uint16_t ext4_superblock_get_mount_count(ext4_superblock_t *); 228 extern void ext4_superblock_set_mount_count(ext4_superblock_t *, uint16_t); 217 229 extern uint16_t ext4_superblock_get_max_mount_count(ext4_superblock_t *); 230 extern void ext4_superblock_set_max_mount_count(ext4_superblock_t *, uint16_t); 218 231 extern uint16_t ext4_superblock_get_magic(ext4_superblock_t *); 219 232 extern uint16_t ext4_superblock_get_state(ext4_superblock_t *); 233 extern void ext4_superblock_set_state(ext4_superblock_t *, uint16_t); 220 234 extern uint16_t ext4_superblock_get_errors(ext4_superblock_t *); 235 extern void ext4_superblock_set_errors(ext4_superblock_t *, uint16_t); 221 236 extern uint16_t ext4_superblock_get_minor_rev_level(ext4_superblock_t *); 237 extern void ext4_superblock_set_minor_rev_level(ext4_superblock_t *, uint16_t); 222 238 extern uint32_t ext4_superblock_get_last_check_time(ext4_superblock_t *); 239 extern void ext4_superblock_set_last_check_time(ext4_superblock_t *, uint32_t); 223 240 extern uint32_t ext4_superblock_get_check_interval(ext4_superblock_t *); 241 extern void ext4_superblock_set_check_interval(ext4_superblock_t *, uint32_t); 224 242 extern uint32_t ext4_superblock_get_creator_os(ext4_superblock_t *); 243 extern void ext4_superblock_set_creator_os(ext4_superblock_t *, uint32_t); 225 244 extern 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 245 extern void ext4_superblock_set_rev_level(ext4_superblock_t *, uint32_t); 246 extern uint16_t ext4_superblock_get_def_resuid(ext4_superblock_t *); 247 extern void ext4_superblock_set_def_resuid(ext4_superblock_t *, uint16_t); 248 extern uint16_t ext4_superblock_get_def_resgid(ext4_superblock_t *); 249 extern void ext4_superblock_set_def_resgid(ext4_superblock_t *, uint16_t); 232 250 extern uint32_t ext4_superblock_get_first_inode(ext4_superblock_t *); 251 extern void ext4_superblock_set_first_inode(ext4_superblock_t *, uint32_t); 233 252 extern uint16_t ext4_superblock_get_inode_size(ext4_superblock_t *); 253 extern void ext4_superblock_set_inode_size(ext4_superblock_t *, uint16_t); 234 254 extern uint16_t ext4_superblock_get_block_group_number(ext4_superblock_t *); 255 extern void ext4_superblock_set_block_group_number(ext4_superblock_t *, uint16_t); 235 256 extern uint32_t ext4_superblock_get_features_compatible(ext4_superblock_t *); 257 extern void ext4_superblock_set_features_compatible(ext4_superblock_t *, uint32_t); 236 258 extern uint32_t ext4_superblock_get_features_incompatible(ext4_superblock_t *); 259 extern void ext4_superblock_set_features_incompatible(ext4_superblock_t *, uint32_t); 237 260 extern uint32_t ext4_superblock_get_features_read_only(ext4_superblock_t *); 261 extern void ext4_superblock_set_features_read_only(ext4_superblock_t *, uint32_t); 238 262 239 263 /* … … 251 275 */ 252 276 extern uint32_t* ext4_superblock_get_hash_seed(ext4_superblock_t *); 253 254 277 /* 255 278 uint8_t s_def_hash_version; // Default hash version to use … … 258 281 259 282 extern uint16_t ext4_superblock_get_desc_size(ext4_superblock_t *); 283 extern void ext4_superblock_set_desc_size(ext4_superblock_t *, uint16_t); 260 284 261 285 /* … … 268 292 */ 269 293 extern uint32_t ext4_superblock_get_flags(ext4_superblock_t *); 294 extern void ext4_superblock_set_flags(ext4_superblock_t *, uint32_t); 270 295 /* 271 296 uint16_t s_raid_stride; // RAID stride
Note:
See TracChangeset
for help on using the changeset viewer.