aboutsummaryrefslogtreecommitdiff
path: root/stand/efi
diff options
context:
space:
mode:
authorMichal Meloun <mmel@FreeBSD.org>2020-10-14 13:13:14 +0000
committerMichal Meloun <mmel@FreeBSD.org>2020-10-14 13:13:14 +0000
commit5b5438c6f3e82f56564e17f3b2497798a2d4099e (patch)
tree337c203848dc1b869fa3414592b40d6e31e82ed3 /stand/efi
parenta525283161f88f2044200af7f8aac12c2c6819df (diff)
downloadsrc-5b5438c6f3e82f56564e17f3b2497798a2d4099e.tar.gz
src-5b5438c6f3e82f56564e17f3b2497798a2d4099e.zip
Add 'netserver' command to EFI loader.
In some environments is difficult to access bootp/dhcp configuration as "standard user". Add a command that allows to set or display the URI of the network server used as "net:" device. Currently only tftp and nfs protocols are supported. Typical usage pattern is: netserver tftp://192.168.168.1/path_to_obj_dir/arm.armv7/sys/GENERIC/ boot net:kernel Reviewed by: imp, kevans MFC after: 4 weeks Differential Revision: https://reviews.freebsd.org/D26736
Notes
Notes: svn path=/head/; revision=366700
Diffstat (limited to 'stand/efi')
-rw-r--r--stand/efi/loader/main.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
index d0d09ebd6a75..ad81b784cb66 100644
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -40,10 +40,14 @@ __FBSDID("$FreeBSD$");
#include <sys/zfs_bootenv.h>
#endif
#include <paths.h>
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
#include <stdint.h>
#include <string.h>
#include <setjmp.h>
#include <disk.h>
+#include <dev_net.h>
+#include <net.h>
#include <efi.h>
#include <efilib.h>
@@ -1594,3 +1598,34 @@ command_chain(int argc, char *argv[])
}
COMMAND_SET(chain, "chain", "chain load file", command_chain);
+
+extern struct in_addr servip;
+static int
+command_netserver(int argc, char *argv[])
+{
+ char *proto;
+ n_long rootaddr;
+
+ if (argc > 2) {
+ command_errmsg = "wrong number of arguments";
+ return (CMD_ERROR);
+ }
+ if (argc < 2) {
+ proto = netproto == NET_TFTP ? "tftp://" : "nfs://";
+ printf("Netserver URI: %s%s%s\n", proto, intoa(rootip.s_addr),
+ rootpath);
+ return (CMD_OK);
+ }
+ if (argc == 2) {
+ strncpy(rootpath, argv[1], sizeof(rootpath));
+ rootpath[sizeof(rootpath) -1] = '\0';
+ if ((rootaddr = net_parse_rootpath()) != INADDR_NONE)
+ servip.s_addr = rootip.s_addr = rootaddr;
+ return (CMD_OK);
+ }
+ return (CMD_ERROR); /* not reached */
+
+}
+
+COMMAND_SET(netserver, "netserver", "change or display netserver URI",
+ command_netserver);