xdr.h 2.9 KB

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