2005-04-17 02:20:36 +04:00
/*
* This file contains all the stubs needed when communicating with lockd .
* This level of indirection is necessary so we can run nfsd + lockd without
* requiring the nfs client to be compiled in / loaded , and vice versa .
*
* Copyright ( C ) 1996 , Olaf Kirch < okir @ monad . swb . de >
*/
# include <linux/file.h>
# include <linux/lockd/bind.h>
2009-12-03 21:30:56 +03:00
# include "nfsd.h"
2009-11-05 02:12:35 +03:00
# include "vfs.h"
2005-04-17 02:20:36 +04:00
# define NFSDDBG_FACILITY NFSDDBG_LOCKD
2008-07-25 12:48:55 +04:00
# ifdef CONFIG_LOCKD_V4
# define nlm_stale_fh nlm4_stale_fh
# define nlm_failed nlm4_failed
# else
# define nlm_stale_fh nlm_lck_denied_nolocks
# define nlm_failed nlm_lck_denied_nolocks
# endif
2005-04-17 02:20:36 +04:00
/*
* Note : we hold the dentry use count while the file is open .
*/
2006-12-13 11:35:03 +03:00
static __be32
2005-04-17 02:20:36 +04:00
nlm_fopen ( struct svc_rqst * rqstp , struct nfs_fh * f , struct file * * filp )
{
2006-10-20 10:29:02 +04:00
__be32 nfserr ;
2005-04-17 02:20:36 +04:00
struct svc_fh fh ;
/* must initialize before using! but maxsize doesn't matter */
fh_init ( & fh , 0 ) ;
fh . fh_handle . fh_size = f - > size ;
memcpy ( ( char * ) & fh . fh_handle . fh_base , f - > data , f - > size ) ;
fh . fh_export = NULL ;
2008-06-16 15:20:29 +04:00
nfserr = nfsd_open ( rqstp , & fh , S_IFREG , NFSD_MAY_LOCK , filp ) ;
2005-04-17 02:20:36 +04:00
fh_put ( & fh ) ;
2006-10-17 11:10:18 +04:00
/* We return nlm error codes as nlm doesn't know
* about nfsd , but nfsd does know about nlm . .
2005-04-17 02:20:36 +04:00
*/
switch ( nfserr ) {
case nfs_ok :
return 0 ;
2006-10-17 11:10:18 +04:00
case nfserr_dropit :
return nlm_drop_reply ;
2005-04-17 02:20:36 +04:00
case nfserr_stale :
2008-07-25 12:48:55 +04:00
return nlm_stale_fh ;
2005-04-17 02:20:36 +04:00
default :
2008-07-25 12:48:55 +04:00
return nlm_failed ;
2005-04-17 02:20:36 +04:00
}
}
static void
nlm_fclose ( struct file * filp )
{
fput ( filp ) ;
}
static struct nlmsvc_binding nfsd_nlm_ops = {
. fopen = nlm_fopen , /* open file for locking */
. fclose = nlm_fclose , /* close file */
} ;
void
nfsd_lockd_init ( void )
{
dprintk ( " nfsd: initializing lockd \n " ) ;
nlmsvc_ops = & nfsd_nlm_ops ;
}
void
nfsd_lockd_shutdown ( void )
{
nlmsvc_ops = NULL ;
}