arm start.c: Make runtime function address calculation tolerant for more compilers
[barebox-mini2440.git] / commands / loadenv.c
blob14fbf1e336d9c92f1daf6e83bb72c6f2f8ff1e1a
1 /*
2 * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
4 * See file CREDITS for list of people who contributed to this
5 * project.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /**
22 * @file
23 * @brief loadenv: Restoring a environment
26 #include <common.h>
27 #include <command.h>
28 #include <environment.h>
30 static int do_loadenv(struct command *cmdtp, int argc, char *argv[])
32 char *filename, *dirname;
34 if (argc < 3)
35 dirname = "/env";
36 else
37 dirname = argv[2];
38 if (argc < 2)
39 filename = "/dev/env0";
40 else
41 filename = argv[1];
42 printf("loading environment from %s\n", filename);
43 return envfs_load(filename, dirname);
46 static const __maybe_unused char cmd_loadenv_help[] =
47 "Usage: loadenv [ENVFS] [DIRECTORY]\n"
48 "Load the persistent storage contained in <envfs> to the directory\n"
49 "<directory>.\n"
50 "If ommitted <directory> defaults to /env and <envfs> defaults to /dev/env0.\n"
51 "Note that envfs can only handle files. Directories are skipped silently.\n";
53 BAREBOX_CMD_START(loadenv)
54 .cmd = do_loadenv,
55 .usage = "load environment from persistent storage",
56 BAREBOX_CMD_HELP(cmd_loadenv_help)
57 BAREBOX_CMD_END
59 /**
60 * @page loadenv_command loadenv
62 * Usage: loadenv [\<directory>] [\<envfs>]
64 * Load the persistent storage contained in \<envfs> to the directory \<directory>.
66 * If ommitted \<directory> defaults to \c /env and \<envfs> defaults to
67 * \c /dev/env0.
69 * @note envfs can only handle files. Directories are skipped silently.