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/>.
24 #include "libcli/raw/interfaces.h"
25 #include "param/share.h"
27 /* modules can use the following to determine if the interface has changed */
28 /* version 1 -> 0 - make module stacking easier -- metze */
29 #define NTVFS_INTERFACE_VERSION 0
31 struct ntvfs_module_context;
34 /* each backend has to be one one of the following 3 basic types. In
35 * earlier versions of Samba backends needed to handle all types, now
36 * we implement them separately. */
37 enum ntvfs_type {NTVFS_DISK, NTVFS_PRINT, NTVFS_IPC};
39 /* the ntvfs operations structure - contains function pointers to
40 the backend implementations of each operation */
46 NTSTATUS (*connect)(struct ntvfs_module_context *ntvfs,
47 struct ntvfs_request *req,
48 const char *sharename);
49 NTSTATUS (*disconnect)(struct ntvfs_module_context *ntvfs);
51 /* async_setup - called when a backend is processing a async request */
52 NTSTATUS (*async_setup)(struct ntvfs_module_context *ntvfs,
53 struct ntvfs_request *req,
56 /* filesystem operations */
57 NTSTATUS (*fsinfo)(struct ntvfs_module_context *ntvfs,
58 struct ntvfs_request *req,
59 union smb_fsinfo *fs);
62 NTSTATUS (*unlink)(struct ntvfs_module_context *ntvfs,
63 struct ntvfs_request *req,
64 union smb_unlink *unl);
65 NTSTATUS (*chkpath)(struct ntvfs_module_context *ntvfs,
66 struct ntvfs_request *req,
67 union smb_chkpath *cp);
68 NTSTATUS (*qpathinfo)(struct ntvfs_module_context *ntvfs,
69 struct ntvfs_request *req,
70 union smb_fileinfo *st);
71 NTSTATUS (*setpathinfo)(struct ntvfs_module_context *ntvfs,
72 struct ntvfs_request *req,
73 union smb_setfileinfo *st);
74 NTSTATUS (*mkdir)(struct ntvfs_module_context *ntvfs,
75 struct ntvfs_request *req,
77 NTSTATUS (*rmdir)(struct ntvfs_module_context *ntvfs,
78 struct ntvfs_request *req,
79 struct smb_rmdir *rd);
80 NTSTATUS (*rename)(struct ntvfs_module_context *ntvfs,
81 struct ntvfs_request *req,
82 union smb_rename *ren);
83 NTSTATUS (*copy)(struct ntvfs_module_context *ntvfs,
84 struct ntvfs_request *req,
86 NTSTATUS (*open)(struct ntvfs_module_context *ntvfs,
87 struct ntvfs_request *req,
90 /* directory search */
91 NTSTATUS (*search_first)(struct ntvfs_module_context *ntvfs,
92 struct ntvfs_request *req,
93 union smb_search_first *io, void *private,
94 bool (*callback)(void *private, const union smb_search_data *file));
95 NTSTATUS (*search_next)(struct ntvfs_module_context *ntvfs,
96 struct ntvfs_request *req,
97 union smb_search_next *io, void *private,
98 bool (*callback)(void *private, const union smb_search_data *file));
99 NTSTATUS (*search_close)(struct ntvfs_module_context *ntvfs,
100 struct ntvfs_request *req,
101 union smb_search_close *io);
103 /* operations on open files */
104 NTSTATUS (*ioctl)(struct ntvfs_module_context *ntvfs,
105 struct ntvfs_request *req,
106 union smb_ioctl *io);
107 NTSTATUS (*read)(struct ntvfs_module_context *ntvfs,
108 struct ntvfs_request *req,
110 NTSTATUS (*write)(struct ntvfs_module_context *ntvfs,
111 struct ntvfs_request *req,
112 union smb_write *io);
113 NTSTATUS (*seek)(struct ntvfs_module_context *ntvfs,
114 struct ntvfs_request *req,
116 NTSTATUS (*flush)(struct ntvfs_module_context *ntvfs,
117 struct ntvfs_request *req,
118 union smb_flush *flush);
119 NTSTATUS (*lock)(struct ntvfs_module_context *ntvfs,
120 struct ntvfs_request *req,
121 union smb_lock *lck);
122 NTSTATUS (*qfileinfo)(struct ntvfs_module_context *ntvfs,
123 struct ntvfs_request *req,
124 union smb_fileinfo *info);
125 NTSTATUS (*setfileinfo)(struct ntvfs_module_context *ntvfs,
126 struct ntvfs_request *req,
127 union smb_setfileinfo *info);
128 NTSTATUS (*close)(struct ntvfs_module_context *ntvfs,
129 struct ntvfs_request *req,
130 union smb_close *io);
132 /* trans interface - used by IPC backend for pipes and RAP calls */
133 NTSTATUS (*trans)(struct ntvfs_module_context *ntvfs,
134 struct ntvfs_request *req,
135 struct smb_trans2 *trans);
137 /* trans2 interface - only used by CIFS backend to prover complete passthru for testing */
138 NTSTATUS (*trans2)(struct ntvfs_module_context *ntvfs,
139 struct ntvfs_request *req,
140 struct smb_trans2 *trans2);
142 /* change notify request */
143 NTSTATUS (*notify)(struct ntvfs_module_context *ntvfs,
144 struct ntvfs_request *req,
145 union smb_notify *info);
147 /* cancel - cancels any pending async request */
148 NTSTATUS (*cancel)(struct ntvfs_module_context *ntvfs,
149 struct ntvfs_request *req);
151 /* printing specific operations */
152 NTSTATUS (*lpq)(struct ntvfs_module_context *ntvfs,
153 struct ntvfs_request *req,
156 /* logoff - called when a vuid is closed */
157 NTSTATUS (*logoff)(struct ntvfs_module_context *ntvfs,
158 struct ntvfs_request *req);
159 NTSTATUS (*exit)(struct ntvfs_module_context *ntvfs,
160 struct ntvfs_request *req);
163 struct ntvfs_module_context {
164 struct ntvfs_module_context *prev, *next;
165 struct ntvfs_context *ctx;
167 const struct ntvfs_ops *ops;
171 struct ntvfs_context {
172 enum ntvfs_type type;
174 /* the reported filesystem type */
177 /* the reported device type */
180 enum protocol_types protocol;
183 * linked list of module contexts
185 struct ntvfs_module_context *modules;
187 struct share_config *config;
189 struct server_id server_id;
190 struct event_context *event_ctx;
191 struct messaging_context *msg_ctx;
195 NTSTATUS (*handler)(void *private_data, struct ntvfs_handle *handle, uint8_t level);
200 struct socket_address *(*get_my_addr)(void *private_data, TALLOC_CTX *mem_ctx);
201 struct socket_address *(*get_peer_addr)(void *private_data, TALLOC_CTX *mem_ctx);
206 NTSTATUS (*create_new)(void *private_data, struct ntvfs_request *req, struct ntvfs_handle **h);
207 NTSTATUS (*make_valid)(void *private_data, struct ntvfs_handle *h);
208 void (*destroy)(void *private_data, struct ntvfs_handle *h);
209 struct ntvfs_handle *(*search_by_wire_key)(void *private_data, struct ntvfs_request *req, const DATA_BLOB *key);
210 DATA_BLOB (*get_wire_key)(void *private_data, struct ntvfs_handle *handle, TALLOC_CTX *mem_ctx);
214 /* a set of flags to control handling of request structures */
215 #define NTVFS_ASYNC_STATE_ASYNC (1<<1) /* the backend will answer this one later */
216 #define NTVFS_ASYNC_STATE_MAY_ASYNC (1<<2) /* the backend is allowed to answer async */
218 /* the ntvfs_async_state structure allows backend functions to
219 delay replying to requests. To use this, the front end must
220 set send_fn to a function to be called by the backend
221 when the reply is finally ready to be sent. The backend
222 must set status to the status it wants in the
223 reply. The backend must set the NTVFS_ASYNC_STATE_ASYNC
224 control_flag on the request to indicate that it wishes to
227 If NTVFS_ASYNC_STATE_MAY_ASYNC is not set then the backend cannot
228 ask for a delayed reply for this request
230 note that the private_data pointer is private to the layer which alloced this struct
232 struct ntvfs_async_state {
233 struct ntvfs_async_state *prev, *next;
234 /* the async handling infos */
237 void (*send_fn)(struct ntvfs_request *);
240 /* the passthru module's per session private data */
241 struct ntvfs_module_context *ntvfs;
244 struct ntvfs_request {
245 /* the ntvfs_context this requests belongs to */
246 struct ntvfs_context *ctx;
248 /* ntvfs per request async states */
249 struct ntvfs_async_state *async_states;
251 /* the session_info, with security_token and maybe delegated credentials */
252 struct auth_session_info *session_info;
254 /* the smb pid is needed for locking contexts */
257 /* some statictics for the management tools */
259 /* the system time when the request arrived */
260 struct timeval request_time;
268 struct ntvfs_handle {
269 struct ntvfs_context *ctx;
271 struct auth_session_info *session_info;
275 struct ntvfs_handle_data {
276 struct ntvfs_handle_data *prev, *next;
277 struct ntvfs_module_context *owner;
278 void *private_data;/* this must be a valid talloc pointer */
286 /* this structure is used by backends to determine the size of some critical types */
287 struct ntvfs_critical_sizes {
288 int interface_version;
289 int sizeof_ntvfs_critical_sizes;
290 int sizeof_ntvfs_context;
291 int sizeof_ntvfs_module_context;
292 int sizeof_ntvfs_ops;
293 int sizeof_ntvfs_async_state;
294 int sizeof_ntvfs_request;
295 int sizeof_ntvfs_handle;
296 int sizeof_ntvfs_handle_data;
299 #define NTVFS_CURRENT_CRITICAL_SIZES(c) \
300 struct ntvfs_critical_sizes c = { \
301 .interface_version = NTVFS_INTERFACE_VERSION, \
302 .sizeof_ntvfs_critical_sizes = sizeof(struct ntvfs_critical_sizes), \
303 .sizeof_ntvfs_context = sizeof(struct ntvfs_context), \
304 .sizeof_ntvfs_module_context = sizeof(struct ntvfs_module_context), \
305 .sizeof_ntvfs_ops = sizeof(struct ntvfs_ops), \
306 .sizeof_ntvfs_async_state = sizeof(struct ntvfs_async_state), \
307 .sizeof_ntvfs_request = sizeof(struct ntvfs_request), \
308 .sizeof_ntvfs_handle = sizeof(struct ntvfs_handle), \
309 .sizeof_ntvfs_handle_data = sizeof(struct ntvfs_handle_data), \
312 struct messaging_context;
313 #include "librpc/gen_ndr/security.h"
314 #include "librpc/gen_ndr/notify.h"
315 #include "ntvfs/ntvfs_proto.h"
317 #endif /* _NTVFS_H_ */