xdr3.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * XDR types for NFSv3 in nfsd.
  4. *
  5. * Copyright (C) 1996-1998, Olaf Kirch <okir@monad.swb.de>
  6. */
  7. #ifndef _LINUX_NFSD_XDR3_H
  8. #define _LINUX_NFSD_XDR3_H
  9. #include "xdr.h"
  10. struct nfsd3_sattrargs {
  11. struct svc_fh fh;
  12. struct iattr attrs;
  13. int check_guard;
  14. struct timespec64 guardtime;
  15. };
  16. struct nfsd3_diropargs {
  17. struct svc_fh fh;
  18. char * name;
  19. unsigned int len;
  20. };
  21. struct nfsd3_accessargs {
  22. struct svc_fh fh;
  23. __u32 access;
  24. };
  25. struct nfsd3_readargs {
  26. struct svc_fh fh;
  27. __u64 offset;
  28. __u32 count;
  29. };
  30. struct nfsd3_writeargs {
  31. svc_fh fh;
  32. __u64 offset;
  33. __u32 count;
  34. int stable;
  35. __u32 len;
  36. struct xdr_buf payload;
  37. };
  38. struct nfsd3_createargs {
  39. struct svc_fh fh;
  40. char * name;
  41. unsigned int len;
  42. int createmode;
  43. struct iattr attrs;
  44. __be32 * verf;
  45. };
  46. struct nfsd3_mknodargs {
  47. struct svc_fh fh;
  48. char * name;
  49. unsigned int len;
  50. __u32 ftype;
  51. __u32 major, minor;
  52. struct iattr attrs;
  53. };
  54. struct nfsd3_renameargs {
  55. struct svc_fh ffh;
  56. char * fname;
  57. unsigned int flen;
  58. struct svc_fh tfh;
  59. char * tname;
  60. unsigned int tlen;
  61. };
  62. struct nfsd3_linkargs {
  63. struct svc_fh ffh;
  64. struct svc_fh tfh;
  65. char * tname;
  66. unsigned int tlen;
  67. };
  68. struct nfsd3_symlinkargs {
  69. struct svc_fh ffh;
  70. char * fname;
  71. unsigned int flen;
  72. char * tname;
  73. unsigned int tlen;
  74. struct iattr attrs;
  75. struct kvec first;
  76. };
  77. struct nfsd3_readdirargs {
  78. struct svc_fh fh;
  79. __u64 cookie;
  80. __u32 count;
  81. __be32 * verf;
  82. };
  83. struct nfsd3_commitargs {
  84. struct svc_fh fh;
  85. __u64 offset;
  86. __u32 count;
  87. };
  88. struct nfsd3_getaclargs {
  89. struct svc_fh fh;
  90. __u32 mask;
  91. };
  92. struct posix_acl;
  93. struct nfsd3_setaclargs {
  94. struct svc_fh fh;
  95. __u32 mask;
  96. struct posix_acl *acl_access;
  97. struct posix_acl *acl_default;
  98. };
  99. struct nfsd3_attrstat {
  100. __be32 status;
  101. struct svc_fh fh;
  102. struct kstat stat;
  103. };
  104. /* LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD */
  105. struct nfsd3_diropres {
  106. __be32 status;
  107. struct svc_fh dirfh;
  108. struct svc_fh fh;
  109. };
  110. struct nfsd3_accessres {
  111. __be32 status;
  112. struct svc_fh fh;
  113. __u32 access;
  114. struct kstat stat;
  115. };
  116. struct nfsd3_readlinkres {
  117. __be32 status;
  118. struct svc_fh fh;
  119. __u32 len;
  120. struct page **pages;
  121. };
  122. struct nfsd3_readres {
  123. __be32 status;
  124. struct svc_fh fh;
  125. unsigned long count;
  126. __u32 eof;
  127. struct page **pages;
  128. };
  129. struct nfsd3_writeres {
  130. __be32 status;
  131. struct svc_fh fh;
  132. unsigned long count;
  133. int committed;
  134. __be32 verf[2];
  135. };
  136. struct nfsd3_renameres {
  137. __be32 status;
  138. struct svc_fh ffh;
  139. struct svc_fh tfh;
  140. };
  141. struct nfsd3_linkres {
  142. __be32 status;
  143. struct svc_fh tfh;
  144. struct svc_fh fh;
  145. };
  146. struct nfsd3_readdirres {
  147. /* Components of the reply */
  148. __be32 status;
  149. struct svc_fh fh;
  150. __be32 verf[2];
  151. /* Used to encode the reply's entry list */
  152. struct xdr_stream xdr;
  153. struct xdr_buf dirlist;
  154. struct svc_fh scratch;
  155. struct readdir_cd common;
  156. unsigned int cookie_offset;
  157. struct svc_rqst * rqstp;
  158. };
  159. struct nfsd3_fsstatres {
  160. __be32 status;
  161. struct kstatfs stats;
  162. __u32 invarsec;
  163. };
  164. struct nfsd3_fsinfores {
  165. __be32 status;
  166. __u32 f_rtmax;
  167. __u32 f_rtpref;
  168. __u32 f_rtmult;
  169. __u32 f_wtmax;
  170. __u32 f_wtpref;
  171. __u32 f_wtmult;
  172. __u32 f_dtpref;
  173. __u64 f_maxfilesize;
  174. __u32 f_properties;
  175. };
  176. struct nfsd3_pathconfres {
  177. __be32 status;
  178. __u32 p_link_max;
  179. __u32 p_name_max;
  180. __u32 p_no_trunc;
  181. __u32 p_chown_restricted;
  182. __u32 p_case_insensitive;
  183. __u32 p_case_preserving;
  184. };
  185. struct nfsd3_commitres {
  186. __be32 status;
  187. struct svc_fh fh;
  188. __be32 verf[2];
  189. };
  190. struct nfsd3_getaclres {
  191. __be32 status;
  192. struct svc_fh fh;
  193. int mask;
  194. struct posix_acl *acl_access;
  195. struct posix_acl *acl_default;
  196. struct kstat stat;
  197. };
  198. /* dummy type for release */
  199. struct nfsd3_fhandle_pair {
  200. __u32 dummy;
  201. struct svc_fh fh1;
  202. struct svc_fh fh2;
  203. };
  204. /*
  205. * Storage requirements for XDR arguments and results.
  206. */
  207. union nfsd3_xdrstore {
  208. struct nfsd3_sattrargs sattrargs;
  209. struct nfsd3_diropargs diropargs;
  210. struct nfsd3_readargs readargs;
  211. struct nfsd3_writeargs writeargs;
  212. struct nfsd3_createargs createargs;
  213. struct nfsd3_renameargs renameargs;
  214. struct nfsd3_linkargs linkargs;
  215. struct nfsd3_symlinkargs symlinkargs;
  216. struct nfsd3_readdirargs readdirargs;
  217. struct nfsd3_diropres diropres;
  218. struct nfsd3_accessres accessres;
  219. struct nfsd3_readlinkres readlinkres;
  220. struct nfsd3_readres readres;
  221. struct nfsd3_writeres writeres;
  222. struct nfsd3_renameres renameres;
  223. struct nfsd3_linkres linkres;
  224. struct nfsd3_readdirres readdirres;
  225. struct nfsd3_fsstatres fsstatres;
  226. struct nfsd3_fsinfores fsinfores;
  227. struct nfsd3_pathconfres pathconfres;
  228. struct nfsd3_commitres commitres;
  229. struct nfsd3_getaclres getaclres;
  230. };
  231. #define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore)
  232. bool nfs3svc_decode_fhandleargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  233. bool nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  234. bool nfs3svc_decode_diropargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  235. bool nfs3svc_decode_accessargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  236. bool nfs3svc_decode_readargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  237. bool nfs3svc_decode_writeargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  238. bool nfs3svc_decode_createargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  239. bool nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  240. bool nfs3svc_decode_mknodargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  241. bool nfs3svc_decode_renameargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  242. bool nfs3svc_decode_linkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  243. bool nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  244. bool nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  245. bool nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  246. bool nfs3svc_decode_commitargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  247. bool nfs3svc_encode_getattrres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  248. bool nfs3svc_encode_wccstat(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  249. bool nfs3svc_encode_lookupres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  250. bool nfs3svc_encode_accessres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  251. bool nfs3svc_encode_readlinkres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  252. bool nfs3svc_encode_readres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  253. bool nfs3svc_encode_writeres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  254. bool nfs3svc_encode_createres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  255. bool nfs3svc_encode_renameres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  256. bool nfs3svc_encode_linkres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  257. bool nfs3svc_encode_readdirres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  258. bool nfs3svc_encode_fsstatres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  259. bool nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  260. bool nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  261. bool nfs3svc_encode_commitres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
  262. void nfs3svc_release_fhandle(struct svc_rqst *);
  263. void nfs3svc_release_fhandle2(struct svc_rqst *);
  264. void nfs3svc_encode_cookie3(struct nfsd3_readdirres *resp, u64 offset);
  265. int nfs3svc_encode_entry3(void *data, const char *name, int namlen,
  266. loff_t offset, u64 ino, unsigned int d_type);
  267. int nfs3svc_encode_entryplus3(void *data, const char *name, int namlen,
  268. loff_t offset, u64 ino, unsigned int d_type);
  269. /* Helper functions for NFSv3 ACL code */
  270. bool svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp);
  271. bool svcxdr_encode_nfsstat3(struct xdr_stream *xdr, __be32 status);
  272. bool svcxdr_encode_post_op_attr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
  273. const struct svc_fh *fhp);
  274. #endif /* _LINUX_NFSD_XDR3_H */