MFC r200471, r201044:
Add a few more V_hacks to nfsclient to allow machines with a VIMAGE kernel to boot from NFS. [1] Note: this is not a full virtualization of nfsclient. It is only does what advertised above and nothing more.
This commit is contained in:
parent
5413a67902
commit
dc0dae367e
@ -584,6 +584,8 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td)
|
||||
int retry;
|
||||
const char *s;
|
||||
|
||||
CURVNET_SET(TD_TO_VNET(td));
|
||||
|
||||
/*
|
||||
* Create socket and set its recieve timeout.
|
||||
*/
|
||||
@ -960,6 +962,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td)
|
||||
out:
|
||||
soclose(so);
|
||||
out0:
|
||||
CURVNET_RESTORE();
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -974,6 +977,8 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx,
|
||||
struct ifaddr *ifa;
|
||||
struct sockaddr_dl *sdl;
|
||||
|
||||
CURVNET_SET(TD_TO_VNET(td));
|
||||
|
||||
error = socreate(AF_INET, &ifctx->so, SOCK_DGRAM, 0, td->td_ucred, td);
|
||||
if (error != 0)
|
||||
panic("nfs_boot: socreate, error=%d", error);
|
||||
@ -1048,6 +1053,8 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx,
|
||||
ifctx->ireq.ifr_name);
|
||||
ifctx->sdl = sdl;
|
||||
|
||||
CURVNET_RESTORE();
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/proc.h>
|
||||
@ -55,6 +56,8 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <rpc/types.h>
|
||||
@ -213,6 +216,8 @@ krpc_call(struct sockaddr_in *sa, u_int prog, u_int vers, u_int func,
|
||||
nam = mhead = NULL;
|
||||
from = NULL;
|
||||
|
||||
CURVNET_SET(TD_TO_VNET(td));
|
||||
|
||||
/*
|
||||
* Create socket and set its recieve timeout.
|
||||
*/
|
||||
@ -425,6 +430,7 @@ krpc_call(struct sockaddr_in *sa, u_int prog, u_int vers, u_int func,
|
||||
if (mhead) m_freem(mhead);
|
||||
if (from) free(from, M_SONAME);
|
||||
soclose(so);
|
||||
CURVNET_RESTORE();
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <rpc/rpc.h>
|
||||
@ -825,6 +827,8 @@ nfs_mount(struct mount *mp)
|
||||
has_fh_opt = 0;
|
||||
has_hostname_opt = 0;
|
||||
|
||||
CURVNET_SET(CRED_TO_VNET(curthread->td_ucred));
|
||||
|
||||
if (vfs_filteropt(mp->mnt_optnew, nfs_opts)) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
@ -1124,6 +1128,7 @@ nfs_mount(struct mount *mp)
|
||||
mp->mnt_kern_flag |= (MNTK_MPSAFE|MNTK_LOOKUP_SHARED);
|
||||
MNT_IUNLOCK(mp);
|
||||
}
|
||||
CURVNET_RESTORE();
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -1555,14 +1555,21 @@ nfs_create(struct vop_create_args *ap)
|
||||
struct vattr vattr;
|
||||
int v3 = NFS_ISV3(dvp);
|
||||
|
||||
CURVNET_SET(CRED_TO_VNET(curthread->td_ucred));
|
||||
|
||||
/*
|
||||
* Oops, not for me..
|
||||
*/
|
||||
if (vap->va_type == VSOCK)
|
||||
return (nfs_mknodrpc(dvp, ap->a_vpp, cnp, vap));
|
||||
|
||||
if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred)) != 0)
|
||||
if (vap->va_type == VSOCK) {
|
||||
error = nfs_mknodrpc(dvp, ap->a_vpp, cnp, vap);
|
||||
CURVNET_RESTORE();
|
||||
return (error);
|
||||
}
|
||||
|
||||
if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred)) != 0) {
|
||||
CURVNET_RESTORE();
|
||||
return (error);
|
||||
}
|
||||
if (vap->va_vaflags & VA_EXCLUSIVE)
|
||||
fmode |= O_EXCL;
|
||||
again:
|
||||
@ -1658,6 +1665,7 @@ nfs_create(struct vop_create_args *ap)
|
||||
KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(dvp);
|
||||
}
|
||||
mtx_unlock(&(VTONFS(dvp))->n_mtx);
|
||||
CURVNET_RESTORE();
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user