Changes in uspace/lib/ext4/src/superblock.c [6ea5e7a:6ba36a0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/src/superblock.c
r6ea5e7a r6ba36a0 1315 1315 ext4_superblock_get_blocks_per_group(sb); 1316 1316 uint64_t total_blocks = 1317 ext4_superblock_get_blocks_count(sb); 1318 uint32_t first_block = 1319 ext4_superblock_get_first_data_block(sb); 1317 ext4_superblock_get_blocks_count(sb) - 1; 1320 1318 1321 1319 if (bgid < block_group_count - 1) 1322 1320 return blocks_per_group; 1323 1321 else 1324 return (total_blocks - ((block_group_count - 1) * blocks_per_group)) - first_block;1322 return (total_blocks - ((block_group_count - 1) * blocks_per_group)); 1325 1323 } 1326 1324 … … 1394 1392 { 1395 1393 sb->reserved_gdt_blocks = host2uint32_t_le(n); 1396 }1397 1398 /** Get the size of the flex groups1399 *1400 * @param sb Pointer to the superblock1401 *1402 * @return Size of the flex groups1403 */1404 uint32_t ext4_superblock_get_flex_group_size(ext4_superblock_t *sb)1405 {1406 return 2 << sb->log_groups_per_flex;1407 1394 } 1408 1395 … … 1478 1465 */ 1479 1466 1467 if (idx == 0 && block_size == 1024) { 1468 /* 1469 * Special case for first group were the boot block 1470 * resides 1471 */ 1472 r++; 1473 } 1474 1480 1475 /* This accounts for the superblock */ 1481 1476 r++; … … 1510 1505 uuid_t uuid; 1511 1506 uint32_t cur_ts; 1512 uint64_t first_block = 0;1507 uint64_t first_block; 1513 1508 uint64_t fs_blocks; 1514 1509 uint32_t blocks_count; … … 1523 1518 uint32_t idx; 1524 1519 size_t fs_bsize; 1525 size_t fs_bsize_log;1526 1520 errno_t rc; 1527 1521 struct timespec ts; … … 1539 1533 cur_ts = ts.tv_sec; 1540 1534 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 } 1535 fs_bsize = 1024; 1536 first_block = 1; /* 1 for 1k block size, 0 otherwise */ 1559 1537 1560 1538 if (fs_bsize % dev_bsize == 0) { … … 1565 1543 fs_blocks = dev_bcnt * (dev_bsize / fs_bsize); 1566 1544 } 1545 1546 /* FS blocks per group */ 1547 blocks_group = 8 * fs_bsize; 1567 1548 1568 1549 /* Inodes per group */ … … 1600 1581 ext4_superblock_set_free_inodes_count(sb, inodes_count); 1601 1582 ext4_superblock_set_first_data_block(sb, first_block); 1602 ext4_superblock_set_log_block_size(sb, fs_bsize_log); 1583 /* Block size will be 1024 bytes */ 1584 ext4_superblock_set_log_block_size(sb, 0); 1603 1585 /* Fragment size should be equal to block size */ 1604 ext4_superblock_set_log_frag_size(sb, fs_bsize_log);1586 ext4_superblock_set_log_frag_size(sb, 0); 1605 1587 ext4_superblock_set_blocks_per_group(sb, blocks_group); 1606 1588 /* Should be the same as blocks per group. */ … … 1652 1634 /* Compute free blocks */ 1653 1635 free_blocks = blocks_count; 1636 ++free_blocks; // XXX Why? 1654 1637 for (idx = 0; idx < ngroups; idx++) { 1655 1638 free_blocks -= ext4_superblock_get_group_backup_blocks(sb, idx);
Note:
See TracChangeset
for help on using the changeset viewer.