summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2015-12-16 17:13:09 +0000
committerbapt <bapt@FreeBSD.org>2015-12-16 17:13:09 +0000
commit15c888577ca75f34386af6f93cc29c8818044afe (patch)
treeec499553f40e2e6fcafe53afa38af59c08a2a29d /lib
parent2fca0caf45275f1f3821f9e7095ed671a7f5b9b5 (diff)
downloadFreeBSD-src-15c888577ca75f34386af6f93cc29c8818044afe.zip
FreeBSD-src-15c888577ca75f34386af6f93cc29c8818044afe.tar.gz
pxeboot: make the tftp loader use the option root-path directive
pxeboot in tftp loader mode (when built with LOADER_TFTP_SUPPORT) now prefix all the path to open with the path obtained via the option 'root-path' directive. This allows to be able to use the traditional content /boot out of box. Meaning it now works pretty much like all other loaders. It simplifies hosting hosting multiple version of FreeBSD on a tftp server. As a consequence, pxeboot does not look anymore for a pxeboot.4th (which was never provided) Note: that pxeboot in tftp loader mode is not built by default. Reviewed by: rpokala Relnotes: yes Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D4590
Diffstat (limited to 'lib')
-rw-r--r--lib/libstand/tftp.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/libstand/tftp.c b/lib/libstand/tftp.c
index 6527c4e..001cbfd 100644
--- a/lib/libstand/tftp.c
+++ b/lib/libstand/tftp.c
@@ -399,6 +399,8 @@ tftp_open(const char *path, struct open_file *f)
struct tftp_handle *tftpfile;
struct iodesc *io;
int res;
+ size_t pathsize;
+ const char *extraslash;
if (strcmp(f->f_dev->dv_name, "net") != 0) {
#ifdef __i386__
@@ -424,10 +426,22 @@ tftp_open(const char *path, struct open_file *f)
io->destip = servip;
tftpfile->off = 0;
- tftpfile->path = strdup(path);
+ pathsize = (strlen(rootpath) + 1 + strlen(path) + 1) * sizeof(char);
+ tftpfile->path = malloc(pathsize);
if (tftpfile->path == NULL) {
- free(tftpfile);
- return(ENOMEM);
+ free(tftpfile);
+ return(ENOMEM);
+ }
+ if (rootpath[strlen(rootpath) - 1] == '/' || path[0] == '/')
+ extraslash = "";
+ else
+ extraslash = "/";
+ res = snprintf(tftpfile->path, pathsize, "%s%s%s",
+ rootpath, extraslash, path);
+ if (res < 0 || res > pathsize) {
+ free(tftpfile->path);
+ free(tftpfile);
+ return(ENOMEM);
}
res = tftp_makereq(tftpfile);
OpenPOWER on IntegriCloud