mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 5/5] copy_file: limit progress bar to sensible limits
Date: Sun, 19 Feb 2012 18:58:08 +0100	[thread overview]
Message-ID: <1329674288-25583-6-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1329674288-25583-1-git-send-email-s.hauer@pengutronix.de>

When copying in verbose mode from a tftp server we might
not know the size of the file being transfered. In this
case print one progress item per 16k instead of one for
each single byte.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 lib/copy_file.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/copy_file.c b/lib/copy_file.c
index 967806c..484b2ca 100644
--- a/lib/copy_file.c
+++ b/lib/copy_file.c
@@ -21,6 +21,7 @@ int copy_file(const char *src, const char *dst, int verbose)
 	int ret = 1;
 	void *buf;
 	int total = 0;
+	struct stat statbuf;
 
 	rw_buf = xmalloc(RW_BUF_SIZE);
 
@@ -37,8 +38,6 @@ int copy_file(const char *src, const char *dst, int verbose)
 	}
 
 	if (verbose) {
-		struct stat statbuf;
-
 		if (stat(src, &statbuf) < 0)
 			statbuf.st_size = 0;
 
@@ -67,7 +66,7 @@ int copy_file(const char *src, const char *dst, int verbose)
 		}
 
 		if (verbose)
-			show_progress(total);
+			show_progress(statbuf.st_size ? total : total / 16384);
 	}
 
 	ret = 0;
-- 
1.7.9


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2012-02-19 17:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-19 17:58 tftp filesystem support Sascha Hauer
2012-02-19 17:58 ` [PATCH 1/5] Add suport for tftp as a filesystem Sascha Hauer
2012-02-20  4:54   ` Jean-Christophe PLAGNIOL-VILLARD
2012-02-20 18:16     ` Sascha Hauer
2012-02-19 17:58 ` [PATCH 2/5] make uimages work on tftpfs Sascha Hauer
2012-02-19 17:58 ` [PATCH 3/5] net: let net_udp_get_payload return void * Sascha Hauer
2012-02-19 17:58 ` [PATCH 4/5] add string for -ETIMEDOUT Sascha Hauer
2012-02-19 17:58 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1329674288-25583-6-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox