Skip to content

Commit

Permalink
update superBlockUsedBlocks for all xxxclone
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-Tsai committed Aug 30, 2023
1 parent c905de5 commit 8f93125
Show file tree
Hide file tree
Showing 20 changed files with 28 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ src/partclone.xfs
src/partclone.minix
src/partclone.f2fs
src/partclone.nilfs2
src/partclone.imgfuse
src/version.h
stamp-h1
*.m4
Expand Down
1 change: 1 addition & 0 deletions src/apfsclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ void read_super_blocks(char* device, file_system_info* fs_info)
fs_info->block_size = nxsb.nx_block_size;
fs_info->totalblock = nxsb.nx_block_count;
fs_info->usedblocks = fs_info->totalblock-free_blocks;
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
fs_info->device_size = fs_info->totalblock*fs_info->block_size;
fs_close();
}
Expand Down
2 changes: 2 additions & 0 deletions src/btrfsclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,12 @@ void read_super_blocks(char* device, file_system_info* fs_info)

fs_info->block_size = btrfs_super_nodesize(root->fs_info->super_copy);
fs_info->usedblocks = btrfs_super_bytes_used(root->fs_info->super_copy) / fs_info->block_size;
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
fs_info->device_size = btrfs_super_total_bytes(root->fs_info->super_copy);
fs_info->totalblock = fs_info->device_size / fs_info->block_size;
log_mesg(0, 0, 0, fs_opt.debug, "block_size = %i\n", fs_info->block_size);
log_mesg(0, 0, 0, fs_opt.debug, "usedblock = %lli\n", fs_info->usedblocks);
log_mesg(0, 0, 0, fs_opt.debug, "superBlockUsedBlocks = %lli\n", fs_info->superBlockUsedBlocks);
log_mesg(0, 0, 0, fs_opt.debug, "device_size = %llu\n", fs_info->device_size);
log_mesg(0, 0, 0, fs_opt.debug, "totalblock = %lli\n", fs_info->totalblock);

Expand Down
1 change: 1 addition & 0 deletions src/ddclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ void read_super_blocks(char* device, file_system_info* fs_info)
fs_info->device_size = get_partition_size(&src);
fs_info->totalblock = fs_info->device_size / PART_SECTOR_SIZE;
fs_info->usedblocks = fs_info->device_size / PART_SECTOR_SIZE;
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
close(src);
}
1 change: 1 addition & 0 deletions src/exfatclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void read_super_blocks(char* device, file_system_info* fs_info)
fs_info->block_size = EXFAT_SECTOR_SIZE(*sb);
fs_info->totalblock = le64_to_cpu(sb->sector_count);
fs_info->usedblocks = le64_to_cpu(sb->sector_count) - free_sectors;
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
fs_info->device_size = fs_info->totalblock * fs_info->block_size;
fs_close();
}
Expand Down
2 changes: 2 additions & 0 deletions src/extfsclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,12 @@ void read_super_blocks(char* device, file_system_info* fs_info)
fs_info->totalblock = block_count();
fs_info->usedblocks = get_used_blocks();
fs_info->device_size = fs_info->block_size * fs_info->totalblock;
fs_info->superBlockUsedBlocks = fs_info->usedblocks;

log_mesg(1, 0, 0, fs_opt.debug, "%s: extfs block_size %i\n", __FILE__, fs_info->block_size);
log_mesg(1, 0, 0, fs_opt.debug, "%s: extfs total block %lli\n", __FILE__, fs_info->totalblock);
log_mesg(1, 0, 0, fs_opt.debug, "%s: extfs used blocks %lli\n", __FILE__, fs_info->usedblocks);
log_mesg(1, 0, 0, fs_opt.debug, "%s: extfs superBlock used blocks %lli\n", __FILE__, fs_info->superBlockUsedBlocks);
log_mesg(1, 0, 0, fs_opt.debug, "%s: extfs device size %lli\n", __FILE__, fs_info->device_size);

fs_close();
Expand Down
1 change: 1 addition & 0 deletions src/f2fsclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ extern void read_super_blocks(char* device, file_system_info* fs_info)
fs_info->block_size = F2FS_BLKSIZE;
fs_info->totalblock = sb->block_count;
fs_info->usedblocks = (sb->segment_count-cp->free_segment_count)*DEFAULT_BLOCKS_PER_SEGMENT;
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
fs_info->device_size = config.total_sectors*config.sector_size;
fs_close();
}
Expand Down
2 changes: 2 additions & 0 deletions src/fatclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,12 @@ void read_super_blocks(char* device, file_system_info* fs_info)
fs_info->block_size = fat_sb.sector_size;
fs_info->totalblock = total_sector;
fs_info->usedblocks = bused;
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
fs_info->device_size = total_sector * fs_info->block_size;
log_mesg(2, 0, 0, fs_opt.debug, "%s: Block Size:%i\n", __FILE__, fs_info->block_size);
log_mesg(2, 0, 0, fs_opt.debug, "%s: Total Blocks:%llu\n", __FILE__, fs_info->totalblock);
log_mesg(2, 0, 0, fs_opt.debug, "%s: Used Blocks:%llu\n", __FILE__, fs_info->usedblocks);
log_mesg(2, 0, 0, fs_opt.debug, "%s: superBlockUsedBlocks:%llu\n", __FILE__, fs_info->superBlockUsedBlocks);
log_mesg(2, 0, 0, fs_opt.debug, "%s: Device Size:%llu\n", __FILE__, fs_info->device_size);

fs_close();
Expand Down
8 changes: 5 additions & 3 deletions src/hfsplusclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,11 @@ void read_super_blocks(char* device, file_system_info* fs_info)
fs_info->usedblocks = be32toh(sb.totalBlocks) - be32toh(sb.freeBlocks);
fs_info->device_size = fs_info->block_size * fs_info->totalblock;
}
log_mesg(2, 0, 0, 2, "%s: blockSize:%i\n", __FILE__, fs_info->block_size);
log_mesg(2, 0, 0, 2, "%s: totalBlocks:%i\n", __FILE__, fs_info->totalblock);
log_mesg(2, 0, 0, 2, "%s: freeBlocks:%i\n", __FILE__, fs_info->totalblock - fs_info->usedblocks);
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
log_mesg(2, 0, 0, 2, "%s: blockSize:%lli\n", __FILE__, fs_info->block_size);
log_mesg(2, 0, 0, 2, "%s: totalBlocks:%lli\n", __FILE__, fs_info->totalblock);
log_mesg(2, 0, 0, 2, "%s: freeBlocks:%lli\n", __FILE__, fs_info->totalblock - fs_info->usedblocks);
log_mesg(2, 0, 0, 2, "%s: superBlockUsedBlocks:%lli\n", __FILE__, fs_info->superBlockUsedBlocks);
print_fork_data(&sb.allocationFile);
print_fork_data(&sb.extentsFile);
print_fork_data(&sb.catalogFile);
Expand Down
1 change: 1 addition & 0 deletions src/jfsclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ void read_super_blocks(char* device, file_system_info* fs_info) {
fs_info->block_size = sb.s_bsize;
fs_info->totalblock = total_blocks;
fs_info->usedblocks = used_blocks;
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
fs_info->device_size = total_blocks * sb.s_bsize;
fs_close();
}
Expand Down
4 changes: 0 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ int main(int argc, char **argv) {

/// get Super Block information from partition
read_super_blocks(source, &fs_info);
fs_info.superBlockUsedBlocks = fs_info.usedblocks;

if (img_opt.checksum_mode != CSM_NONE && img_opt.blocks_per_checksum == 0) {

Expand Down Expand Up @@ -309,7 +308,6 @@ int main(int argc, char **argv) {

/// get Super Block information from partition
read_super_blocks(source, &fs_info);
fs_info.superBlockUsedBlocks = fs_info.usedblocks;

check_mem_size(fs_info, img_opt, opt);

Expand Down Expand Up @@ -341,7 +339,6 @@ int main(int argc, char **argv) {
if (dfr != 0){
fs_info.device_size = get_partition_size(&dfr);
read_super_blocks(source, &fs_info);
fs_info.superBlockUsedBlocks = fs_info.usedblocks;
}else{
if (target_stdout) {
log_mesg(0, 1, 1, debug, "%s, %i, stdout is not supported\n", __func__, __LINE__);
Expand All @@ -355,7 +352,6 @@ int main(int argc, char **argv) {
fs_info.device_size = get_free_space(target);
}
read_super_blocks(target, &fs_info);
fs_info.superBlockUsedBlocks = fs_info.usedblocks;
}
img_opt.checksum_mode = opt.checksum_mode;
img_opt.checksum_size = get_checksum_size(opt.checksum_mode, opt.debug);
Expand Down
1 change: 1 addition & 0 deletions src/minixclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ void read_super_blocks(char* device, file_system_info* fs_info) {
fs_info->block_size = get_block_size();
fs_info->totalblock = get_nzones();
fs_info->usedblocks = count_used_block();
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
fs_info->device_size = fs_info->totalblock * fs_info->block_size;
fs_close();
}
Expand Down
1 change: 1 addition & 0 deletions src/nilfsclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ extern void read_super_blocks(char* device, file_system_info* fs_info)
fs_info->block_size = nilfs_get_block_size(nilfs);
fs_info->totalblock = sbp->s_dev_size / fs_info->block_size;
fs_info->usedblocks = fs_info->totalblock - sbp->s_free_blocks_count;
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
fs_info->device_size = sbp->s_dev_size;
fs_close();
}
Expand Down
1 change: 1 addition & 0 deletions src/reiser4clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ void read_super_blocks(char* device, file_system_info* fs_info)
fs_info->block_size = get_ms_blksize(SUPER(fs->master));
fs_info->totalblock = reiser4_format_get_len(fs->format);
fs_info->usedblocks = reiser4_format_get_len(fs->format) - free_blocks;
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
fs_info->device_size = fs_info->block_size * fs_info->totalblock;
fs_close();
}
Expand Down
1 change: 1 addition & 0 deletions src/reiserfsclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ void read_super_blocks(char* device, file_system_info* fs_info)
fs_info->block_size = fs->super->s_v1.sb_block_size;
fs_info->totalblock = fs->super->s_v1.sb_block_count;
fs_info->usedblocks = fs->super->s_v1.sb_block_count - fs->super->s_v1.sb_free_blocks;
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
fs_info->device_size = fs_info->block_size * fs_info->totalblock;
fs_close();
}
Expand Down
1 change: 1 addition & 0 deletions src/ufsclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ void read_super_blocks(char* device, file_system_info* fs_info)
strncpy(fs_info->fs, ufs_MAGIC, FS_MAGIC_SIZE);
fs_info->block_size = afs.fs_fsize;
fs_info->usedblocks = get_used_block();
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
switch (disk.d_ufs) {
case 2:
fs_info->totalblock = afs.fs_size;
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* WHETHER THEY ARE BUILT BY OTHERS OR DURING DEVELOPMENT OR FOR THE
* OFFICIAL PARTCLONE RELEASES.
*/
#define git_version "897b3a368f91c99e13a5dcf3f26ba8bc83f8999a"
#define git_version "c905de58e162d559138eeabc5c9152a41bfa2f9e"

2 changes: 2 additions & 0 deletions src/vmfs5clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,14 @@ void read_super_blocks(char* device, file_system_info* fs_info)
fs_info->block_size = vmfs_fs_get_blocksize(fs);
fs_info->totalblock = total;
fs_info->usedblocks = alloc;
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
fs_info->device_size = vmfs_fs_get_blocksize(fs) * total;
total_block = total+100;
log_mesg(3, 0, 0, fs_opt.debug, "block_size %u\n", fs_info->block_size);
log_mesg(3, 0, 0, fs_opt.debug, "totalblock %llu\n", fs_info->totalblock);
log_mesg(3, 0, 0, fs_opt.debug, "device_size %llu\n", fs_info->device_size);
log_mesg(3, 0, 0, fs_opt.debug, "usedblocks %llu\n", fs_info->usedblocks);
log_mesg(3, 0, 0, fs_opt.debug, "superBlockUsedBlocks %llu\n", fs_info->superBlockUsedBlocks);

fs_close();
}
Expand Down
1 change: 1 addition & 0 deletions src/vmfsclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ void read_super_blocks(char* device, file_system_info* fs_info)
fs_info->block_size = vmfs_fs_get_blocksize(fs);
fs_info->totalblock = total;
fs_info->usedblocks = alloc;
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
fs_info->device_size = vmfs_fs_get_blocksize(fs) * total;
fs_close();
}
Expand Down
2 changes: 2 additions & 0 deletions src/xfsclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,13 @@ void read_super_blocks(char* device, file_system_info* fs_info)
fs_info->block_size = mp->m_sb.sb_blocksize;
fs_info->totalblock = mp->m_sb.sb_dblocks;
fs_info->usedblocks = mp->m_sb.sb_dblocks - mp->m_sb.sb_fdblocks;
fs_info->superBlockUsedBlocks = fs_info->usedblocks;
fs_info->device_size = fs_info->totalblock * fs_info->block_size;
log_mesg(1, 0, 0, fs_opt.debug, "%s: blcos size= %i\n", __FILE__, mp->m_sb.sb_blocksize);
log_mesg(1, 0, 0, fs_opt.debug, "%s: total b= %lli\n", __FILE__, mp->m_sb.sb_dblocks);
log_mesg(1, 0, 0, fs_opt.debug, "%s: free block= %lli\n", __FILE__, mp->m_sb.sb_fdblocks);
log_mesg(1, 0, 0, fs_opt.debug, "%s: used block= %lli\n", __FILE__, (mp->m_sb.sb_dblocks - mp->m_sb.sb_fdblocks));
log_mesg(1, 0, 0, fs_opt.debug, "%s: superBlockUsedBlocks= %lli\n", __FILE__, fs_info->superBlockUsedBlocks);
log_mesg(1, 0, 0, fs_opt.debug, "%s: device size= %lli\n", __FILE__, (mp->m_sb.sb_blocksize*mp->m_sb.sb_dblocks));
fs_close();

Expand Down

0 comments on commit 8f93125

Please sign in to comment.