Skip to content

Commit

Permalink
report used blocks and free space based on bitmap
Browse files Browse the repository at this point in the history
  • Loading branch information
joergmlpts committed Aug 24, 2023
1 parent 0e07190 commit a52a21f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ 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 @@ -308,6 +309,7 @@ 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 @@ -339,6 +341,7 @@ 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 @@ -352,6 +355,7 @@ 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
6 changes: 3 additions & 3 deletions src/partclone.c
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ void update_used_blocks_count(file_system_info* fs_info, unsigned long* bitmap)
++used;
}

fs_info->used_bitmap = used;
fs_info->usedblocks = used;
}


Expand Down Expand Up @@ -1907,7 +1907,7 @@ void print_file_system_info(file_system_info fs_info, cmd_opt opt) {
unsigned int block_s = fs_info.block_size;
unsigned long long total = fs_info.totalblock;
unsigned long long used = fs_info.usedblocks;
unsigned long long used_bitmap = fs_info.used_bitmap;
unsigned long long superBlockUsedBlocks = fs_info.superBlockUsedBlocks;
int debug = opt.debug;
char size_str[11];

Expand All @@ -1926,7 +1926,7 @@ void print_file_system_info(file_system_info fs_info, cmd_opt opt) {
log_mesg(0, 0, 1, debug, _("Free Space: %s = %llu Blocks\n"), size_str, (total-used));

log_mesg(0, 0, 1, debug, _("Block size: %i Byte\n"), block_s);
log_mesg(2, 0, 1, debug, _("Used Blocks in Bitmap: %llu Blocks\n"), used_bitmap);
log_mesg(2, 0, 1, debug, _("Used Blocks in Super-Block: %llu Blocks\n"), superBlockUsedBlocks);
}

/// print image info
Expand Down
4 changes: 2 additions & 2 deletions src/partclone.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ typedef struct
unsigned long long totalblock;

/// Number of blocks in use as reported by the file system
unsigned long long usedblocks;
unsigned long long superBlockUsedBlocks;

/// Number of blocks in use in the bitmap
unsigned long long used_bitmap;
unsigned long long usedblocks;

/// Number of bytes in each block
unsigned int block_size;
Expand Down

0 comments on commit a52a21f

Please sign in to comment.