* [PATCH] net: make default netboot artifact directory configurable
@ 2026-01-20 12:27 Ahmad Fatoum
0 siblings, 0 replies; only message in thread
From: Ahmad Fatoum @ 2026-01-20 12:27 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-20 12:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-20 12:27 [PATCH] net: make default netboot artifact directory configurable Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox