fw_printenv - changed MTD include and fixed compiler warnings
PATCH 1/1 fw_printenv - changed MTD include and fixed compiler warnings
This user-space program was including a kernel header, which prevented compilation. Compiler warnings were 'fixed' by some casts. If anyone stores binary data in environment variables this may not work.
The DULG mentions a 'fw_setenv' command, which doesn't technically exist. The Makefile was modified to create a link that becomes this command.
--- tools/env/Makefile | 3 ++- tools/env/README | 3 ++- tools/env/fw_env.c | 16 ++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-)
tools/env/Makefile +2 -1
@@ -32,9 +32,10 @@ all: $(obj)fw_printenv $(obj)fw_printenv: $(SRCS) $(HEADERS) $(CROSS_COMPILE)gcc $(CPPFLAGS) $(SRCS) -o $(obj)fw_printenv + ln -s $(obj)fw_printenv $(obj)fw_setenv clean: - rm -f $(obj)fw_printenv $(obj)crc32.c + rm -f $(obj)fw_printenv $(obj)crc32.c $(obj)fw_setenv $(obj)crc32.c: ln -s $(src)../../lib_generic/crc32.c $(obj)crc32.c
tools/env/README +1 -1
@@ -34,7 +34,8 @@ The DEVICEx_NAME constants define which be used to access the environment. The DEVICEx_OFFSET constants define the environment offset within the -MTD character device. +MTD character device. Note that if your Linux kernel is compiled with
MTD
+PARTITION support, this value will probably be 0.
ENVx_SIZE defines the size in bytes taken by the environment, which may be less then flash sector size, if the environment takes less
tools/env/fw_env.c +8 -8
@@ -31,7 +31,7 @@ #include <sys/types.h>#include <sys/ioctl.h> #include <sys/stat.h> #include <unistd.h> -#include <linux/mtd/mtd.h> +#include <mtd/mtd-user.h> #include "fw_env.h" typedef unsigned char uchar ;
@@ -40,7 +40,7 @@ #define CMD_GETENV "fw_printenv"#define CMD_SETENV "fw_setenv" typedef struct envdev_s { - uchar devname[16]; /* Device name */ + char devname[16]; /* Device name */ ulong devoff; /* Device offset */ ulong env_size; /* environment size */ ulong erase_size; /* device erase size */
@@ -241,8 +241,8 @@ void fw_printenv (int argc, char *argv[] }for (i =1 ; i < argc; ++i) {/* print single env variables */ -uchar *name = argv[i]; -uchar *val =NULL ; +char *name = argv[i]; +char *val =NULL ;for (env = environment.data; *env; env = nxt +1 ) {
@@ -253,7 +253,7 @@ void fw_printenv (int argc, char *argv[]return ; } } - val =envmatch (name, env); + val = (char *)envmatch ((uchar *)name, env);if (val) {if (!n_flag) {fputs (name, stdout);
@@ -281,7 +281,7 @@ int fw_setenv (int argc, char *argv[])int i, len;uchar *env, *nxt;uchar *oldval =NULL ; -uchar *name; +char *name;if (argc <2 ) {return (EINVAL );
@@ -303,7 +303,7 @@ int fw_setenv (int argc, char *argv[])return (EINVAL ); } } -if ((oldval =envmatch (name, env)) !=NULL ) +if ((oldval =envmatch ((uchar *)name, env)) !=NULL )break ; }
@@ -361,7 +361,7 @@ int fw_setenv (int argc, char *argv[])while ((*env = *name++) !='\0' ) env++;for (i =2 ; i < argc; ++i) { -uchar *val = argv[i]; +char *val = argv[i]; *env = (i ==2 ) ?'=' :' ' ;while ((*++env = *val++) !='\0' );
Signature · 1 line
1.4.1
PATCH 1/1 fw_printenv - changed MTD include and fixed compiler warnings
Quoted 3 lines · In message <[email protected]> you wrote:
This user-space program was including a kernel header, which prevented compilation. Compiler warnings were 'fixed' by some casts. If anyone stores binary data in environment variables this may not work.
IIRC this change breaks building against a 2.4 kernel tree.
Or did you test this in a 2.4 kernel environment?
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, HRB 165235 Munich, CEO: Wolfgang Denk Office: Kirchenstr. 5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de As of 1992, they're called European Economic Community fries.
PATCH 1/1 fw_printenv - changed MTD include and fixed compiler warnings
Quoted 8 lines · Wolfgang Denk
Quoted 3 lines · In message <[email protected]> you wrote:
This user-space program was including a kernel header, which prevented compilation. Compiler warnings were 'fixed' by some casts. If anyone stores binary data in environment variables this may not work.
IIRC this change breaks building against a 2.4 kernel tree.
Or did you test this in a 2.4 kernel environment?
Sorry, 2.6 only. I can add a test for kernel version, I guess.