Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * linux/include/linux/lockd/xdr.h
0004  *
0005  * XDR types for the NLM protocol
0006  *
0007  * Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de>
0008  */
0009 
0010 #ifndef LOCKD_XDR_H
0011 #define LOCKD_XDR_H
0012 
0013 #include <linux/fs.h>
0014 #include <linux/nfs.h>
0015 #include <linux/sunrpc/xdr.h>
0016 
0017 #define SM_MAXSTRLEN        1024
0018 #define SM_PRIV_SIZE        16
0019 
0020 struct nsm_private {
0021     unsigned char       data[SM_PRIV_SIZE];
0022 };
0023 
0024 struct svc_rqst;
0025 
0026 #define NLM_MAXCOOKIELEN        32
0027 #define NLM_MAXSTRLEN       1024
0028 
0029 #define nlm_granted     cpu_to_be32(NLM_LCK_GRANTED)
0030 #define nlm_lck_denied      cpu_to_be32(NLM_LCK_DENIED)
0031 #define nlm_lck_denied_nolocks  cpu_to_be32(NLM_LCK_DENIED_NOLOCKS)
0032 #define nlm_lck_blocked     cpu_to_be32(NLM_LCK_BLOCKED)
0033 #define nlm_lck_denied_grace_period cpu_to_be32(NLM_LCK_DENIED_GRACE_PERIOD)
0034 
0035 #define nlm_drop_reply      cpu_to_be32(30000)
0036 
0037 /* Lock info passed via NLM */
0038 struct nlm_lock {
0039     char *          caller;
0040     unsigned int        len;    /* length of "caller" */
0041     struct nfs_fh       fh;
0042     struct xdr_netobj   oh;
0043     u32         svid;
0044     u64         lock_start;
0045     u64         lock_len;
0046     struct file_lock    fl;
0047 };
0048 
0049 /*
0050  *  NLM cookies. Technically they can be 1K, but Linux only uses 8 bytes.
0051  *  FreeBSD uses 16, Apple Mac OS X 10.3 uses 20. Therefore we set it to
0052  *  32 bytes.
0053  */
0054  
0055 struct nlm_cookie
0056 {
0057     unsigned char data[NLM_MAXCOOKIELEN];
0058     unsigned int len;
0059 };
0060 
0061 /*
0062  * Generic lockd arguments for all but sm_notify
0063  */
0064 struct nlm_args {
0065     struct nlm_cookie   cookie;
0066     struct nlm_lock     lock;
0067     u32         block;
0068     u32         reclaim;
0069     u32         state;
0070     u32         monitor;
0071     u32         fsm_access;
0072     u32         fsm_mode;
0073 };
0074 
0075 typedef struct nlm_args nlm_args;
0076 
0077 /*
0078  * Generic lockd result
0079  */
0080 struct nlm_res {
0081     struct nlm_cookie   cookie;
0082     __be32          status;
0083     struct nlm_lock     lock;
0084 };
0085 
0086 /*
0087  * statd callback when client has rebooted
0088  */
0089 struct nlm_reboot {
0090     char            *mon;
0091     unsigned int        len;
0092     u32         state;
0093     struct nsm_private  priv;
0094 };
0095 
0096 /*
0097  * Contents of statd callback when monitored host rebooted
0098  */
0099 #define NLMSVC_XDRSIZE      sizeof(struct nlm_args)
0100 
0101 bool    nlmsvc_decode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0102 bool    nlmsvc_decode_testargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0103 bool    nlmsvc_decode_lockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0104 bool    nlmsvc_decode_cancargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0105 bool    nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0106 bool    nlmsvc_decode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0107 bool    nlmsvc_decode_reboot(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0108 bool    nlmsvc_decode_shareargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0109 bool    nlmsvc_decode_notify(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0110 
0111 bool    nlmsvc_encode_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0112 bool    nlmsvc_encode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0113 bool    nlmsvc_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0114 bool    nlmsvc_encode_shareres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0115 
0116 #endif /* LOCKD_XDR_H */