xref: /reactos/base/services/nfsd/nfs41_ops.h (revision c2c66aff)
1 /* NFSv4.1 client for Windows
2  * Copyright � 2012 The Regents of the University of Michigan
3  *
4  * Olga Kornievskaia <aglo@umich.edu>
5  * Casey Bodley <cbodley@umich.edu>
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation; either version 2.1 of the License, or (at
10  * your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * without any warranty; without even the implied warranty of merchantability
14  * or fitness for a particular purpose.  See the GNU Lesser General Public
15  * License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  */
21 
22 #ifndef __NFS41_NFS_OPS_H__
23 #define __NFS41_NFS_OPS_H__
24 
25 #include "nfs41.h"
26 #include "pnfs.h"
27 
28 
29 /* Operation arrays */
30 enum nfs_opnum4 {
31     OP_ACCESS               = 3,
32     OP_CLOSE                = 4,
33     OP_COMMIT               = 5,
34     OP_CREATE               = 6,
35     OP_DELEGPURGE           = 7,
36     OP_DELEGRETURN          = 8,
37     OP_GETATTR              = 9,
38     OP_GETFH                = 10,
39     OP_LINK                 = 11,
40     OP_LOCK                 = 12,
41     OP_LOCKT                = 13,
42     OP_LOCKU                = 14,
43     OP_LOOKUP               = 15,
44     OP_LOOKUPP              = 16,
45     OP_NVERIFY              = 17,
46     OP_OPEN                 = 18,
47     OP_OPENATTR             = 19,
48     OP_OPEN_CONFIRM         = 20, /* Mandatory not-to-implement */
49     OP_OPEN_DOWNGRADE       = 21,
50     OP_PUTFH                = 22,
51     OP_PUTPUBFH             = 23,
52     OP_PUTROOTFH            = 24,
53     OP_READ                 = 25,
54     OP_READDIR              = 26,
55     OP_READLINK             = 27,
56     OP_REMOVE               = 28,
57     OP_RENAME               = 29,
58     OP_RENEW                = 30, /* Mandatory not-to-implement */
59     OP_RESTOREFH            = 31,
60     OP_SAVEFH               = 32,
61     OP_SECINFO              = 33,
62     OP_SETATTR              = 34,
63     OP_SETCLIENTID          = 35, /* Mandatory not-to-implement */
64     OP_SETCLIENTID_CONFIRM  = 36, /* Mandatory not-to-implement */
65     OP_VERIFY               = 37,
66     OP_WRITE                = 38,
67     OP_RELEASE_LOCKOWNER    = 39, /* Mandatory not-to-implement */
68 
69     /* new operations for NFSv4.1 */
70     OP_BACKCHANNEL_CTL      = 40,
71     OP_BIND_CONN_TO_SESSION = 41,
72     OP_EXCHANGE_ID          = 42,
73     OP_CREATE_SESSION       = 43,
74     OP_DESTROY_SESSION      = 44,
75     OP_FREE_STATEID         = 45,
76     OP_GET_DIR_DELEGATION   = 46,
77     OP_GETDEVICEINFO        = 47,
78     OP_GETDEVICELIST        = 48,
79     OP_LAYOUTCOMMIT         = 49,
80     OP_LAYOUTGET            = 50,
81     OP_LAYOUTRETURN         = 51,
82     OP_SECINFO_NO_NAME      = 52,
83     OP_SEQUENCE             = 53,
84     OP_SET_SSV              = 54,
85     OP_TEST_STATEID         = 55,
86     OP_WANT_DELEGATION      = 56,
87     OP_DESTROY_CLIENTID     = 57,
88     OP_RECLAIM_COMPLETE     = 58,
89     OP_ILLEGAL              = 10044
90 };
91 
92 
93 /* OP_EXCHANGE_ID */
94 enum {
95     EXCHGID4_FLAG_SUPP_MOVED_REFER      = 0x00000001,
96     EXCHGID4_FLAG_SUPP_MOVED_MIGR       = 0x00000002,
97 
98     EXCHGID4_FLAG_BIND_PRINC_STATEID    = 0x00000100,
99 
100     EXCHGID4_FLAG_USE_NON_PNFS          = 0x00010000,
101     EXCHGID4_FLAG_USE_PNFS_MDS          = 0x00020000,
102     EXCHGID4_FLAG_USE_PNFS_DS           = 0x00040000,
103 
104     EXCHGID4_FLAG_MASK_PNFS             = 0x00070000,
105 
106     EXCHGID4_FLAG_UPD_CONFIRMED_REC_A   = 0x40000000,
107     EXCHGID4_FLAG_CONFIRMED_R           = 0x80000000
108 };
109 
110 typedef enum {
111     SP4_NONE        = 0,
112     SP4_MACH_CRED   = 1,
113     SP4_SSV         = 2
114 } state_protect_how4;
115 
116 typedef struct __state_protect4_a {
117     state_protect_how4      spa_how;
118 } state_protect4_a;
119 
120 typedef struct __nfs41_exchange_id_args {
121     client_owner4           *eia_clientowner;
122     uint32_t                eia_flags;
123     state_protect4_a        eia_state_protect;
124     nfs_impl_id4            *eia_client_impl_id; /* <1> */
125 } nfs41_exchange_id_args;
126 
127 typedef struct __state_protect4_r {
128     state_protect_how4      spr_how;
129 } state_protect4_r;
130 
131 typedef struct __nfs41_exchange_id_res {
132     uint32_t                status;
133     uint64_t                clientid;
134     uint32_t                sequenceid;
135     uint32_t                flags;
136     state_protect4_r        state_protect;
137     server_owner4           server_owner;
138     uint32_t                server_scope_len;
139     char                    server_scope[NFS4_OPAQUE_LIMIT];
140 } nfs41_exchange_id_res;
141 
142 typedef struct __nfs41_callback_sec_parms {
143     uint32_t type;
144     union {
145         /* case AUTH_SYS */
146         struct __authsys_parms {
147             uint32_t        stamp;
148             char            *machinename;
149         } auth_sys;
150         /* case RPCSEC_GSS */
151         struct __rpcsec_gss_parms {
152             uint32_t        gss_srv_type;
153             char            *srv_gssctx_handle;
154             uint32_t         srv_gssctx_hdle_len;
155             char            *clnt_gssctx_handle;
156             uint32_t        clnt_gssctx_hdle_len;
157         } rpcsec_gss;
158     } u;
159 } nfs41_callback_secparms;
160 
161 /* OP_CREATE_SESSION */
162 typedef struct __nfs41_create_session_args {
163     uint64_t                csa_clientid;
164     uint32_t                csa_sequence;
165     uint32_t                csa_flags;
166     nfs41_channel_attrs     csa_fore_chan_attrs;
167     nfs41_channel_attrs     csa_back_chan_attrs;
168     uint32_t                csa_cb_program;
169     nfs41_callback_secparms csa_cb_secparams[2];
170 } nfs41_create_session_args;
171 
172 typedef struct __nfs41_create_session_res {
173     unsigned char           *csr_sessionid;
174     uint32_t                csr_sequence;
175     uint32_t                csr_flags;
176     nfs41_channel_attrs     *csr_fore_chan_attrs;
177     nfs41_channel_attrs     *csr_back_chan_attrs;
178 } nfs41_create_session_res;
179 
180 
181 /* OP_BIND_CONN_TO_SESSION */
182 enum channel_dir_from_client4 {
183     CDFC4_FORE              = 0x1,
184     CDFC4_BACK              = 0x2,
185     CDFC4_FORE_OR_BOTH      = 0x3,
186     CDFC4_BACK_OR_BOTH      = 0x7
187 };
188 
189 enum channel_dir_from_server4 {
190     CDFS4_FORE              = 0x1,
191     CDFS4_BACK              = 0x2,
192     CDFS4_BOTH              = 0x3
193 };
194 
195 typedef struct __nfs41_bind_conn_to_session_args {
196     unsigned char           *sessionid;
197     enum channel_dir_from_client4 dir;
198 } nfs41_bind_conn_to_session_args;
199 
200 typedef struct __nfs41_bind_conn_to_session_res {
201     enum nfsstat4           status;
202     /* case NFS4_OK: */
203     enum channel_dir_from_server4 dir;
204 } nfs41_bind_conn_to_session_res;
205 
206 
207 /* OP_DESTROY_SESSION */
208 typedef struct __nfs41_destroy_session_args {
209     unsigned char           *dsa_sessionid;
210 } nfs41_destroy_session_args;
211 
212 typedef struct __nfs41_destroy_session_res {
213     uint32_t                dsr_status;
214 } nfs41_destroy_session_res;
215 
216 
217 /* OP_DESTROY_CLIENTID */
218 typedef struct __nfs41_destroy_clientid_args {
219     uint64_t        dca_clientid;
220 } nfs41_destroy_clientid_args;
221 
222 typedef struct __nfs41_destroy_clientid_res {
223     uint32_t        dcr_status;
224 } nfs41_destroy_clientid_res;
225 
226 
227 /* OP_SEQUENCE */
228 typedef struct __nfs41_sequence_args {
229     unsigned char           *sa_sessionid;
230     uint32_t                sa_sequenceid;
231     uint32_t                sa_slotid;
232     uint32_t                sa_highest_slotid;
233     bool_t                  sa_cachethis;
234 } nfs41_sequence_args;
235 
236 enum {
237     SEQ4_STATUS_CB_PATH_DOWN                = 0x00000001,
238     SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING    = 0x00000002,
239     SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRED     = 0x00000004,
240     SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED   = 0x00000008,
241     SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED  = 0x00000010,
242     SEQ4_STATUS_ADMIN_STATE_REVOKED         = 0x00000020,
243     SEQ4_STATUS_RECALLABLE_STATE_REVOKED    = 0x00000040,
244     SEQ4_STATUS_LEASE_MOVED                 = 0x00000080,
245     SEQ4_STATUS_RESTART_RECLAIM_NEEDED      = 0x00000100,
246     SEQ4_STATUS_CB_PATH_DOWN_SESSION        = 0x00000200,
247     SEQ4_STATUS_BACKCHANNEL_FAULT           = 0x00000400,
248     SEQ4_STATUS_DEVID_CHANGED               = 0x00000800,
249     SEQ4_STATUS_DEVID_DELETED               = 0x00001000
250 };
251 
252 typedef struct __nfs41_sequence_res_ok {
253     unsigned char           sr_sessionid[NFS4_SESSIONID_SIZE];
254     uint32_t                sr_sequenceid;
255     uint32_t                sr_slotid;
256     uint32_t                sr_highest_slotid;
257     uint32_t                sr_target_highest_slotid;
258     uint32_t                sr_status_flags;
259 } nfs41_sequence_res_ok;
260 
261 typedef struct __nfs41_sequence_res {
262     uint32_t                sr_status;
263     /* case NFS4_OK: */
264     nfs41_sequence_res_ok   sr_resok4;
265 } nfs41_sequence_res;
266 
267 
268 /* OP_RECLAIM_COMPLETE */
269 typedef struct __nfs41_reclaim_complete_res {
270     enum nfsstat4           status;
271 } nfs41_reclaim_complete_res;
272 
273 
274 /* recoverable stateid argument */
275 enum stateid_type {
276     STATEID_OPEN,
277     STATEID_LOCK,
278     STATEID_DELEG_FILE,
279     STATEID_DELEG_DIR,
280     STATEID_LAYOUT,
281     STATEID_SPECIAL
282 };
283 typedef struct __stateid_arg {
284     stateid4                stateid;
285     enum stateid_type       type;
286     nfs41_open_state        *open;
287     nfs41_delegation_state  *delegation;
288 } stateid_arg;
289 
290 
291 /* OP_ACCESS */
292 enum {
293     ACCESS4_READ            = 0x00000001,
294     ACCESS4_LOOKUP          = 0x00000002,
295     ACCESS4_MODIFY          = 0x00000004,
296     ACCESS4_EXTEND          = 0x00000008,
297     ACCESS4_DELETE          = 0x00000010,
298     ACCESS4_EXECUTE         = 0x00000020
299 };
300 
301 typedef struct __nfs41_access_args {
302     uint32_t                access;
303 } nfs41_access_args;
304 
305 typedef struct __nfs41_access_res {
306     uint32_t                status;
307     /* case NFS4_OK: */
308     uint32_t                supported;
309     uint32_t                access;
310 } nfs41_access_res;
311 
312 
313 /* OP_CLOSE */
314 typedef struct __nfs41_op_close_args {
315 //  uint32_t                seqid; // not used, always 0
316     stateid_arg             *stateid;
317 } nfs41_op_close_args;
318 
319 typedef struct __nfs41_op_close_res {
320     uint32_t                status;
321 } nfs41_op_close_res;
322 
323 
324 /* OP_COMMIT */
325 typedef struct __nfs41_commit_args {
326     uint64_t                offset;
327     uint32_t                count;
328 } nfs41_commit_args;
329 
330 typedef struct __nfs41_commit_res {
331     uint32_t                status;
332     nfs41_write_verf        *verf;
333 } nfs41_commit_res;
334 
335 
336 /* OP_CREATE */
337 typedef struct __specdata4 {
338     uint32_t                specdata1;
339     uint32_t                specdata2;
340 } specdata4;
341 
342 typedef struct __createtype4 {
343     uint32_t                type;
344     union {
345     /* case NF4LNK: */
346         struct __create_type_lnk {
347             uint32_t        linkdata_len;
348             const char      *linkdata;
349         } lnk;
350     /* case NF4BLK, NF4CHR: */
351         specdata4           devdata;
352     } u;
353 } createtype4;
354 
355 typedef struct __nfs41_create_args {
356     createtype4             objtype;
357     const nfs41_component   *name;
358     nfs41_file_info         *createattrs;
359 } nfs41_create_args;
360 
361 typedef struct __nfs41_create_res {
362     uint32_t                status;
363     /* case NFS4_OK: */
364     change_info4            cinfo;
365     bitmap4                 attrset;
366 } nfs41_create_res;
367 
368 
369 /* OP_DELEGPURGE */
370 typedef struct __nfs41_delegpurge_res {
371     uint32_t                status;
372 } nfs41_delegpurge_res;
373 
374 
375 /* OP_DELEGRETURN */
376 typedef struct __nfs41_delegreturn_args {
377     stateid_arg             *stateid;
378 } nfs41_delegreturn_args;
379 
380 typedef struct __nfs41_delegreturn_res {
381     uint32_t                status;
382 } nfs41_delegreturn_res;
383 
384 
385 /* OP_LINK */
386 typedef struct __nfs41_link_args {
387     const nfs41_component   *newname;
388 } nfs41_link_args;
389 
390 typedef struct __nfs41_link_res {
391     uint32_t                status;
392     /* case NFS4_OK */
393     change_info4            cinfo;
394 } nfs41_link_res;
395 
396 
397 /* OP_LOCK */
398 enum {
399     READ_LT                 = 1,
400     WRITE_LT                = 2,
401     READW_LT                = 3,    /* blocking read */
402     WRITEW_LT               = 4     /* blocking write */
403 };
404 
405 typedef struct __open_to_lock_owner4 {
406     uint32_t                open_seqid;
407     stateid_arg             *open_stateid;
408     uint32_t                lock_seqid;
409     state_owner4            *lock_owner;
410 } open_to_lock_owner4;
411 
412 typedef struct __exist_lock_owner4 {
413     stateid_arg             *lock_stateid;
414     uint32_t                lock_seqid;
415 } exist_lock_owner4;
416 
417 typedef struct __locker4 {
418     bool_t                  new_lock_owner;
419     union {
420         /* case TRUE: */
421         open_to_lock_owner4 open_owner;
422         /* case FALSE: */
423         exist_lock_owner4   lock_owner;
424     } u;
425 } locker4;
426 
427 typedef struct __nfs41_lock_args {
428     uint32_t                locktype;
429     bool_t                  reclaim;
430     uint64_t                offset;
431     uint64_t                length;
432     locker4                 locker;
433 } nfs41_lock_args;
434 
435 typedef struct __lock_res_denied {
436     uint64_t                offset;
437     uint64_t                length;
438     uint32_t                locktype;
439     state_owner4            owner;
440 } lock_res_denied;
441 
442 typedef struct __lock_res_ok {
443     stateid4                *lock_stateid;
444 } lock_res_ok;
445 
446 typedef struct __nfs41_lock_res {
447     uint32_t                status;
448     union {
449     /* case NFS4_OK: */
450         lock_res_ok         resok4;
451     /* case NFS4ERR_DENIED: */
452         lock_res_denied     denied;
453     /* default: void; */
454     } u;
455 } nfs41_lock_res;
456 
457 
458 /* OP_LOCKT */
459 typedef struct __nfs41_lockt_args {
460     uint32_t                locktype;
461     uint64_t                offset;
462     uint64_t                length;
463     state_owner4            *owner;
464 } nfs41_lockt_args;
465 
466 typedef struct __nfs41_lockt_res {
467     uint32_t                status;
468     /* case NFS4ERR_DENIED: */
469     lock_res_denied         denied;
470     /* default: void; */
471 } nfs41_lockt_res;
472 
473 
474 /* OP_LOCKU */
475 typedef struct __nfs41_locku_args {
476     uint32_t                locktype;
477     uint32_t                seqid;
478     stateid_arg             *lock_stateid;
479     uint64_t                offset;
480     uint64_t                length;
481 } nfs41_locku_args;
482 
483 typedef struct __nfs41_locku_res {
484     uint32_t                status;
485     /* case NFS4_OK: */
486     stateid4                *lock_stateid;
487 } nfs41_locku_res;
488 
489 
490 /* OP_LOOKUP */
491 typedef struct __nfs41_lookup_args {
492     const nfs41_component   *name;
493 } nfs41_lookup_args;
494 
495 typedef struct __nfs41_lookup_res {
496     uint32_t                status;
497 } nfs41_lookup_res;
498 
499 
500 /* OP_GETFH */
501 typedef struct __nfs41_getfh_res {
502     uint32_t                status;
503     /* case NFS4_OK: */
504     nfs41_fh                *fh;
505 } nfs41_getfh_res;
506 
507 
508 /* OP_PUTFH */
509 typedef struct __nfs41_putfh_args {
510     nfs41_path_fh           *file;
511     bool_t                  in_recovery;
512 } nfs41_putfh_args;
513 
514 typedef struct __nfs41_putfh_res {
515     uint32_t                status;
516 } nfs41_putfh_res;
517 
518 
519 /* OP_PUTROOTFH */
520 typedef struct __nfs41_putrootfh_res {
521     uint32_t                status;
522 } nfs41_putrootfh_res;
523 
524 
525 /* OP_GETATTR */
526 typedef struct __nfs41_getattr_args {
527     bitmap4                 *attr_request;
528 } nfs41_getattr_args;
529 
530 typedef struct __nfs41_getattr_res {
531     uint32_t                status;
532     /* case NFS4_OK: */
533     fattr4                  obj_attributes;
534     nfs41_file_info         *info;
535 } nfs41_getattr_res;
536 
537 
538 /* OP_OPEN */
539 enum createmode4 {
540     UNCHECKED4      = 0,
541     GUARDED4        = 1,
542     EXCLUSIVE4      = 2,
543     EXCLUSIVE4_1    = 3
544 };
545 
546 typedef struct __createhow4 {
547     uint32_t            mode;
548     nfs41_file_info     *createattrs;
549     unsigned char       createverf[NFS4_VERIFIER_SIZE];
550 } createhow4;
551 
552 enum opentype4 {
553     OPEN4_NOCREATE  = 0,
554     OPEN4_CREATE    = 1
555 };
556 
557 typedef struct __openflag4 {
558     uint32_t                opentype;
559     /* case OPEN4_CREATE: */
560     createhow4              how;
561 } openflag4;
562 
563 enum {
564     OPEN4_SHARE_ACCESS_READ     = 0x00000001,
565     OPEN4_SHARE_ACCESS_WRITE    = 0x00000002,
566     OPEN4_SHARE_ACCESS_BOTH     = 0x00000003,
567 
568     OPEN4_SHARE_DENY_NONE       = 0x00000000,
569     OPEN4_SHARE_DENY_READ       = 0x00000001,
570     OPEN4_SHARE_DENY_WRITE      = 0x00000002,
571     OPEN4_SHARE_DENY_BOTH       = 0x00000003,
572 
573     OPEN4_SHARE_ACCESS_WANT_DELEG_MASK      = 0xFF00,
574     OPEN4_SHARE_ACCESS_WANT_NO_PREFERENCE   = 0x0000,
575     OPEN4_SHARE_ACCESS_WANT_READ_DELEG      = 0x0100,
576     OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG     = 0x0200,
577     OPEN4_SHARE_ACCESS_WANT_ANY_DELEG       = 0x0300,
578     OPEN4_SHARE_ACCESS_WANT_NO_DELEG        = 0x0400,
579     OPEN4_SHARE_ACCESS_WANT_CANCEL          = 0x0500,
580 
581     OPEN4_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL = 0x10000,
582     OPEN4_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED = 0x20000
583 };
584 
585 enum open_delegation_type4 {
586     OPEN_DELEGATE_NONE      = 0,
587     OPEN_DELEGATE_READ      = 1,
588     OPEN_DELEGATE_WRITE     = 2,
589     OPEN_DELEGATE_NONE_EXT  = 3
590 };
591 
592 enum open_claim_type4 {
593     CLAIM_NULL              = 0,
594     CLAIM_PREVIOUS          = 1,
595     CLAIM_DELEGATE_CUR      = 2,
596     CLAIM_DELEGATE_PREV     = 3,
597     CLAIM_FH                = 4,
598     CLAIM_DELEG_CUR_FH      = 5,
599     CLAIM_DELEG_PREV_FH     = 6
600 };
601 
602 enum why_no_delegation4 {
603     WND4_NOT_WANTED         = 0,
604     WND4_CONTENTION         = 1,
605     WND4_RESOURCE           = 2,
606     WND4_NOT_SUPP_FTYPE     = 3,
607     WND4_WRITE_DELEG_NOT_SUPP_FTYPE = 4,
608     WND4_NOT_SUPP_UPGRADE   = 5,
609     WND4_NOT_SUPP_DOWNGRADE = 6,
610     WND4_CANCELED           = 7,
611     WND4_IS_DIR             = 8
612 };
613 
614 typedef struct __open_claim4 {
615     uint32_t                claim;
616     union {
617     /* case CLAIM_NULL: */
618         struct __open_claim_null {
619             const nfs41_component *filename;
620         } null;
621     /* case CLAIM_PREVIOUS: */
622         struct __open_claim_prev {
623             uint32_t        delegate_type;
624         } prev;
625     /* case CLAIM_DELEGATE_CUR: */
626         struct __open_claim_deleg_cur {
627             stateid_arg     *delegate_stateid;
628             nfs41_component *name;
629         } deleg_cur;
630     /* case CLAIM_DELEG_CUR_FH: */
631         struct __open_claim_deleg_cur_fh {
632             stateid_arg     *delegate_stateid;
633         } deleg_cur_fh;
634     /* case CLAIM_DELEGATE_PREV: */
635         struct __open_claim_deleg_prev {
636             const nfs41_component *filename;
637         } deleg_prev;
638     } u;
639 } open_claim4;
640 
641 typedef struct __nfs41_op_open_args {
642     uint32_t                seqid;
643     uint32_t                share_access;
644     uint32_t                share_deny;
645     state_owner4            *owner;
646     openflag4               openhow;
647     open_claim4             *claim;
648 } nfs41_op_open_args;
649 
650 enum {
651     OPEN4_RESULT_CONFIRM            = 0x00000002,
652     OPEN4_RESULT_LOCKTYPE_POSIX     = 0x00000004,
653     OPEN4_RESULT_PRESERVE_UNLINKED  = 0x00000008,
654     OPEN4_RESULT_MAY_NOTIFY_LOCK    = 0x00000020
655 };
656 
657 typedef struct __nfs41_op_open_res_ok {
658     stateid4                *stateid;
659     change_info4            cinfo;
660     uint32_t                rflags;
661     bitmap4                 attrset;
662     open_delegation4        *delegation;
663 } nfs41_op_open_res_ok;
664 
665 typedef struct __nfs41_op_open_res {
666     uint32_t                status;
667     /* case NFS4_OK: */
668     nfs41_op_open_res_ok    resok4;
669 } nfs41_op_open_res;
670 
671 
672 /* OP_OPENATTR */
673 typedef struct __nfs41_openattr_args {
674     bool_t                  createdir;
675 } nfs41_openattr_args;
676 
677 typedef struct __nfs41_openattr_res {
678     uint32_t                status;
679 } nfs41_openattr_res;
680 
681 
682 /* OP_READ */
683 typedef struct __nfs41_read_args {
684     stateid_arg             *stateid; /* -> nfs41_op_open_res_ok.stateid */
685     uint64_t                offset;
686     uint32_t                count;
687 } nfs41_read_args;
688 
689 typedef struct __nfs41_read_res_ok {
690     bool_t                  eof;
691     uint32_t                data_len;
692     unsigned char           *data; /* caller-allocated */
693 } nfs41_read_res_ok;
694 
695 typedef struct __nfs41_read_res {
696     uint32_t                status;
697     /* case NFS4_OK: */
698     nfs41_read_res_ok       resok4;
699 } nfs41_read_res;
700 
701 
702 /* OP_READDIR */
703 typedef struct __nfs41_readdir_args {
704     nfs41_readdir_cookie    cookie;
705     uint32_t                dircount;
706     uint32_t                maxcount;
707     bitmap4                 *attr_request;
708 } nfs41_readdir_args;
709 
710 typedef struct __nfs41_readdir_entry {
711     uint64_t                cookie;
712     uint32_t                name_len;
713     uint32_t                next_entry_offset;
714     nfs41_file_info         attr_info;
715     char                    name[1];
716 } nfs41_readdir_entry;
717 
718 typedef struct __nfs41_readdir_list {
719     bool_t                  has_entries;
720     uint32_t                entries_len;
721     unsigned char           *entries;
722     bool_t                  eof;
723 } nfs41_readdir_list;
724 
725 typedef struct __nfs41_readdir_res {
726     uint32_t                status;
727     /* case NFS4_OK: */
728     unsigned char           cookieverf[NFS4_VERIFIER_SIZE];
729     nfs41_readdir_list      reply;
730 } nfs41_readdir_res;
731 
732 
733 /* OP_READLINK */
734 typedef struct __nfs41_readlink_res {
735     uint32_t                status;
736     /* case NFS4_OK: */
737     uint32_t                link_len;
738     char                    *link;
739 } nfs41_readlink_res;
740 
741 
742 /* OP_REMOVE */
743 typedef struct __nfs41_remove_args {
744     const nfs41_component   *target;
745 } nfs41_remove_args;
746 
747 typedef struct __nfs41_remove_res {
748     uint32_t                status;
749     /* case NFS4_OK: */
750     change_info4            cinfo;
751 } nfs41_remove_res;
752 
753 
754 /* OP_RENAME */
755 typedef struct __nfs41_rename_args {
756     const nfs41_component   *oldname;
757     const nfs41_component   *newname;
758 } nfs41_rename_args;
759 
760 typedef struct __nfs41_rename_res {
761     uint32_t                status;
762     /* case NFS4_OK: */
763     change_info4            source_cinfo;
764     change_info4            target_cinfo;
765 } nfs41_rename_res;
766 
767 
768 /* OP_RESTOREFH */
769 /* OP_SAVEFH */
770 typedef struct __nfs41_restorefh_savefh_res {
771     uint32_t                status;
772 } nfs41_restorefh_res, nfs41_savefh_res;
773 
774 
775 /* OP_SETATTR */
776 enum time_how4 {
777     SET_TO_SERVER_TIME4 = 0,
778     SET_TO_CLIENT_TIME4 = 1
779 };
780 
781 typedef struct __nfs41_setattr_args {
782     stateid_arg             *stateid;
783     nfs41_file_info         *info;
784 } nfs41_setattr_args;
785 
786 typedef struct __nfs41_setattr_res {
787     uint32_t                status;
788     bitmap4                 attrsset;
789 } nfs41_setattr_res;
790 
791 
792 /* OP_WANT_DELEGATION */
793 typedef struct __deleg_claim4 {
794     uint32_t                claim;
795     /* case CLAIM_PREVIOUS: */
796     uint32_t                prev_delegate_type;
797 } deleg_claim4;
798 
799 typedef struct __nfs41_want_delegation_args {
800     uint32_t                want;
801     deleg_claim4            *claim;
802 } nfs41_want_delegation_args;
803 
804 typedef struct __nfs41_want_delegation_res {
805     uint32_t                status;
806     /* case NFS4_OK: */
807     open_delegation4        *delegation;
808 } nfs41_want_delegation_res;
809 /* OP_FREE_STATEID */
810 typedef struct __nfs41_free_stateid_args {
811     stateid4                *stateid;
812 } nfs41_free_stateid_args;
813 
814 typedef struct __nfs41_free_stateid_res {
815     uint32_t                status;
816 } nfs41_free_stateid_res;
817 
818 
819 /* OP_TEST_STATEID */
820 typedef struct __nfs41_test_stateid_args {
821     uint32_t                count;
822     stateid_arg             *stateids; // caller-allocated array
823 } nfs41_test_stateid_args;
824 
825 typedef struct __nfs41_test_stateid_res {
826     uint32_t                status;
827     struct {
828         uint32_t            count;
829         uint32_t            *status; // caller-allocated array
830     } resok;
831 } nfs41_test_stateid_res;
832 
833 
834 /* OP_WRITE */
835 enum stable_how4 {
836     UNSTABLE4       = 0,
837     DATA_SYNC4      = 1,
838     FILE_SYNC4      = 2
839 };
840 
841 typedef struct __nfs41_write_args {
842     stateid_arg             *stateid; /* -> nfs41_op_open_res_ok.stateid */
843     uint64_t                offset;
844     uint32_t                stable; /* stable_how4 */
845     uint32_t                data_len;
846     unsigned char           *data; /* caller-allocated */
847 } nfs41_write_args;
848 
849 typedef struct __nfs41_write_res_ok {
850     uint32_t                count;
851     nfs41_write_verf        *verf;
852 } nfs41_write_res_ok;
853 
854 typedef struct __nfs41_write_res {
855     uint32_t                status;
856     /* case NFS4_OK: */
857     nfs41_write_res_ok      resok4;
858 } nfs41_write_res;
859 
860 /* OP_SECINFO */
861 enum sec_flavor {
862     RPC_GSS_SVC_NONE = 1,
863     RPC_GSS_SVC_INTEGRITY = 2,
864     RPC_GSS_SVC_PRIVACY = 3,
865 };
866 
867 #define RPCSEC_GSS 6
868 #define MAX_OID_LEN 128
869 typedef struct __nfs41_secinfo_info {
870     char                    oid[MAX_OID_LEN];
871     uint32_t                oid_len;
872     uint32_t                sec_flavor;
873     uint32_t                qop;
874     enum sec_flavor         type;
875 } nfs41_secinfo_info;
876 
877 typedef struct __nfs41_secinfo_args {
878     const nfs41_component   *name;
879 } nfs41_secinfo_args;
880 
881 #define MAX_SECINFOS 6
882 
883 /* OP_SECINFO_NO_NAME */
884 enum secinfo_no_name_type {
885     SECINFO_STYLE4_CURRENT_FH = 0,
886     SECINFO_STYLE4_PARENT = 1
887 };
888 
889 typedef struct __nfs41_secinfo_noname_args {
890 #ifdef __REACTOS__
891     uint32_t type;
892 #else
893     enum secinfo_noname_type type;
894 #endif
895 } nfs41_secinfo_noname_args;
896 
897 typedef struct __nfs41_secinfo_noname_res {
898     uint32_t                status;
899     /* case NFS4_OK: */
900     nfs41_secinfo_info      *secinfo;
901     uint32_t                count;
902 } nfs41_secinfo_noname_res;
903 
904 /* LAYOUTGET */
905 typedef struct __pnfs_layoutget_args {
906     bool_t                  signal_layout_avail;
907     enum pnfs_layout_type   layout_type;
908     enum pnfs_iomode        iomode;
909     uint64_t                offset;
910     uint64_t                length;
911     uint64_t                minlength;
912     stateid_arg             *stateid;
913     uint32_t                maxcount;
914 } pnfs_layoutget_args;
915 
916 typedef struct __pnfs_layoutget_res_ok {
917     bool_t                  return_on_close;
918     stateid4                stateid;
919     uint32_t                count;
920     struct list_entry       layouts; /* list of pnfs_layouts */
921 } pnfs_layoutget_res_ok;
922 
923 typedef struct __pnfs_layoutget_res {
924     enum nfsstat4           status;
925     union {
926     /* case NFS4_OK: */
927         pnfs_layoutget_res_ok *res_ok;
928     /* case NFS4ERR_LAYOUTTRYLATER: */
929         bool_t              will_signal_layout_avail;
930     /* default: void; */
931     } u;
932 } pnfs_layoutget_res;
933 
934 
935 /* LAYOUTCOMMIT */
936 typedef struct __pnfs_layoutcommit_args {
937     uint64_t                offset;
938     uint64_t                length;
939     stateid4                *stateid;
940     nfstime4                *new_time;
941     uint64_t                *new_offset;
942 } pnfs_layoutcommit_args;
943 
944 typedef struct __pnfs_layoutcommit_res {
945     uint32_t                status;
946     /* case NFS4_OK */
947     bool_t                  has_new_size;
948     /* case TRUE */
949     uint64_t                new_size;
950 } pnfs_layoutcommit_res;
951 
952 
953 /* LAYOUTRETURN */
954 typedef struct __pnfs_layoutreturn_args {
955     bool_t                  reclaim;
956     enum pnfs_layout_type   type;
957     enum pnfs_iomode        iomode;
958     enum pnfs_return_type   return_type;
959     /* case LAYOUTRETURN4_FILE: */
960     uint64_t                offset;
961     uint64_t                length;
962     stateid4                *stateid;
963 } pnfs_layoutreturn_args;
964 
965 typedef struct __pnfs_layoutreturn_res {
966     enum nfsstat4           status;
967     /* case NFS4_OK: */
968     bool_t                  stateid_present;
969     /* case true: */
970     stateid4                stateid;
971 } pnfs_layoutreturn_res;
972 
973 
974 /* GETDEVICEINFO */
975 typedef struct __pnfs_getdeviceinfo_args {
976     unsigned char           *deviceid;
977     enum pnfs_layout_type   layout_type;
978     uint32_t                maxcount;
979     bitmap4                 notify_types;
980 } pnfs_getdeviceinfo_args;
981 
982 typedef struct __pnfs_getdeviceinfo_res_ok {
983     pnfs_file_device        *device;
984     bitmap4                 notification;
985 } pnfs_getdeviceinfo_res_ok;
986 
987 typedef struct __pnfs_getdeviceinfo_res {
988     enum nfsstat4           status;
989     union {
990     /* case NFS4_OK: */
991         pnfs_getdeviceinfo_res_ok res_ok;
992     /* case NFS4ERR_TOOSMALL: */
993        uint32_t             mincount;
994     /* default: void; */
995     } u;
996 } pnfs_getdeviceinfo_res;
997 
998 
999 /* nfs41_ops.c */
1000 int nfs41_exchange_id(
1001     IN nfs41_rpc_clnt *rpc,
1002     IN client_owner4 *owner,
1003     IN uint32_t flags_in,
1004     OUT nfs41_exchange_id_res *res_out);
1005 
1006 int nfs41_create_session(
1007     IN nfs41_client *clnt,
1008     OUT nfs41_session *session,
1009     IN bool_t try_recovery);
1010 
1011 enum nfsstat4 nfs41_bind_conn_to_session(
1012     IN nfs41_rpc_clnt *rpc,
1013     IN const unsigned char *sessionid,
1014     IN enum channel_dir_from_client4 dir);
1015 
1016 int nfs41_destroy_session(
1017     IN nfs41_session *session);
1018 
1019 int nfs41_destroy_clientid(
1020     IN nfs41_rpc_clnt *rpc,
1021     IN uint64_t clientid);
1022 
1023 int nfs41_send_sequence(
1024     IN nfs41_session *session);
1025 
1026 enum nfsstat4 nfs41_reclaim_complete(
1027     IN nfs41_session *session);
1028 
1029 int nfs41_lookup(
1030     IN nfs41_root *root,
1031     IN nfs41_session *session,
1032     IN OUT nfs41_abs_path *path,
1033     OUT OPTIONAL nfs41_path_fh *parent_out,
1034     OUT OPTIONAL nfs41_path_fh *target_out,
1035     OUT OPTIONAL nfs41_file_info *info_out,
1036     OUT nfs41_session **session_out);
1037 
1038 int nfs41_open(
1039     IN nfs41_session *session,
1040     IN nfs41_path_fh *parent,
1041     IN nfs41_path_fh *file,
1042     IN state_owner4 *owner,
1043     IN open_claim4 *claim,
1044     IN uint32_t allow,
1045     IN uint32_t deny,
1046     IN uint32_t create,
1047     IN uint32_t how_mode,
1048     IN OPTIONAL nfs41_file_info *createattrs,
1049     IN bool_t try_recovery,
1050     OUT stateid4 *stateid,
1051     OUT open_delegation4 *delegation,
1052     OUT OPTIONAL nfs41_file_info *info);
1053 
1054 int nfs41_create(
1055     IN nfs41_session *session,
1056     IN uint32_t type,
1057     IN nfs41_file_info *createattrs,
1058     IN OPTIONAL const char *symlink,
1059     IN nfs41_path_fh *parent,
1060     OUT nfs41_path_fh *file,
1061     OUT nfs41_file_info *info);
1062 
1063 int nfs41_close(
1064     IN nfs41_session *session,
1065     IN nfs41_path_fh *file,
1066     IN stateid_arg *stateid);
1067 
1068 int nfs41_write(
1069     IN nfs41_session *session,
1070     IN nfs41_path_fh *file,
1071     IN stateid_arg *stateid,
1072     IN unsigned char *data,
1073     IN uint32_t data_len,
1074     IN uint64_t offset,
1075     IN enum stable_how4 stable,
1076     OUT uint32_t *bytes_written,
1077     OUT nfs41_write_verf *verf,
1078     OUT nfs41_file_info *cinfo);
1079 
1080 int nfs41_read(
1081     IN nfs41_session *session,
1082     IN nfs41_path_fh *file,
1083     IN stateid_arg *stateid,
1084     IN uint64_t offset,
1085     IN uint32_t count,
1086     OUT unsigned char *data_out,
1087     OUT uint32_t *data_len_out,
1088     OUT bool_t *eof_out);
1089 
1090 int nfs41_commit(
1091     IN nfs41_session *session,
1092     IN nfs41_path_fh *file,
1093     IN uint64_t offset,
1094     IN uint32_t count,
1095     IN bool_t do_getattr,
1096     OUT nfs41_write_verf *verf,
1097     OUT nfs41_file_info *cinfo);
1098 
1099 int nfs41_lock(
1100     IN nfs41_session *session,
1101     IN nfs41_path_fh *file,
1102     IN state_owner4 *owner,
1103     IN uint32_t type,
1104     IN uint64_t offset,
1105     IN uint64_t length,
1106     IN bool_t reclaim,
1107     IN bool_t try_recovery,
1108     IN OUT stateid_arg *stateid);
1109 
1110 int nfs41_unlock(
1111     IN nfs41_session *session,
1112     IN nfs41_path_fh *file,
1113     IN uint64_t offset,
1114     IN uint64_t length,
1115     IN OUT stateid_arg *stateid);
1116 
1117 stateid4* nfs41_lock_stateid_copy(
1118     IN nfs41_lock_state *lock_state,
1119     IN OUT stateid4 *dest);
1120 
1121 int nfs41_readdir(
1122     IN nfs41_session *session,
1123     IN nfs41_path_fh *file,
1124     IN bitmap4 *attr_request,
1125     IN nfs41_readdir_cookie *cookie,
1126     OUT unsigned char *entries,
1127     IN OUT uint32_t *entries_len,
1128     OUT bool_t *eof_out);
1129 
1130 int nfs41_getattr(
1131     IN nfs41_session *session,
1132     IN OPTIONAL nfs41_path_fh *file,
1133     IN bitmap4 *attr_request,
1134     OUT nfs41_file_info *info);
1135 
1136 int nfs41_superblock_getattr(
1137     IN nfs41_session *session,
1138     IN nfs41_path_fh *file,
1139     IN bitmap4 *attr_request,
1140     OUT nfs41_file_info *info,
1141     OUT bool_t *supports_named_attrs);
1142 
1143 /* getattr.c */
1144 int nfs41_cached_getattr(
1145     IN nfs41_session *session,
1146     IN nfs41_path_fh *file,
1147     OUT nfs41_file_info *info);
1148 
1149 int nfs41_remove(
1150     IN nfs41_session *session,
1151     IN nfs41_path_fh *parent,
1152     IN const nfs41_component *target,
1153     IN uint64_t fileid);
1154 
1155 int nfs41_rename(
1156     IN nfs41_session *session,
1157     IN nfs41_path_fh *src_dir,
1158     IN const nfs41_component *src_name,
1159     IN nfs41_path_fh *dst_dir,
1160     IN const nfs41_component *dst_name);
1161 
1162 int nfs41_setattr(
1163     IN nfs41_session *session,
1164     IN nfs41_path_fh *file,
1165     IN stateid_arg *stateid,
1166     IN nfs41_file_info *info);
1167 
1168 int nfs41_link(
1169     IN nfs41_session *session,
1170     IN nfs41_path_fh *src,
1171     IN nfs41_path_fh *dst_dir,
1172     IN const nfs41_component *target,
1173     OUT nfs41_file_info *cinfo);
1174 
1175 /* symlink.c */
1176 int nfs41_symlink_target(
1177     IN nfs41_session *session,
1178     IN nfs41_path_fh *file,
1179     OUT nfs41_abs_path *target);
1180 
1181 int nfs41_symlink_follow(
1182     IN nfs41_root *root,
1183     IN nfs41_session *session,
1184     IN nfs41_path_fh *symlink,
1185     OUT nfs41_file_info *info);
1186 
1187 int nfs41_readlink(
1188     IN nfs41_session *session,
1189     IN nfs41_path_fh *file,
1190     IN uint32_t max_len,
1191     OUT char *link_out,
1192     OUT uint32_t *len_out);
1193 
1194 int nfs41_access(
1195     IN nfs41_session *session,
1196     IN nfs41_path_fh *file,
1197     IN uint32_t requested,
1198     OUT uint32_t *supported OPTIONAL,
1199     OUT uint32_t *access OPTIONAL);
1200 
1201 enum nfsstat4 nfs41_want_delegation(
1202     IN nfs41_session *session,
1203     IN nfs41_path_fh *file,
1204     IN deleg_claim4 *claim,
1205     IN uint32_t want,
1206     IN bool_t try_recovery,
1207     OUT open_delegation4 *delegation);
1208 
1209 int nfs41_delegpurge(
1210     IN nfs41_session *session);
1211 
1212 int nfs41_delegreturn(
1213     IN nfs41_session *session,
1214     IN nfs41_path_fh *file,
1215     IN stateid_arg *stateid,
1216     IN bool_t try_recovery);
1217 
1218 enum nfsstat4 nfs41_fs_locations(
1219     IN nfs41_session *session,
1220     IN nfs41_path_fh *parent,
1221     IN const nfs41_component *name,
1222     OUT fs_locations4 *locations);
1223 
1224 int nfs41_secinfo(
1225     IN nfs41_session *session,
1226     IN nfs41_path_fh *file,
1227     IN const nfs41_component *name,
1228     OUT nfs41_secinfo_info *secinfo);
1229 
1230 int nfs41_secinfo_noname(
1231     IN nfs41_session *session,
1232     IN nfs41_path_fh *file,
1233     OUT nfs41_secinfo_info *secinfo);
1234 
1235 enum nfsstat4 nfs41_free_stateid(
1236     IN nfs41_session *session,
1237     IN stateid4 *stateid);
1238 
1239 enum nfsstat4 nfs41_test_stateid(
1240     IN nfs41_session *session,
1241     IN stateid_arg *stateid_array,
1242     IN uint32_t count,
1243     OUT uint32_t *status_array);
1244 
1245 enum nfsstat4 pnfs_rpc_layoutget(
1246     IN nfs41_session *session,
1247     IN nfs41_path_fh *file,
1248     IN stateid_arg *stateid,
1249     IN enum pnfs_iomode iomode,
1250     IN uint64_t offset,
1251     IN uint64_t minlength,
1252     IN uint64_t length,
1253     OUT pnfs_layoutget_res_ok *layoutget_res);
1254 
1255 enum nfsstat4 pnfs_rpc_layoutcommit(
1256     IN nfs41_session *session,
1257     IN nfs41_path_fh *file,
1258     IN stateid4 *stateid,
1259     IN uint64_t offset,
1260     IN uint64_t length,
1261     IN OPTIONAL uint64_t *new_last_offset,
1262     IN OPTIONAL nfstime4 *new_time_modify,
1263     OUT nfs41_file_info *info);
1264 
1265 enum nfsstat4 pnfs_rpc_layoutreturn(
1266     IN nfs41_session *session,
1267     IN nfs41_path_fh *file,
1268     IN enum pnfs_layout_type type,
1269     IN enum pnfs_iomode iomode,
1270     IN uint64_t offset,
1271     IN uint64_t length,
1272     IN stateid4 *stateid,
1273     OUT pnfs_layoutreturn_res *layoutreturn_res);
1274 
1275 enum nfsstat4 pnfs_rpc_getdeviceinfo(
1276     IN nfs41_session *session,
1277     IN unsigned char *deviceid,
1278     OUT pnfs_file_device *device);
1279 
1280 enum nfsstat4 nfs41_rpc_openattr(
1281     IN nfs41_session *session,
1282     IN nfs41_path_fh *file,
1283     IN bool_t createdir,
1284     OUT nfs41_fh *fh_out);
1285 
1286 #endif /* !__NFS41_NFS_OPS_H__ */
1287