xdr4.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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. /* The lk_replay_owner is the open owner in the open_to_lock_owner
  135. * case and the lock owner otherwise: */
  136. struct nfs4_stateowner *lk_replay_owner;
  137. };
  138. #define lk_new_open_seqid v.new.open_seqid
  139. #define lk_new_open_stateid v.new.open_stateid
  140. #define lk_new_lock_seqid v.new.lock_seqid
  141. #define lk_new_clientid v.new.clientid
  142. #define lk_new_owner v.new.owner
  143. #define lk_old_lock_stateid v.old.lock_stateid
  144. #define lk_old_lock_seqid v.old.lock_seqid
  145. #define lk_rflags u.ok.rflags
  146. #define lk_resp_stateid u.ok.stateid
  147. #define lk_denied u.denied
  148. struct nfsd4_lockt {
  149. u32 lt_type;
  150. clientid_t lt_clientid;
  151. struct xdr_netobj lt_owner;
  152. u64 lt_offset;
  153. u64 lt_length;
  154. struct nfs4_stateowner * lt_stateowner;
  155. struct nfsd4_lock_denied lt_denied;
  156. };
  157. struct nfsd4_locku {
  158. u32 lu_type;
  159. u32 lu_seqid;
  160. stateid_t lu_stateid;
  161. u64 lu_offset;
  162. u64 lu_length;
  163. struct nfs4_stateowner *lu_stateowner;
  164. };
  165. struct nfsd4_lookup {
  166. u32 lo_len; /* request */
  167. char * lo_name; /* request */
  168. };
  169. struct nfsd4_putfh {
  170. u32 pf_fhlen; /* request */
  171. char *pf_fhval; /* request */
  172. };
  173. struct nfsd4_open {
  174. u32 op_claim_type; /* request */
  175. struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */
  176. u32 op_delegate_type; /* request - CLAIM_PREV only */
  177. stateid_t op_delegate_stateid; /* request - response */
  178. u32 op_create; /* request */
  179. u32 op_createmode; /* request */
  180. u32 op_bmval[2]; /* request */
  181. union { /* request */
  182. struct iattr iattr; /* UNCHECKED4,GUARDED4 */
  183. nfs4_verifier verf; /* EXCLUSIVE4 */
  184. } u;
  185. clientid_t op_clientid; /* request */
  186. struct xdr_netobj op_owner; /* request */
  187. u32 op_seqid; /* request */
  188. u32 op_share_access; /* request */
  189. u32 op_share_deny; /* request */
  190. stateid_t op_stateid; /* response */
  191. u32 op_recall; /* recall */
  192. struct nfsd4_change_info op_cinfo; /* response */
  193. u32 op_rflags; /* response */
  194. int op_truncate; /* used during processing */
  195. struct nfs4_stateowner *op_stateowner; /* used during processing */
  196. struct nfs4_acl *op_acl;
  197. };
  198. #define op_iattr u.iattr
  199. #define op_verf u.verf
  200. struct nfsd4_open_confirm {
  201. stateid_t oc_req_stateid /* request */;
  202. u32 oc_seqid /* request */;
  203. stateid_t oc_resp_stateid /* response */;
  204. struct nfs4_stateowner * oc_stateowner; /* response */
  205. };
  206. struct nfsd4_open_downgrade {
  207. stateid_t od_stateid;
  208. u32 od_seqid;
  209. u32 od_share_access;
  210. u32 od_share_deny;
  211. struct nfs4_stateowner *od_stateowner;
  212. };
  213. struct nfsd4_read {
  214. stateid_t rd_stateid; /* request */
  215. u64 rd_offset; /* request */
  216. u32 rd_length; /* request */
  217. struct kvec rd_iov[RPCSVC_MAXPAGES];
  218. int rd_vlen;
  219. struct file *rd_filp;
  220. struct svc_rqst *rd_rqstp; /* response */
  221. struct svc_fh * rd_fhp; /* response */
  222. };
  223. struct nfsd4_readdir {
  224. u64 rd_cookie; /* request */
  225. nfs4_verifier rd_verf; /* request */
  226. u32 rd_dircount; /* request */
  227. u32 rd_maxcount; /* request */
  228. u32 rd_bmval[2]; /* request */
  229. struct svc_rqst *rd_rqstp; /* response */
  230. struct svc_fh * rd_fhp; /* response */
  231. struct readdir_cd common;
  232. u32 * buffer;
  233. int buflen;
  234. u32 * offset;
  235. };
  236. struct nfsd4_release_lockowner {
  237. clientid_t rl_clientid;
  238. struct xdr_netobj rl_owner;
  239. };
  240. struct nfsd4_readlink {
  241. struct svc_rqst *rl_rqstp; /* request */
  242. struct svc_fh * rl_fhp; /* request */
  243. };
  244. struct nfsd4_remove {
  245. u32 rm_namelen; /* request */
  246. char * rm_name; /* request */
  247. struct nfsd4_change_info rm_cinfo; /* response */
  248. };
  249. struct nfsd4_rename {
  250. u32 rn_snamelen; /* request */
  251. char * rn_sname; /* request */
  252. u32 rn_tnamelen; /* request */
  253. char * rn_tname; /* request */
  254. struct nfsd4_change_info rn_sinfo; /* response */
  255. struct nfsd4_change_info rn_tinfo; /* response */
  256. };
  257. struct nfsd4_setattr {
  258. stateid_t sa_stateid; /* request */
  259. u32 sa_bmval[2]; /* request */
  260. struct iattr sa_iattr; /* request */
  261. struct nfs4_acl *sa_acl;
  262. };
  263. struct nfsd4_setclientid {
  264. nfs4_verifier se_verf; /* request */
  265. u32 se_namelen; /* request */
  266. char * se_name; /* request */
  267. u32 se_callback_prog; /* request */
  268. u32 se_callback_netid_len; /* request */
  269. char * se_callback_netid_val; /* request */
  270. u32 se_callback_addr_len; /* request */
  271. char * se_callback_addr_val; /* request */
  272. u32 se_callback_ident; /* request */
  273. clientid_t se_clientid; /* response */
  274. nfs4_verifier se_confirm; /* response */
  275. };
  276. struct nfsd4_setclientid_confirm {
  277. clientid_t sc_clientid;
  278. nfs4_verifier sc_confirm;
  279. };
  280. /* also used for NVERIFY */
  281. struct nfsd4_verify {
  282. u32 ve_bmval[2]; /* request */
  283. u32 ve_attrlen; /* request */
  284. char * ve_attrval; /* request */
  285. };
  286. struct nfsd4_write {
  287. stateid_t wr_stateid; /* request */
  288. u64 wr_offset; /* request */
  289. u32 wr_stable_how; /* request */
  290. u32 wr_buflen; /* request */
  291. struct kvec wr_vec[RPCSVC_MAXPAGES]; /* request */
  292. int wr_vlen;
  293. u32 wr_bytes_written; /* response */
  294. u32 wr_how_written; /* response */
  295. nfs4_verifier wr_verifier; /* response */
  296. };
  297. struct nfsd4_op {
  298. int opnum;
  299. int status;
  300. union {
  301. struct nfsd4_access access;
  302. struct nfsd4_close close;
  303. struct nfsd4_commit commit;
  304. struct nfsd4_create create;
  305. struct nfsd4_delegreturn delegreturn;
  306. struct nfsd4_getattr getattr;
  307. struct svc_fh * getfh;
  308. struct nfsd4_link link;
  309. struct nfsd4_lock lock;
  310. struct nfsd4_lockt lockt;
  311. struct nfsd4_locku locku;
  312. struct nfsd4_lookup lookup;
  313. struct nfsd4_verify nverify;
  314. struct nfsd4_open open;
  315. struct nfsd4_open_confirm open_confirm;
  316. struct nfsd4_open_downgrade open_downgrade;
  317. struct nfsd4_putfh putfh;
  318. struct nfsd4_read read;
  319. struct nfsd4_readdir readdir;
  320. struct nfsd4_readlink readlink;
  321. struct nfsd4_remove remove;
  322. struct nfsd4_rename rename;
  323. clientid_t renew;
  324. struct nfsd4_setattr setattr;
  325. struct nfsd4_setclientid setclientid;
  326. struct nfsd4_setclientid_confirm setclientid_confirm;
  327. struct nfsd4_verify verify;
  328. struct nfsd4_write write;
  329. struct nfsd4_release_lockowner release_lockowner;
  330. } u;
  331. struct nfs4_replay * replay;
  332. };
  333. struct nfsd4_compoundargs {
  334. /* scratch variables for XDR decode */
  335. u32 * p;
  336. u32 * end;
  337. struct page ** pagelist;
  338. int pagelen;
  339. u32 tmp[8];
  340. u32 * tmpp;
  341. struct tmpbuf {
  342. struct tmpbuf *next;
  343. void (*release)(const void *);
  344. void *buf;
  345. } *to_free;
  346. struct svc_rqst *rqstp;
  347. u32 taglen;
  348. char * tag;
  349. u32 minorversion;
  350. u32 opcnt;
  351. struct nfsd4_op *ops;
  352. struct nfsd4_op iops[8];
  353. };
  354. struct nfsd4_compoundres {
  355. /* scratch variables for XDR encode */
  356. u32 * p;
  357. u32 * end;
  358. struct xdr_buf * xbuf;
  359. struct svc_rqst * rqstp;
  360. u32 taglen;
  361. char * tag;
  362. u32 opcnt;
  363. u32 * tagp; /* where to encode tag and opcount */
  364. };
  365. #define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs)
  366. static inline void
  367. set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
  368. {
  369. BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved);
  370. cinfo->atomic = 1;
  371. cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
  372. cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
  373. cinfo->after_ctime_sec = fhp->fh_post_ctime.tv_sec;
  374. cinfo->after_ctime_nsec = fhp->fh_post_ctime.tv_nsec;
  375. }
  376. int nfs4svc_encode_voidres(struct svc_rqst *, u32 *, void *);
  377. int nfs4svc_decode_compoundargs(struct svc_rqst *, u32 *,
  378. struct nfsd4_compoundargs *);
  379. int nfs4svc_encode_compoundres(struct svc_rqst *, u32 *,
  380. struct nfsd4_compoundres *);
  381. void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
  382. void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
  383. int nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
  384. struct dentry *dentry, u32 *buffer, int *countp,
  385. u32 *bmval, struct svc_rqst *);
  386. extern int nfsd4_setclientid(struct svc_rqst *rqstp,
  387. struct nfsd4_setclientid *setclid);
  388. extern int nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
  389. struct nfsd4_setclientid_confirm *setclientid_confirm);
  390. extern int nfsd4_process_open1(struct nfsd4_open *open);
  391. extern int nfsd4_process_open2(struct svc_rqst *rqstp,
  392. struct svc_fh *current_fh, struct nfsd4_open *open);
  393. extern int nfsd4_open_confirm(struct svc_rqst *rqstp,
  394. struct svc_fh *current_fh, struct nfsd4_open_confirm *oc,
  395. struct nfs4_stateowner **);
  396. extern int nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh,
  397. struct nfsd4_close *close,
  398. struct nfs4_stateowner **replay_owner);
  399. extern int nfsd4_open_downgrade(struct svc_rqst *rqstp,
  400. struct svc_fh *current_fh, struct nfsd4_open_downgrade *od,
  401. struct nfs4_stateowner **replay_owner);
  402. extern int nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh,
  403. struct nfsd4_lock *lock,
  404. struct nfs4_stateowner **replay_owner);
  405. extern int nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh,
  406. struct nfsd4_lockt *lockt);
  407. extern int nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh,
  408. struct nfsd4_locku *locku,
  409. struct nfs4_stateowner **replay_owner);
  410. extern int
  411. nfsd4_release_lockowner(struct svc_rqst *rqstp,
  412. struct nfsd4_release_lockowner *rlockowner);
  413. extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *);
  414. extern int nfsd4_delegreturn(struct svc_rqst *rqstp,
  415. struct svc_fh *current_fh, struct nfsd4_delegreturn *dr);
  416. #endif
  417. /*
  418. * Local variables:
  419. * c-basic-offset: 8
  420. * End:
  421. */