Changeset 3c8b0a8 in mainline for uspace/lib/ext4/src/superblock.c
- Timestamp:
- 2018-12-15T15:48:59Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4bb4cf88
- Parents:
- b6d5e31 (diff), 6ea5e7a (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. - git-author:
- Maurizio Lombardi <m.lombardi85@…> (2018-12-15 15:48:59)
- git-committer:
- GitHub <noreply@…> (2018-12-15 15:48:59)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/src/superblock.c
rb6d5e31 r3c8b0a8 1315 1315 ext4_superblock_get_blocks_per_group(sb); 1316 1316 uint64_t total_blocks = 1317 ext4_superblock_get_blocks_count(sb) - 1; 1317 ext4_superblock_get_blocks_count(sb); 1318 uint32_t first_block = 1319 ext4_superblock_get_first_data_block(sb); 1318 1320 1319 1321 if (bgid < block_group_count - 1) 1320 1322 return blocks_per_group; 1321 1323 else 1322 return (total_blocks - ((block_group_count - 1) * blocks_per_group)) ;1324 return (total_blocks - ((block_group_count - 1) * blocks_per_group)) - first_block; 1323 1325 } 1324 1326 … … 1392 1394 { 1393 1395 sb->reserved_gdt_blocks = host2uint32_t_le(n); 1396 } 1397 1398 /** Get the size of the flex groups 1399 * 1400 * @param sb Pointer to the superblock 1401 * 1402 * @return Size of the flex groups 1403 */ 1404 uint32_t ext4_superblock_get_flex_group_size(ext4_superblock_t *sb) 1405 { 1406 return 2 << sb->log_groups_per_flex; 1394 1407 } 1395 1408 … … 1465 1478 */ 1466 1479 1467 if (idx == 0 && block_size == 1024) {1468 /*1469 * Special case for first group were the boot block1470 * resides1471 */1472 r++;1473 }1474 1475 1480 /* This accounts for the superblock */ 1476 1481 r++; … … 1505 1510 uuid_t uuid; 1506 1511 uint32_t cur_ts; 1507 uint64_t first_block ;1512 uint64_t first_block = 0; 1508 1513 uint64_t fs_blocks; 1509 1514 uint32_t blocks_count; … … 1518 1523 uint32_t idx; 1519 1524 size_t fs_bsize; 1525 size_t fs_bsize_log; 1520 1526 errno_t rc; 1521 1527 struct timespec ts; … … 1533 1539 cur_ts = ts.tv_sec; 1534 1540 1535 fs_bsize = 1024; 1536 first_block = 1; /* 1 for 1k block size, 0 otherwise */ 1541 fs_bsize = cfg->bsize; 1542 switch (fs_bsize) { 1543 case 1024: 1544 first_block = 1; 1545 fs_bsize_log = 0; 1546 blocks_group = 8192; 1547 break; 1548 case 2048: 1549 fs_bsize_log = 1; 1550 blocks_group = 8192 * 2; 1551 break; 1552 case 4096: 1553 fs_bsize_log = 2; 1554 blocks_group = 8192 * 4; 1555 break; 1556 default: 1557 return ENOTSUP; 1558 } 1537 1559 1538 1560 if (fs_bsize % dev_bsize == 0) { … … 1543 1565 fs_blocks = dev_bcnt * (dev_bsize / fs_bsize); 1544 1566 } 1545 1546 /* FS blocks per group */1547 blocks_group = 8 * fs_bsize;1548 1567 1549 1568 /* Inodes per group */ … … 1581 1600 ext4_superblock_set_free_inodes_count(sb, inodes_count); 1582 1601 ext4_superblock_set_first_data_block(sb, first_block); 1583 /* Block size will be 1024 bytes */ 1584 ext4_superblock_set_log_block_size(sb, 0); 1602 ext4_superblock_set_log_block_size(sb, fs_bsize_log); 1585 1603 /* Fragment size should be equal to block size */ 1586 ext4_superblock_set_log_frag_size(sb, 0);1604 ext4_superblock_set_log_frag_size(sb, fs_bsize_log); 1587 1605 ext4_superblock_set_blocks_per_group(sb, blocks_group); 1588 1606 /* Should be the same as blocks per group. */ … … 1634 1652 /* Compute free blocks */ 1635 1653 free_blocks = blocks_count; 1636 ++free_blocks; // XXX Why?1637 1654 for (idx = 0; idx < ngroups; idx++) { 1638 1655 free_blocks -= ext4_superblock_get_group_backup_blocks(sb, idx);
Note:
See TracChangeset
for help on using the changeset viewer.