From: short <> Date: Tue, 10 Jun 2003 22:15:54 +0000 (+0000) Subject: Do partial transfer if destination device is shorter than the source X-Git-Url: http://git.jankratochvil.net/?p=badblock-guess.git;a=commitdiff_plain;h=ecd4617f5b30bc5816680650ef70b34073602d80 Do partial transfer if destination device is shorter than the source --- diff --git a/badblock-guess.c b/badblock-guess.c index e7dacd2..69103fd 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; @@ -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