Do the RPC to bootparamd a little later (just before the mountd call) trunk
authorgwr <gwr@NetBSD.org>
Tue, 13 Feb 1996 17:53:32 +0000
branchtrunk
changeset 17747 19a776b0469b
parent 17746 831e79d70f76
child 17748 b617c7dce14d
Do the RPC to bootparamd a little later (just before the mountd call) so that we do not ask for the "swap" path when swapping on disk.
sys/nfs/nfs_boot.c
sys/nfs/nfs_vfsops.c
sys/nfs/nfsdiskless.h
--- a/sys/nfs/nfs_boot.c	Tue Feb 13 17:45:32 1996 +0000
+++ b/sys/nfs/nfs_boot.c	Tue Feb 13 17:53:32 1996 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_boot.c,v 1.22 1996/02/10 22:55:16 pk Exp $ */
+/*	$NetBSD: nfs_boot.c,v 1.23 1996/02/13 17:53:33 gwr Exp $ */
 
 /*
  * Copyright (c) 1995 Adam Glass, Gordon Ross
@@ -240,27 +240,29 @@
 	}
 #endif
 
-	get_path_and_handle(&bp_sin, "root", &nd->nd_root);
-	get_path_and_handle(&bp_sin, "swap", &nd->nd_swap);
+	bcopy(&bp_sin, &nd->nd_boot, sizeof(bp_sin));
 
 	return (0);
 }
 
-static void
-get_path_and_handle(bpsin, key, ndmntp)
+void
+nfs_boot_getfh(bpsin, key, ndmntp)
 	struct sockaddr_in *bpsin;	/* bootparam server */
 	char *key;			/* root or swap */
 	struct nfs_dlmount *ndmntp;	/* output */
 {
 	char pathname[MAXPATHLEN];
 	char *sp, *dp, *endp;
+	struct sockaddr_in *sin;
 	int error;
 
+	sin = &ndmntp->ndm_saddr;
+
 	/*
 	 * Get server:pathname for "key" (root or swap)
 	 * using RPC to bootparam/getfile
 	 */
-	error = bp_getfile(bpsin, key, &ndmntp->ndm_saddr,
+	error = bp_getfile(bpsin, key, sin,
 	    ndmntp->ndm_host, pathname);
 	if (error)
 		panic("nfs_boot: bootparam get %s: %d", key, error);
@@ -269,10 +271,16 @@
 	 * Get file handle for "key" (root or swap)
 	 * using RPC to mountd/mount
 	 */
-	error = md_mount(&ndmntp->ndm_saddr, pathname, ndmntp->ndm_fh);
+	error = md_mount(sin, pathname, ndmntp->ndm_fh);
 	if (error)
 		panic("nfs_boot: mountd %s, error=%d", key, error);
 
+	/* Set port number for NFS use. */
+	/* XXX: NFS port is always 2049, right? */
+	error = krpc_portmap(sin, NFS_PROG, NFS_VER2, &sin->sin_port);
+	if (error)
+		panic("nfs_boot: portmap NFS/v2, error=%d", error);
+
 	/* Construct remote path (for getmntinfo(3)) */
 	dp = ndmntp->ndm_host;
 	endp = dp + MNAMELEN - 1;
@@ -516,20 +524,23 @@
 	if (error)
 		return error;	/* message already freed */
 
+	/* The reply might have only the errno. */
+	if (m->m_len < 4)
+		goto bad;
+	/* Have at least errno, so check that. */
+	rdata = mtod(m, struct rdata *);
+	error = fxdr_unsigned(u_int32_t, rdata->errno);
+	if (error)
+		goto out;
+
+	/* Have errno==0, so the fh must be there. */
 	if (m->m_len < sizeof(*rdata)) {
 		m = m_pullup(m, sizeof(*rdata));
 		if (m == NULL)
 			goto bad;
+		rdata = mtod(m, struct rdata *);
 	}
-	rdata = mtod(m, struct rdata *);
-	error = fxdr_unsigned(u_int32_t, rdata->errno);
-	if (error)
-		goto out;
 	bcopy(rdata->fh, fhp, NFS_FHSIZE);
-
-	/* Set port number for NFS use. */
-	error = krpc_portmap(mdsin, NFS_PROG, NFS_VER2,
-						 &mdsin->sin_port);
 	goto out;
 
 bad:
--- a/sys/nfs/nfs_vfsops.c	Tue Feb 13 17:45:32 1996 +0000
+++ b/sys/nfs/nfs_vfsops.c	Tue Feb 13 17:53:32 1996 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.41 1996/02/09 21:48:38 christos Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.42 1996/02/13 17:53:35 gwr Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -197,6 +197,7 @@
 	/*
 	 * Create the root mount point.
 	 */
+	nfs_boot_getfh(&nd.nd_boot, "root", &nd.nd_root);
 	mp = nfs_mount_diskless(&nd.nd_root, "/", 0, &vp);
 	printf("root on %s\n", nd.nd_root.ndm_host);
 
@@ -248,6 +249,7 @@
 	 * Create a fake mount point just for the swap vnode so that the
 	 * swap file can be on a different server from the rootfs.
 	 */
+	nfs_boot_getfh(&nd.nd_boot, "swap", &nd.nd_swap);
 	mp = nfs_mount_diskless(&nd.nd_swap, "/swap", 0, &vp);
 	printf("swap on %s\n", nd.nd_swap.ndm_host);
 
@@ -291,7 +293,7 @@
 
 	/* Create the mount point. */
 	mp = (struct mount *)malloc((u_long)sizeof(struct mount),
-	    M_MOUNT, M_NOWAIT);
+	    M_MOUNT, M_WAITOK);
 	if (mp == NULL)
 		panic("nfs_mountroot: malloc mount for %s", mntname);
 	bzero((char *)mp, (u_long)sizeof(struct mount));
--- a/sys/nfs/nfsdiskless.h	Tue Feb 13 17:45:32 1996 +0000
+++ b/sys/nfs/nfsdiskless.h	Tue Feb 13 17:53:32 1996 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfsdiskless.h,v 1.7 1994/06/29 06:42:31 cgd Exp $	*/
+/*	$NetBSD: nfsdiskless.h,v 1.8 1996/02/13 17:53:32 gwr Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -55,6 +55,12 @@
 	u_char		ndm_fh[NFS_FHSIZE]; 	/* The file's file handle */
 };
 struct nfs_diskless {
+	struct sockaddr_in nd_boot;	/* Address of boot server */
 	struct nfs_dlmount nd_root; 	/* Mount info for root */
 	struct nfs_dlmount nd_swap; 	/* Mount info for swap */
 };
+
+int nfs_boot_init __P((struct nfs_diskless *nd, struct proc *procp));
+void nfs_boot_getfh __P((struct sockaddr_in *bpsin, char *key,
+		struct nfs_dlmount *ndmntp));
+