This adds (back) support for non volatile variables. Non volatile
variables are variables which are stored in the environment over
reboot. They are used in the same way as the global variables, but
with a 'nv' command and device. The variables are stored under
/env/nv/, one variable per file. Adding a nv variable automatically
adds a global variable with the same name. Changing a nv variable
also changes the same global variable, but not the other way round.
This allows for example to configure the username as:
nv user=sha; saveenv
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Instead of storing the complete files with a 'saveenv' command
only store the files that have changes to the default environment.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Collect all files in a list first and iterate over the list
when creating the actual environment image. Makes the next
patches easier.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
In order to be able to mark an stored envfs image with special features
(intentional ignore for example), we now can feed forward these flags.
By forwarding a '0' for the flags nothing changes because the envfs superblock
was already allocated with xzalloc.
Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Add a simple flag to envfs to be able to mark an external environment as
"not to be used".
This change should not affect existing systems, because the current envfs
implementation ensures the 'flags' member in the envfs master block is always
zeroed.
Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The purpose of envfs_register_partition is to print an error
message when the partition does not exist. Print an error message
from generic code instead and drop this function.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Properly detect when an environment file is truncated. This can happen
when a previous saveenv failed because the environment partition is too
small.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The return value check of the write call is completely bogus. We
check if we have written at minimum sizeof(struct envfs_super) bytes
instead of all bytes. Properly check for all bytes written instead
and allow write to write less bytes than requested.
Do not use write_full because this file is compiled for userspace
aswell.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
envfs_load_data needs a pointer to the envfs_super, otherwise it
works on an unitialized struct when detecting the envfs version.
This is broken since:
| commit 0a2a8f7059
| Author: Sascha Hauer <s.hauer@pengutronix.de>
| Date: Thu Feb 20 08:16:01 2014 +0100
|
| environment: Add function to load envfs from buffer
|
| Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Grmpf. Most compilers do not issue a warning, only the blackfin
gcc 4.3.5 warns about this.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
We can compile barebox for multiple boards at once, but currently
they all share a single default environment. This patch adds a
defaultenv_append() which boards can call to customize the default
environment during runtime. Each board now generate default environment
snippets using bbenv-y and add them during runtime with defaultenv_append()
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
default_environment_path only exists when CONFIG_ENV_HANDLING is enabled.
Boards would have to #ifdef this if they wanted to use
default_environment_path. Use accessor functions instead which can
be ifdeffed on a single place.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
- heavily copied from register_persistant_environment which was
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
Signed-off-by: Eric Bénard <eric@eukrea.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This implements two new options for the loadenv command:
-s: removes (scrubs) old directory contents to be able to
create a fresh environment from for example /dev/defaultenv
-n: no overwrite. Do not overwrite existing files. This allows
to keep parts of the old environment.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The FSF address has changed in the past. Instead of updating it
each time the address changes, just drop it completely treewide.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Introduce a struct envfs_inode_end with more data.
Today this will just containt the file mode to be able to add the symlink
support.
But this is compatible with the previous envfs version as they will do not
care about the extra as the previous version is just reading the filename and
then consume the extra data without using them.
Increase the envfs version to 1.0
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
they are store in the super block at byte 16th and 17th.
set the verison at 0.1
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Normally errno contains a positive error value. A certain unnamed developer
mixed this up while implementing U-Boot-v2. Also, normally errno is never
set to zero by any library function.
This patch fixes this.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
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>
Issue:
Compiling on Ubuntu 8.10 Fails:
inlined from 'envfs_save' at scripts/../common/environment.c:135:
/usr/include/bits/fcntl2.h:51: error: call to '_open_missing_mod'
declared with attribute error: open with O_CREAT in second argument
needs 3 arguments
Usage: open(filename, O_WRONLY | O_CREAT)
Fix:
When using open with O_CREAT, it requires
mode to be defined.
Signed-off-by: Nishanth Menon <nm@ti.com>
Fixed the handling of data similiar as found in cramfs.
This fixes the problem with an unreadable defaultenv on big-endian
targets.
The endian macors are now loaded from /asm/common.h by default.
Signed-off-by: Carsten Schlote <c.schlote@konzeptpark.de>
- Add help texts for many commands.
- Let the linker sort the command table.
- Add support for multiple argmuments in several commands
(mkdir, rmdir, rm, cat)