* better
[mascara-docs.git] / i386 / linux-2.3.21 / fs / nfsd / lockd.c
blobe23f48e5b9515f3abd12d1b75ac30a679f71f549
1 /*
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>
9 */
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.
22 static u32
23 nlm_fopen(struct svc_rqst *rqstp, struct knfs_fh *f, struct file *filp)
25 u32 nfserr;
26 struct svc_fh fh;
28 /* must initialize before using! */
29 fh_init(&fh);
30 fh.fh_handle = *f;
31 fh.fh_export = NULL;
33 nfserr = nfsd_open(rqstp, &fh, S_IFREG, 0, filp);
34 if (!nfserr)
35 dget(filp->f_dentry);
36 fh_put(&fh);
37 return nfserr;
40 static void
41 nlm_fclose(struct file *filp)
43 nfsd_close(filp);
44 dput(filp->f_dentry);
47 struct nlmsvc_binding nfsd_nlm_ops = {
48 exp_readlock, /* lock export table for reading */
49 exp_unlock, /* unlock export table */
50 exp_getclient, /* look up NFS client */
51 nlm_fopen, /* open file for locking */
52 nlm_fclose, /* close file */
53 exp_nlmdetach, /* lockd shutdown notification */
57 * When removing an NFS client entry, notify lockd that it is gone.
58 * FIXME: We should do the same when unexporting an NFS volume.
60 void
61 nfsd_lockd_unexport(struct svc_client *clnt)
63 nlmsvc_invalidate_client(clnt);
66 void
67 nfsd_lockd_init(void)
69 dprintk("nfsd: initializing lockd\n");
70 nlmsvc_ops = &nfsd_nlm_ops;
73 void
74 nfsd_lockd_shutdown(void)
76 nlmsvc_ops = NULL;