at v6.0 3.0 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * linux/include/linux/lockd/xdr.h 4 * 5 * XDR types for the NLM protocol 6 * 7 * Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de> 8 */ 9 10#ifndef LOCKD_XDR_H 11#define LOCKD_XDR_H 12 13#include <linux/fs.h> 14#include <linux/nfs.h> 15#include <linux/sunrpc/xdr.h> 16 17#define SM_MAXSTRLEN 1024 18#define SM_PRIV_SIZE 16 19 20struct nsm_private { 21 unsigned char data[SM_PRIV_SIZE]; 22}; 23 24struct svc_rqst; 25 26#define NLM_MAXCOOKIELEN 32 27#define NLM_MAXSTRLEN 1024 28 29#define nlm_granted cpu_to_be32(NLM_LCK_GRANTED) 30#define nlm_lck_denied cpu_to_be32(NLM_LCK_DENIED) 31#define nlm_lck_denied_nolocks cpu_to_be32(NLM_LCK_DENIED_NOLOCKS) 32#define nlm_lck_blocked cpu_to_be32(NLM_LCK_BLOCKED) 33#define nlm_lck_denied_grace_period cpu_to_be32(NLM_LCK_DENIED_GRACE_PERIOD) 34 35#define nlm_drop_reply cpu_to_be32(30000) 36 37/* Lock info passed via NLM */ 38struct nlm_lock { 39 char * caller; 40 unsigned int len; /* length of "caller" */ 41 struct nfs_fh fh; 42 struct xdr_netobj oh; 43 u32 svid; 44 u64 lock_start; 45 u64 lock_len; 46 struct file_lock fl; 47}; 48 49/* 50 * NLM cookies. Technically they can be 1K, but Linux only uses 8 bytes. 51 * FreeBSD uses 16, Apple Mac OS X 10.3 uses 20. Therefore we set it to 52 * 32 bytes. 53 */ 54 55struct nlm_cookie 56{ 57 unsigned char data[NLM_MAXCOOKIELEN]; 58 unsigned int len; 59}; 60 61/* 62 * Generic lockd arguments for all but sm_notify 63 */ 64struct nlm_args { 65 struct nlm_cookie cookie; 66 struct nlm_lock lock; 67 u32 block; 68 u32 reclaim; 69 u32 state; 70 u32 monitor; 71 u32 fsm_access; 72 u32 fsm_mode; 73}; 74 75typedef struct nlm_args nlm_args; 76 77/* 78 * Generic lockd result 79 */ 80struct nlm_res { 81 struct nlm_cookie cookie; 82 __be32 status; 83 struct nlm_lock lock; 84}; 85 86/* 87 * statd callback when client has rebooted 88 */ 89struct nlm_reboot { 90 char *mon; 91 unsigned int len; 92 u32 state; 93 struct nsm_private priv; 94}; 95 96/* 97 * Contents of statd callback when monitored host rebooted 98 */ 99#define NLMSVC_XDRSIZE sizeof(struct nlm_args) 100 101bool nlmsvc_decode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr); 102bool nlmsvc_decode_testargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 103bool nlmsvc_decode_lockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 104bool nlmsvc_decode_cancargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 105bool nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 106bool nlmsvc_decode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr); 107bool nlmsvc_decode_reboot(struct svc_rqst *rqstp, struct xdr_stream *xdr); 108bool nlmsvc_decode_shareargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 109bool nlmsvc_decode_notify(struct svc_rqst *rqstp, struct xdr_stream *xdr); 110 111bool nlmsvc_encode_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 112bool nlmsvc_encode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr); 113bool nlmsvc_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr); 114bool nlmsvc_encode_shareres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 115 116#endif /* LOCKD_XDR_H */