Lines Matching refs:TT
87 (TT.start.tv_sec * 1000000 + TT.start.tv_usec))/1000000.0; in status()
89 if (TT.show_records) in status()
91 TT.in_full, TT.in_part, TT.out_full, TT.out_part); in status()
93 if (TT.show_xfer) { in status()
94 human_readable(toybuf, TT.bytes, HR_SPACE|HR_B); in status()
95 fprintf(stderr, "%llu bytes (%s) copied, ", TT.bytes, toybuf); in status()
96 human_readable(toybuf, TT.bytes/seconds, HR_SPACE|HR_B); in status()
109 TT.out.bp = TT.out.buff; in write_out()
110 while (TT.out.count) { in write_out()
111 ssize_t nw = writeall(TT.out.fd, TT.out.bp, ((all)? TT.out.count : TT.out.sz)); in write_out()
114 if (nw <= 0) perror_exit("%s: write error", TT.out.name); in write_out()
115 if (nw == TT.out.sz) TT.out_full++; in write_out()
116 else TT.out_part++; in write_out()
117 TT.out.count -= nw; in write_out()
118 TT.out.bp += nw; in write_out()
119 TT.bytes += nw; in write_out()
120 if (TT.out.count < TT.out.sz) break; in write_out()
122 if (TT.out.count) memmove(TT.out.buff, TT.out.bp, TT.out.count); //move remainder to front in write_out()
144 TT.show_xfer = TT.show_records = 1; in dd_main()
145 TT.c_count = ULLONG_MAX; in dd_main()
147 TT.in.sz = TT.out.sz = 512; //default io block size in dd_main()
152 else if (strstart(&arg, "ibs=")) TT.in.sz = atolx_range(arg, 1, LONG_MAX); in dd_main()
153 else if (strstart(&arg, "obs=")) TT.out.sz = atolx_range(arg, 1, LONG_MAX); in dd_main()
155 TT.c_count = atolx_range(arg, 0, LLONG_MAX); in dd_main()
156 else if (strstart(&arg, "if=")) TT.in.name = arg; in dd_main()
157 else if (strstart(&arg, "of=")) TT.out.name = arg; in dd_main()
159 TT.out.offset = atolx_range(arg, 0, LLONG_MAX); in dd_main()
161 TT.in.offset = atolx_range(arg, 0, LLONG_MAX); in dd_main()
163 if (!strcmp(arg, "noxfer")) TT.show_xfer = 0; in dd_main()
164 else if (!strcmp(arg, "none")) TT.show_xfer = TT.show_records = 0; in dd_main()
167 parse_flags("conv", arg, dd_conv, ARRAY_LEN(dd_conv), &TT.conv); in dd_main()
168 fprintf(stderr, "conv=%x\n", TT.conv); in dd_main()
170 parse_flags("iflag", arg, dd_iflag, ARRAY_LEN(dd_iflag), &TT.iflag); in dd_main()
172 parse_flags("oflag", arg, dd_oflag, ARRAY_LEN(dd_oflag), &TT.oflag); in dd_main()
175 if (bs) TT.in.sz = TT.out.sz = bs; in dd_main()
180 gettimeofday(&TT.start, NULL); in dd_main()
184 TT.in.buff = TT.out.buff = xmalloc(TT.in.sz + (bs ? 0 : TT.out.sz)); in dd_main()
185 TT.in.bp = TT.out.bp = TT.in.buff; in dd_main()
187 if (!TT.in.name) TT.in.name = "stdin"; in dd_main()
188 else TT.in.fd = xopenro(TT.in.name); in dd_main()
190 if (TT.conv & _DD_conv_notrunc) trunc = 0; in dd_main()
192 if (!TT.out.name) { in dd_main()
193 TT.out.name = "stdout"; in dd_main()
194 TT.out.fd = 1; in dd_main()
195 } else TT.out.fd = xcreate(TT.out.name, in dd_main()
196 O_WRONLY|O_CREAT|(trunc*!TT.out.offset), 0666); in dd_main()
199 if (TT.in.offset) { in dd_main()
200 off_t off = TT.in.offset; in dd_main()
202 if (!(TT.iflag & _DD_iflag_skip_bytes)) off *= TT.in.sz; in dd_main()
203 if (lseek(TT.in.fd, off, SEEK_CUR) < 0) { in dd_main()
205 int chunk = off < TT.in.sz ? off : TT.in.sz; in dd_main()
206 ssize_t n = read(TT.in.fd, TT.in.bp, chunk); in dd_main()
209 perror_msg("%s", TT.in.name); in dd_main()
210 if (TT.conv & _DD_conv_noerror) status(); in dd_main()
213 xprintf("%s: Can't skip\n", TT.in.name); in dd_main()
224 bs = TT.out.offset; in dd_main()
225 if (!(TT.oflag & _DD_oflag_seek_bytes)) bs *= TT.out.sz; in dd_main()
229 xlseek(TT.out.fd, bs, SEEK_CUR); in dd_main()
230 if (trunc && !fstat(TT.out.fd, &st) && S_ISREG(st.st_mode) in dd_main()
231 && ftruncate(TT.out.fd, bs)) perror_exit("unexpected ftruncate failure"); in dd_main()
234 unsigned long long bytes_left = TT.c_count; in dd_main()
235 if (TT.c_count != ULLONG_MAX && !(TT.iflag & _DD_iflag_count_bytes)) { in dd_main()
236 bytes_left *= TT.in.sz; in dd_main()
239 int chunk = bytes_left < TT.in.sz ? bytes_left : TT.in.sz; in dd_main()
242 TT.in.bp = TT.in.buff + TT.in.count; in dd_main()
243 if (TT.conv & _DD_conv_sync) memset(TT.in.bp, 0, TT.in.sz); in dd_main()
244 if (!(n = read(TT.in.fd, TT.in.bp, chunk))) break; in dd_main()
248 perror_msg("%s: read error", TT.in.name); in dd_main()
249 if (!(TT.conv & _DD_conv_noerror)) exit(1); in dd_main()
251 xlseek(TT.in.fd, TT.in.sz, SEEK_CUR); in dd_main()
252 if (!(TT.conv & _DD_conv_sync)) continue; in dd_main()
254 n = TT.in.sz; in dd_main()
256 if (n == TT.in.sz) { in dd_main()
257 TT.in_full++; in dd_main()
258 TT.in.count += n; in dd_main()
260 TT.in_part++; in dd_main()
261 if (TT.conv & _DD_conv_sync) TT.in.count += TT.in.sz; in dd_main()
262 else TT.in.count += n; in dd_main()
266 TT.out.count = TT.in.count; in dd_main()
269 TT.in.count = 0; in dd_main()
273 if (TT.in.count >= TT.out.sz) { in dd_main()
275 TT.in.count = TT.out.count; in dd_main()
278 if (TT.out.count) write_out(1); //write any remaining input blocks in dd_main()
279 if ((TT.conv & _DD_conv_fsync) && fsync(TT.out.fd)<0) in dd_main()
280 perror_exit("%s: fsync", TT.out.name); in dd_main()
282 close(TT.in.fd); in dd_main()
283 close(TT.out.fd); in dd_main()
284 if (TT.in.buff) free(TT.in.buff); in dd_main()