2007-11-09 22:19:54 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief saveenv: Make the environment persistent
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fs.h>
|
|
|
|
#include <fcntl.h>
|
2013-01-20 12:16:28 +00:00
|
|
|
#include <envfs.h>
|
2007-11-09 22:19:54 +00:00
|
|
|
|
2011-12-21 13:18:57 +00:00
|
|
|
static int do_saveenv(int argc, char *argv[])
|
2007-11-09 22:19:54 +00:00
|
|
|
{
|
2014-04-09 10:14:06 +00:00
|
|
|
int ret;
|
2007-11-09 22:19:54 +00:00
|
|
|
char *filename, *dirname;
|
|
|
|
|
|
|
|
printf("saving environment\n");
|
|
|
|
if (argc < 3)
|
|
|
|
dirname = "/env";
|
|
|
|
else
|
|
|
|
dirname = argv[2];
|
|
|
|
if (argc < 2)
|
2014-01-23 12:58:49 +00:00
|
|
|
filename = default_environment_path_get();
|
2007-11-09 22:19:54 +00:00
|
|
|
else
|
|
|
|
filename = argv[1];
|
|
|
|
|
|
|
|
ret = envfs_save(filename, dirname);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-11-01 16:59:12 +00:00
|
|
|
BAREBOX_CMD_HELP_START(saveenv)
|
|
|
|
BAREBOX_CMD_HELP_USAGE("saveenv [envfs] [directory]\n")
|
|
|
|
BAREBOX_CMD_HELP_SHORT("Save the files in <directory> to the persistent storage device <envfs>.\n")
|
|
|
|
BAREBOX_CMD_HELP_END
|
2007-11-09 22:19:54 +00:00
|
|
|
|
2009-12-15 08:11:09 +00:00
|
|
|
BAREBOX_CMD_START(saveenv)
|
2007-11-09 22:19:54 +00:00
|
|
|
.cmd = do_saveenv,
|
|
|
|
.usage = "save environment to persistent storage",
|
commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 14:14:05 +00:00
|
|
|
BAREBOX_CMD_GROUP(CMD_GRP_ENV)
|
2009-12-15 08:11:09 +00:00
|
|
|
BAREBOX_CMD_HELP(cmd_saveenv_help)
|
|
|
|
BAREBOX_CMD_END
|
2007-11-09 22:19:54 +00:00
|
|
|
|
|
|
|
/**
|
2010-11-01 16:59:12 +00:00
|
|
|
* @page saveenv_command
|
|
|
|
|
|
|
|
<p>\<envfs> is usually a block in flash but can be any other file. If
|
2011-10-13 19:23:31 +00:00
|
|
|
omitted, \<directory> defaults to /env and \<envfs> defaults to
|
2010-11-01 16:59:12 +00:00
|
|
|
/dev/env0. Note that envfs can only handle files, directories are being
|
|
|
|
skipped silently.</p>
|
|
|
|
|
|
|
|
\todo What does 'block in flash' mean? Add example.
|
|
|
|
|
2007-11-09 22:19:54 +00:00
|
|
|
*/
|
2010-11-01 16:59:12 +00:00
|
|
|
|