path: root/commands/nv.c
Commit message (Collapse)AuthorAgeFilesLines
* commands/*: Replace license and copyright boilerplate by SPDX identfiersUwe Kleine-König2020-04-271-18/+5
| | | | | | | | | | | | | While at it also drop references to the non-existing CREDITS file and do some small rearrangements for some uniform formatting. (SPDX-License-Identifier first, then copyright texts and then an empty line.) The advantage is that these specifiers are machine-parseable which helps license conformance. Signed-off-by: Uwe Kleine-König <> Signed-off-by: Sascha Hauer <>
* Allow usage of default environment without environment file storageAlbert Schwarzkopf2019-12-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the default environment is only used when the barebox environment on the persistent store is not valid or when ENVFS_FLAGS_FORCE_BUILT_IN is set in the super block. However, ENVFS_FLAGS_FORCE_BUILT_IN can be cleared and the environmnet variables in the persistent store will be used again. This may not be desirable. This patch allows building CONFIG_DEFAULT_ENVIRONMENT independent of CONFIG_ENV_HANDLING. This can be useful if you never want to load or write values from the persistent store and you only need to read environment variables from your default environment. If CONFIG_ENV_HANDLING is not set, a message will be printed to the user indicating that changes to non-volatile variables won't be persisted. Move envfs functions that are needed when CONFIG_DEFAULT_ENVIRONMENT and/or CONFIG_ENV_HANDLING is set to a new file common/envfs-core.c. Signed-off-by: Albert Schwarzkopf <> Signed-off-by: Sascha Hauer <>
* nv: add device parameter overwrites to completion listSascha Hauer2017-11-231-1/+1
| | | | | | | | nv variables in the form dev.<devname>.* can be used to make device parameters persistent. Add these to the completion list to make setting these variables more convenient. Signed-off-by: Sascha Hauer <>
* command: nv: rewrap help text linesEnrico Jorns2017-11-031-3/+3
| | | | | | | Just let the help text appear a bit more aligned. Signed-off-by: Enrico Jorns <> Signed-off-by: Sascha Hauer <>
* commands: nv: adjust command helpEnrico Jorns2017-11-031-5/+5
| | | | | | | | | | Help did not point out that -r option requires n arguments and did not mention support for removing variables in help text. Also introduce and consistently reuse 'NV' as abbreviation for 'non volatile'. Signed-off-by: Enrico Jorns <> Signed-off-by: Sascha Hauer <>
* commands: nv: assure error code will be returned when an error occurredEnrico Jorns2017-11-031-4/+14
| | | | | | | | | | | | | | Due to iteration over possibly multiple variables, the return value of an individual call to nvvar_remove() / nvvar_add() gets lost. This will result in do_nv() returning success (0) if any variable processing failed as long as processing of the last variable succeeded. Processing will not be aborted on individual errors, such as the 'cp' handles it for invalid files. Signed-off-by: Enrico Jorns <> Signed-off-by: Sascha Hauer <>
* commands: nv: call nvvar_print() only if no argument is givenEnrico Jorns2017-11-031-4/+5
| | | | | | | | Printing the nv variables (before performing any modification!) is useless and irritating. Signed-off-by: Enrico Jorns <> Signed-off-by: Sascha Hauer <>
* commands: nv: fail with verbose message if invoked without argsEnrico Jorns2017-11-031-1/+3
| | | | | Signed-off-by: Enrico Jorns <> Signed-off-by: Sascha Hauer <>
* complete: Add completion for nv and globalvar commandsSascha Hauer2016-10-181-0/+2
| | | | | | | | The 'nv' command is often used to create a nv variable for an existing global variable, so add a command completion function for this. Signed-off-by: Sascha Hauer <>
* nv: Allow to set/remove multiple variables with one commandSascha Hauer2016-07-221-13/+15
| | | | | | | | It's convenient to set/remove multiple nv variables in one go. With this patch we iterate over the remaining nonopts instead of expecting exactly one nonopt. Signed-off-by: Sascha Hauer <>
* nv: Add option to explicitly save nv variablesSascha Hauer2016-07-221-4/+11
| | | | | | | | | We now have code to save the nv variables without saving the rest of the environment. This gives us the possibility to explicitly save the nv variables. This patch adds an option to the 'nv' command for this. Signed-off-by: Sascha Hauer <>
* Add support for non volatile variablesSascha Hauer2014-11-061-0/+84
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 <>