2 * linux/fs/nfsd/lockd.c
4 * This file contains all the stubs needed when communicating with lockd.
5 * This level of indirection is necessary so we can run nfsd+lockd without
6 * requiring the nfs client to be compiled in/loaded, and vice versa.
8 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
11 #include <linux/types.h>
12 #include <linux/sunrpc/clnt.h>
13 #include <linux/sunrpc/svc.h>
14 #include <linux/nfsd/nfsd.h>
15 #include <linux/lockd/bind.h>
17 #define NFSDDBG_FACILITY NFSDDBG_LOCKD
20 * Note: we hold the dentry use count while the file is open.
23 nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file *filp)
28 /* must initialize before using! but maxsize doesn't matter */
30 fh.fh_handle.fh_size = f->size;
31 memcpy((char*)&fh.fh_handle.fh_base, f->data, f->size);
34 nfserr = nfsd_open(rqstp, &fh, S_IFREG, MAY_LOCK, filp);
37 mntget(filp->f_vfsmnt);
40 /* nlm and nfsd don't share error codes.
41 * we invent: 0 = no error
42 * 1 = stale file handle
56 nlm_fclose(struct file *filp)
60 mntput(filp->f_vfsmnt);
63 struct nlmsvc_binding nfsd_nlm_ops = {
64 exp_readlock, /* lock export table for reading */
65 exp_unlock, /* unlock export table */
66 exp_getclient, /* look up NFS client */
67 nlm_fopen, /* open file for locking */
68 nlm_fclose, /* close file */
69 exp_nlmdetach, /* lockd shutdown notification */
73 * When removing an NFS client entry, notify lockd that it is gone.
74 * FIXME: We should do the same when unexporting an NFS volume.
77 nfsd_lockd_unexport(struct svc_client *clnt)
79 nlmsvc_invalidate_client(clnt);
85 dprintk("nfsd: initializing lockd\n");
86 nlmsvc_ops = &nfsd_nlm_ops;
90 nfsd_lockd_shutdown(void)