environment: make default env path configurable
Normally the default path to save the environment is /dev/env0. However, we can't map a file in a fat filesystem to /dev/env0. So if we want to store the environment in a file in fat we have to make it configurable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
c75ab78763
commit
9640c2b4a5
|
@ -36,7 +36,7 @@ static int do_loadenv(struct command *cmdtp, int argc, char *argv[])
|
|||
else
|
||||
dirname = argv[2];
|
||||
if (argc < 2)
|
||||
filename = "/dev/env0";
|
||||
filename = default_environment_path;
|
||||
else
|
||||
filename = argv[1];
|
||||
printf("loading environment from %s\n", filename);
|
||||
|
|
|
@ -41,7 +41,7 @@ static int do_saveenv(struct command *cmdtp, int argc, char *argv[])
|
|||
else
|
||||
dirname = argv[2];
|
||||
if (argc < 2)
|
||||
filename = "/dev/env0";
|
||||
filename = default_environment_path;
|
||||
else
|
||||
filename = argv[1];
|
||||
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
#define EXPORT_SYMBOL(x)
|
||||
#endif
|
||||
|
||||
char *default_environment_path = "/dev/env0";
|
||||
|
||||
int file_size_action(const char *filename, struct stat *statbuf,
|
||||
void *userdata, int depth)
|
||||
{
|
||||
|
|
|
@ -144,10 +144,11 @@ void start_barebox (void)
|
|||
display_meminfo();
|
||||
|
||||
#ifdef CONFIG_ENV_HANDLING
|
||||
if (envfs_load("/dev/env0", "/env")) {
|
||||
if (envfs_load(default_environment_path, "/env")) {
|
||||
#ifdef CONFIG_DEFAULT_ENVIRONMENT
|
||||
printf("no valid environment found on /dev/env0. "
|
||||
"Using default environment\n");
|
||||
printf("no valid environment found on %s. "
|
||||
"Using default environment\n",
|
||||
default_environment_path);
|
||||
envfs_load("/dev/defaultenv", "/env");
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -62,6 +62,9 @@ static inline int setenv(const char *var, const char *val)
|
|||
int env_pop_context(void);
|
||||
int env_push_context(void);
|
||||
|
||||
/* defaults to /dev/env0 */
|
||||
extern char *default_environment_path;
|
||||
|
||||
int envfs_load(char *filename, char *dirname);
|
||||
int envfs_save(char *filename, char *dirname);
|
||||
|
||||
|
|
Loading…
Reference in New Issue