Lines Matching refs:TT
254 uint32_t dblocks = (uint32_t)((size+(TT.blocksize-1))/TT.blocksize); in file_blocks_used()
255 uint32_t idx=TT.blocksize/4, iblocks=0, diblocks=0, tiblocks=0; in file_blocks_used()
311 TT.treeblocks += that->st.st_blocks; in check_treesize()
315 TT.treeblocks += blocks = file_blocks_used(*size, 0); in check_treesize()
316 TT.treeinodes++; in check_treesize()
364 temp = (inodes + TT.groups - 1) / TT.groups; in get_inodespg()
365 inodes = TT.blocksize/sizeof(struct ext2_inode); in get_inodespg()
377 for (temp = 0; temp < 4; temp++) if (TT.blocksize == 1024<<temp) break; in init_superblock()
383 sb->blocks_count = SWAP_LE32(TT.blocks); in init_superblock()
384 sb->free_blocks_count = SWAP_LE32(TT.freeblocks); in init_superblock()
385 temp = (TT.blocks * (uint64_t)TT.reserved_percent) / 100; in init_superblock()
388 sb->first_data_block = SWAP_LE32(TT.blocksize == 1024 ? 1 : 0); in init_superblock()
393 sb->blocks_per_group = sb->frags_per_group = SWAP_LE32(TT.blockbits); in init_superblock()
396 sb->inodes_per_group = SWAP_LE32(TT.inodespg); in init_superblock()
397 sb->inodes_count = SWAP_LE32(TT.inodespg * TT.groups); in init_superblock()
400 temp = TT.inodespg*TT.groups - INODES_RESERVED; in init_superblock()
401 if (temp < TT.treeinodes) error_exit("Not enough inodes.\n"); in init_superblock()
402 sb->free_inodes_count = SWAP_LE32(temp - TT.treeinodes); in init_superblock()
448 used = TT.groups * sizeof(struct ext2_group); in group_superblock_overhead()
449 used += TT.blocksize - 1; in group_superblock_overhead()
450 used /= TT.blocksize; in group_superblock_overhead()
454 if (!group && TT.blocksize == 1024) used++; in group_superblock_overhead()
464 return group_superblock_overhead(group) + 2 + get_inodespg(TT.inodespg) in group_overhead()
465 / (TT.blocksize/sizeof(struct ext2_inode)); in group_overhead()
488 if(-1 == lseek(TT.fsfd, len, SEEK_SET)) { in put_zeroes()
492 xwrite(TT.fsfd, toybuf, out); in put_zeroes()
508 int i, group = TT.nextblock/TT.blockbits; in fill_inode()
513 while (group >= TT.nextgroup) in fill_inode()
514 TT.nextblock += group_overhead(TT.nextgroup++); in fill_inode()
556 sscanf(toys.optargs[1], "%u", &TT.blocks); in mke2fs_main()
559 if (!TT.reserved_percent) TT.reserved_percent = 5; in mke2fs_main()
564 TT.fsfd = xcreate(*toys.optargs, temp, 0777); in mke2fs_main()
569 length = fdlength(TT.fsfd); in mke2fs_main()
570 if (!TT.blocksize) TT.blocksize = (length && length < 1<<29) ? 1024 : 4096; in mke2fs_main()
571 TT.blockbits = 8*TT.blocksize; in mke2fs_main()
572 if (!TT.blocks) TT.blocks = length/TT.blocksize; in mke2fs_main()
576 if (TT.gendir) { in mke2fs_main()
577 strncpy(toybuf, TT.gendir, sizeof(toybuf)); in mke2fs_main()
601 if (!TT.inodes) { in mke2fs_main()
602 if (!TT.bytes_per_inode) TT.bytes_per_inode = 8192; in mke2fs_main()
603 TT.inodes = (TT.blocks * (uint64_t)TT.blocksize) / TT.bytes_per_inode; in mke2fs_main()
609 if (!TT.blocks) TT.groups = (TT.treeblocks/TT.blockbits)+1; in mke2fs_main()
610 else TT.groups = div_round_up(TT.blocks, TT.blockbits); in mke2fs_main()
613 temp = TT.treeblocks; in mke2fs_main()
615 for (i = 0; i<TT.groups; i++) temp += group_overhead(i); in mke2fs_main()
617 if (TT.blocks) { in mke2fs_main()
618 if (TT.blocks < temp) error_exit("Not enough space.\n"); in mke2fs_main()
621 if (temp <= TT.groups * TT.blockbits) { in mke2fs_main()
622 TT.blocks = temp; in mke2fs_main()
625 TT.groups++; in mke2fs_main()
627 TT.freeblocks = TT.blocks - temp; in mke2fs_main()
638 for (i=0; i<TT.groups; i++) { in mke2fs_main()
644 end = TT.blockbits; in mke2fs_main()
645 if ((i+1)*TT.blockbits > TT.blocks) end = TT.blocks & (TT.blockbits-1); in mke2fs_main()
648 itable = (TT.inodespg*sizeof(struct ext2_inode))/TT.blocksize; in mke2fs_main()
654 int treeblocks = TT.treeblocks, treeinodes = TT.treeinodes; in mke2fs_main()
659 xwrite(TT.fsfd, &sb, sizeof(struct ext2_superblock)); in mke2fs_main()
660 temp = TT.blocksize - sizeof(struct ext2_superblock); in mke2fs_main()
661 if (!i && TT.blocksize > 1024) temp -= 1024; in mke2fs_main()
662 memset(toybuf, 0, TT.blocksize); in mke2fs_main()
663 xwrite(TT.fsfd, toybuf, temp); in mke2fs_main()
666 for(j=0; j<TT.groups; j++) { in mke2fs_main()
672 slot = j % (TT.blocksize/sizeof(struct ext2_group)); in mke2fs_main()
674 if (j) xwrite(TT.fsfd, bg, TT.blocksize); in mke2fs_main()
675 memset(bg, 0, TT.blocksize); in mke2fs_main()
679 temp = TT.inodespg; in mke2fs_main()
691 temp = TT.inodespg/(TT.blocksize/sizeof(struct ext2_inode)) + 2; in mke2fs_main()
703 used += j*TT.blockbits; in mke2fs_main()
709 xwrite(TT.fsfd, bg, TT.blocksize); in mke2fs_main()
717 memset(toybuf, 0, TT.blocksize); in mke2fs_main()
719 bits_set(toybuf, end, TT.blockbits-end); in mke2fs_main()
720 temp = TT.treeblocks - usedblocks; in mke2fs_main()
725 xwrite(TT.fsfd, toybuf, TT.blocksize); in mke2fs_main()
728 memset(toybuf, 0, TT.blocksize); in mke2fs_main()
731 bits_set(toybuf, TT.inodespg, slot = TT.blockbits-TT.inodespg); in mke2fs_main()
732 temp = TT.treeinodes - usedinodes; in mke2fs_main()
737 xwrite(TT.fsfd, toybuf, TT.blocksize); in mke2fs_main()
740 for (j = 0; j<TT.inodespg; j++) { in mke2fs_main()
741 slot = j % (TT.blocksize/sizeof(struct ext2_inode)); in mke2fs_main()
743 if (j) xwrite(TT.fsfd, in, TT.blocksize); in mke2fs_main()
744 memset(in, 0, TT.blocksize); in mke2fs_main()
754 xwrite(TT.fsfd, in, TT.blocksize); in mke2fs_main()
761 put_zeroes(TT.blocksize); in mke2fs_main()
766 put_zeroes((end-start) * TT.blocksize); in mke2fs_main()