Changeset 6accc5cf in mainline
- Timestamp:
- 2015-07-28T14:12:56Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b10460a
- Parents:
- 47726b5e (diff), fb4d788 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace
- Files:
-
- 1 added
- 2 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/crypto/Makefile
r47726b5e r6accc5cf 33 33 crypto.c \ 34 34 aes.c \ 35 rc4.c 35 rc4.c \ 36 crc16_ibm.c 36 37 37 38 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/crypto/crypto.h
r47726b5e r6accc5cf 56 56 extern int pbkdf2(uint8_t *, size_t, uint8_t *, size_t, uint8_t *); 57 57 58 extern uint16_t crc16_ibm(uint16_t crc, uint8_t *buf, size_t len); 59 58 60 #endif -
uspace/lib/ext4/Makefile
r47726b5e r6accc5cf 29 29 USPACE_PREFIX = ../.. 30 30 LIBRARY = libext4 31 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) 32 LIBS = $(LIBBLOCK_PREFIX)/libblock.a 31 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBCRYPTO_PREFIX) 32 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBCRYPTO_PREFIX)/libcrypto.a 33 33 34 34 SOURCES = \ … … 36 36 libext4_bitmap.c \ 37 37 libext4_block_group.c \ 38 libext4_crc.c \39 38 libext4_directory.c \ 40 39 libext4_directory_index.c \ -
uspace/lib/ext4/libext4.h
r47726b5e r6accc5cf 37 37 #include "libext4_bitmap.h" 38 38 #include "libext4_block_group.h" 39 #include "libext4_crc.h"40 39 #include "libext4_directory.h" 41 40 #include "libext4_directory_index.h" -
uspace/lib/ext4/libext4_balloc.c
r47726b5e r6accc5cf 39 39 #include "libext4.h" 40 40 41 /** Compute number of block group from block address.42 *43 * @param sb Superblock pointer.44 * @param block_addr Absolute address of block.45 *46 * @return Block group index47 *48 */49 static uint32_t ext4_balloc_get_bgid_of_block(ext4_superblock_t *sb,50 uint32_t block_addr)51 {52 uint32_t blocks_per_group =53 ext4_superblock_get_blocks_per_group(sb);54 uint32_t first_block =55 ext4_superblock_get_first_data_block(sb);56 57 /* First block == 0 or 1 */58 if (first_block == 0)59 return block_addr / blocks_per_group;60 else61 return (block_addr - 1) / blocks_per_group;62 }63 64 41 /** Free block. 65 42 * … … 76 53 77 54 /* Compute indexes */ 78 uint32_t block_group = ext4_ balloc_get_bgid_of_block(sb, block_addr);55 uint32_t block_group = ext4_filesystem_blockaddr2group(sb, block_addr); 79 56 uint32_t index_in_group = 80 57 ext4_filesystem_blockaddr2_index_in_group(sb, block_addr); … … 135 112 } 136 113 137 /** Free continuous set of blocks. 138 * 139 * @param inode_ref Inode, where the blocks are allocated 140 * @param first First block to release 141 * @param count Number of blocks to release 142 * 143 */ 144 int ext4_balloc_free_blocks(ext4_inode_ref_t *inode_ref, 114 static int ext4_balloc_free_blocks_internal(ext4_inode_ref_t *inode_ref, 145 115 uint32_t first, uint32_t count) 146 116 { 147 117 ext4_filesystem_t *fs = inode_ref->fs; 148 118 ext4_superblock_t *sb = fs->superblock; 149 119 150 120 /* Compute indexes */ 151 uint32_t block_group_first = 152 ext4_balloc_get_bgid_of_block(sb,first);153 uint32_t block_group_last = 154 ext4_balloc_get_bgid_of_block(sb,first + count - 1);155 121 uint32_t block_group_first = ext4_filesystem_blockaddr2group(sb, 122 first); 123 uint32_t block_group_last = ext4_filesystem_blockaddr2group(sb, 124 first + count - 1); 125 156 126 assert(block_group_first == block_group_last); 157 127 158 128 /* Load block group reference */ 159 129 ext4_block_group_ref_t *bg_ref; … … 161 131 if (rc != EOK) 162 132 return rc; 163 133 164 134 uint32_t index_in_group_first = 165 135 ext4_filesystem_blockaddr2_index_in_group(sb, first); 166 136 167 137 /* Load block with bitmap */ 168 138 uint32_t bitmap_block_addr = 169 139 ext4_block_group_get_block_bitmap(bg_ref->block_group, sb); 170 140 171 141 block_t *bitmap_block; 172 142 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0); … … 175 145 return rc; 176 146 } 177 147 178 148 /* Modify bitmap */ 179 149 ext4_bitmap_free_bits(bitmap_block->data, index_in_group_first, count); 180 150 bitmap_block->dirty = true; 181 151 182 152 /* Release block with bitmap */ 183 153 rc = block_put(bitmap_block); … … 187 157 return rc; 188 158 } 189 159 190 160 uint32_t block_size = ext4_superblock_get_block_size(sb); 191 161 192 162 /* Update superblock free blocks count */ 193 163 uint32_t sb_free_blocks = … … 195 165 sb_free_blocks += count; 196 166 ext4_superblock_set_free_blocks_count(sb, sb_free_blocks); 197 167 198 168 /* Update inode blocks count */ 199 169 uint64_t ino_blocks = … … 202 172 ext4_inode_set_blocks_count(sb, inode_ref->inode, ino_blocks); 203 173 inode_ref->dirty = true; 204 174 205 175 /* Update block group free blocks count */ 206 176 uint32_t free_blocks = … … 210 180 sb, free_blocks); 211 181 bg_ref->dirty = true; 212 182 213 183 /* Release block group reference */ 214 184 return ext4_filesystem_put_block_group_ref(bg_ref); 215 185 } 216 186 187 /** Free continuous set of blocks. 188 * 189 * @param inode_ref Inode, where the blocks are allocated 190 * @param first First block to release 191 * @param count Number of blocks to release 192 * 193 */ 194 int ext4_balloc_free_blocks(ext4_inode_ref_t *inode_ref, 195 uint32_t first, uint32_t count) 196 { 197 int r; 198 uint32_t gid; 199 uint64_t limit; 200 ext4_filesystem_t *fs = inode_ref->fs; 201 ext4_superblock_t *sb = fs->superblock; 202 203 while (count) { 204 gid = ext4_filesystem_blockaddr2group(sb, first); 205 limit = ext4_filesystem_index_in_group2blockaddr(sb, 0, 206 gid + 1); 207 208 if ((first + count) >= limit) { 209 /* This extent spans over 2 or more block groups, 210 * we'll break it into smaller parts. 211 */ 212 uint32_t s = limit - first; 213 214 r = ext4_balloc_free_blocks_internal(inode_ref, 215 first, s); 216 if (r != EOK) 217 return r; 218 219 first = limit; 220 count -= s; 221 } else { 222 return ext4_balloc_free_blocks_internal(inode_ref, 223 first, count); 224 } 225 } 226 227 return EOK; 228 } 229 217 230 /** Compute first block for data in block group. 218 231 * … … 227 240 ext4_block_group_ref_t *bg_ref) 228 241 { 229 uint32_t block_group_count = ext4_superblock_get_block_group_count(sb); 230 uint32_t inode_table_first_block = 231 ext4_block_group_get_inode_table_first_block(bg_ref->block_group, sb); 232 uint16_t inode_table_item_size = ext4_superblock_get_inode_size(sb); 233 uint32_t inodes_per_group = ext4_superblock_get_inodes_per_group(sb); 234 uint32_t block_size = ext4_superblock_get_block_size(sb); 235 uint32_t inode_table_bytes; 236 237 if (bg_ref->index < block_group_count - 1) { 238 inode_table_bytes = inodes_per_group * inode_table_item_size; 239 } else { 240 /* Last block group could be smaller */ 241 uint32_t inodes_count_total = ext4_superblock_get_inodes_count(sb); 242 inode_table_bytes = 243 (inodes_count_total - ((block_group_count - 1) * inodes_per_group)) * 244 inode_table_item_size; 245 } 246 247 uint32_t inode_table_blocks = inode_table_bytes / block_size; 248 249 if (inode_table_bytes % block_size) 250 inode_table_blocks++; 251 252 return inode_table_first_block + inode_table_blocks; 242 uint32_t r; 243 uint64_t itable = ext4_block_group_get_inode_table_first_block( 244 bg_ref->block_group, sb); 245 uint32_t itable_sz = ext4_filesystem_bg_get_itable_size(sb, bg_ref); 246 247 if (!ext4_superblock_has_feature_incompatible(sb, 248 EXT4_FEATURE_INCOMPAT_FLEX_BG)) { 249 /* If we are not using FLEX_BG, the first data block 250 * is always after the inode table. 251 */ 252 r = itable + itable_sz; 253 return ext4_filesystem_blockaddr2_index_in_group(sb, r); 254 } 255 256 uint64_t bbmap = ext4_block_group_get_block_bitmap(bg_ref->block_group, 257 sb); 258 uint64_t ibmap = ext4_block_group_get_inode_bitmap(bg_ref->block_group, 259 sb); 260 261 r = ext4_filesystem_index_in_group2blockaddr(sb, 0, bg_ref->index); 262 r += ext4_filesystem_bg_get_backup_blocks(bg_ref); 263 264 if (ext4_filesystem_blockaddr2group(sb, bbmap) != bg_ref->index) 265 bbmap = -1; /* Invalid */ 266 267 if (ext4_filesystem_blockaddr2group(sb, ibmap) != bg_ref->index) 268 ibmap = -1; 269 270 while (1) { 271 if (r == bbmap || r == ibmap) 272 r++; 273 else if (r >= itable && r < (itable + itable_sz)) 274 r = itable + itable_sz; 275 else 276 break; 277 } 278 279 return r; 253 280 } 254 281 … … 264 291 *goal = 0; 265 292 ext4_superblock_t *sb = inode_ref->fs->superblock; 266 293 267 294 uint64_t inode_size = ext4_inode_get_size(sb, inode_ref->inode); 268 295 uint32_t block_size = ext4_superblock_get_block_size(sb); 269 296 uint32_t inode_block_count = inode_size / block_size; 270 297 271 298 if (inode_size % block_size != 0) 272 299 inode_block_count++; 273 300 274 301 /* If inode has some blocks, get last block address + 1 */ 275 302 if (inode_block_count > 0) { … … 278 305 if (rc != EOK) 279 306 return rc; 280 307 281 308 if (goal != 0) { 282 309 (*goal)++; 283 310 return EOK; 284 311 } 285 286 312 /* If goal == 0, sparse file -> continue */ 287 313 } 288 314 289 315 /* Identify block group of inode */ 290 316 uint32_t inodes_per_group = ext4_superblock_get_inodes_per_group(sb); 291 317 uint32_t block_group = (inode_ref->index - 1) / inodes_per_group; 292 block_size = ext4_superblock_get_block_size(sb); 293 318 294 319 /* Load block group reference */ 295 320 ext4_block_group_ref_t *bg_ref; … … 298 323 if (rc != EOK) 299 324 return rc; 300 301 /* Compute indexes */ 302 uint32_t block_group_count = ext4_superblock_get_block_group_count(sb); 303 uint32_t inode_table_first_block = 304 ext4_block_group_get_inode_table_first_block(bg_ref->block_group, sb); 305 uint16_t inode_table_item_size = ext4_superblock_get_inode_size(sb); 306 uint32_t inode_table_bytes; 307 308 /* Check for last block group */ 309 if (block_group < block_group_count - 1) { 310 inode_table_bytes = inodes_per_group * inode_table_item_size; 311 } else { 312 /* Last block group could be smaller */ 313 uint32_t inodes_count_total = ext4_superblock_get_inodes_count(sb); 314 inode_table_bytes = 315 (inodes_count_total - ((block_group_count - 1) * inodes_per_group)) * 316 inode_table_item_size; 317 } 318 319 uint32_t inode_table_blocks = inode_table_bytes / block_size; 320 321 if (inode_table_bytes % block_size) 322 inode_table_blocks++; 323 324 *goal = inode_table_first_block + inode_table_blocks; 325 325 326 *goal = ext4_balloc_get_first_data_block_in_group(sb, bg_ref); 327 326 328 return ext4_filesystem_put_block_group_ref(bg_ref); 327 329 } … … 353 355 354 356 /* Load block group number for goal and relative index */ 355 uint32_t block_group = ext4_ balloc_get_bgid_of_block(sb, goal);357 uint32_t block_group = ext4_filesystem_blockaddr2group(sb, goal); 356 358 uint32_t index_in_group = 357 359 ext4_filesystem_blockaddr2_index_in_group(sb, goal); … … 626 628 627 629 /* Compute indexes */ 628 uint32_t block_group = ext4_ balloc_get_bgid_of_block(sb, fblock);630 uint32_t block_group = ext4_filesystem_blockaddr2group(sb, fblock); 629 631 uint32_t index_in_group = 630 632 ext4_filesystem_blockaddr2_index_in_group(sb, fblock); -
uspace/lib/ext4/libext4_filesystem.c
r47726b5e r6accc5cf 40 40 #include <malloc.h> 41 41 #include <ipc/vfs.h> 42 #include <align.h> 43 #include <crypto.h> 42 44 #include "libext4.h" 43 45 … … 53 55 enum cache_mode cmode) 54 56 { 57 int rc; 55 58 ext4_superblock_t *temp_superblock = NULL; 56 59 … … 58 61 59 62 /* Initialize block library (4096 is size of communication channel) */ 60 intrc = block_init(EXCHANGE_SERIALIZE, fs->device, 4096);63 rc = block_init(EXCHANGE_SERIALIZE, fs->device, 4096); 61 64 if (rc != EOK) 62 65 goto err; … … 139 142 /* Release memory space for superblock */ 140 143 free(fs->superblock); 141 144 142 145 /* Finish work with block library */ 143 146 block_cache_fini(fs->device); … … 250 253 } 251 254 255 /** Convert the absolute block number to group number 256 * 257 * @param sb Pointer to the superblock 258 * @param b Absolute block number 259 * 260 * @return Group number 261 */ 262 uint32_t ext4_filesystem_blockaddr2group(ext4_superblock_t *sb, uint64_t b) 263 { 264 uint32_t blocks_per_group = ext4_superblock_get_blocks_per_group(sb); 265 uint32_t first_block = ext4_superblock_get_first_data_block(sb); 266 267 return (b - first_block) / blocks_per_group; 268 } 269 252 270 /** Initialize block bitmap in block group. 253 271 * … … 259 277 static int ext4_filesystem_init_block_bitmap(ext4_block_group_ref_t *bg_ref) 260 278 { 279 uint64_t itb; 280 uint32_t sz; 281 uint32_t i; 282 261 283 /* Load bitmap */ 262 uint32_t bitmap_block_addr = ext4_block_group_get_block_bitmap( 284 ext4_superblock_t *sb = bg_ref->fs->superblock; 285 uint64_t bitmap_block_addr = ext4_block_group_get_block_bitmap( 286 bg_ref->block_group, bg_ref->fs->superblock); 287 uint64_t bitmap_inode_addr = ext4_block_group_get_inode_bitmap( 263 288 bg_ref->block_group, bg_ref->fs->superblock); 264 289 … … 272 297 273 298 /* Initialize all bitmap bits to zero */ 274 uint32_t block_size = ext4_superblock_get_block_size( bg_ref->fs->superblock);299 uint32_t block_size = ext4_superblock_get_block_size(sb); 275 300 memset(bitmap, 0, block_size); 276 301 277 /* Determine first block and first data block in group */ 278 uint32_t first_idx = 0; 279 280 uint32_t first_data = ext4_balloc_get_first_data_block_in_group( 281 bg_ref->fs->superblock, bg_ref); 282 uint32_t first_data_idx = ext4_filesystem_blockaddr2_index_in_group( 283 bg_ref->fs->superblock, first_data); 284 302 /* Determine the number of reserved blocks in the group */ 303 uint32_t reserved_cnt = ext4_filesystem_bg_get_backup_blocks(bg_ref); 304 285 305 /* Set bits from to first block to first data block - 1 to one (allocated) */ 286 for (uint32_t block = first_idx; block < first_data_idx; ++block)306 for (uint32_t block = 0; block < reserved_cnt; ++block) 287 307 ext4_bitmap_set_bit(bitmap, block); 288 308 309 uint32_t bitmap_block_gid = ext4_filesystem_blockaddr2group(sb, 310 bitmap_block_addr); 311 if (bitmap_block_gid == bg_ref->index) { 312 ext4_bitmap_set_bit(bitmap, 313 ext4_filesystem_blockaddr2_index_in_group(sb, bitmap_block_addr)); 314 } 315 316 uint32_t bitmap_inode_gid = ext4_filesystem_blockaddr2group(sb, 317 bitmap_inode_addr); 318 if (bitmap_inode_gid == bg_ref->index) { 319 ext4_bitmap_set_bit(bitmap, 320 ext4_filesystem_blockaddr2_index_in_group(sb, bitmap_inode_addr)); 321 } 322 323 itb = ext4_block_group_get_inode_table_first_block(bg_ref->block_group, 324 sb); 325 sz = ext4_filesystem_bg_get_itable_size(sb, bg_ref); 326 327 for (i = 0; i < sz; ++i, ++itb) { 328 uint32_t gid = ext4_filesystem_blockaddr2group(sb, itb); 329 if (gid == bg_ref->index) { 330 ext4_bitmap_set_bit(bitmap, 331 ext4_filesystem_blockaddr2_index_in_group(sb, itb)); 332 } 333 } 334 289 335 bitmap_block->dirty = true; 290 336 … … 423 469 } 424 470 425 /* Initi tialize in-memory representation */471 /* Initialize in-memory representation */ 426 472 newref->block_group = newref->block->data + offset; 427 473 newref->fs = fs; … … 488 534 /* If checksum not supported, 0 will be returned */ 489 535 uint16_t crc = 0; 490 536 491 537 /* Compute the checksum only if the filesystem supports it */ 492 538 if (ext4_superblock_has_feature_read_only(sb, … … 501 547 502 548 /* Initialization */ 503 crc = crc16 (~0, sb->uuid, sizeof(sb->uuid));549 crc = crc16_ibm(~0, sb->uuid, sizeof(sb->uuid)); 504 550 505 551 /* Include index of block group */ 506 crc = crc16 (crc, (uint8_t *) &le_group, sizeof(le_group));552 crc = crc16_ibm(crc, (uint8_t *) &le_group, sizeof(le_group)); 507 553 508 554 /* Compute crc from the first part (stop before checksum field) */ 509 crc = crc16 (crc, (uint8_t *) bg, offset);555 crc = crc16_ibm(crc, (uint8_t *) bg, offset); 510 556 511 557 /* Skip checksum */ … … 516 562 EXT4_FEATURE_INCOMPAT_64BIT)) && 517 563 (offset < ext4_superblock_get_desc_size(sb))) 518 crc = crc16 (crc, ((uint8_t *) bg) + offset,564 crc = crc16_ibm(crc, ((uint8_t *) bg) + offset, 519 565 ext4_superblock_get_desc_size(sb) - offset); 520 566 } … … 523 569 } 524 570 571 /** Get the size of the block group's inode table 572 * 573 * @param sb Pointer to the superblock 574 * @param bg_ref Pointer to the block group reference 575 * 576 * @return Size of the inode table in blocks. 577 */ 578 uint32_t ext4_filesystem_bg_get_itable_size(ext4_superblock_t *sb, 579 ext4_block_group_ref_t *bg_ref) 580 { 581 uint32_t itable_size; 582 uint32_t block_group_count = ext4_superblock_get_block_group_count(sb); 583 uint16_t inode_table_item_size = ext4_superblock_get_inode_size(sb); 584 uint32_t inodes_per_group = ext4_superblock_get_inodes_per_group(sb); 585 uint32_t block_size = ext4_superblock_get_block_size(sb); 586 587 if (bg_ref->index < block_group_count - 1) { 588 itable_size = inodes_per_group * inode_table_item_size; 589 } else { 590 /* Last block group could be smaller */ 591 uint32_t inodes_count_total = ext4_superblock_get_inodes_count(sb); 592 itable_size = 593 (inodes_count_total - ((block_group_count - 1) * inodes_per_group)) * 594 inode_table_item_size; 595 } 596 597 return ROUND_UP(itable_size, block_size) / block_size; 598 } 599 600 /* Check if n is a power of p */ 601 static bool is_power_of(uint32_t n, unsigned p) 602 { 603 if (p == 1 && n != p) 604 return false; 605 606 while (n != p) { 607 if (n < p) 608 return false; 609 else if ((n % p) != 0) 610 return false; 611 612 n /= p; 613 } 614 615 return true; 616 } 617 618 /** Get the number of blocks used by superblock + gdt + reserved gdt backups 619 * 620 * @param bg Pointer to block group 621 * 622 * @return Number of blocks 623 */ 624 uint32_t ext4_filesystem_bg_get_backup_blocks(ext4_block_group_ref_t *bg) 625 { 626 uint32_t const idx = bg->index; 627 uint32_t r = 0; 628 bool has_backups = false; 629 ext4_superblock_t *sb = bg->fs->superblock; 630 631 /* First step: determine if the block group contains the backups */ 632 633 if (idx <= 1) 634 has_backups = true; 635 else { 636 if (ext4_superblock_has_feature_compatible(sb, 637 EXT4_FEATURE_COMPAT_SPARSE_SUPER2)) { 638 uint32_t g1, g2; 639 640 ext4_superblock_get_backup_groups_sparse2(sb, 641 &g1, &g2); 642 643 if (idx == g1 || idx == g2) 644 has_backups = true; 645 } else if (!ext4_superblock_has_feature_read_only(sb, 646 EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER)) { 647 /* Very old fs were all block groups have 648 * superblock and block descriptors backups. 649 */ 650 has_backups = true; 651 } else { 652 if ((idx & 1) && (is_power_of(idx, 3) || 653 is_power_of(idx, 5) || is_power_of(idx, 7))) 654 has_backups = true; 655 } 656 } 657 658 if (has_backups) { 659 uint32_t bg_count; 660 uint32_t bg_desc_sz; 661 uint32_t gdt_table; /* Size of the GDT in blocks */ 662 uint32_t block_size = ext4_superblock_get_block_size(sb); 663 664 /* Now we know that this block group has backups, 665 * we have to compute how many blocks are reserved 666 * for them 667 */ 668 669 if (idx == 0 && block_size == 1024) { 670 /* Special case for first group were the boot block 671 * resides 672 */ 673 r++; 674 } 675 676 /* This accounts for the superblock */ 677 r++; 678 679 /* Add the number of blocks used for the GDT */ 680 bg_count = ext4_superblock_get_block_group_count(sb); 681 bg_desc_sz = ext4_superblock_get_desc_size(sb); 682 gdt_table = ROUND_UP(bg_count * bg_desc_sz, block_size) / 683 block_size; 684 685 r += gdt_table; 686 687 /* And now the number of reserved GDT blocks */ 688 r += ext4_superblock_get_reserved_gdt_blocks(sb); 689 } 690 691 return r; 692 } 693 525 694 /** Put reference to block group. 526 695 * 527 * @ oaram ref Pointer for reference to be put back696 * @param ref Pointer for reference to be put back 528 697 * 529 698 * @return Error code -
uspace/lib/ext4/libext4_filesystem.h
r47726b5e r6accc5cf 47 47 extern uint32_t ext4_filesystem_index_in_group2blockaddr(ext4_superblock_t *, 48 48 uint32_t, uint32_t); 49 extern uint32_t ext4_filesystem_blockaddr2group(ext4_superblock_t *, uint64_t); 49 50 extern int ext4_filesystem_get_block_group_ref(ext4_filesystem_t *, uint32_t, 50 51 ext4_block_group_ref_t **); … … 64 65 extern int ext4_filesystem_append_inode_block(ext4_inode_ref_t *, uint32_t *, 65 66 uint32_t *); 67 uint32_t ext4_filesystem_bg_get_backup_blocks(ext4_block_group_ref_t *bg); 68 uint32_t ext4_filesystem_bg_get_itable_size(ext4_superblock_t *sb, 69 ext4_block_group_ref_t *bg_ref); 66 70 67 71 #endif -
uspace/lib/ext4/libext4_superblock.c
r47726b5e r6accc5cf 1298 1298 } 1299 1299 1300 /** Get the backup groups used with SPARSE_SUPER2 1301 * 1302 * @param sb Pointer to the superblock 1303 * @param g1 Output pointer to the first backup group 1304 * @param g2 Output pointer to the second backup group 1305 */ 1306 void ext4_superblock_get_backup_groups_sparse2(ext4_superblock_t *sb, 1307 uint32_t *g1, uint32_t *g2) 1308 { 1309 *g1 = uint32_t_le2host(sb->backup_bgs[0]); 1310 *g2 = uint32_t_le2host(sb->backup_bgs[1]); 1311 } 1312 1313 /** Set the backup groups (SPARSE SUPER2) 1314 * 1315 * @param sb Pointer to the superblock 1316 * @param g1 Index of the first group 1317 * @param g2 Index of the second group 1318 */ 1319 void ext4_superblock_set_backup_groups_sparse2(ext4_superblock_t *sb, 1320 uint32_t g1, uint32_t g2) 1321 { 1322 sb->backup_bgs[0] = host2uint32_t_le(g1); 1323 sb->backup_bgs[1] = host2uint32_t_le(g2); 1324 } 1325 1326 /** Get the number of blocks (per group) reserved to GDT expansion 1327 * 1328 * @param sb Pointer to the superblock 1329 * 1330 * @return Number of blocks 1331 */ 1332 uint32_t ext4_superblock_get_reserved_gdt_blocks(ext4_superblock_t *sb) 1333 { 1334 return uint32_t_le2host(sb->reserved_gdt_blocks); 1335 } 1336 1337 /** Set the number of blocks (per group) reserved to GDT expansion 1338 * 1339 * @param sb Pointer to the superblock 1340 * @param n Number of reserved blocks 1341 */ 1342 void ext4_superblock_set_reserved_gdt_blocks(ext4_superblock_t *sb, 1343 uint32_t n) 1344 { 1345 sb->reserved_gdt_blocks = host2uint32_t_le(n); 1346 } 1347 1300 1348 /** 1301 1349 * @} -
uspace/lib/ext4/libext4_superblock.h
r47726b5e r6accc5cf 135 135 extern void ext4_superblock_set_flags(ext4_superblock_t *, uint32_t); 136 136 137 extern void ext4_superblock_get_backup_groups_sparse2(ext4_superblock_t *sb, 138 uint32_t *g1, uint32_t *g2); 139 extern void ext4_superblock_set_backup_groups_sparse2(ext4_superblock_t *sb, 140 uint32_t g1, uint32_t g2); 141 142 extern uint32_t ext4_superblock_get_reserved_gdt_blocks(ext4_superblock_t *sb); 143 extern void ext4_superblock_set_reserved_gdt_blocks(ext4_superblock_t *sb, 144 uint32_t n); 145 137 146 /* More complex superblock functions */ 138 147 extern bool ext4_superblock_has_flag(ext4_superblock_t *, uint32_t); -
uspace/lib/ext4/libext4_types.h
r47726b5e r6accc5cf 83 83 * happen if the EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on. 84 84 */ 85 uint8_t s_prealloc_blocks;/* Number of blocks to try to preallocate */86 uint8_t s_prealloc_dir_blocks;/* Number to preallocate for dirs */87 uint16_t s_reserved_gdt_blocks;/* Per group desc for online growth */85 uint8_t prealloc_blocks; /* Number of blocks to try to preallocate */ 86 uint8_t prealloc_dir_blocks; /* Number to preallocate for dirs */ 87 uint16_t reserved_gdt_blocks; /* Per group desc for online growth */ 88 88 89 89 /* … … 133 133 uint64_t last_error_block; /* Block involved of last error */ 134 134 uint8_t last_error_func[32]; /* Function where the error happened */ 135 uint8_t mount_opts[64]; 136 uint32_t padding[112]; /* Padding to the end of the block */ 135 uint8_t mount_opts[64]; /* String containing the mount options */ 136 uint32_t usr_quota_inum; /* Inode number of user quota file */ 137 uint32_t grp_quota_inum; /* Inode number of group quota file */ 138 uint32_t overhead_blocks; /* Overhead blocks/clusters */ 139 uint32_t backup_bgs[2]; /* Block groups containing superblock backups (if SPARSE_SUPER2) */ 140 uint32_t encrypt_algos; /* Encrypt algorithm in use */ 141 uint32_t padding[105]; /* Padding to the end of the block */ 137 142 } __attribute__((packed)) ext4_superblock_t; 138 143 … … 176 181 #define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010 177 182 #define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020 183 #define EXT4_FEATURE_COMPAT_SPARSE_SUPER2 0x0200 178 184 179 185 /* … … 208 214 (EXT4_FEATURE_INCOMPAT_FILETYPE | \ 209 215 EXT4_FEATURE_INCOMPAT_EXTENTS | \ 210 EXT4_FEATURE_INCOMPAT_64BIT) 216 EXT4_FEATURE_INCOMPAT_64BIT | \ 217 EXT4_FEATURE_INCOMPAT_FLEX_BG) 211 218 212 219 #define EXT4_FEATURE_RO_COMPAT_SUPP \ -
uspace/srv/fs/ext4fs/Makefile
r47726b5e r6accc5cf 28 28 29 29 USPACE_PREFIX = ../../.. 30 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBFS_PREFIX)/libfs.a $(LIBEXT4_PREFIX)/libext4.a 31 EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX) -I$(LIBEXT4_PREFIX) 30 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBFS_PREFIX)/libfs.a \ 31 $(LIBEXT4_PREFIX)/libext4.a $(LIBCRYPTO_PREFIX)/libcrypto.a 32 EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX) -I$(LIBEXT4_PREFIX) -I$(LIBCRYPTO_PREFIX) 32 33 BINARY = ext4fs 33 34 STATIC_NEEDED = y
Note:
See TracChangeset
for help on using the changeset viewer.