xdr.h 3.1 KB

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