mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Teresa Gámez" <t.gamez@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCH] lib: Fix copy_file when filesize is FILESIZE_MAX
Date: Fri, 27 Sep 2013 09:33:21 +0200	[thread overview]
Message-ID: <1380267201-17783-1-git-send-email-t.gamez@phytec.de> (raw)

Using tftp command does not work proper when files
have FILESIZE_MAX, as copy_file and show_progress
can not handle it. Check the file size for FILESIZE_MAX
and handle it as file size = 0.

Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
---
 lib/copy_file.c     |    8 ++++++--
 lib/show_progress.c |    5 +++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/copy_file.c b/lib/copy_file.c
index ab3d845..55dee38 100644
--- a/lib/copy_file.c
+++ b/lib/copy_file.c
@@ -63,8 +63,12 @@ int copy_file(const char *src, const char *dst, int verbose)
 			total += w;
 		}
 
-		if (verbose)
-			show_progress(statbuf.st_size ? total : total / 16384);
+		if (verbose) {
+			if (statbuf.st_size && statbuf.st_size != FILESIZE_MAX)
+				show_progress(total);
+			else
+				show_progress(total / 16384);
+		}
 	}
 
 	ret = 0;
diff --git a/lib/show_progress.c b/lib/show_progress.c
index bc067ea..98dc849 100644
--- a/lib/show_progress.c
+++ b/lib/show_progress.c
@@ -18,6 +18,7 @@
  */
 
 #include <common.h>
+#include <fs.h>
 #include <progress.h>
 #include <asm-generic/div64.h>
 #include <linux/stringify.h>
@@ -37,7 +38,7 @@ void show_progress(int now)
 		return;
 	}
 
-	if (progress_max) {
+	if (progress_max && progress_max != FILESIZE_MAX) {
 		uint64_t tmp = (int64_t)now * HASHES_PER_LINE;
 		do_div(tmp, progress_max);
 		now = tmp;
@@ -56,7 +57,7 @@ void init_progression_bar(int max)
 	printed = 0;
 	progress_max = max;
 	spin = 0;
-	if (progress_max)
+	if (progress_max && progress_max != FILESIZE_MAX)
 		printf("\t[%"__stringify(HASHES_PER_LINE)"s]\r\t[", "");
 	else
 		printf("\t");
-- 
1.7.0.4


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

             reply	other threads:[~2013-09-27  7:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-27  7:33 Teresa Gámez [this message]
2013-09-27 14:20 ` Sascha Hauer

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=1380267201-17783-1-git-send-email-t.gamez@phytec.de \
    --to=t.gamez@phytec.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