Patchwork [U-Boot] UBIFS: Change ubifsload to set the filesize variable

login
register
mail settings
Submitter Bastian Ruppert
Date Sept. 5, 2011, 11:03 a.m.
Message ID <1315220629-9192-1-git-send-email-Bastian.Ruppert@Sewerin.de>
Download mbox | patch
Permalink /patch/113338/
State Changes Requested
Headers show

Comments

Bastian Ruppert - Sept. 5, 2011, 11:03 a.m.
This is the same behaviour like tftp or fatload command.

Signed-off-by: Bastian Ruppert <Bastian.Ruppert@Sewerin.de>
CC: kmpark@infradead.org
---
 fs/ubifs/ubifs.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
Wolfgang Denk - Sept. 5, 2011, 11:27 a.m.
Dear Bastian Ruppert,

In message <1315220629-9192-1-git-send-email-Bastian.Ruppert@Sewerin.de> you wrote:
> This is the same behaviour like tftp or fatload command.

> @@ -719,6 +720,9 @@ int ubifs_load(char *filename, u32 addr, u32 size)
>  	printf("Loading file '%s' to addr 0x%08x with size %d (0x%08x)...\n",
>  	       filename, addr, size, size);
>  
> +	sprintf(buf, "%lX", size);
> +	setenv("filesize", buf);
> +

Please insert this piece of code _after_ the file has successfully
been loaded to RAM (not before starting to load it).

Best regards,

Wolfgang Denk
Marek Vasut - Sept. 5, 2011, 1:12 p.m.
On Monday, September 05, 2011 01:03:49 PM Bastian Ruppert wrote:
> This is the same behaviour like tftp or fatload command.
> 
> Signed-off-by: Bastian Ruppert <Bastian.Ruppert@Sewerin.de>
> CC: kmpark@infradead.org
> ---
>  fs/ubifs/ubifs.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> index 5a5c739..2b9d2d2 100644
> --- a/fs/ubifs/ubifs.c
> +++ b/fs/ubifs/ubifs.c
> @@ -688,6 +688,7 @@ int ubifs_load(char *filename, u32 addr, u32 size)
>  	int i;
>  	int count;
>  	int last_block_size = 0;
> +	char buf [10];
> 
>  	c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY);
>  	/* ubifs_findfile will resolve symlinks, so we know that we get
> @@ -719,6 +720,9 @@ int ubifs_load(char *filename, u32 addr, u32 size)
>  	printf("Loading file '%s' to addr 0x%08x with size %d (0x%08x)...\n",
>  	       filename, addr, size, size);
> 
> +	sprintf(buf, "%lX", size);
> +	setenv("filesize", buf);
> +

Hi,

maybe you want to check set_local_var() too ?

>  	page.addr = (void *)addr;
>  	page.index = 0;
>  	page.inode = inode;
Wolfgang Denk - Sept. 5, 2011, 2:27 p.m.
Dear Marek Vasut,

In message <201109051512.48148.marek.vasut@gmail.com> you wrote:
>
> > +	setenv("filesize", buf);
> 
> maybe you want to check set_local_var() too ?

Yes, we should clean up all these auto-generated environment variables
one day.  But what you propose here is not a good approach:

(1) not all boards use the hush shell, and set_local_var() is only
    available there.
(2) if you make such a change, then you must make it everywhere, and
    you must make sure not to break existent use of these things.

Both is definitely out of the scope of this patch.

Best regards,

Wolfgang Denk
Marek Vasut - Sept. 5, 2011, 3:04 p.m.
On Monday, September 05, 2011 04:27:28 PM Wolfgang Denk wrote:
> Dear Marek Vasut,
> 
> In message <201109051512.48148.marek.vasut@gmail.com> you wrote:
> > > +	setenv("filesize", buf);
> > 
> > maybe you want to check set_local_var() too ?
> 
> Yes, we should clean up all these auto-generated environment variables
> one day.  But what you propose here is not a good approach:
> 
> (1) not all boards use the hush shell, and set_local_var() is only
>     available there.
> (2) if you make such a change, then you must make it everywhere, and
>     you must make sure not to break existent use of these things.
> 
> Both is definitely out of the scope of this patch.

You're definitelly right on this thing.

> 
> Best regards,
> 
> Wolfgang Denk

Patch

diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 5a5c739..2b9d2d2 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -688,6 +688,7 @@  int ubifs_load(char *filename, u32 addr, u32 size)
 	int i;
 	int count;
 	int last_block_size = 0;
+	char buf [10];
 
 	c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY);
 	/* ubifs_findfile will resolve symlinks, so we know that we get
@@ -719,6 +720,9 @@  int ubifs_load(char *filename, u32 addr, u32 size)
 	printf("Loading file '%s' to addr 0x%08x with size %d (0x%08x)...\n",
 	       filename, addr, size, size);
 
+	sprintf(buf, "%lX", size);
+	setenv("filesize", buf);
+
 	page.addr = (void *)addr;
 	page.index = 0;
 	page.inode = inode;