X-Git-Url: http://git.jankratochvil.net/?p=badblock-guess.git;a=blobdiff_plain;f=badblock-guess.c;h=eb1642c26d9f92814b0bcd5504a54d7a6228b347;hp=e7dacd238f5d766cd8df355bc153392da2eb61c6;hb=ad1f5c98ae9185db345a6f3f923941771e4c7bb5;hpb=6b440e700542984772b723f222f2d6d3426210b9 diff --git a/badblock-guess.c b/badblock-guess.c index e7dacd2..eb1642c 100644 --- a/badblock-guess.c +++ b/badblock-guess.c @@ -56,8 +56,8 @@ static void finish(void) G_GNUC_NORETURN; static int src_fd=-1,dst_fd=-1; static const char *src_name,*dst_name; -static ext2_loff_t src_len; /* in blocks! */ -static blk_t src_lenblk; /* ==src_len, just a different type */ +static ext2_loff_t src_len,dst_len; /* in blocks! */ +static blk_t src_lenblk,dst_lenblk; /* ==src_len,==dst_len, just a different type */ static ext2_loff_t stat_lastread,stat_todo,stat_bads,stat_largest,stat_todo_hunks; @@ -175,13 +175,13 @@ struct range *key,*neigh_left,*neigh_right; if (start>=end) return; key=node_build(start,end); - if ((neigh_left =g_tree_search(bad_tree,(GSearchFunc)search_end ,&start))) { + if ((neigh_left =g_tree_search(bad_tree,(GCompareFunc)search_end ,&start))) { g_assert(neigh_left->end==key->start); key->start=neigh_left->start; g_tree_remove(bad_tree,neigh_left); g_mem_chunk_free(node_memchunk,neigh_left); } - if ((neigh_right=g_tree_search(bad_tree,(GSearchFunc)search_start,&end ))) { + if ((neigh_right=g_tree_search(bad_tree,(GCompareFunc)search_start,&end ))) { g_assert(neigh_right->start==key->end); key->end=neigh_right->end; g_tree_remove(bad_tree,neigh_right); @@ -470,6 +470,23 @@ struct stat src_stat,dst_stat; fprintf(stderr,"\"%s\" length %llu <=0\n",src_name,(unsigned long long)src_len); exit(EXIT_FAILURE); } + if (dst_fd!=-1) { + if (ext2fs_get_device_size(dst_name,BLOCK,&dst_lenblk)) { + fprintf(stderr,"ext2fs_get_device_size(\"%s\",%d,...): %m\n",dst_name,BLOCK); + exit(EXIT_FAILURE); + } + dst_len=dst_lenblk; + if (dst_len<=0) { + fprintf(stderr,"\"%s\" length %llu <=0\n",dst_name,(unsigned long long)dst_len); + exit(EXIT_FAILURE); + } + if (dst_len