]>
Commit | Line | Data |
---|---|---|
d716123c ER |
1 | diff -u ../ddrescue-1.2/ddrescue.cc ./ddrescue.cc |
2 | --- ../ddrescue-1.2/ddrescue.cc 2006-03-16 19:14:05.000000000 +0100 | |
3 | +++ ./ddrescue.cc 2006-08-14 16:48:54.000000000 +0200 | |
4 | @@ -28,6 +28,7 @@ | |
5 | #include <queue> | |
6 | #include <signal.h> | |
7 | #include <unistd.h> | |
8 | +#include <inttypes.h> | |
9 | ||
10 | #include "ddrescue.h" | |
11 | ||
12 | @@ -190,19 +191,20 @@ | |
13 | } | |
14 | ||
15 | ||
16 | -void show_status( const long long ipos, const long long opos, | |
17 | +void show_status( std::vector< Sblock > & sblock_vector, | |
18 | + const long long ipos, const long long opos, | |
19 | const long long recsize, const long long errsize, | |
20 | - const int errors, const char * msg, bool force ) throw() | |
21 | + const int errors, const char * msg, bool force, int hardbs ) throw() | |
22 | { | |
23 | static const char * const up = "\x1b[A"; | |
24 | static long long a_rate = 0, c_rate = 0, first_size = 0, last_size = 0; | |
25 | static long long last_ipos = 0, last_opos = 0; | |
26 | static time_t t0 = 0, t1 = 0; | |
27 | static int oldlen = 0; | |
28 | + static int first= 1; | |
29 | if( t0 == 0 ) | |
30 | { | |
31 | t0 = t1 = std::time( 0 ); first_size = last_size = recsize; force = true; | |
32 | - std::printf( "\n\n\n" ); | |
33 | } | |
34 | ||
35 | if( ipos >= 0 ) last_ipos = ipos; | |
36 | @@ -216,7 +218,59 @@ | |
37 | c_rate = ( recsize - last_size ) / ( t2 - t1 ); | |
38 | t1 = t2; last_size = recsize; | |
39 | } | |
40 | - std::printf( "\r%s%s%s", up, up, up ); | |
41 | + if(!first) | |
42 | + std::printf( "\r%s%s%s", up, up, up ); | |
43 | + if(width && height) | |
44 | + { | |
45 | + int cell_count= width*height; | |
46 | + int64_t block_count=sblock_vector[sblock_vector.size()-1].end() / hardbs; | |
47 | + | |
48 | + cell_count= block_count / ((block_count + cell_count - 1) / cell_count); | |
49 | + | |
50 | + if(!first) | |
51 | + for(int i=0; i<cell_count; i+= width) | |
52 | + std::printf(up); | |
53 | + | |
54 | + int j=0; | |
55 | + for(int i=0; i<cell_count; i++) | |
56 | + { | |
57 | + int64_t start= i *hardbs*block_count / cell_count; | |
58 | + int64_t end = (i+1)*hardbs*block_count / cell_count; | |
59 | + int non_tried=0; | |
60 | + int bad=0; | |
61 | + int ok=0; | |
62 | + for(; j<sblock_vector.size() && sblock_vector[j].end() <= start; j++); | |
63 | + for(; j<sblock_vector.size() && sblock_vector[j].pos() < end; j++) | |
64 | + { | |
65 | + Sblock & sb = sblock_vector[j]; | |
66 | + int size= (std::min(end, (int64_t)sb.end()) - std::max(start, (int64_t)sb.pos()) ) / hardbs; | |
67 | + switch( sb.status() ) | |
68 | + { | |
69 | + case Sblock::non_tried : non_tried+= size; break; | |
3b01456d | 70 | + case Sblock::non_split : |
d716123c ER |
71 | + case Sblock::bad_block : bad += size; break; |
72 | + case Sblock::done : ok += size; break; | |
73 | + } | |
74 | + } | |
75 | + j--; | |
76 | + | |
77 | + if(opos*(int64_t)cell_count / (hardbs*block_count) == i) | |
78 | + std::printf("\x1b[05;04m"); | |
79 | + | |
80 | + if(non_tried) std::printf("?"); | |
81 | + else if( !bad && ok) std::printf(" "); | |
82 | + else if( bad && !ok) std::printf("\x1b[01;31mX"); | |
83 | + else if( !bad && !ok) std::printf("!"); | |
84 | + else if( bad > 3*ok) std::printf("\x1b[31mx"); | |
85 | + else if( bad > ok) std::printf("\x1b[01;33m+"); | |
86 | + else if(3*bad > ok) std::printf("\x1b[33m-"); | |
87 | + else std::printf("\x1b[32m."); | |
88 | + std::printf("\x1b[00m"); | |
89 | + | |
90 | + if(i%width == width - 1 || i+1 == cell_count) | |
91 | + std::printf("\n"); | |
92 | + } | |
93 | + } | |
94 | std::printf( "rescued: %10sB,", format_num( recsize ) ); | |
95 | std::printf( " errsize:%9sB,", format_num( errsize, 99999 ) ); | |
96 | std::printf( " current rate: %9sB/s\n", format_num( c_rate, 99999 ) ); | |
97 | @@ -231,4 +285,5 @@ | |
98 | oldlen = len; | |
99 | std::fflush( stdout ); | |
100 | } | |
101 | + first=0; | |
102 | } | |
d716123c ER |
103 | diff -u ../ddrescue-1.2/ddrescue.h ./ddrescue.h |
104 | --- ../ddrescue-1.2/ddrescue.h 2006-03-29 18:29:46.000000000 +0200 | |
105 | +++ ./ddrescue.h 2006-08-06 09:18:41.000000000 +0200 | |
106 | @@ -105,15 +105,18 @@ | |
107 | int do_rescue( const int ides, const int odes ) throw(); | |
108 | }; | |
109 | ||
110 | +extern int width ; | |
111 | +extern int height; | |
112 | ||
113 | // Defined in ddrescue.cc | |
114 | // | |
115 | const char * format_num( long long num, long long max = 999999, | |
116 | const int set_prefix = 0 ) throw(); | |
117 | void set_handler() throw(); | |
118 | -void show_status( const long long ipos, const long long opos, | |
119 | +void show_status( std::vector< Sblock > & sblock_vector, | |
120 | + const long long ipos, const long long opos, | |
121 | const long long recsize, const long long errsize, | |
122 | - const int errors, const char * msg = 0, bool force = false ) throw(); | |
123 | + const int errors, const char * msg = 0, bool force = false, int hardbs = 512 ) throw(); | |
124 | ||
125 | ||
126 | // Defined in main.cc | |
d716123c ER |
127 | diff -u ../ddrescue-1.2/logbook.cc ./logbook.cc |
128 | --- ../ddrescue-1.2/logbook.cc 2006-04-03 12:52:39.000000000 +0200 | |
129 | +++ ./logbook.cc 2006-08-06 09:16:37.000000000 +0200 | |
130 | @@ -300,8 +300,8 @@ | |
131 | } | |
132 | if( _verbosity >= 0 ) | |
133 | { | |
134 | - show_status( chip.pos(), chip.pos() + _offset, recsize, errsize, errors, | |
135 | - "Copying data...", first_post ); first_post = false; | |
136 | + show_status( sblock_vector, chip.pos(), chip.pos() + _offset, recsize, errsize, errors, | |
137 | + "Copying data...", first_post, _hardbs ); first_post = false; | |
138 | } | |
139 | std::vector< Sblock > result; | |
140 | int retval = copy_non_tried_block( chip, result ); | |
141 | @@ -354,8 +354,8 @@ | |
142 | } | |
143 | if( _verbosity >= 0 ) | |
144 | { | |
145 | - show_status( chip.pos(), chip.pos() + _offset, recsize, errsize, errors, | |
146 | - "Splitting error areas...", first_post ); first_post = false; | |
147 | + show_status( sblock_vector, chip.pos(), chip.pos() + _offset, recsize, errsize, errors, | |
148 | + "Splitting error areas...", first_post, _hardbs ); first_post = false; | |
149 | } | |
150 | std::vector< Sblock > result; | |
151 | int retval = copy_bad_block( chip, result ); | |
152 | @@ -413,8 +413,8 @@ | |
153 | } | |
154 | if( _verbosity >= 0 ) | |
155 | { | |
156 | - show_status( chip.pos(), chip.pos() + _offset, recsize, errsize, errors, | |
157 | - msgbuf, first_post ); first_post = false; | |
158 | + show_status( sblock_vector, chip.pos(), chip.pos() + _offset, recsize, errsize, errors, | |
159 | + msgbuf, first_post, _hardbs ); first_post = false; | |
160 | } | |
161 | std::vector< Sblock > result; | |
162 | int retval = copy_bad_block( chip, result ); | |
163 | @@ -532,7 +532,7 @@ | |
164 | if( retval < 0 ) { msg = "Interrupted by user"; retval = 0; } | |
165 | else if( _max_errors >= 0 && errors > _max_errors ) | |
166 | msg = "Too many errors in input file"; | |
167 | - show_status( -1, -1, recsize, errsize, errors, msg, true ); | |
168 | + show_status( sblock_vector, -1, -1, recsize, errsize, errors, msg, true, _hardbs ); | |
169 | std::fputc( '\n', stdout ); | |
170 | } | |
171 | compact_sblock_vector( sblock_vector ); | |
d716123c ER |
172 | diff -u ../ddrescue-1.2/main.cc ./main.cc |
173 | --- ../ddrescue-1.2/main.cc 2006-04-03 12:48:36.000000000 +0200 | |
174 | +++ ./main.cc 2006-08-14 16:26:51.000000000 +0200 | |
175 | @@ -39,6 +39,9 @@ | |
176 | #include "ddrescue.h" | |
177 | ||
178 | ||
179 | +int width = 0; | |
180 | +int height= 0; | |
181 | + | |
182 | namespace { | |
183 | ||
184 | // Date of this version: 2006-04-03 | |
185 | @@ -72,6 +75,8 @@ | |
186 | std::printf( " -s, --max-size=<bytes> maximum size of data to be copied\n" ); | |
187 | std::printf( " -t, --truncate truncate output file\n" ); | |
188 | std::printf( " -v, --verbose verbose operation\n" ); | |
189 | + std::printf( " -W, --width ascii art width\n" ); | |
190 | + std::printf( " -H, --height ascii art height\n" ); | |
191 | std::printf( "Numbers may be followed by a multiplier: b = blocks, k = kB = 10^3 = 1000,\n" ); | |
192 | std::printf( "Ki = KiB = 2^10 = 1024, M = 10^6, Mi = 2^20, G = 10^9, Gi = 2^30, etc...\n" ); | |
193 | std::printf( "\nReport bugs to bug-ddrescue@gnu.org\n"); | |
194 | @@ -203,6 +208,8 @@ | |
195 | { 't', "truncate", Arg_parser::no }, | |
196 | { 'v', "verbose", Arg_parser::no }, | |
197 | { 'V', "version", Arg_parser::no }, | |
198 | + { 'W', "width", Arg_parser::yes }, | |
199 | + { 'H', "height", Arg_parser::yes }, | |
200 | { 0 , 0, Arg_parser::no } }; | |
201 | ||
202 | Arg_parser parser( argc, argv, options ); | |
203 | @@ -231,6 +238,8 @@ | |
204 | case 's': max_size = getnum( arg, hardbs, -1 ); break; | |
205 | case 't': o_trunc = O_TRUNC; break; | |
206 | case 'v': verbosity = 1; break; | |
207 | + case 'W': width = getnum( arg, 0, 1, INT_MAX ); break; | |
208 | + case 'H': height = getnum( arg, 0, 1, INT_MAX ); break; | |
209 | case 'V': show_version(); return 0; | |
210 | default : internal_error( "uncaught option" ); | |
211 | } |