Skip to contentSkip to conversation

UBIFS: Change ubifsload to set the filesize variable

PATCH Superseded Bastian Ruppert 4 participants 10 messages Sep 5, 2011 – Sep 10, 2011 UBI file system (UBIFS)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 UBIFS: Change ubifsload to set the filesize variable

This is the same behaviour like tftp or fatload command.

CC kmpark at infradead.org
---
 fs/ubifs/ubifs.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
fs/ubifs/ubifs.c +4 -0
index 5a5c739..2b9d2d2 100644
@@ -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;
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 1/1 UBIFS: Change ubifsload to set the filesize variable

Dear Bastian Ruppert,

fs/ubifs/ubifs.c int ubifs_load(char *filename, u32 addr, u32 size) · line 725

Quoted 9 lines · In message <[email protected]> you…

This is the same behaviour like tftp or fatload command.

fs/ubifs/ubifs.c +3 -0
@@ -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

Signature · 8 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I wrote my name at the top of the page. I wrote down  the  number  of
the  question  ``1''.  After much reflection I put a bracket round it
thus ``(1)''. But thereafter I could not think of anything  connected
with it that was either relevant or true.
                        - Sir Winston Churchill _My Early Life_ ch. 2
#2 lore raw

PATCH v2 1/1 UBIFS: Change ubifsload to set the filesize variable

In reply to Bastian Ruppert

This is the same behaviour like tftp or fatload command.

CC kmpark at infradead.org
---
 fs/ubifs/ubifs.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
fs/ubifs/ubifs.c +5 -1
index 5a5c739..75a2edc 100644
@@ -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
@@ -739,8 +740,11 @@ int ubifs_load(char *filename, u32 addr, u32 size)
 
 	if (err)
 		printf("Error reading file '%s'\n", filename);
-	else
+	else {
+	        sprintf(buf, "%lX", size);
+		setenv("filesize", buf);
 		printf("Done\n");
+	}
 
 	ubifs_iput(inode);
 
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH v2 1/1 UBIFS: Change ubifsload to set the filesize variable

Hi Bastian,

Quoted 4 lines

This is the same behaviour like tftp or fatload command.

CC kmpark at infradead.org

Cheers
Detlev

Signature · 8 lines
Paul Simon sang "Fifty Ways to Lose Your Lover", because quite
frankly, "A Million Ways to Tell a Developer He Is a D*ckhead"
doesn't scan nearly as well.  But I'm sure he thought about it.
                            -- linux/Documentation/ManagementStyle
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
#4 lore raw

PATCH v2 1/1 UBIFS: Change ubifsload to set the filesize variable

In reply to Bastian Ruppert

Dear Bastian Ruppert,

Quoted 7 lines · In message <[email protected]> you…

This is the same behaviour like tftp or fatload command.

CC kmpark at infradead.org
---
 fs/ubifs/ubifs.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
When choosing between two evils, I always like to take the  one  I've
never tried before.                     -- Mae West, "Klondike Annie"
#5 lore raw

PATCH 1/1 UBIFS: fix warning: format '%lX' expects type 'long unsigned int'

In reply to Bastian Ruppert

Commit 46d7274 "UBIFS: Change ubifsload to set the filesize variable" introduced the follwing compiler warning:

ubifs.c: In function 'ubifs_load':
ubifs.c:742: warning: format '%lX' expects type 'long unsigned int', but argument 3 has type 'u32'

Cc Bastian Ruppert <[email protected]>
---
 fs/ubifs/ubifs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/ubifs/ubifs.c +1 -1
index 2e6313a..604eb8f 100644
@@ -739,7 +739,7 @@ int ubifs_load(char *filename, u32 addr, u32 size)
 	if (err)
 		printf("Error reading file '%s'\n", filename);
 	else {
-	        sprintf(buf, "%lX", size);
+	        sprintf(buf, "%X", size);
 		setenv("filesize", buf);
 		printf("Done\n");
 	}
Signature · 1 line
1.7.6
#6 lore raw

PATCH 1/1 UBIFS: fix warning: format '%lX' expects type 'long unsigned int'

Dear Wolfgang Denk,

Quoted 11 lines · In message <[email protected]> you wrote:

Commit 46d7274 "UBIFS: Change ubifsload to set the filesize variable" introduced the follwing compiler warning:

ubifs.c: In function 'ubifs_load':
ubifs.c:742: warning: format '%lX' expects type 'long unsigned int', but argument 3 has type 'u32'

Cc Bastian Ruppert <[email protected]>
---
 fs/ubifs/ubifs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Premature optimization is the root of all evil.         -- D.E. Knuth
#7 lore raw

PATCH 1/1 UBIFS: Change ubifsload to set the filesize variable

In reply to Bastian Ruppert
Quoted 21 lines · Bastian Ruppert

This is the same behaviour like tftp or fatload command.

CC kmpark at infradead.org
---
 fs/ubifs/ubifs.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
fs/ubifs/ubifs.c +1 -0
index 5a5c739..2b9d2d2 100644
@@ -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

fs/ubifs/ubifs.c int ubifs_load(char *filename, u32 addr, u32 size) · line 725

Quoted 6 lines
fs/ubifs/ubifs.c +3 -0
@@ -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 ?

Quoted 3 lines
fs/ubifs/ubifs.c +0 -0
 	page.addr = (void *)addr;
 	page.index = 0;
 	page.inode = inode;
#8 lore raw

PATCH 1/1 UBIFS: Change ubifsload to set the filesize variable

Dear Marek Vasut,

Quoted 4 lines · In message <[email protected]> you wrote:

fs/ubifs/ubifs.c int ubifs_load(char *filename, u32 addr, u32 size) · line 724

Quoted 2 lines
fs/ubifs/ubifs.c +1 -0
+	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

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Quote from a recent meeting:   "We are going to continue having these
meetings everyday until I find out why no work is getting done."
#9 lore raw

PATCH 1/1 UBIFS: Change ubifsload to set the filesize variable

Quoted 10 lines · Wolfgang Denk

Dear Marek Vasut,

Quoted 3 lines · In message <[email protected]> you wrote:

fs/ubifs/ubifs.c int ubifs_load(char *filename, u32 addr, u32 size) · line 724

Quoted 1 line
fs/ubifs/ubifs.c +1 -0
+	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:

Quoted 6 lines

(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.

Quoted 4 lines

Best regards,

Wolfgang Denk