xdr4.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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_compound_state {
  44. struct svc_fh current_fh;
  45. struct svc_fh save_fh;
  46. struct nfs4_stateowner *replay_owner;
  47. };
  48. struct nfsd4_change_info {
  49. u32 atomic;
  50. u32 before_ctime_sec;
  51. u32 before_ctime_nsec;
  52. u32 after_ctime_sec;
  53. u32 after_ctime_nsec;
  54. };
  55. struct nfsd4_access {
  56. u32 ac_req_access; /* request */
  57. u32 ac_supported; /* response */
  58. u32 ac_resp_access; /* response */
  59. };
  60. struct nfsd4_close {
  61. u32 cl_seqid; /* request */
  62. stateid_t cl_stateid; /* request+response */
  63. struct nfs4_stateowner * cl_stateowner; /* response */
  64. };
  65. struct nfsd4_commit {
  66. u64 co_offset; /* request */
  67. u32 co_count; /* request */
  68. nfs4_verifier co_verf; /* response */
  69. };
  70. struct nfsd4_create {
  71. u32 cr_namelen; /* request */
  72. char * cr_name; /* request */
  73. u32 cr_type; /* request */
  74. union { /* request */
  75. struct {
  76. u32 namelen;
  77. char *name;
  78. } link; /* NF4LNK */
  79. struct {
  80. u32 specdata1;
  81. u32 specdata2;
  82. } dev; /* NF4BLK, NF4CHR */
  83. } u;
  84. u32 cr_bmval[2]; /* request */
  85. struct iattr cr_iattr; /* request */
  86. struct nfsd4_change_info cr_cinfo; /* response */
  87. struct nfs4_acl *cr_acl;
  88. };
  89. #define cr_linklen u.link.namelen
  90. #define cr_linkname u.link.name
  91. #define cr_specdata1 u.dev.specdata1
  92. #define cr_specdata2 u.dev.specdata2
  93. struct nfsd4_delegreturn {
  94. stateid_t dr_stateid;
  95. };
  96. struct nfsd4_getattr {
  97. u32 ga_bmval[2]; /* request */
  98. struct svc_fh *ga_fhp; /* response */
  99. };
  100. struct nfsd4_link {
  101. u32 li_namelen; /* request */
  102. char * li_name; /* request */
  103. struct nfsd4_change_info li_cinfo; /* response */
  104. };
  105. struct nfsd4_lock_denied {
  106. clientid_t ld_clientid;
  107. struct nfs4_stateowner *ld_sop;
  108. u64 ld_start;
  109. u64 ld_length;
  110. u32 ld_type;
  111. };
  112. struct nfsd4_lock {
  113. /* request */
  114. u32 lk_type;
  115. u32 lk_reclaim; /* boolean */
  116. u64 lk_offset;
  117. u64 lk_length;
  118. u32 lk_is_new;
  119. union {
  120. struct {
  121. u32 open_seqid;
  122. stateid_t open_stateid;
  123. u32 lock_seqid;
  124. clientid_t clientid;
  125. struct xdr_netobj owner;
  126. } new;
  127. struct {
  128. stateid_t lock_stateid;
  129. u32 lock_seqid;
  130. } old;
  131. } v;
  132. /* response */
  133. union {
  134. struct {
  135. stateid_t stateid;
  136. } ok;
  137. struct nfsd4_lock_denied denied;
  138. } u;
  139. /* The lk_replay_owner is the open owner in the open_to_lock_owner
  140. * case and the lock owner otherwise: */
  141. struct nfs4_stateowner *lk_replay_owner;
  142. };
  143. #define lk_new_open_seqid v.new.open_seqid
  144. #define lk_new_open_stateid v.new.open_stateid
  145. #define lk_new_lock_seqid v.new.lock_seqid
  146. #define lk_new_clientid v.new.clientid
  147. #define lk_new_owner v.new.owner
  148. #define lk_old_lock_stateid v.old.lock_stateid
  149. #define lk_old_lock_seqid v.old.lock_seqid
  150. #define lk_rflags u.ok.rflags
  151. #define lk_resp_stateid u.ok.stateid
  152. #define lk_denied u.denied
  153. struct nfsd4_lockt {
  154. u32 lt_type;
  155. clientid_t lt_clientid;
  156. struct xdr_netobj lt_owner;
  157. u64 lt_offset;
  158. u64 lt_length;
  159. struct nfs4_stateowner * lt_stateowner;
  160. struct nfsd4_lock_denied lt_denied;
  161. };
  162. struct nfsd4_locku {
  163. u32 lu_type;
  164. u32 lu_seqid;
  165. stateid_t lu_stateid;
  166. u64 lu_offset;
  167. u64 lu_length;
  168. struct nfs4_stateowner *lu_stateowner;
  169. };
  170. struct nfsd4_lookup {
  171. u32 lo_len; /* request */
  172. char * lo_name; /* request */
  173. };
  174. struct nfsd4_putfh {
  175. u32 pf_fhlen; /* request */
  176. char *pf_fhval; /* request */
  177. };
  178. struct nfsd4_open {
  179. u32 op_claim_type; /* request */
  180. struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */
  181. u32 op_delegate_type; /* request - CLAIM_PREV only */
  182. stateid_t op_delegate_stateid; /* request - response */
  183. u32 op_create; /* request */
  184. u32 op_createmode; /* request */
  185. u32 op_bmval[2]; /* request */
  186. union { /* request */
  187. struct iattr iattr; /* UNCHECKED4,GUARDED4 */
  188. nfs4_verifier verf; /* EXCLUSIVE4 */
  189. } u;
  190. clientid_t op_clientid; /* request */
  191. struct xdr_netobj op_owner; /* request */
  192. u32 op_seqid; /* request */
  193. u32 op_share_access; /* request */
  194. u32 op_share_deny; /* request */
  195. stateid_t op_stateid; /* response */
  196. u32 op_recall; /* recall */
  197. struct nfsd4_change_info op_cinfo; /* response */
  198. u32 op_rflags; /* response */
  199. int op_truncate; /* used during processing */
  200. struct nfs4_stateowner *op_stateowner; /* used during processing */
  201. struct nfs4_acl *op_acl;
  202. };
  203. #define op_iattr u.iattr
  204. #define op_verf u.verf
  205. struct nfsd4_open_confirm {
  206. stateid_t oc_req_stateid /* request */;
  207. u32 oc_seqid /* request */;
  208. stateid_t oc_resp_stateid /* response */;
  209. struct nfs4_stateowner * oc_stateowner; /* response */
  210. };
  211. struct nfsd4_open_downgrade {
  212. stateid_t od_stateid;
  213. u32 od_seqid;
  214. u32 od_share_access;
  215. u32 od_share_deny;
  216. struct nfs4_stateowner *od_stateowner;
  217. };
  218. struct nfsd4_read {
  219. stateid_t rd_stateid; /* request */
  220. u64 rd_offset; /* request */
  221. u32 rd_length; /* request */
  222. int rd_vlen;
  223. struct file *rd_filp;
  224. struct svc_rqst *rd_rqstp; /* response */
  225. struct svc_fh * rd_fhp; /* response */
  226. };
  227. struct nfsd4_readdir {
  228. u64 rd_cookie; /* request */
  229. nfs4_verifier rd_verf; /* request */
  230. u32 rd_dircount; /* request */
  231. u32 rd_maxcount; /* request */
  232. u32 rd_bmval[2]; /* request */
  233. struct svc_rqst *rd_rqstp; /* response */
  234. struct svc_fh * rd_fhp; /* response */
  235. struct readdir_cd common;
  236. __be32 * buffer;
  237. int buflen;
  238. __be32 * offset;
  239. };
  240. struct nfsd4_release_lockowner {
  241. clientid_t rl_clientid;
  242. struct xdr_netobj rl_owner;
  243. };
  244. struct nfsd4_readlink {
  245. struct svc_rqst *rl_rqstp; /* request */
  246. struct svc_fh * rl_fhp; /* request */
  247. };
  248. struct nfsd4_remove {
  249. u32 rm_namelen; /* request */
  250. char * rm_name; /* request */
  251. struct nfsd4_change_info rm_cinfo; /* response */
  252. };
  253. struct nfsd4_rename {
  254. u32 rn_snamelen; /* request */
  255. char * rn_sname; /* request */
  256. u32 rn_tnamelen; /* request */
  257. char * rn_tname; /* request */
  258. struct nfsd4_change_info rn_sinfo; /* response */
  259. struct nfsd4_change_info rn_tinfo; /* response */
  260. };
  261. struct nfsd4_secinfo {
  262. u32 si_namelen; /* request */
  263. char *si_name; /* request */
  264. struct svc_export *si_exp; /* response */
  265. };
  266. struct nfsd4_setattr {
  267. stateid_t sa_stateid; /* request */
  268. u32 sa_bmval[2]; /* request */
  269. struct iattr sa_iattr; /* request */
  270. struct nfs4_acl *sa_acl;
  271. };
  272. struct nfsd4_setclientid {
  273. nfs4_verifier se_verf; /* request */
  274. u32 se_namelen; /* request */
  275. char * se_name; /* request */
  276. u32 se_callback_prog; /* request */
  277. u32 se_callback_netid_len; /* request */
  278. char * se_callback_netid_val; /* request */
  279. u32 se_callback_addr_len; /* request */
  280. char * se_callback_addr_val; /* request */
  281. u32 se_callback_ident; /* request */
  282. clientid_t se_clientid; /* response */
  283. nfs4_verifier se_confirm; /* response */
  284. };
  285. struct nfsd4_setclientid_confirm {
  286. clientid_t sc_clientid;
  287. nfs4_verifier sc_confirm;
  288. };
  289. /* also used for NVERIFY */
  290. struct nfsd4_verify {
  291. u32 ve_bmval[2]; /* request */
  292. u32 ve_attrlen; /* request */
  293. char * ve_attrval; /* request */
  294. };
  295. struct nfsd4_write {
  296. stateid_t wr_stateid; /* request */
  297. u64 wr_offset; /* request */
  298. u32 wr_stable_how; /* request */
  299. u32 wr_buflen; /* request */
  300. int wr_vlen;
  301. u32 wr_bytes_written; /* response */
  302. u32 wr_how_written; /* response */
  303. nfs4_verifier wr_verifier; /* response */
  304. };
  305. struct nfsd4_op {
  306. int opnum;
  307. __be32 status;
  308. union {
  309. struct nfsd4_access access;
  310. struct nfsd4_close close;
  311. struct nfsd4_commit commit;
  312. struct nfsd4_create create;
  313. struct nfsd4_delegreturn delegreturn;
  314. struct nfsd4_getattr getattr;
  315. struct svc_fh * getfh;
  316. struct nfsd4_link link;
  317. struct nfsd4_lock lock;
  318. struct nfsd4_lockt lockt;
  319. struct nfsd4_locku locku;
  320. struct nfsd4_lookup lookup;
  321. struct nfsd4_verify nverify;
  322. struct nfsd4_open open;
  323. struct nfsd4_open_confirm open_confirm;
  324. struct nfsd4_open_downgrade open_downgrade;
  325. struct nfsd4_putfh putfh;
  326. struct nfsd4_read read;
  327. struct nfsd4_readdir readdir;
  328. struct nfsd4_readlink readlink;
  329. struct nfsd4_remove remove;
  330. struct nfsd4_rename rename;
  331. clientid_t renew;
  332. struct nfsd4_secinfo secinfo;
  333. struct nfsd4_setattr setattr;
  334. struct nfsd4_setclientid setclientid;
  335. struct nfsd4_setclientid_confirm setclientid_confirm;
  336. struct nfsd4_verify verify;
  337. struct nfsd4_write write;
  338. struct nfsd4_release_lockowner release_lockowner;
  339. } u;
  340. struct nfs4_replay * replay;
  341. };
  342. struct nfsd4_compoundargs {
  343. /* scratch variables for XDR decode */
  344. __be32 * p;
  345. __be32 * end;
  346. struct page ** pagelist;
  347. int pagelen;
  348. __be32 tmp[8];
  349. __be32 * tmpp;
  350. struct tmpbuf {
  351. struct tmpbuf *next;
  352. void (*release)(const void *);
  353. void *buf;
  354. } *to_free;
  355. struct svc_rqst *rqstp;
  356. u32 taglen;
  357. char * tag;
  358. u32 minorversion;
  359. u32 opcnt;
  360. struct nfsd4_op *ops;
  361. struct nfsd4_op iops[8];
  362. };
  363. struct nfsd4_compoundres {
  364. /* scratch variables for XDR encode */
  365. __be32 * p;
  366. __be32 * end;
  367. struct xdr_buf * xbuf;
  368. struct svc_rqst * rqstp;
  369. u32 taglen;
  370. char * tag;
  371. u32 opcnt;
  372. __be32 * tagp; /* where to encode tag and opcount */
  373. };
  374. #define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs)
  375. static inline void
  376. set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
  377. {
  378. BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved);
  379. cinfo->atomic = 1;
  380. cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
  381. cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
  382. cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec;
  383. cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec;
  384. }
  385. int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *, void *);
  386. int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *,
  387. struct nfsd4_compoundargs *);
  388. int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *,
  389. struct nfsd4_compoundres *);
  390. void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
  391. void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
  392. __be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
  393. struct dentry *dentry, __be32 *buffer, int *countp,
  394. u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
  395. extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
  396. struct nfsd4_compound_state *,
  397. struct nfsd4_setclientid *setclid);
  398. extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
  399. struct nfsd4_compound_state *,
  400. struct nfsd4_setclientid_confirm *setclientid_confirm);
  401. extern __be32 nfsd4_process_open1(struct nfsd4_open *open);
  402. extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
  403. struct svc_fh *current_fh, struct nfsd4_open *open);
  404. extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,
  405. struct nfsd4_compound_state *, struct nfsd4_open_confirm *oc);
  406. extern __be32 nfsd4_close(struct svc_rqst *rqstp,
  407. struct nfsd4_compound_state *,
  408. struct nfsd4_close *close);
  409. extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp,
  410. struct nfsd4_compound_state *,
  411. struct nfsd4_open_downgrade *od);
  412. extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
  413. struct nfsd4_lock *lock);
  414. extern __be32 nfsd4_lockt(struct svc_rqst *rqstp,
  415. struct nfsd4_compound_state *,
  416. struct nfsd4_lockt *lockt);
  417. extern __be32 nfsd4_locku(struct svc_rqst *rqstp,
  418. struct nfsd4_compound_state *,
  419. struct nfsd4_locku *locku);
  420. extern __be32
  421. nfsd4_release_lockowner(struct svc_rqst *rqstp,
  422. struct nfsd4_compound_state *,
  423. struct nfsd4_release_lockowner *rlockowner);
  424. extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *);
  425. extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp,
  426. struct nfsd4_compound_state *, struct nfsd4_delegreturn *dr);
  427. extern __be32 nfsd4_renew(struct svc_rqst *rqstp,
  428. struct nfsd4_compound_state *, clientid_t *clid);
  429. #endif
  430. /*
  431. * Local variables:
  432. * c-basic-offset: 8
  433. * End:
  434. */