xdr.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* XDR types for nfsd. This is mainly a typing exercise. */
  3. #ifndef LINUX_NFSD_H
  4. #define LINUX_NFSD_H
  5. #include <linux/vfs.h>
  6. #include "nfsd.h"
  7. #include "nfsfh.h"
  8. struct nfsd_fhandle {
  9. struct svc_fh fh;
  10. };
  11. struct nfsd_sattrargs {
  12. struct svc_fh fh;
  13. struct iattr attrs;
  14. };
  15. struct nfsd_diropargs {
  16. struct svc_fh fh;
  17. char * name;
  18. unsigned int len;
  19. };
  20. struct nfsd_readargs {
  21. struct svc_fh fh;
  22. __u32 offset;
  23. __u32 count;
  24. };
  25. struct nfsd_writeargs {
  26. svc_fh fh;
  27. __u32 offset;
  28. __u32 len;
  29. struct xdr_buf payload;
  30. };
  31. struct nfsd_createargs {
  32. struct svc_fh fh;
  33. char * name;
  34. unsigned int len;
  35. struct iattr attrs;
  36. };
  37. struct nfsd_renameargs {
  38. struct svc_fh ffh;
  39. char * fname;
  40. unsigned int flen;
  41. struct svc_fh tfh;
  42. char * tname;
  43. unsigned int tlen;
  44. };
  45. struct nfsd_linkargs {
  46. struct svc_fh ffh;
  47. struct svc_fh tfh;
  48. char * tname;
  49. unsigned int tlen;
  50. };
  51. struct nfsd_symlinkargs {
  52. struct svc_fh ffh;
  53. char * fname;
  54. unsigned int flen;
  55. char * tname;
  56. unsigned int tlen;
  57. struct iattr attrs;
  58. struct kvec first;
  59. };
  60. struct nfsd_readdirargs {
  61. struct svc_fh fh;
  62. __u32 cookie;
  63. __u32 count;
  64. };
  65. struct nfsd_stat {
  66. __be32 status;
  67. };
  68. struct nfsd_attrstat {
  69. __be32 status;
  70. struct svc_fh fh;
  71. struct kstat stat;
  72. };
  73. struct nfsd_diropres {
  74. __be32 status;
  75. struct svc_fh fh;
  76. struct kstat stat;
  77. };
  78. struct nfsd_readlinkres {
  79. __be32 status;
  80. int len;
  81. struct page *page;
  82. };
  83. struct nfsd_readres {
  84. __be32 status;
  85. struct svc_fh fh;
  86. unsigned long count;
  87. struct kstat stat;
  88. struct page **pages;
  89. };
  90. struct nfsd_readdirres {
  91. /* Components of the reply */
  92. __be32 status;
  93. int count;
  94. /* Used to encode the reply's entry list */
  95. struct xdr_stream xdr;
  96. struct xdr_buf dirlist;
  97. struct readdir_cd common;
  98. unsigned int cookie_offset;
  99. };
  100. struct nfsd_statfsres {
  101. __be32 status;
  102. struct kstatfs stats;
  103. };
  104. /*
  105. * Storage requirements for XDR arguments and results.
  106. */
  107. union nfsd_xdrstore {
  108. struct nfsd_sattrargs sattr;
  109. struct nfsd_diropargs dirop;
  110. struct nfsd_readargs read;
  111. struct nfsd_writeargs write;
  112. struct nfsd_createargs create;
  113. struct nfsd_renameargs rename;
  114. struct nfsd_linkargs link;
  115. struct nfsd_symlinkargs symlink;
  116. struct nfsd_readdirargs readdir;
  117. };
  118. #define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore)
  119. bool nfssvc_decode_fhandleargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  120. bool nfssvc_decode_sattrargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  121. bool nfssvc_decode_diropargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  122. bool nfssvc_decode_readargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  123. bool nfssvc_decode_writeargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  124. bool nfssvc_decode_createargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  125. bool nfssvc_decode_renameargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  126. bool nfssvc_decode_linkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  127. bool nfssvc_decode_symlinkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  128. bool nfssvc_decode_readdirargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  129. bool nfssvc_encode_statres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  130. bool nfssvc_encode_attrstatres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  131. bool nfssvc_encode_diropres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  132. bool nfssvc_encode_readlinkres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  133. bool nfssvc_encode_readres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  134. bool nfssvc_encode_statfsres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  135. bool nfssvc_encode_readdirres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  136. void nfssvc_encode_nfscookie(struct nfsd_readdirres *resp, u32 offset);
  137. int nfssvc_encode_entry(void *data, const char *name, int namlen,
  138. loff_t offset, u64 ino, unsigned int d_type);
  139. void nfssvc_release_attrstat(struct svc_rqst *rqstp);
  140. void nfssvc_release_diropres(struct svc_rqst *rqstp);
  141. void nfssvc_release_readres(struct svc_rqst *rqstp);
  142. /* Helper functions for NFSv2 ACL code */
  143. bool svcxdr_decode_fhandle(struct xdr_stream *xdr, struct svc_fh *fhp);
  144. bool svcxdr_encode_stat(struct xdr_stream *xdr, __be32 status);
  145. bool svcxdr_encode_fattr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
  146. const struct svc_fh *fhp, const struct kstat *stat);
  147. #endif /* LINUX_NFSD_H */