From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] bbu: command: update via TFTP if no image given
Date: Mon, 1 Jul 2024 09:14:55 +0200 [thread overview]
Message-ID: <20240701071455.138644-1-a.fatoum@pengutronix.de> (raw)
Booting barebox over TFTP is a common operation that even has a default
boot target: `boot bnet`.
Once, a chainloaded barebox was tested to work, it may need to be
persisted, which needs a cumbersome:
barebox_update /mnt/tftp/${global.user}-barebox-${global.hostname}
Make this more straight-forward by interpreting barebox_update called
without any non-option argument to mean just that.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
commands/barebox-update.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/commands/barebox-update.c b/commands/barebox-update.c
index 4b23433e84f2..59db315e5650 100644
--- a/commands/barebox-update.c
+++ b/commands/barebox-update.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <command.h>
#include <libfile.h>
+#include <globalvar.h>
#include <getopt.h>
#include <malloc.h>
#include <errno.h>
@@ -20,6 +21,7 @@ static void print_handlers_list(void)
static int do_barebox_update(int argc, char *argv[])
{
+ char pathbuf[PATH_MAX];
int opt, ret, repair = 0;
struct bbu_data data = {};
struct bbu_handler *handler;
@@ -82,14 +84,17 @@ static int do_barebox_update(int argc, char *argv[])
if (argc - optind > 0) {
data.imagefile = argv[optind];
+ } else if (!repair) {
+ snprintf(pathbuf, sizeof(pathbuf), "/mnt/tftp/%s-barebox-%s",
+ globalvar_get("user"), globalvar_get("hostname"));
+ data.imagefile = pathbuf;
+ }
+ if (data.imagefile) {
image = read_file(data.imagefile, &data.len);
if (!image)
return -errno;
data.image = image;
- } else {
- if (!repair)
- return COMMAND_ERROR_USAGE;
}
ret = barebox_update(&data, handler);
--
2.39.2
next reply other threads:[~2024-07-01 7:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 7:14 Ahmad Fatoum [this message]
2024-07-01 10:08 ` Sascha Hauer
2024-07-01 10:11 ` Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240701071455.138644-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox