From owner-svn-src-all@freebsd.org Wed Dec 16 17:13:10 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C281DA497DD; Wed, 16 Dec 2015 17:13:10 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 85B1C1BC1; Wed, 16 Dec 2015 17:13:10 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tBGHD9cm007263; Wed, 16 Dec 2015 17:13:09 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tBGHD942007257; Wed, 16 Dec 2015 17:13:09 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201512161713.tBGHD942007257@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Wed, 16 Dec 2015 17:13:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r292344 - in head: . lib/libstand sys/boot/i386/libi386 sys/boot/i386/loader X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Dec 2015 17:13:11 -0000 Author: bapt Date: Wed Dec 16 17:13:09 2015 New Revision: 292344 URL: https://svnweb.freebsd.org/changeset/base/292344 Log: 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 Modified: head/UPDATING head/lib/libstand/tftp.c head/sys/boot/i386/libi386/libi386.h head/sys/boot/i386/libi386/pxe.c head/sys/boot/i386/loader/main.c Modified: head/UPDATING ============================================================================== --- head/UPDATING Wed Dec 16 16:48:59 2015 (r292343) +++ head/UPDATING Wed Dec 16 17:13:09 2015 (r292344) @@ -31,6 +31,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11 disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20151216: + The tftp loader (pxeboot) now uses the option root-path directive. As a + consequence it no longer looks for a pxeboot.4th file on the tftp + server. Instead it uses the regular /boot infrastructure as with the + other loaders. + 20151211: The code to start recording plug and play data into the modules has been committed. While the old tools will properly build a new kernel, Modified: head/lib/libstand/tftp.c ============================================================================== --- head/lib/libstand/tftp.c Wed Dec 16 16:48:59 2015 (r292343) +++ head/lib/libstand/tftp.c Wed Dec 16 17:13:09 2015 (r292344) @@ -399,6 +399,8 @@ tftp_open(const char *path, struct open_ 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_ 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); Modified: head/sys/boot/i386/libi386/libi386.h ============================================================================== --- head/sys/boot/i386/libi386/libi386.h Wed Dec 16 16:48:59 2015 (r292343) +++ head/sys/boot/i386/libi386/libi386.h Wed Dec 16 17:13:09 2015 (r292344) @@ -123,5 +123,4 @@ int bi_load32(char *args, int *howtop, i int bi_load64(char *args, vm_offset_t addr, vm_offset_t *modulep, vm_offset_t *kernend, int add_smap); -char *pxe_default_rc(void); void pxe_enable(void *pxeinfo); Modified: head/sys/boot/i386/libi386/pxe.c ============================================================================== --- head/sys/boot/i386/libi386/pxe.c Wed Dec 16 16:48:59 2015 (r292343) +++ head/sys/boot/i386/libi386/pxe.c Wed Dec 16 17:13:09 2015 (r292344) @@ -288,8 +288,10 @@ pxe_open(struct open_file *f, ...) bootp(pxe_sock, BOOTP_PXE); if (rootip.s_addr == 0) rootip.s_addr = bootplayer.sip; +#ifdef LOADER_NFS_SUPPORT if (!rootpath[0]) strcpy(rootpath, PXENFSROOTPATH); +#endif for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++) if (rootpath[i] == ':') @@ -317,6 +319,7 @@ pxe_open(struct open_file *f, ...) setenv("boot.nfsroot.path", rootpath, 1); #else setenv("boot.netif.server", inet_ntoa(rootip), 1); + setenv("boot.tftproot.path", rootpath, 1); #endif setenv("dhcp.host-name", hostname, 1); @@ -705,26 +708,3 @@ readudp(struct iodesc *h, void *pkt, siz uh->uh_sport = udpread_p->s_port; return udpread_p->buffer_size; } - -char * -pxe_default_rc(void) -{ - char *rc; - size_t count, rcsz; - - /* XXX It may not be a good idea to modify the PXE boot file. */ - rc = (char *)bootplayer.bootfile; - rcsz = sizeof(bootplayer.bootfile); - - /* Ignore how we define rc and rcsz above -- it can change. */ - if (rcsz < 6) - return (NULL); - if (*rc == '\0') { - strncpy(rc, "pxeboot", rcsz); - rc[rcsz - 1] = '\0'; - } - count = strlen(rc); - strncat(rc, ".4th", rcsz - count - 1); - printf("PXE: loading Forth from %s\n", rc); - return (rc); -} Modified: head/sys/boot/i386/loader/main.c ============================================================================== --- head/sys/boot/i386/loader/main.c Wed Dec 16 16:48:59 2015 (r292343) +++ head/sys/boot/i386/loader/main.c Wed Dec 16 17:13:09 2015 (r292344) @@ -196,11 +196,6 @@ main(void) bios_getsmap(); -#ifdef LOADER_TFTP_SUPPORT - if (kargs->bootflags & KARGS_FLAGS_PXE) - interact(pxe_default_rc()); - else -#endif interact(NULL); /* if we ever get here, it is an error */