summaryrefslogtreecommitdiffstats
path: root/sys/fs/nfsclient/nfs_clvfsops.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/fs/nfsclient/nfs_clvfsops.c')
-rw-r--r--sys/fs/nfsclient/nfs_clvfsops.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c
index b2cd92b..816d288 100644
--- a/sys/fs/nfsclient/nfs_clvfsops.c
+++ b/sys/fs/nfsclient/nfs_clvfsops.c
@@ -96,10 +96,13 @@ SYSCTL_INT(_vfs_newnfs, NFS_TPRINTF_DELAY,
static void nfs_sec_name(char *, int *);
static void nfs_decode_args(struct mount *mp, struct nfsmount *nmp,
- struct nfs_args *argp, struct ucred *, struct thread *);
+ struct nfs_args *argp, const char *, struct ucred *,
+ struct thread *);
static int mountnfs(struct nfs_args *, struct mount *,
struct sockaddr *, char *, u_char *, u_char *, u_char *,
struct vnode **, struct ucred *, struct thread *, int);
+static void nfs_getnlminfo(struct vnode *, uint8_t *, int *,
+ struct sockaddr_storage *, int *, off_t *);
static vfs_mount_t nfs_mount;
static vfs_cmount_t nfs_cmount;
static vfs_unmount_t nfs_unmount;
@@ -518,10 +521,11 @@ nfs_sec_name(char *sec, int *flagsp)
static void
nfs_decode_args(struct mount *mp, struct nfsmount *nmp, struct nfs_args *argp,
- struct ucred *cred, struct thread *td)
+ const char *hostname, struct ucred *cred, struct thread *td)
{
int s;
int adjsock;
+ char *p;
s = splnet();
@@ -659,6 +663,14 @@ nfs_decode_args(struct mount *mp, struct nfsmount *nmp, struct nfs_args *argp,
nmp->nm_sotype = argp->sotype;
nmp->nm_soproto = argp->proto;
}
+
+ if (hostname != NULL) {
+ strlcpy(nmp->nm_hostname, hostname,
+ sizeof(nmp->nm_hostname));
+ p = strchr(nmp->nm_hostname, ':');
+ if (p != NULL)
+ *p = '\0';
+ }
}
static const char *nfs_opts[] = { "from",
@@ -933,7 +945,7 @@ nfs_mount(struct mount *mp)
NFSMNT_INTEGRITY |
NFSMNT_PRIVACY |
NFSMNT_NOLOCKD /*|NFSMNT_XLATECOOKIE*/));
- nfs_decode_args(mp, nmp, &args, td->td_ucred, td);
+ nfs_decode_args(mp, nmp, &args, NULL, td->td_ucred, td);
goto out;
}
@@ -1110,13 +1122,14 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam,
nmp->nm_sockreq.nr_cred = crhold(cred);
mtx_init(&nmp->nm_sockreq.nr_mtx, "nfssock", NULL, MTX_DEF);
mp->mnt_data = nmp;
+ nmp->nm_getinfo = nfs_getnlminfo;
}
vfs_getnewfsid(mp);
nmp->nm_mountp = mp;
mtx_init(&nmp->nm_mtx, "NFSmount lock", NULL, MTX_DEF | MTX_DUPOK);
nmp->nm_negnametimeo = negnametimeo;
- nfs_decode_args(mp, nmp, argp, cred, td);
+ nfs_decode_args(mp, nmp, argp, hst, cred, td);
/*
* V2 can only handle 32 bit filesizes. A 4GB-1 limit may be too
@@ -1447,3 +1460,26 @@ nfs_sysctl(struct mount *mp, fsctlop_t op, struct sysctl_req *req)
return (0);
}
+/*
+ * Extract the information needed by the nlm from the nfs vnode.
+ */
+static void
+nfs_getnlminfo(struct vnode *vp, uint8_t *fhp, int *fhlenp,
+ struct sockaddr_storage *sp, int *is_v3p, off_t *sizep)
+{
+ struct nfsmount *nmp;
+ struct nfsnode *np = VTONFS(vp);
+
+ nmp = VFSTONFS(vp->v_mount);
+ if (fhlenp != NULL)
+ *fhlenp = np->n_fhp->nfh_len;
+ if (fhp != NULL)
+ bcopy(np->n_fhp->nfh_fh, fhp, np->n_fhp->nfh_len);
+ if (sp != NULL)
+ bcopy(nmp->nm_nam, sp, min(nmp->nm_nam->sa_len, sizeof(*sp)));
+ if (is_v3p != NULL)
+ *is_v3p = NFS_ISV3(vp);
+ if (sizep != NULL)
+ *sizep = np->n_size;
+}
+
OpenPOWER on IntegriCloud