+ register struct mount *mp;
+ register struct mbuf *m;
+ struct socket *so;
+ struct vnode *vp;
+ int error;
+
+ /*
+ * Do enough of ifconfig(8) so that critical net interface can
+ * talk to the server.
+ */
+ if (socreate(nfs_diskless.myif.ifra_addr.sa_family, &so, SOCK_DGRAM, 0))
+ panic("nfs ifconf");
+ if (ifioctl(so, SIOCAIFADDR, &nfs_diskless.myif))
+ panic("nfs ifconf2");
+ soclose(so);
+
+ /*
+ * If the gateway field is filled in, set it as the default route.
+ */
+#ifdef COMPAT_43
+ if (nfs_diskless.mygateway.sa_family == AF_INET) {
+ struct ortentry rt;
+ struct sockaddr_in *sin;
+
+ sin = (struct sockaddr_in *) &rt.rt_dst;
+ sin->sin_len = sizeof (struct sockaddr_in);
+ sin->sin_family = AF_INET;
+ sin->sin_addr.s_addr = 0; /* default */
+ bcopy((caddr_t)&nfs_diskless.mygateway, (caddr_t)&rt.rt_gateway,
+ sizeof (struct sockaddr_in));
+ rt.rt_flags = (RTF_UP | RTF_GATEWAY);
+ if (rtioctl(SIOCADDRT, (caddr_t)&rt))
+ panic("nfs root route");
+ }
+#endif /* COMPAT_43 */
+
+ /*
+ * If swapping to an nfs node (indicated by swdevt[0].sw_dev == NODEV):
+ * Create a fake mount point just for the swap vnode so that the
+ * swap file can be on a different server from the rootfs.
+ */
+ if (swdevt[0].sw_dev == NODEV) {
+ mp = (struct mount *)malloc((u_long)sizeof(struct mount),
+ M_MOUNT, M_NOWAIT);
+ if (mp == NULL)
+ panic("nfs root mount");
+ mp->mnt_op = &nfs_vfsops;
+ mp->mnt_flag = 0;
+ mp->mnt_exroot = 0;
+ mp->mnt_mounth = NULLVP;
+
+ /*
+ * Set up the diskless nfs_args for the swap mount point
+ * and then call mountnfs() to mount it.
+ * Since the swap file is not the root dir of a file system,
+ * hack it to a regular file.
+ */
+ nfs_diskless.swap_args.fh = (nfsv2fh_t *)nfs_diskless.swap_fh;
+ MGET(m, MT_SONAME, M_DONTWAIT);
+ if (m == NULL)
+ panic("nfs root mbuf");
+ bcopy((caddr_t)&nfs_diskless.swap_saddr, mtod(m, caddr_t),
+ nfs_diskless.swap_saddr.sa_len);
+ m->m_len = nfs_diskless.swap_saddr.sa_len;
+ if (mountnfs(&nfs_diskless.swap_args, mp, m, "/swap",
+ nfs_diskless.swap_hostnam, &vp))
+ panic("nfs swap");
+ vp->v_type = VREG;
+ vp->v_flag = 0;
+ swapdev_vp = vp;
+ VREF(vp);
+ swdevt[0].sw_vp = vp;
+ }
+
+ /*
+ * Create the rootfs mount point.
+ */
+ mp = (struct mount *)malloc((u_long)sizeof(struct mount),
+ M_MOUNT, M_NOWAIT);
+ if (mp == NULL)
+ panic("nfs root mount2");
+ mp->mnt_op = &nfs_vfsops;
+ mp->mnt_flag = MNT_RDONLY;
+ mp->mnt_exroot = 0;
+ mp->mnt_mounth = NULLVP;
+
+ /*
+ * Set up the root fs args and call mountnfs() to do the rest.
+ */
+ nfs_diskless.root_args.fh = (nfsv2fh_t *)nfs_diskless.root_fh;
+ MGET(m, MT_SONAME, M_DONTWAIT);
+ if (m == NULL)
+ panic("nfs root mbuf2");
+ bcopy((caddr_t)&nfs_diskless.root_saddr, mtod(m, caddr_t),
+ nfs_diskless.root_saddr.sa_len);
+ m->m_len = nfs_diskless.root_saddr.sa_len;
+ if (mountnfs(&nfs_diskless.root_args, mp, m, "/",
+ nfs_diskless.root_hostnam, &vp))
+ panic("nfs root");
+ if (vfs_lock(mp))
+ panic("nfs root2");
+ rootfs = mp;
+ mp->mnt_next = mp;
+ mp->mnt_prev = mp;
+ mp->mnt_vnodecovered = NULLVP;
+ vfs_unlock(mp);
+ rootvp = vp;
+ inittodr((time_t)0); /* There is no time in the nfs fsstat so ?? */
+ return (0);