diff --git a/sys/boot/i386/libi386/pxe.c b/sys/boot/i386/libi386/pxe.c index 0357cbe3130..8391bb825a6 100644 --- a/sys/boot/i386/libi386/pxe.c +++ b/sys/boot/i386/libi386/pxe.c @@ -40,6 +40,8 @@ #include #include +#include +#include #include #include @@ -76,6 +78,7 @@ static int pxe_open(struct open_file *f, ...); static int pxe_close(struct open_file *f); static void pxe_print(int verbose); static void pxe_cleanup(void); +static void pxe_setnfshandle(char *rootpath); static void pxe_perror(int error); static int pxe_netif_match(struct netif *nif, void *machdep_hint); @@ -295,11 +298,15 @@ pxe_open(struct open_file *f, ...) printf("pxe_open: server path: %s\n", rootpath); printf("pxe_open: gateway ip: %s\n", inet_ntoa(gateip)); - setenv("boot.pxe.server_addr", inet_ntoa(rootip), 1); - setenv("boot.pxe.rootpath", rootpath, 1); - setenv("boot.pxe.gateway", inet_ntoa(gateip), 1); - setenv("boot.pxe.myip", inet_ntoa(myip), 1); - setenv("boot.pxe.netmask", intoa(netmask), 1); + setenv("boot.netif.ip", inet_ntoa(myip), 1); + setenv("boot.netif.netmask", intoa(netmask), 1); + setenv("boot.netif.gateway", inet_ntoa(gateip), 1); + if (bootplayer.Hardware == ETHER_TYPE) { + sprintf(temp, "%6D", bootplayer.CAddr, ":"); + setenv("boot.netif.hwaddr", temp, 1); + } + setenv("boot.nfsroot.server", inet_ntoa(rootip), 1); + setenv("boot.nfsroot.path", rootpath, 1); } } pxe_opens++; @@ -326,7 +333,11 @@ pxe_close(struct open_file *f) if (pxe_opens > 0) return(0); + /* get an NFS filehandle for our root filesystem */ + pxe_setnfshandle(rootpath); + if (pxe_sock >= 0) { + #ifdef PXE_DEBUG if (pxe_debug) printf("pxe_close: calling netif_close()\n"); @@ -390,6 +401,34 @@ pxe_perror(int err) return; } +/* + * Reach inside the libstand NFS code and dig out an NFS handle + * for the root filesystem. + */ +struct nfs_iodesc { + struct iodesc *iodesc; + off_t off; + u_char fh[NFS_FHSIZE]; + /* structure truncated here */ +}; +extern struct nfs_iodesc nfs_root_node; + +static void +pxe_setnfshandle(char *rootpath) +{ + int i; + u_char *fh; + char buf[2 * NFS_FHSIZE + 3], *cp; + + fh = &nfs_root_node.fh[0]; + buf[0] = 'X'; + cp = &buf[1]; + for (i = 0; i < NFS_FHSIZE; i++, cp += 2) + sprintf(cp, "%02x", fh[i]); + sprintf(cp, "X"); + setenv("boot.nfsroot.nfshandle", buf, 1); +} + void pxenv_call(int func) {