s4:dsdb Remove unused variables
[Samba/ekacnet.git] / source4 / ntvfs / ntvfs.h
blob5e9c6577372cb33a12a0f1175b84ac38a4721e79
1 /*
2 Unix SMB/CIFS implementation.
3 NTVFS structures and defines
4 Copyright (C) Andrew Tridgell 2003
5 Copyright (C) Stefan Metzmacher 2004
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef _NTVFS_H_
22 #define _NTVFS_H_
24 #include "libcli/raw/interfaces.h"
25 #include "param/share.h"
26 #include "librpc/gen_ndr/security.h"
27 #include "librpc/gen_ndr/server_id.h"
29 /* modules can use the following to determine if the interface has changed */
30 /* version 1 -> 0 - make module stacking easier -- metze */
31 #define NTVFS_INTERFACE_VERSION 0
33 struct ntvfs_module_context;
34 struct ntvfs_request;
36 /* each backend has to be one one of the following 3 basic types. In
37 earlier versions of Samba backends needed to handle all types, now
38 we implement them separately.
39 The values 1..3 match the SMB2 SMB2_SHARE_TYPE_* values
41 enum ntvfs_type {NTVFS_DISK=1, NTVFS_IPC=2, NTVFS_PRINT=3};
43 /* the ntvfs operations structure - contains function pointers to
44 the backend implementations of each operation */
45 struct ntvfs_ops {
46 const char *name;
47 enum ntvfs_type type;
49 /* initial setup */
50 NTSTATUS (*connect)(struct ntvfs_module_context *ntvfs,
51 struct ntvfs_request *req,
52 union smb_tcon *tcon);
53 NTSTATUS (*disconnect)(struct ntvfs_module_context *ntvfs);
55 /* async_setup - called when a backend is processing a async request */
56 NTSTATUS (*async_setup)(struct ntvfs_module_context *ntvfs,
57 struct ntvfs_request *req,
58 void *private_data);
60 /* filesystem operations */
61 NTSTATUS (*fsinfo)(struct ntvfs_module_context *ntvfs,
62 struct ntvfs_request *req,
63 union smb_fsinfo *fs);
65 /* path operations */
66 NTSTATUS (*unlink)(struct ntvfs_module_context *ntvfs,
67 struct ntvfs_request *req,
68 union smb_unlink *unl);
69 NTSTATUS (*chkpath)(struct ntvfs_module_context *ntvfs,
70 struct ntvfs_request *req,
71 union smb_chkpath *cp);
72 NTSTATUS (*qpathinfo)(struct ntvfs_module_context *ntvfs,
73 struct ntvfs_request *req,
74 union smb_fileinfo *st);
75 NTSTATUS (*setpathinfo)(struct ntvfs_module_context *ntvfs,
76 struct ntvfs_request *req,
77 union smb_setfileinfo *st);
78 NTSTATUS (*mkdir)(struct ntvfs_module_context *ntvfs,
79 struct ntvfs_request *req,
80 union smb_mkdir *md);
81 NTSTATUS (*rmdir)(struct ntvfs_module_context *ntvfs,
82 struct ntvfs_request *req,
83 struct smb_rmdir *rd);
84 NTSTATUS (*rename)(struct ntvfs_module_context *ntvfs,
85 struct ntvfs_request *req,
86 union smb_rename *ren);
87 NTSTATUS (*copy)(struct ntvfs_module_context *ntvfs,
88 struct ntvfs_request *req,
89 struct smb_copy *cp);
90 NTSTATUS (*open)(struct ntvfs_module_context *ntvfs,
91 struct ntvfs_request *req,
92 union smb_open *oi);
94 /* directory search */
95 NTSTATUS (*search_first)(struct ntvfs_module_context *ntvfs,
96 struct ntvfs_request *req,
97 union smb_search_first *io, void *private_data,
98 bool (*callback)(void *private_data, const union smb_search_data *file));
99 NTSTATUS (*search_next)(struct ntvfs_module_context *ntvfs,
100 struct ntvfs_request *req,
101 union smb_search_next *io, void *private_data,
102 bool (*callback)(void *private_data, const union smb_search_data *file));
103 NTSTATUS (*search_close)(struct ntvfs_module_context *ntvfs,
104 struct ntvfs_request *req,
105 union smb_search_close *io);
107 /* operations on open files */
108 NTSTATUS (*ioctl)(struct ntvfs_module_context *ntvfs,
109 struct ntvfs_request *req,
110 union smb_ioctl *io);
111 NTSTATUS (*read)(struct ntvfs_module_context *ntvfs,
112 struct ntvfs_request *req,
113 union smb_read *io);
114 NTSTATUS (*write)(struct ntvfs_module_context *ntvfs,
115 struct ntvfs_request *req,
116 union smb_write *io);
117 NTSTATUS (*seek)(struct ntvfs_module_context *ntvfs,
118 struct ntvfs_request *req,
119 union smb_seek *io);
120 NTSTATUS (*flush)(struct ntvfs_module_context *ntvfs,
121 struct ntvfs_request *req,
122 union smb_flush *flush);
123 NTSTATUS (*lock)(struct ntvfs_module_context *ntvfs,
124 struct ntvfs_request *req,
125 union smb_lock *lck);
126 NTSTATUS (*qfileinfo)(struct ntvfs_module_context *ntvfs,
127 struct ntvfs_request *req,
128 union smb_fileinfo *info);
129 NTSTATUS (*setfileinfo)(struct ntvfs_module_context *ntvfs,
130 struct ntvfs_request *req,
131 union smb_setfileinfo *info);
132 NTSTATUS (*close)(struct ntvfs_module_context *ntvfs,
133 struct ntvfs_request *req,
134 union smb_close *io);
136 /* trans interface - used by IPC backend for pipes and RAP calls */
137 NTSTATUS (*trans)(struct ntvfs_module_context *ntvfs,
138 struct ntvfs_request *req,
139 struct smb_trans2 *trans);
141 /* trans2 interface - only used by CIFS backend to prover complete passthru for testing */
142 NTSTATUS (*trans2)(struct ntvfs_module_context *ntvfs,
143 struct ntvfs_request *req,
144 struct smb_trans2 *trans2);
146 /* change notify request */
147 NTSTATUS (*notify)(struct ntvfs_module_context *ntvfs,
148 struct ntvfs_request *req,
149 union smb_notify *info);
151 /* cancel - cancels any pending async request */
152 NTSTATUS (*cancel)(struct ntvfs_module_context *ntvfs,
153 struct ntvfs_request *req);
155 /* printing specific operations */
156 NTSTATUS (*lpq)(struct ntvfs_module_context *ntvfs,
157 struct ntvfs_request *req,
158 union smb_lpq *lpq);
160 /* logoff - called when a vuid is closed */
161 NTSTATUS (*logoff)(struct ntvfs_module_context *ntvfs,
162 struct ntvfs_request *req);
163 NTSTATUS (*exit)(struct ntvfs_module_context *ntvfs,
164 struct ntvfs_request *req);
167 struct ntvfs_module_context {
168 struct ntvfs_module_context *prev, *next;
169 struct ntvfs_context *ctx;
170 int depth;
171 const struct ntvfs_ops *ops;
172 void *private_data;
175 struct ntvfs_context {
176 enum ntvfs_type type;
178 /* the reported filesystem type */
179 char *fs_type;
181 /* the reported device type */
182 char *dev_type;
184 enum protocol_types protocol;
187 * client capabilities
188 * this field doesn't use protocol specific
189 * values!
191 #define NTVFS_CLIENT_CAP_LEVEL_II_OPLOCKS 0x0000000000000001LLU
192 uint64_t client_caps;
195 * linked list of module contexts
197 struct ntvfs_module_context *modules;
199 struct share_config *config;
201 struct server_id server_id;
202 struct loadparm_context *lp_ctx;
203 struct tevent_context *event_ctx;
204 struct messaging_context *msg_ctx;
206 struct {
207 void *private_data;
208 NTSTATUS (*handler)(void *private_data, struct ntvfs_handle *handle, uint8_t level);
209 } oplock;
211 struct {
212 void *private_data;
213 struct socket_address *(*get_my_addr)(void *private_data, TALLOC_CTX *mem_ctx);
214 struct socket_address *(*get_peer_addr)(void *private_data, TALLOC_CTX *mem_ctx);
215 } client;
217 struct {
218 void *private_data;
219 NTSTATUS (*create_new)(void *private_data, struct ntvfs_request *req, struct ntvfs_handle **h);
220 NTSTATUS (*make_valid)(void *private_data, struct ntvfs_handle *h);
221 void (*destroy)(void *private_data, struct ntvfs_handle *h);
222 struct ntvfs_handle *(*search_by_wire_key)(void *private_data, struct ntvfs_request *req, const DATA_BLOB *key);
223 DATA_BLOB (*get_wire_key)(void *private_data, struct ntvfs_handle *handle, TALLOC_CTX *mem_ctx);
224 } handles;
227 /* a set of flags to control handling of request structures */
228 #define NTVFS_ASYNC_STATE_ASYNC (1<<1) /* the backend will answer this one later */
229 #define NTVFS_ASYNC_STATE_MAY_ASYNC (1<<2) /* the backend is allowed to answer async */
230 #define NTVFS_ASYNC_STATE_CLOSE (1<<3) /* the backend session should be closed */
232 /* the ntvfs_async_state structure allows backend functions to
233 delay replying to requests. To use this, the front end must
234 set send_fn to a function to be called by the backend
235 when the reply is finally ready to be sent. The backend
236 must set status to the status it wants in the
237 reply. The backend must set the NTVFS_ASYNC_STATE_ASYNC
238 control_flag on the request to indicate that it wishes to
239 delay the reply
241 If NTVFS_ASYNC_STATE_MAY_ASYNC is not set then the backend cannot
242 ask for a delayed reply for this request
244 note that the private_data pointer is private to the layer which alloced this struct
246 struct ntvfs_async_state {
247 struct ntvfs_async_state *prev, *next;
248 /* the async handling infos */
249 unsigned int state;
250 void *private_data;
251 void (*send_fn)(struct ntvfs_request *);
252 NTSTATUS status;
254 /* the passthru module's per session private data */
255 struct ntvfs_module_context *ntvfs;
258 struct ntvfs_request {
259 /* the ntvfs_context this requests belongs to */
260 struct ntvfs_context *ctx;
262 /* ntvfs per request async states */
263 struct ntvfs_async_state *async_states;
265 /* the session_info, with security_token and maybe delegated credentials */
266 struct auth_session_info *session_info;
268 /* the smb pid is needed for locking contexts */
269 uint32_t smbpid;
272 * client capabilities
273 * this field doesn't use protocol specific
274 * values!
275 * see NTVFS_CLIENT_CAP_*
277 uint64_t client_caps;
279 /* some statictics for the management tools */
280 struct {
281 /* the system time when the request arrived */
282 struct timeval request_time;
283 } statistics;
285 struct {
286 void *private_data;
287 } frontend_data;
290 struct ntvfs_handle {
291 struct ntvfs_context *ctx;
293 struct auth_session_info *session_info;
295 uint16_t smbpid;
297 struct ntvfs_handle_data {
298 struct ntvfs_handle_data *prev, *next;
299 struct ntvfs_module_context *owner;
300 void *private_data;/* this must be a valid talloc pointer */
301 } *backend_data;
303 struct {
304 void *private_data;
305 } frontend_data;
308 /* this structure is used by backends to determine the size of some critical types */
309 struct ntvfs_critical_sizes {
310 int interface_version;
311 int sizeof_ntvfs_critical_sizes;
312 int sizeof_ntvfs_context;
313 int sizeof_ntvfs_module_context;
314 int sizeof_ntvfs_ops;
315 int sizeof_ntvfs_async_state;
316 int sizeof_ntvfs_request;
317 int sizeof_ntvfs_handle;
318 int sizeof_ntvfs_handle_data;
321 #define NTVFS_CURRENT_CRITICAL_SIZES(c) \
322 struct ntvfs_critical_sizes c = { \
323 .interface_version = NTVFS_INTERFACE_VERSION, \
324 .sizeof_ntvfs_critical_sizes = sizeof(struct ntvfs_critical_sizes), \
325 .sizeof_ntvfs_context = sizeof(struct ntvfs_context), \
326 .sizeof_ntvfs_module_context = sizeof(struct ntvfs_module_context), \
327 .sizeof_ntvfs_ops = sizeof(struct ntvfs_ops), \
328 .sizeof_ntvfs_async_state = sizeof(struct ntvfs_async_state), \
329 .sizeof_ntvfs_request = sizeof(struct ntvfs_request), \
330 .sizeof_ntvfs_handle = sizeof(struct ntvfs_handle), \
331 .sizeof_ntvfs_handle_data = sizeof(struct ntvfs_handle_data), \
334 struct messaging_context;
335 #include "librpc/gen_ndr/security.h"
336 #include "librpc/gen_ndr/notify.h"
337 #include "ntvfs/ntvfs_proto.h"
339 #endif /* _NTVFS_H_ */