mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] net: make default netboot artifact directory configurable
Date: Tue, 20 Jan 2026 13:27:03 +0100	[thread overview]
Message-ID: <20260120122713.633785-1-a.fatoum@pengutronix.de> (raw)

From: Ahmad Fatoum <a.fatoum@barebox.org>

The artifacts we currently look up exclusively via TFTP could be equally
well in a virtfs, NFS or in the future a HTTP web server.

To allow users and tests to override the directory, move it into a
globalvar.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 commands/barebox-update.c              | 5 +----
 defaultenv/defaultenv-2-base/boot/bnet | 4 ++--
 defaultenv/defaultenv-2-base/boot/net  | 2 +-
 net/net.c                              | 6 +++++-
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/commands/barebox-update.c b/commands/barebox-update.c
index e474fff87f36..3d967b729cff 100644
--- a/commands/barebox-update.c
+++ b/commands/barebox-update.c
@@ -85,10 +85,7 @@ static int do_barebox_update(int argc, char *argv[])
 	if (argc - optind > 0) {
 		data.imagefile = argv[optind];
 	} else if (!repair) {
-		if (!IS_ENABLED(CONFIG_FS_TFTP))
-			return COMMAND_ERROR_USAGE;
-
-		pathbuf = xasprintf("/mnt/tftp/%s-barebox-%s",
+		pathbuf = xasprintf("%s/%s-barebox-%s", globalvar_get("net.fetchdir"),
 				    globalvar_get("user"), globalvar_get("hostname"));
 		data.imagefile = pathbuf;
 	}
diff --git a/defaultenv/defaultenv-2-base/boot/bnet b/defaultenv/defaultenv-2-base/boot/bnet
index 877616758dc9..a09269ffcc77 100644
--- a/defaultenv/defaultenv-2-base/boot/bnet
+++ b/defaultenv/defaultenv-2-base/boot/bnet
@@ -1,8 +1,8 @@
 #!/bin/sh
 
-# script to boot barebox over tftp
+# script to boot barebox over network
 
-path="/mnt/tftp"
+path="${global.net.fetchdir}"
 
 global.bootm.image="${path}/${global.user}-barebox-${global.hostname}"
 if [ ! -f "${global.bootm.image}" ]; then
diff --git a/defaultenv/defaultenv-2-base/boot/net b/defaultenv/defaultenv-2-base/boot/net
index 98286ff5e050..8408ceaf3937 100644
--- a/defaultenv/defaultenv-2-base/boot/net
+++ b/defaultenv/defaultenv-2-base/boot/net
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-path="/mnt/tftp"
+path="${global.net.fetchdir}"
 
 # global.net.server and global.hostname may be set by DHCP, so trigger it first
 ifup -a1
diff --git a/net/net.c b/net/net.c
index 60f325ec63de..fc32c4562b66 100644
--- a/net/net.c
+++ b/net/net.c
@@ -31,7 +31,7 @@
 
 static unsigned int net_ip_id;
 
-char *net_server;
+char *net_server, *net_fetchdir;
 IPaddr_t net_gateway;
 static IPaddr_t net_nameserver;
 static char *net_domainname;
@@ -874,10 +874,13 @@ int net_alloc_packets(void **packets, int count)
 
 static int net_init(void)
 {
+	net_fetchdir = xstrdup("/mnt/tftp");
+
 	globalvar_add_simple_ip("net.nameserver", &net_nameserver);
 	globalvar_add_simple_string("net.domainname", &net_domainname);
 	globalvar_add_simple_string("net.server", &net_server);
 	globalvar_add_simple_ip("net.gateway", &net_gateway);
+	globalvar_add_simple_string("net.fetchdir", &net_fetchdir);
 
 	return 0;
 }
@@ -887,3 +890,4 @@ postcore_initcall(net_init);
 BAREBOX_MAGICVAR(global.net.nameserver, "The DNS server used for resolving host names");
 BAREBOX_MAGICVAR(global.net.domainname, "Domain name used for DNS requests");
 BAREBOX_MAGICVAR(global.net.server, "Standard server used for NFS/TFTP");
+BAREBOX_MAGICVAR(global.net.fetchdir, "The directory within which artifacts are fetched for network boot targets (/mnt/tftp by default)");
-- 
2.47.3




                 reply	other threads:[~2026-01-20 12:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260120122713.633785-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=a.fatoum@barebox.org \
    --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