Skip to content
Snippets Groups Projects
Commit 229695fe authored by Tom Rini's avatar Tom Rini
Browse files

fw_env.c: Switch get_config to use '%ms' in sscanf


We currently limit ourself to 16 characters for the device name to read
the environment from.  This is insufficient for /dev/mmcblk0boot1 to
work for example.  Switch to '%ms' which gives us a dynamically
allocated buffer instead.  We're short lived enough to not bother
free()ing the buffer.

Signed-off-by: default avatarTom Rini <trini@ti.com>
parent 548a64d8
Branches
Tags
No related merge requests found
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
_min1 < _min2 ? _min1 : _min2; }) _min1 < _min2 ? _min1 : _min2; })
struct envdev_s { struct envdev_s {
char devname[16]; /* Device name */ const char *devname; /* Device name */
ulong devoff; /* Device offset */ ulong devoff; /* Device offset */
ulong env_size; /* environment size */ ulong env_size; /* environment size */
ulong erase_size; /* device erase size */ ulong erase_size; /* device erase size */
...@@ -1243,7 +1243,7 @@ static int parse_config () ...@@ -1243,7 +1243,7 @@ static int parse_config ()
return -1; return -1;
} }
#else #else
strcpy (DEVNAME (0), DEVICE1_NAME); DEVNAME (0) = DEVICE1_NAME;
DEVOFFSET (0) = DEVICE1_OFFSET; DEVOFFSET (0) = DEVICE1_OFFSET;
ENVSIZE (0) = ENV1_SIZE; ENVSIZE (0) = ENV1_SIZE;
/* Default values are: erase-size=env-size */ /* Default values are: erase-size=env-size */
...@@ -1258,7 +1258,7 @@ static int parse_config () ...@@ -1258,7 +1258,7 @@ static int parse_config ()
#endif #endif
#ifdef HAVE_REDUND #ifdef HAVE_REDUND
strcpy (DEVNAME (1), DEVICE2_NAME); DEVNAME (1) = DEVICE2_NAME;
DEVOFFSET (1) = DEVICE2_OFFSET; DEVOFFSET (1) = DEVICE2_OFFSET;
ENVSIZE (1) = ENV2_SIZE; ENVSIZE (1) = ENV2_SIZE;
/* Default values are: erase-size=env-size */ /* Default values are: erase-size=env-size */
...@@ -1297,6 +1297,7 @@ static int get_config (char *fname) ...@@ -1297,6 +1297,7 @@ static int get_config (char *fname)
int i = 0; int i = 0;
int rc; int rc;
char dump[128]; char dump[128];
char *devname;
fp = fopen (fname, "r"); fp = fopen (fname, "r");
if (fp == NULL) if (fp == NULL)
...@@ -1307,8 +1308,8 @@ static int get_config (char *fname) ...@@ -1307,8 +1308,8 @@ static int get_config (char *fname)
if (dump[0] == '#') if (dump[0] == '#')
continue; continue;
rc = sscanf (dump, "%s %lx %lx %lx %lx", rc = sscanf (dump, "%ms %lx %lx %lx %lx",
DEVNAME (i), &devname,
&DEVOFFSET (i), &DEVOFFSET (i),
&ENVSIZE (i), &ENVSIZE (i),
&DEVESIZE (i), &DEVESIZE (i),
...@@ -1317,6 +1318,8 @@ static int get_config (char *fname) ...@@ -1317,6 +1318,8 @@ static int get_config (char *fname)
if (rc < 3) if (rc < 3)
continue; continue;
DEVNAME(i) = devname;
if (rc < 4) if (rc < 4)
/* Assume the erase size is the same as the env-size */ /* Assume the erase size is the same as the env-size */
DEVESIZE(i) = ENVSIZE(i); DEVESIZE(i) = ENVSIZE(i);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment