xdr4.h 16 KB

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