xref: /reactos/base/services/nfsd/upcall.h (revision 4561998a)
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_DAEMON_UPCALL_H__
23 #define __NFS41_DAEMON_UPCALL_H__
24 
25 #include "nfs41_ops.h"
26 #include "from_kernel.h"
27 
28 #define NFSD_VERSION_MISMATCH 116
29 
30 /* structures for upcall arguments */
31 typedef struct __mount_upcall_args {
32     const char *hostname;
33     const char *path;
34     DWORD       sec_flavor;
35     DWORD       rsize;
36     DWORD       wsize;
37     DWORD       lease_time;
38     FILE_FS_ATTRIBUTE_INFORMATION FsAttrs;
39 } mount_upcall_args;
40 
41 typedef struct __open_upcall_args {
42     nfs41_abs_path symlink;
43     FILE_BASIC_INFO basic_info;
44     FILE_STANDARD_INFO std_info;
45     const char *path;
46     ULONG access_mask;
47     ULONG access_mode;
48     ULONG file_attrs;
49     ULONG disposition;
50     ULONG create_opts;
51     LONG open_owner_id;
52     DWORD mode;
53     ULONGLONG changeattr;
54     HANDLE srv_open;
55     DWORD deleg_type;
56     PFILE_FULL_EA_INFORMATION ea;
57     BOOLEAN created;
58     BOOLEAN symlink_embedded;
59 } open_upcall_args;
60 
61 typedef struct __close_upcall_args {
62     HANDLE srv_open;
63     const char *path;
64     BOOLEAN remove;
65     BOOLEAN renamed;
66 } close_upcall_args;
67 
68 typedef struct __readwrite_upcall_args {
69     unsigned char *buffer;
70     ULONGLONG offset;
71     ULONG len;
72     ULONG out_len;
73     ULONGLONG ctime;
74 } readwrite_upcall_args;
75 
76 typedef struct __lock_upcall_args {
77     uint64_t offset;
78     uint64_t length;
79     BOOLEAN exclusive;
80     BOOLEAN blocking;
81     BOOLEAN acquired;
82 } lock_upcall_args;
83 
84 typedef struct __unlock_upcall_args {
85     uint32_t count;
86     unsigned char *buf;
87     uint32_t buf_len;
88 } unlock_upcall_args;
89 
90 typedef struct __getattr_upcall_args {
91     FILE_BASIC_INFO basic_info;
92     FILE_STANDARD_INFO std_info;
93     FILE_ATTRIBUTE_TAG_INFO tag_info;
94     FILE_INTERNAL_INFORMATION intr_info;
95     FILE_NETWORK_OPEN_INFORMATION network_info;
96     int query_class;
97     int buf_len;
98     int query_reply_len;
99     ULONGLONG ctime;
100 } getattr_upcall_args;
101 
102 typedef struct __setattr_upcall_args {
103     const char *path;
104     nfs41_root *root;
105     nfs41_open_state *state;
106     unsigned char *buf;
107     uint32_t buf_len;
108     int set_class;
109     ULONGLONG ctime;
110 } setattr_upcall_args;
111 
112 typedef struct __getexattr_upcall_args {
113     const char *path;
114     unsigned char *buf;
115     uint32_t buf_len;
116     ULONG eaindex;
117     unsigned char *ealist;
118     uint32_t ealist_len;
119     uint32_t overflow;
120     BOOLEAN single;
121     BOOLEAN restart;
122 } getexattr_upcall_args;
123 
124 
125 typedef struct __setexattr_upcall_args {
126     const char *path;
127     unsigned char *buf;
128     uint32_t buf_len;
129     uint32_t mode;
130     ULONGLONG ctime;
131 } setexattr_upcall_args;
132 
133 typedef struct __readdir_upcall_args {
134     const char *filter;
135     nfs41_root *root;
136     nfs41_open_state *state;
137     int buf_len;
138     int query_class;
139     int query_reply_len;
140     BOOLEAN initial;
141     BOOLEAN restart;
142     BOOLEAN single;
143     unsigned char *kbuf;
144 } readdir_upcall_args;
145 
146 typedef struct __symlink_upcall_args {
147     nfs41_abs_path target_get;
148     char *target_set;
149     const char *path;
150     BOOLEAN set;
151 } symlink_upcall_args;
152 
153 typedef struct __volume_upcall_args {
154     FS_INFORMATION_CLASS query;
155     int len;
156     union {
157         FILE_FS_SIZE_INFORMATION size;
158         FILE_FS_FULL_SIZE_INFORMATION fullsize;
159         FILE_FS_ATTRIBUTE_INFORMATION attribute;
160     } info;
161 } volume_upcall_args;
162 
163 typedef struct __getacl_upcall_args {
164     SECURITY_INFORMATION query;
165     PSECURITY_DESCRIPTOR sec_desc;
166     DWORD sec_desc_len;
167 } getacl_upcall_args;
168 
169 typedef struct __setacl_upcall_args {
170     SECURITY_INFORMATION query;
171     PSECURITY_DESCRIPTOR sec_desc;
172     ULONGLONG ctime;
173 } setacl_upcall_args;
174 
175 typedef union __upcall_args {
176     mount_upcall_args       mount;
177     open_upcall_args        open;
178     close_upcall_args       close;
179     readwrite_upcall_args   rw;
180     lock_upcall_args        lock;
181     unlock_upcall_args      unlock;
182     getattr_upcall_args     getattr;
183     getexattr_upcall_args   getexattr;
184     setattr_upcall_args     setattr;
185     setexattr_upcall_args   setexattr;
186     readdir_upcall_args     readdir;
187     symlink_upcall_args     symlink;
188     volume_upcall_args      volume;
189     getacl_upcall_args      getacl;
190     setacl_upcall_args      setacl;
191 } upcall_args;
192 
193 typedef struct __nfs41_upcall {
194     uint64_t                xid;
195     uint32_t                opcode;
196     uint32_t                status;
197     uint32_t                last_error;
198     upcall_args             args;
199 
200     uid_t                   uid;
201     gid_t                   gid;
202 
203     /* store referenced pointers with the upcall for
204      * automatic dereferencing on upcall_cleanup();
205      * see upcall_root_ref() and upcall_open_state_ref() */
206     nfs41_root              *root_ref;
207     nfs41_open_state        *state_ref;
208 } nfs41_upcall;
209 
210 
211 /* upcall operation interface */
212 typedef int (*upcall_parse_proc)(unsigned char*, uint32_t, nfs41_upcall*);
213 typedef int (*upcall_handle_proc)(nfs41_upcall*);
214 typedef int (*upcall_marshall_proc)(unsigned char*, uint32_t*, nfs41_upcall*);
215 typedef void (*upcall_cancel_proc)(nfs41_upcall*);
216 typedef void (*upcall_cleanup_proc)(nfs41_upcall*);
217 
218 typedef struct __nfs41_upcall_op {
219     upcall_parse_proc       parse;
220     upcall_handle_proc      handle;
221     upcall_marshall_proc    marshall;
222     upcall_cancel_proc      cancel;
223     upcall_cleanup_proc     cleanup;
224 } nfs41_upcall_op;
225 
226 
227 /* upcall.c */
228 int upcall_parse(
229     IN unsigned char *buffer,
230     IN uint32_t length,
231     OUT nfs41_upcall *upcall);
232 
233 int upcall_handle(
234     IN nfs41_upcall *upcall);
235 
236 void upcall_marshall(
237     IN nfs41_upcall *upcall,
238     OUT unsigned char *buffer,
239     IN uint32_t length,
240     OUT uint32_t *length_out);
241 
242 void upcall_cancel(
243     IN nfs41_upcall *upcall);
244 
245 void upcall_cleanup(
246     IN nfs41_upcall *upcall);
247 
248 #endif /* !__NFS41_DAEMON_UPCALL_H__ */
249