xdr.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. #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. struct file_lock fl;
  36. };
  37. /*
  38. * NLM cookies. Technically they can be 1K, but Linux only uses 8 bytes.
  39. * FreeBSD uses 16, Apple Mac OS X 10.3 uses 20. Therefore we set it to
  40. * 32 bytes.
  41. */
  42. struct nlm_cookie
  43. {
  44. unsigned char data[NLM_MAXCOOKIELEN];
  45. unsigned int len;
  46. };
  47. /*
  48. * Generic lockd arguments for all but sm_notify
  49. */
  50. struct nlm_args {
  51. struct nlm_cookie cookie;
  52. struct nlm_lock lock;
  53. u32 block;
  54. u32 reclaim;
  55. u32 state;
  56. u32 monitor;
  57. u32 fsm_access;
  58. u32 fsm_mode;
  59. };
  60. typedef struct nlm_args nlm_args;
  61. /*
  62. * Generic lockd result
  63. */
  64. struct nlm_res {
  65. struct nlm_cookie cookie;
  66. __be32 status;
  67. struct nlm_lock lock;
  68. };
  69. /*
  70. * statd callback when client has rebooted
  71. */
  72. struct nlm_reboot {
  73. char *mon;
  74. unsigned int len;
  75. u32 state;
  76. struct nsm_private priv;
  77. };
  78. /*
  79. * Contents of statd callback when monitored host rebooted
  80. */
  81. #define NLMSVC_XDRSIZE sizeof(struct nlm_args)
  82. int nlmsvc_decode_testargs(struct svc_rqst *, __be32 *);
  83. int nlmsvc_encode_testres(struct svc_rqst *, __be32 *);
  84. int nlmsvc_decode_lockargs(struct svc_rqst *, __be32 *);
  85. int nlmsvc_decode_cancargs(struct svc_rqst *, __be32 *);
  86. int nlmsvc_decode_unlockargs(struct svc_rqst *, __be32 *);
  87. int nlmsvc_encode_res(struct svc_rqst *, __be32 *);
  88. int nlmsvc_decode_res(struct svc_rqst *, __be32 *);
  89. int nlmsvc_encode_void(struct svc_rqst *, __be32 *);
  90. int nlmsvc_decode_void(struct svc_rqst *, __be32 *);
  91. int nlmsvc_decode_shareargs(struct svc_rqst *, __be32 *);
  92. int nlmsvc_encode_shareres(struct svc_rqst *, __be32 *);
  93. int nlmsvc_decode_notify(struct svc_rqst *, __be32 *);
  94. int nlmsvc_decode_reboot(struct svc_rqst *, __be32 *);
  95. /*
  96. int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *);
  97. int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
  98. int nlmclt_encode_cancargs(struct rpc_rqst *, u32 *, struct nlm_args *);
  99. int nlmclt_encode_unlockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
  100. */
  101. #endif /* LOCKD_XDR_H */