xdr4.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. /*
  2. * include/linux/nfsd/xdr4.h
  3. *
  4. * Server-side types for NFSv4.
  5. *
  6. * Copyright (c) 2002 The Regents of the University of Michigan.
  7. * All rights reserved.
  8. *
  9. * Kendrick Smith <kmsmith@umich.edu>
  10. * Andy Adamson <andros@umich.edu>
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions
  14. * are met:
  15. *
  16. * 1. Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer.
  18. * 2. Redistributions in binary form must reproduce the above copyright
  19. * notice, this list of conditions and the following disclaimer in the
  20. * documentation and/or other materials provided with the distribution.
  21. * 3. Neither the name of the University nor the names of its
  22. * contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  26. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  27. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28. * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  29. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  30. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  31. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  32. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  33. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  34. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  35. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36. *
  37. */
  38. #ifndef _LINUX_NFSD_XDR4_H
  39. #define _LINUX_NFSD_XDR4_H
  40. #include <linux/nfs4.h>
  41. #define NFSD4_MAX_TAGLEN 128
  42. #define XDR_LEN(n) (((n) + 3) & ~3)
  43. struct nfsd4_change_info {
  44. u32 atomic;
  45. u32 before_ctime_sec;
  46. u32 before_ctime_nsec;
  47. u32 after_ctime_sec;
  48. u32 after_ctime_nsec;
  49. };
  50. struct nfsd4_access {
  51. u32 ac_req_access; /* request */
  52. u32 ac_supported; /* response */
  53. u32 ac_resp_access; /* response */
  54. };
  55. struct nfsd4_close {
  56. u32 cl_seqid; /* request */
  57. stateid_t cl_stateid; /* request+response */
  58. struct nfs4_stateowner * cl_stateowner; /* response */
  59. };
  60. struct nfsd4_commit {
  61. u64 co_offset; /* request */
  62. u32 co_count; /* request */
  63. nfs4_verifier co_verf; /* response */
  64. };
  65. struct nfsd4_create {
  66. u32 cr_namelen; /* request */
  67. char * cr_name; /* request */
  68. u32 cr_type; /* request */
  69. union { /* request */
  70. struct {
  71. u32 namelen;
  72. char *name;
  73. } link; /* NF4LNK */
  74. struct {
  75. u32 specdata1;
  76. u32 specdata2;
  77. } dev; /* NF4BLK, NF4CHR */
  78. } u;
  79. u32 cr_bmval[2]; /* request */
  80. struct iattr cr_iattr; /* request */
  81. struct nfsd4_change_info cr_cinfo; /* response */
  82. struct nfs4_acl *cr_acl;
  83. };
  84. #define cr_linklen u.link.namelen
  85. #define cr_linkname u.link.name
  86. #define cr_specdata1 u.dev.specdata1
  87. #define cr_specdata2 u.dev.specdata2
  88. struct nfsd4_delegreturn {
  89. stateid_t dr_stateid;
  90. };
  91. struct nfsd4_getattr {
  92. u32 ga_bmval[2]; /* request */
  93. struct svc_fh *ga_fhp; /* response */
  94. };
  95. struct nfsd4_link {
  96. u32 li_namelen; /* request */
  97. char * li_name; /* request */
  98. struct nfsd4_change_info li_cinfo; /* response */
  99. };
  100. struct nfsd4_lock_denied {
  101. clientid_t ld_clientid;
  102. struct nfs4_stateowner *ld_sop;
  103. u64 ld_start;
  104. u64 ld_length;
  105. u32 ld_type;
  106. };
  107. struct nfsd4_lock {
  108. /* request */
  109. u32 lk_type;
  110. u32 lk_reclaim; /* boolean */
  111. u64 lk_offset;
  112. u64 lk_length;
  113. u32 lk_is_new;
  114. union {
  115. struct {
  116. u32 open_seqid;
  117. stateid_t open_stateid;
  118. u32 lock_seqid;
  119. clientid_t clientid;
  120. struct xdr_netobj owner;
  121. } new;
  122. struct {
  123. stateid_t lock_stateid;
  124. u32 lock_seqid;
  125. } old;
  126. } v;
  127. /* response */
  128. union {
  129. struct {
  130. stateid_t stateid;
  131. } ok;
  132. struct nfsd4_lock_denied denied;
  133. } u;
  134. struct nfs4_stateowner *lk_stateowner;
  135. };
  136. #define lk_new_open_seqid v.new.open_seqid
  137. #define lk_new_open_stateid v.new.open_stateid
  138. #define lk_new_lock_seqid v.new.lock_seqid
  139. #define lk_new_clientid v.new.clientid
  140. #define lk_new_owner v.new.owner
  141. #define lk_old_lock_stateid v.old.lock_stateid
  142. #define lk_old_lock_seqid v.old.lock_seqid
  143. #define lk_rflags u.ok.rflags
  144. #define lk_resp_stateid u.ok.stateid
  145. #define lk_denied u.denied
  146. struct nfsd4_lockt {
  147. u32 lt_type;
  148. clientid_t lt_clientid;
  149. struct xdr_netobj lt_owner;
  150. u64 lt_offset;
  151. u64 lt_length;
  152. struct nfs4_stateowner * lt_stateowner;
  153. struct nfsd4_lock_denied lt_denied;
  154. };
  155. struct nfsd4_locku {
  156. u32 lu_type;
  157. u32 lu_seqid;
  158. stateid_t lu_stateid;
  159. u64 lu_offset;
  160. u64 lu_length;
  161. struct nfs4_stateowner *lu_stateowner;
  162. };
  163. struct nfsd4_lookup {
  164. u32 lo_len; /* request */
  165. char * lo_name; /* request */
  166. };
  167. struct nfsd4_putfh {
  168. u32 pf_fhlen; /* request */
  169. char *pf_fhval; /* request */
  170. };
  171. struct nfsd4_open {
  172. u32 op_claim_type; /* request */
  173. struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */
  174. u32 op_delegate_type; /* request - CLAIM_PREV only */
  175. stateid_t op_delegate_stateid; /* request - response */
  176. u32 op_create; /* request */
  177. u32 op_createmode; /* request */
  178. u32 op_bmval[2]; /* request */
  179. union { /* request */
  180. struct iattr iattr; /* UNCHECKED4,GUARDED4 */
  181. nfs4_verifier verf; /* EXCLUSIVE4 */
  182. } u;
  183. clientid_t op_clientid; /* request */
  184. struct xdr_netobj op_owner; /* request */
  185. u32 op_seqid; /* request */
  186. u32 op_share_access; /* request */
  187. u32 op_share_deny; /* request */
  188. stateid_t op_stateid; /* response */
  189. u32 op_recall; /* recall */
  190. struct nfsd4_change_info op_cinfo; /* response */
  191. u32 op_rflags; /* response */
  192. int op_truncate; /* used during processing */
  193. struct nfs4_stateowner *op_stateowner; /* used during processing */
  194. struct nfs4_acl *op_acl;
  195. };
  196. #define op_iattr u.iattr
  197. #define op_verf u.verf
  198. struct nfsd4_open_confirm {
  199. stateid_t oc_req_stateid /* request */;
  200. u32 oc_seqid /* request */;
  201. stateid_t oc_resp_stateid /* response */;
  202. struct nfs4_stateowner * oc_stateowner; /* response */
  203. };
  204. struct nfsd4_open_downgrade {
  205. stateid_t od_stateid;
  206. u32 od_seqid;
  207. u32 od_share_access;
  208. u32 od_share_deny;
  209. struct nfs4_stateowner *od_stateowner;
  210. };
  211. struct nfsd4_read {
  212. stateid_t rd_stateid; /* request */
  213. u64 rd_offset; /* request */
  214. u32 rd_length; /* request */
  215. struct kvec rd_iov[RPCSVC_MAXPAGES];
  216. int rd_vlen;
  217. struct file *rd_filp;
  218. struct svc_rqst *rd_rqstp; /* response */
  219. struct svc_fh * rd_fhp; /* response */
  220. };
  221. struct nfsd4_readdir {
  222. u64 rd_cookie; /* request */
  223. nfs4_verifier rd_verf; /* request */
  224. u32 rd_dircount; /* request */
  225. u32 rd_maxcount; /* request */
  226. u32 rd_bmval[2]; /* request */
  227. struct svc_rqst *rd_rqstp; /* response */
  228. struct svc_fh * rd_fhp; /* response */
  229. struct readdir_cd common;
  230. u32 * buffer;
  231. int buflen;
  232. u32 * offset;
  233. };
  234. struct nfsd4_release_lockowner {
  235. clientid_t rl_clientid;
  236. struct xdr_netobj rl_owner;
  237. };
  238. struct nfsd4_readlink {
  239. struct svc_rqst *rl_rqstp; /* request */
  240. struct svc_fh * rl_fhp; /* request */
  241. };
  242. struct nfsd4_remove {
  243. u32 rm_namelen; /* request */
  244. char * rm_name; /* request */
  245. struct nfsd4_change_info rm_cinfo; /* response */
  246. };
  247. struct nfsd4_rename {
  248. u32 rn_snamelen; /* request */
  249. char * rn_sname; /* request */
  250. u32 rn_tnamelen; /* request */
  251. char * rn_tname; /* request */
  252. struct nfsd4_change_info rn_sinfo; /* response */
  253. struct nfsd4_change_info rn_tinfo; /* response */
  254. };
  255. struct nfsd4_setattr {
  256. stateid_t sa_stateid; /* request */
  257. u32 sa_bmval[2]; /* request */
  258. struct iattr sa_iattr; /* request */
  259. struct nfs4_acl *sa_acl;
  260. };
  261. struct nfsd4_setclientid {
  262. nfs4_verifier se_verf; /* request */
  263. u32 se_namelen; /* request */
  264. char * se_name; /* request */
  265. u32 se_callback_prog; /* request */
  266. u32 se_callback_netid_len; /* request */
  267. char * se_callback_netid_val; /* request */
  268. u32 se_callback_addr_len; /* request */
  269. char * se_callback_addr_val; /* request */
  270. u32 se_callback_ident; /* request */
  271. clientid_t se_clientid; /* response */
  272. nfs4_verifier se_confirm; /* response */
  273. };
  274. struct nfsd4_setclientid_confirm {
  275. clientid_t sc_clientid;
  276. nfs4_verifier sc_confirm;
  277. };
  278. /* also used for NVERIFY */
  279. struct nfsd4_verify {
  280. u32 ve_bmval[2]; /* request */
  281. u32 ve_attrlen; /* request */
  282. char * ve_attrval; /* request */
  283. };
  284. struct nfsd4_write {
  285. stateid_t wr_stateid; /* request */
  286. u64 wr_offset; /* request */
  287. u32 wr_stable_how; /* request */
  288. u32 wr_buflen; /* request */
  289. struct kvec wr_vec[RPCSVC_MAXPAGES]; /* request */
  290. int wr_vlen;
  291. u32 wr_bytes_written; /* response */
  292. u32 wr_how_written; /* response */
  293. nfs4_verifier wr_verifier; /* response */
  294. };
  295. struct nfsd4_op {
  296. int opnum;
  297. int status;
  298. union {
  299. struct nfsd4_access access;
  300. struct nfsd4_close close;
  301. struct nfsd4_commit commit;
  302. struct nfsd4_create create;
  303. struct nfsd4_delegreturn delegreturn;
  304. struct nfsd4_getattr getattr;
  305. struct svc_fh * getfh;
  306. struct nfsd4_link link;
  307. struct nfsd4_lock lock;
  308. struct nfsd4_lockt lockt;
  309. struct nfsd4_locku locku;
  310. struct nfsd4_lookup lookup;
  311. struct nfsd4_verify nverify;
  312. struct nfsd4_open open;
  313. struct nfsd4_open_confirm open_confirm;
  314. struct nfsd4_open_downgrade open_downgrade;
  315. struct nfsd4_putfh putfh;
  316. struct nfsd4_read read;
  317. struct nfsd4_readdir readdir;
  318. struct nfsd4_readlink readlink;
  319. struct nfsd4_remove remove;
  320. struct nfsd4_rename rename;
  321. clientid_t renew;
  322. struct nfsd4_setattr setattr;
  323. struct nfsd4_setclientid setclientid;
  324. struct nfsd4_setclientid_confirm setclientid_confirm;
  325. struct nfsd4_verify verify;
  326. struct nfsd4_write write;
  327. struct nfsd4_release_lockowner release_lockowner;
  328. } u;
  329. struct nfs4_replay * replay;
  330. };
  331. struct nfsd4_compoundargs {
  332. /* scratch variables for XDR decode */
  333. u32 * p;
  334. u32 * end;
  335. struct page ** pagelist;
  336. int pagelen;
  337. u32 tmp[8];
  338. u32 * tmpp;
  339. struct tmpbuf {
  340. struct tmpbuf *next;
  341. void (*release)(const void *);
  342. void *buf;
  343. } *to_free;
  344. struct svc_rqst *rqstp;
  345. u32 taglen;
  346. char * tag;
  347. u32 minorversion;
  348. u32 opcnt;
  349. struct nfsd4_op *ops;
  350. struct nfsd4_op iops[8];
  351. };
  352. struct nfsd4_compoundres {
  353. /* scratch variables for XDR encode */
  354. u32 * p;
  355. u32 * end;
  356. struct xdr_buf * xbuf;
  357. struct svc_rqst * rqstp;
  358. u32 taglen;
  359. char * tag;
  360. u32 opcnt;
  361. u32 * tagp; /* where to encode tag and opcount */
  362. };
  363. #define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs)
  364. static inline void
  365. set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
  366. {
  367. BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved);
  368. cinfo->atomic = 1;
  369. cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
  370. cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
  371. cinfo->after_ctime_sec = fhp->fh_post_ctime.tv_sec;
  372. cinfo->after_ctime_nsec = fhp->fh_post_ctime.tv_nsec;
  373. }
  374. int nfs4svc_encode_voidres(struct svc_rqst *, u32 *, void *);
  375. int nfs4svc_decode_compoundargs(struct svc_rqst *, u32 *,
  376. struct nfsd4_compoundargs *);
  377. int nfs4svc_encode_compoundres(struct svc_rqst *, u32 *,
  378. struct nfsd4_compoundres *);
  379. void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
  380. void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
  381. int nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
  382. struct dentry *dentry, u32 *buffer, int *countp,
  383. u32 *bmval, struct svc_rqst *);
  384. extern int nfsd4_setclientid(struct svc_rqst *rqstp,
  385. struct nfsd4_setclientid *setclid);
  386. extern int nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
  387. struct nfsd4_setclientid_confirm *setclientid_confirm);
  388. extern int nfsd4_process_open1(struct nfsd4_open *open);
  389. extern int nfsd4_process_open2(struct svc_rqst *rqstp,
  390. struct svc_fh *current_fh, struct nfsd4_open *open);
  391. extern int nfsd4_open_confirm(struct svc_rqst *rqstp,
  392. struct svc_fh *current_fh, struct nfsd4_open_confirm *oc);
  393. extern int nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh,
  394. struct nfsd4_close *close);
  395. extern int nfsd4_open_downgrade(struct svc_rqst *rqstp,
  396. struct svc_fh *current_fh, struct nfsd4_open_downgrade *od);
  397. extern int nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh,
  398. struct nfsd4_lock *lock);
  399. extern int nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh,
  400. struct nfsd4_lockt *lockt);
  401. extern int nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh,
  402. struct nfsd4_locku *locku);
  403. extern int
  404. nfsd4_release_lockowner(struct svc_rqst *rqstp,
  405. struct nfsd4_release_lockowner *rlockowner);
  406. extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *);
  407. extern int nfsd4_delegreturn(struct svc_rqst *rqstp,
  408. struct svc_fh *current_fh, struct nfsd4_delegreturn *dr);
  409. #endif
  410. /*
  411. * Local variables:
  412. * c-basic-offset: 8
  413. * End:
  414. */