}
if (nop_flag) {
printf(_("Writing block %llu\n"), (unsigned long long) block);
- seek_relative(fd, blocksize);
+ if (fd != 1)
+ seek_relative(fd, blocksize);
return;
}
count = write(fd, buf, blocksize);
static int print_progress(blk64_t num, blk64_t total)
{
- return printf(_("%llu / %llu blocks (%d%%)"), num, total,
+ return fprintf(stderr, _("%llu / %llu blocks (%d%%)"), num, total,
calc_percent(num, total));
}
exit(1);
}
if (show_progress) {
- printf(_("Copying "));
+ fprintf(stderr, _("Copying "));
bscount = print_progress(total_written, meta_blocks_count);
- fflush(stdout);
+ fflush(stderr);
last_update = time(NULL);
start_time = time(NULL);
}
kill (getpid(), SIGINT);
}
if (show_progress)
- printf ("\r");
- printf(_("Stopping now will destroy the filesystem, "
+ fputc('\r', stderr);
+ fprintf(stderr,
+ _("Stopping now will destroy the filesystem, "
"interrupt again if you are sure\n"));
if (show_progress) {
- printf(_("Copying "));
+ fprintf(stderr, _("Copying "));
bscount = print_progress(total_written,
meta_blocks_count);
- fflush(stdout);
+ fflush(stderr);
}
got_sigint = 0;
time_t duration;
last_update = time(NULL);
while (bscount--)
- printf("\b");
+ fputc('\b', stderr);
bscount = print_progress(total_written,
meta_blocks_count);
duration = time(NULL) - start_time;
total_written) - duration;
char buff[30];
strftime(buff, 30, "%T", gmtime(&est));
- bscount += printf(_(" %s remaining at %.2f MB/s"),
- buff, calc_rate(total_written,
- fs->blocksize,
- duration));
+ bscount += fprintf(stderr,
+ _(" %s remaining at %.2f MB/s"),
+ buff, calc_rate(total_written,
+ fs->blocksize,
+ duration));
}
- fflush (stdout);
+ fflush (stderr);
}
if ((blk >= fs->super->s_first_data_block) &&
ext2fs_test_block_bitmap2(meta_block_map, blk)) {
} else {
sparse_write:
if (fd == 1) {
- generic_write(fd, zero_buf, fs->blocksize, blk);
+ if (!nop_flag)
+ generic_write(fd, zero_buf,
+ fs->blocksize, blk);
continue;
}
sparse += fs->blocksize;
time_t duration = time(NULL) - start_time;
char buff[30];
while (bscount--)
- printf("\b");
+ fputc('\b', stderr);
strftime(buff, 30, "%T", gmtime(&duration));
- printf(_("\b\b\b\b\b\b\b\bCopied %llu / %llu blocks (%llu%%) "
- "in %s at %.2f MB/s \n"),
+ fprintf(stderr, _("\b\b\b\b\b\b\b\bCopied %llu / %llu "
+ "blocks (%llu%%) in %s at %.2f MB/s \n"),
total_written, meta_blocks_count,
calc_percent(total_written, meta_blocks_count), buff,
calc_rate(total_written, fs->blocksize, duration));
exit(1);
}
}
-
+ if (show_progress && (img_type != E2IMAGE_RAW)) {
+ fprintf(stderr, _("The -p option only supported "
+ "in raw mode\n"));
+ exit(1);
+ }
if (img_type)
write_raw_image_file(fs, fd, img_type, flags);
else