Fix U-Boot environment handling (#1001)

* Use /run as default location for lock files for U-Boot tools

While there is a command line parameter to set the lock file explicitly,
there are other tools invoking fw_setenv (in particular rauc) which do
not set the lock file. Using /run by default makes fw_setenv use the
correct lock file in all situations.

* Don't explicitly set lock file location

Since we patch U-Boot tools to use /run by default setting it explicitly
is unnecessary.
This commit is contained in:
Stefan Agner 2020-11-17 15:15:50 +01:00 committed by GitHub
parent 29e92f4231
commit 39debca9fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 2 deletions

View File

@ -0,0 +1,49 @@
From 63d929a7c6523ca5fcaed4a4d2a2e6643aa4ae44 Mon Sep 17 00:00:00 2001
Message-Id: <63d929a7c6523ca5fcaed4a4d2a2e6643aa4ae44.1605605643.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Tue, 17 Nov 2020 10:33:05 +0100
Subject: [PATCH] fw_printenv: use /run as default location for lock files
Use /run as location for lock files. This is the recommended location
for lock files. The current location /var/lock is considered legacy by
systemd.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
tools/env/fw_env_main.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c
index 1d193bd437..0b201b9e62 100644
--- a/tools/env/fw_env_main.c
+++ b/tools/env/fw_env_main.c
@@ -73,7 +73,7 @@ void usage_printenv(void)
" -c, --config configuration file, default:" CONFIG_FILE "\n"
#endif
" -n, --noheader do not repeat variable name in output\n"
- " -l, --lock lock node, default:/var/lock\n"
+ " -l, --lock lock node, default:/run\n"
"\n");
}
@@ -88,7 +88,7 @@ void usage_env_set(void)
#ifdef CONFIG_FILE
" -c, --config configuration file, default:" CONFIG_FILE "\n"
#endif
- " -l, --lock lock node, default:/var/lock\n"
+ " -l, --lock lock node, default:/run\n"
" -s, --script batch mode to minimize writes\n"
"\n"
"Examples:\n"
@@ -206,7 +206,7 @@ int parse_setenv_args(int argc, char *argv[])
int main(int argc, char *argv[])
{
- char *lockname = "/var/lock/" CMD_PRINTENV ".lock";
+ char *lockname = "/run/" CMD_PRINTENV ".lock";
int lockfd = -1;
int retval = EXIT_SUCCESS;
char *_cmdname;
--
2.29.2

View File

@ -8,9 +8,9 @@ MACHINE_ID=$(cat /etc/machine-id)
if [ -e /usr/sbin/fw_setenv ]; then
# machine-id
if [ "$(fw_printenv -l /run -n MACHINE_ID)" != "${MACHINE_ID}" ]; then
if [ "$(fw_printenv -n MACHINE_ID)" != "${MACHINE_ID}" ]; then
echo "[INFO] set machine-id to ${MACHINE_ID}"
fw_setenv -l /run MACHINE_ID "${MACHINE_ID}"
fw_setenv MACHINE_ID "${MACHINE_ID}"
else
echo "[INFO] machine-id is okay"
fi