Changeset 4f38ad77 in mainline
- Timestamp:
- 2018-12-12T18:11:04Z (6 years ago)
- Children:
- be912f53
- Parents:
- c9c1ccd
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkext4/mkext4.c
rc9c1ccd r4f38ad77 159 159 160 160 cfg.volume_name = label; 161 cfg.bsize = 4096; 161 162 (void) nblocks; 162 163 -
uspace/lib/ext4/include/ext4/cfg.h
rc9c1ccd r4f38ad77 53 53 /** Volume name encoded as UTF-8 string */ 54 54 const char *volume_name; 55 /** Filesystem block size */ 56 size_t bsize; 55 57 } ext4_cfg_t; 56 58 -
uspace/lib/ext4/src/filesystem.c
rc9c1ccd r4f38ad77 714 714 /* One for block bitmap one for inode bitmap */ 715 715 free_blocks = free_blocks - reserved - 2 - inode_table_blocks; 716 if (bg_index == 0)717 ++free_blocks; /* XXX Why? */718 716 719 717 ext4_block_group_set_free_blocks_count(bg_ref->block_group, -
uspace/lib/ext4/src/superblock.c
rc9c1ccd r4f38ad77 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 … … 1465 1467 */ 1466 1468 1467 if (idx == 0 && block_size == 1024) {1468 /*1469 * Special case for first group were the boot block1470 * resides1471 */1472 r++;1473 }1474 1475 1469 /* This accounts for the superblock */ 1476 1470 r++; … … 1505 1499 uuid_t uuid; 1506 1500 uint32_t cur_ts; 1507 uint64_t first_block ;1501 uint64_t first_block = 0; 1508 1502 uint64_t fs_blocks; 1509 1503 uint32_t blocks_count; … … 1518 1512 uint32_t idx; 1519 1513 size_t fs_bsize; 1514 size_t fs_bsize_log; 1520 1515 errno_t rc; 1521 1516 struct timespec ts; … … 1533 1528 cur_ts = ts.tv_sec; 1534 1529 1535 fs_bsize = 1024; 1536 first_block = 1; /* 1 for 1k block size, 0 otherwise */ 1530 fs_bsize = cfg->bsize; 1531 switch (fs_bsize) { 1532 case 1024: 1533 first_block = 1; 1534 fs_bsize_log = 0; 1535 blocks_group = 8192; 1536 break; 1537 case 2048: 1538 fs_bsize_log = 1; 1539 blocks_group = 8192 * 2; 1540 break; 1541 case 4096: 1542 fs_bsize_log = 2; 1543 blocks_group = 8192 * 4; 1544 break; 1545 default: 1546 return ENOTSUP; 1547 } 1537 1548 1538 1549 if (fs_bsize % dev_bsize == 0) { … … 1543 1554 fs_blocks = dev_bcnt * (dev_bsize / fs_bsize); 1544 1555 } 1545 1546 /* FS blocks per group */1547 blocks_group = 8 * fs_bsize;1548 1556 1549 1557 /* Inodes per group */ … … 1581 1589 ext4_superblock_set_free_inodes_count(sb, inodes_count); 1582 1590 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); 1591 ext4_superblock_set_log_block_size(sb, fs_bsize_log); 1585 1592 /* Fragment size should be equal to block size */ 1586 ext4_superblock_set_log_frag_size(sb, 0);1593 ext4_superblock_set_log_frag_size(sb, fs_bsize_log); 1587 1594 ext4_superblock_set_blocks_per_group(sb, blocks_group); 1588 1595 /* Should be the same as blocks per group. */ … … 1634 1641 /* Compute free blocks */ 1635 1642 free_blocks = blocks_count; 1636 ++free_blocks; // XXX Why?1637 1643 for (idx = 0; idx < ngroups; idx++) { 1638 1644 free_blocks -= ext4_superblock_get_group_backup_blocks(sb, idx);
Note:
See TracChangeset
for help on using the changeset viewer.