Skip to content
Permalink
Browse files

fix pip issue for dd +bt

  • Loading branch information
partclone committed Sep 24, 2017
1 parent 2a05199 commit 2d1ee7c94139f390453ea8cb8675f67173bde33b
Showing with 41 additions and 5 deletions.
  1. +1 −1 src/ddclone.c
  2. +5 −3 src/main.c
  3. +31 −0 src/partclone.c
  4. +3 −0 src/partclone.h
  5. +1 −1 src/version.h
@@ -30,7 +30,7 @@ void read_super_blocks(char* device, file_system_info* fs_info)
}
strncpy(fs_info->fs, raw_MAGIC, FS_MAGIC_SIZE);
fs_info->block_size = PART_SECTOR_SIZE;
fs_info->device_size = get_partition_size(&src);
//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;
close(src);
@@ -313,11 +313,13 @@ int main(int argc, char **argv) {
log_mesg(0, 0, 1, debug, "done!\n");
} else if (opt.ddd){

if (dfr != 0)
if (dfr != 0){
fs_info.device_size = get_partition_size(&dfr);
read_super_blocks(source, &fs_info);
else
}else{
fs_info.device_size = get_free_space(target);
read_super_blocks(target, &fs_info);

}
img_opt.checksum_mode = opt.checksum_mode;
img_opt.checksum_size = get_checksum_size(opt.checksum_mode, opt.debug);
img_opt.blocks_per_checksum = opt.blocks_per_checksum;
@@ -1238,6 +1238,37 @@ unsigned long long get_bitmap_size_on_disk(const file_system_info* fs_info, cons
return size;
}

/// get free space
unsigned long long get_free_space(char* path){

unsigned long long dest_size;
struct statvfs stvfs;
struct stat statP;
int debug=1;

if (statvfs(path, &stvfs) == -1) {
printf("WARNING: Unknown free space on the destination: %s\n",
strerror(errno));
return 0;
}

/* if file is a FIFO there is no point in checking the size */
if (!stat(path, &statP)) {
if (S_ISFIFO(statP.st_mode))
return 0;
} else {
printf("WARNING: Couldn't get file info because of the following error: %s\n",
strerror(errno));
}

dest_size = (unsigned long long)stvfs.f_frsize * stvfs.f_bfree;
if (!dest_size)
dest_size = (unsigned long long)stvfs.f_bsize * stvfs.f_bfree;
log_mesg(0, 0, 0, debug, "Destination have free space: %llu MB \n", print_size(dest_size, MBYTE));

return dest_size;
}

/// check free space
void check_free_space(char* path, unsigned long long size) {

@@ -318,6 +318,9 @@ extern int open_target(char* target, cmd_opt* opt);
/// check partition size
extern int check_size(int* ret, unsigned long long size);

/// get free size
extern unsigned long long get_free_space(char* path);

/// check free space
extern void check_free_space(char* path, unsigned long long size);

@@ -3,5 +3,5 @@
* WHETHER THEY ARE BUILT BY OTHERS OR DURING DEVELOPMENT OR FOR THE
* OFFICIAL PARTCLONE RELEASES.
*/
#define git_version "20affa9f2e14f1a2a307d0aa6ba8955c00800976"
#define git_version "2a0519953d4513280b1e5afb3d42926f052e3421"

2 comments on commit 2d1ee7c

@Sebastian-Roth

This comment has been minimized.

Copy link
Contributor

Sebastian-Roth replied Jan 4, 2020

@partclone Seems like this fix is breaking partclone.imager which uses read_super_blocks (from ddclone.c) as well. What happens is that it successfully captures an empty image because source device size is zero. Because it doesn't fail the test on partclone.imager didn't catch this problem.

As a quick test I re-enabled line 33 in ddclone.c and partclone.imager works perfectly fine again. As I don't know what you mean by the title "fix pip issue for dd +bt" I am not sure if this would break other things.

May I ask you to take a look at this and help us fix the problem as we make use of partclone.imager in FOGproject imagin solution: FOGProject/fos#35

@Sebastian-Roth

This comment has been minimized.

Copy link
Contributor

Sebastian-Roth replied Jan 11, 2020

@Thomas-Tsai Any chance you can take a look at this? See my above comment. Thanks in advance.

Please sign in to comment.
You can’t perform that action at this time.