summaryrefslogtreecommitdiffstats
path: root/common/environment.c
Commit message (Collapse)AuthorAgeFilesLines
* environment: fix typoUlrich Ölmann2017-01-101-1/+1
| | | | | Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* environment: "wrong magic" gives the impression of an errorSam Ravnborg2016-09-261-1/+1
| | | | | | | | | | | | | | | | | | From 15e7ff689cfda27eab10aacda5c26a1ba47979ec Mon Sep 17 00:00:00 2001 From: Sam Ravnborg <srn@skov.dk> Date: Thu, 22 Sep 2016 06:54:42 +0200 Subject: [PATCH 1/1] environment: "wrong magic" give the impression of an error Introduce a more soft wording when the magic of the superblock does not match. Include a hint to the typical reason "(envfs never written?)" This prevents a "what is wrong?" moment when looking at the boot log. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nv: Save nv variables on shutdownSascha Hauer2016-07-221-0/+4
| | | | | | | | | | | | | | | | | | | With this patch nv variables are automatically saved whenever barebox shuts down (that is 'reset' is executed or a kernel is started). With this the additional 'saveenv' step becomes unnecessary. The nv variables are stored in the environment and the estasblished behaviour is that files in the environment must be manually saved using 'saveenv'. This behaviour shall be kept for now, so this patch cannot just call 'saveenv' since that would save the modified environment files aswell. Instead we read the environment from the device, modifiy the nv variables and save the environment back. Since this changes a long existing behaviour messages are printed the first time a nv variable is modified and during shutdown when the variables are actually saved. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/include-cleanup'Sascha Hauer2016-05-091-2/+3
|\
| * string: Fix (v)asprintf prototypesSascha Hauer2016-04-151-2/+2
| | | | | | | | | | | | | | | | | | | | Our asprintf and vasprintf have different prototypes than the glibc functions. This causes trouble when we want to share barebox code with userspace code. Change the prototypes for (v)asprintf to match the glibc prototypes. Since the current (v)asprintf are convenient to use change the existing functions to b(v)asprintf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * include: move crc specific stuff to crc.hSascha Hauer2016-04-151-0/+1
| | | | | | | | | | | | | | We have a crc.h, so move our crc function prototypes there to further cleanup common.h. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fix erasing/protecting flashes with unspecified sizeSascha Hauer2016-04-191-1/+2
|/ | | | | | | | | | | | | | | | | fixes: 81737c1 mtd: Fix erasing of devices >4GiB Several places erased a complete flash partition passing ~0 as count to erase(). With the above commit count to erase was changed from an unsigned type to a signed type, so the (count > f->size - offset) check in erase() no longer triggers and the ~0 count is no longer adjusted to the whole device size. Among other things this results in saveenv failures on NOR flashes. This patch fixes this by introducing an explicit macro for erasing the whole device which is tested for in erase(). All other negative values are rejected. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Giorgio <giorgio.nicole@arcor.de>
* environment: allow saving of symbolic link changesZahari Doychev2015-12-171-9/+10
| | | | | | | | | | | | | | | | | | | | Currently it is not possible to change symbolic links in the default environment. For example if the default environment contains the link "current_boot -> mmc" then the following does not work: $ rm current_boot $ ln net current_boot $ saveenv After reset the link is still pointing to "mmc" and this error appears: "symlink: /env/boot/current_boot -> net : error -17" The patch fixes the above problem and moves the "ENV_FLAG_NO_OVERWRITE" to enable handling of symbolic links in this case too. Signed-off-by: Zahari Doychev <zahari.doychev@linux.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* environment: support env on at24 eepromAntony Pavlov2015-12-011-6/+6
| | | | | | | | | unprotect(), erase() and protect() return EOPNOTSUPP errno code for at24 I2C eeproms, so envfs_save() doesn't store data to these eeproms without this patch. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2015-03-091-0/+12
|\
| * environment: envfs_{load, save}: add possibility to call with filename and ↵Marc Kleine-Budde2015-03-061-0/+12
| | | | | | | | | | | | | | | | | | dirname == NULL This patch moves fallback to default into the envfs_{load,save} functions. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | environment: Do not remove base env directorySascha Hauer2015-02-191-0/+3
|/ | | | | | | When removing empty directories do not remove the base directory. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add support for non volatile variablesSascha Hauer2014-11-061-0/+1
| | | | | | | | | | | | | | | 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>
* environment: Only save changes to the defaultenvSascha Hauer2014-11-061-6/+105
| | | | | | | 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>
* environment: refactor saveenvSascha Hauer2014-11-061-68/+75
| | | | | | | | 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>
* environment: remove unused variableSascha Hauer2014-11-051-1/+0
| | | | | | fd is unused, remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* environment: drop unnecessary castsSascha Hauer2014-11-051-6/+6
| | | | | | No Need to cast void pointers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* envfs: change API to be able to forward special flags into the envfs superblockJuergen Borleis2014-08-011-8/+16
| | | | | | | | | | 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>
* envfs: provide an intentional way to ignore an existing external environmentJuergen Borleis2014-08-011-0/+9
| | | | | | | | | | | 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>
* env: erase/protect in envfs_saveSascha Hauer2014-04-281-2/+36
| | | | | | So that the envfs_save is more useful outside of the saveenv command Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* environment: drop envfs_register_partitionSascha Hauer2014-04-281-47/+3
| | | | | | | | 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>
* loadenv: detect truncated environment filesSascha Hauer2014-04-091-7/+24
| | | | | | | | 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>
* saveenv: Properly detect write errorsSascha Hauer2014-04-091-6/+14
| | | | | | | | | | | 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>
* environment: Fix unitiliazed variableSascha Hauer2014-03-291-5/+5
| | | | | | | | | | | | | | | | | | | | 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 0a2a8f7059e6cb11e5d4eb882538b37f99d09ee3 | 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>
* defaultenv: Allow multiple defaultenvironment overlaysSascha Hauer2014-02-281-1/+1
| | | | | | | | | | 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>
* environment: Add function to load envfs from bufferSascha Hauer2014-02-201-65/+116
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* environment: constify argumentsSascha Hauer2014-02-201-2/+2
| | | | | | | The directory arguments to envfs_load and envfs_save can be const. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* env: make path arguments to envfs_load/save constSascha Hauer2014-01-271-2/+2
| | | | | | | These functions have no business changing the path argument, so make the argument const. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* environment: Use accessor functions for default environment pathSascha Hauer2014-01-271-1/+13
| | | | | | | | | 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>
* devfs: let devfs_add_partition return the new partitionSascha Hauer2013-07-151-2/+8
| | | | | | Useful for unregistering later or for adding addional flags. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* env: add register_persistent_environmentEric Bénard2013-02-211-0/+40
| | | | | | | | - 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>
* Merge branch 'for-next/compile-log-level'Sascha Hauer2013-02-041-4/+6
|\ | | | | | | | | Conflicts: drivers/usb/host/ehci-hcd.c
| * treewide: fix format specifiersSascha Hauer2013-01-271-4/+6
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | make file_*_action staticSascha Hauer2013-01-201-2/+2
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | move struct action_data to the only file using itSascha Hauer2013-01-201-0/+7
|/ | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* loadenv: allow more fine grained environment loadingSascha Hauer2012-11-291-2/+10
| | | | | | | | | | | 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>
* Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-3/+0
| | | | | | | 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>
* envfs: add support of symlinkJean-Christophe PLAGNIOL-VILLARD2012-09-051-30/+73
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* envfs: add support of variable inode sizeJean-Christophe PLAGNIOL-VILLARD2012-09-051-12/+41
| | | | | | | | | | | | | | 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>
* envfs: introduce version major and minorJean-Christophe PLAGNIOL-VILLARD2012-09-051-0/+2
| | | | | | | | 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>
* Make errno a positive valueSascha Hauer2012-05-141-3/+3
| | | | | | | | | 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>
* environment: make default env path configurableSascha Hauer2011-04-121-0/+2
| | | | | | | | 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>
* common/environment.c: sparse fixesSascha Hauer2010-10-211-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fix error return value while loading environmentLuotao Fu2010-05-031-1/+5
| | | | | Signed-off-by: Luotao Fu <l.fu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rename U-Boot-v2 project to bareboxSascha Hauer2009-12-151-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | This has been done with the following script: find -path ./.git -prune -o -type f -print0 | xargs -0 -r sed -i \ -e 's/u2boot/barebox/g' \ -e 's/U2Boot/barebox/g' \ -e 's/U-boot V2/barebox/g' \ -e 's/u-boot v2/barebox/g' \ -e 's/U-Boot V2/barebox/g' \ -e 's/U-Boot-v2/barebox/g' \ -e 's/U_BOOT/BAREBOX/g' \ -e 's/UBOOT/BAREBOX/g' \ -e 's/uboot/barebox/g' \ -e 's/u-boot/barebox/g' \ -e 's/u_boot/barebox/g' \ -e 's/U-Boot/barebox/g' \ -e 's/U-boot/barebox/g' \ -e 's/U-BOOT/barebox/g' find -path ./.git -prune -o \( -name "*u-boot*" -o -name "*uboot*" -o -name "*u_boot*" \) -print0 | \ xargs -0 -r rename 's/u[-_]?boot/barebox/' It needs some manual fixup following in the next patch Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common:environment: fix mode requirementNishanth Menon2008-12-091-1/+1
| | | | | | | | | | | | | | | | | 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>
* Trivial comment fixSascha Hauer2008-04-041-1/+1
|
* [general] Fixed endian handling for envfsCarsten Schlote2008-02-191-30/+32
| | | | | | | | | | | 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>
* separating environment commands, part 2Juergen Beisert2007-11-121-0/+269
| | | | Signed-off-by: Juergen Beisert <j.beisert@pengutronix.de>
* svn_rev_643Sascha Hauer2007-07-051-236/+0
| | | | structure cleanup