[PATCH 0/2] Some corrections on archosG9
Sascha Hauer
s.hauer at pengutronix.de
Mon Nov 26 03:00:30 EST 2012
On Sat, Nov 24, 2012 at 04:24:22AM +0100, Vicente Bergas wrote:
> In the patch series for archosG9 there were an attempt to improve file
> transfers by reading files at once, but finally this solution was discarded.
> Today I've checked the repository and found this solution there, perhaps this
> is a misunderstanding and it's corrected here.
> Sorry for not checking before.
>
> The other change is just the inverse: a submitted patch that was not applied.
>
> Vicente Bergas (2):
> uimage: fix misunderstanding in common/uimage.c
> archosg9: improve configuration
>
> arch/arm/boards/archosg9/env/config | 4 +++-
> arch/arm/boards/archosg9/env/init/usbboot | 9 +++++----
> arch/arm/configs/archosg9_defconfig | 2 +-
> common/uimage.c | 24 ------------------------
> 4 files changed, 9 insertions(+), 30 deletions(-)
Applied, thanks
As a side note, I still have this patch in my queue which fixes
read_file for tftp severs which do not pass the size. My tftp server at
home is one of these, I'll repost the patch once I tested it again.
Sascha
>From 1508618b3bc53abf122b9c7473f468e67b391b19 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer at pengutronix.de>
Date: Sun, 18 Mar 2012 17:59:46 +0100
Subject: [PATCH] read_file: Make it work on tftp servers which do not pass
size
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
fs/fs.c | 11 +++++++++++
fs/tftp.c | 5 ++++-
include/fs.h | 2 ++
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/fs/fs.c b/fs/fs.c
index db4621a..871dc26 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -41,10 +41,21 @@ void *read_file(const char *filename, size_t *size)
int fd;
struct stat s;
void *buf = NULL;
+ const char *tmpfile = "/_read_file_tmp";
+ int ret;
+again:
if (stat(filename, &s))
return NULL;
+ if (s.st_size == FILESIZE_MAX) {
+ ret = copy_file(filename, tmpfile, 0);
+ if (ret)
+ return NULL;
+ filename = tmpfile;
+ goto again;
+ }
+
buf = xzalloc(s.st_size + 1);
fd = open(filename, O_RDONLY);
diff --git a/fs/tftp.c b/fs/tftp.c
index b58d6fc..13e117a 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -590,7 +590,10 @@ static int tftp_stat(struct device_d *dev, const char *filename, struct stat *s)
return PTR_ERR(priv);
s->st_mode = S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO;
- s->st_size = priv->filesize;
+ if (priv->filesize)
+ s->st_size = priv->filesize;
+ else
+ s->st_size = FILESIZE_MAX;
tftp_do_close(priv);
diff --git a/include/fs.h b/include/fs.h
index 3d5714c..b6a46bb 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -147,6 +147,8 @@ int protect(int fd, size_t count, unsigned long offset, int prot);
int protect_file(const char *file, int prot);
void *memmap(int fd, int flags);
+#define FILESIZE_MAX ((size_t)-1)
+
#define PROT_READ 1
#define PROT_WRITE 2
--
1.7.10.4
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list