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 2 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, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "libcli/raw/interfaces.h"
24 /* modules can use the following to determine if the interface has changed */
25 /* version 1 -> 0 - make module stacking easier -- metze */
26 #define NTVFS_INTERFACE_VERSION 0
28 struct ntvfs_module_context;
31 /* each backend has to be one one of the following 3 basic types. In
32 * earlier versions of Samba backends needed to handle all types, now
33 * we implement them separately. */
34 enum ntvfs_type {NTVFS_DISK, NTVFS_PRINT, NTVFS_IPC};
36 /* the ntvfs operations structure - contains function pointers to
37 the backend implementations of each operation */
43 NTSTATUS (*connect)(struct ntvfs_module_context *ntvfs,
44 struct ntvfs_request *req,
45 const char *sharename);
46 NTSTATUS (*disconnect)(struct ntvfs_module_context *ntvfs);
48 /* async_setup - called when a backend is processing a async request */
49 NTSTATUS (*async_setup)(struct ntvfs_module_context *ntvfs,
50 struct ntvfs_request *req,
53 /* filesystem operations */
54 NTSTATUS (*fsinfo)(struct ntvfs_module_context *ntvfs,
55 struct ntvfs_request *req,
56 union smb_fsinfo *fs);
59 NTSTATUS (*unlink)(struct ntvfs_module_context *ntvfs,
60 struct ntvfs_request *req,
61 union smb_unlink *unl);
62 NTSTATUS (*chkpath)(struct ntvfs_module_context *ntvfs,
63 struct ntvfs_request *req,
64 union smb_chkpath *cp);
65 NTSTATUS (*qpathinfo)(struct ntvfs_module_context *ntvfs,
66 struct ntvfs_request *req,
67 union smb_fileinfo *st);
68 NTSTATUS (*setpathinfo)(struct ntvfs_module_context *ntvfs,
69 struct ntvfs_request *req,
70 union smb_setfileinfo *st);
71 NTSTATUS (*mkdir)(struct ntvfs_module_context *ntvfs,
72 struct ntvfs_request *req,
74 NTSTATUS (*rmdir)(struct ntvfs_module_context *ntvfs,
75 struct ntvfs_request *req,
76 struct smb_rmdir *rd);
77 NTSTATUS (*rename)(struct ntvfs_module_context *ntvfs,
78 struct ntvfs_request *req,
79 union smb_rename *ren);
80 NTSTATUS (*copy)(struct ntvfs_module_context *ntvfs,
81 struct ntvfs_request *req,
83 NTSTATUS (*open)(struct ntvfs_module_context *ntvfs,
84 struct ntvfs_request *req,
87 /* directory search */
88 NTSTATUS (*search_first)(struct ntvfs_module_context *ntvfs,
89 struct ntvfs_request *req,
90 union smb_search_first *io, void *private,
91 BOOL (*callback)(void *private, union smb_search_data *file));
92 NTSTATUS (*search_next)(struct ntvfs_module_context *ntvfs,
93 struct ntvfs_request *req,
94 union smb_search_next *io, void *private,
95 BOOL (*callback)(void *private, union smb_search_data *file));
96 NTSTATUS (*search_close)(struct ntvfs_module_context *ntvfs,
97 struct ntvfs_request *req,
98 union smb_search_close *io);
100 /* operations on open files */
101 NTSTATUS (*ioctl)(struct ntvfs_module_context *ntvfs,
102 struct ntvfs_request *req,
103 union smb_ioctl *io);
104 NTSTATUS (*read)(struct ntvfs_module_context *ntvfs,
105 struct ntvfs_request *req,
107 NTSTATUS (*write)(struct ntvfs_module_context *ntvfs,
108 struct ntvfs_request *req,
109 union smb_write *io);
110 NTSTATUS (*seek)(struct ntvfs_module_context *ntvfs,
111 struct ntvfs_request *req,
113 NTSTATUS (*flush)(struct ntvfs_module_context *ntvfs,
114 struct ntvfs_request *req,
115 union smb_flush *flush);
116 NTSTATUS (*lock)(struct ntvfs_module_context *ntvfs,
117 struct ntvfs_request *req,
118 union smb_lock *lck);
119 NTSTATUS (*qfileinfo)(struct ntvfs_module_context *ntvfs,
120 struct ntvfs_request *req,
121 union smb_fileinfo *info);
122 NTSTATUS (*setfileinfo)(struct ntvfs_module_context *ntvfs,
123 struct ntvfs_request *req,
124 union smb_setfileinfo *info);
125 NTSTATUS (*close)(struct ntvfs_module_context *ntvfs,
126 struct ntvfs_request *req,
127 union smb_close *io);
129 /* trans interface - used by IPC backend for pipes and RAP calls */
130 NTSTATUS (*trans)(struct ntvfs_module_context *ntvfs,
131 struct ntvfs_request *req,
132 struct smb_trans2 *trans);
134 /* trans2 interface - only used by CIFS backend to prover complete passthru for testing */
135 NTSTATUS (*trans2)(struct ntvfs_module_context *ntvfs,
136 struct ntvfs_request *req,
137 struct smb_trans2 *trans2);
139 /* change notify request */
140 NTSTATUS (*notify)(struct ntvfs_module_context *ntvfs,
141 struct ntvfs_request *req,
142 struct smb_notify *info);
144 /* cancel - cancels any pending async request */
145 NTSTATUS (*cancel)(struct ntvfs_module_context *ntvfs,
146 struct ntvfs_request *req);
148 /* printing specific operations */
149 NTSTATUS (*lpq)(struct ntvfs_module_context *ntvfs,
150 struct ntvfs_request *req,
153 /* logoff - called when a vuid is closed */
154 NTSTATUS (*logoff)(struct ntvfs_module_context *ntvfs,
155 struct ntvfs_request *req);
156 NTSTATUS (*exit)(struct ntvfs_module_context *ntvfs,
157 struct ntvfs_request *req);
160 struct ntvfs_module_context {
161 struct ntvfs_module_context *prev, *next;
162 struct ntvfs_context *ctx;
164 const struct ntvfs_ops *ops;
168 struct ntvfs_context {
169 enum ntvfs_type type;
171 /* the reported filesystem type */
174 /* the reported device type */
177 enum protocol_types protocol;
180 * linked list of module contexts
182 struct ntvfs_module_context *modules;
189 struct event_context *event_ctx;
190 struct messaging_context *msg_ctx;
194 NTSTATUS (*handler)(void *private_data, uint16_t fnum, uint8_t level);
199 struct socket_address *(*get_my_addr)(void *private_data, TALLOC_CTX *mem_ctx);
200 struct socket_address *(*get_peer_addr)(void *private_data, TALLOC_CTX *mem_ctx);
205 /* a set of flags to control handling of request structures */
206 #define NTVFS_ASYNC_STATE_ASYNC (1<<1) /* the backend will answer this one later */
207 #define NTVFS_ASYNC_STATE_MAY_ASYNC (1<<2) /* the backend is allowed to answer async */
209 /* the ntvfs_async_state structure allows backend functions to
210 delay replying to requests. To use this, the front end must
211 set send_fn to a function to be called by the backend
212 when the reply is finally ready to be sent. The backend
213 must set status to the status it wants in the
214 reply. The backend must set the NTVFS_ASYNC_STATE_ASYNC
215 control_flag on the request to indicate that it wishes to
218 If NTVFS_ASYNC_STATE_MAY_ASYNC is not set then the backend cannot
219 ask for a delayed reply for this request
221 note that the private_data pointer is private to the layer which alloced this struct
223 struct ntvfs_async_state {
224 struct ntvfs_async_state *prev, *next;
225 /* the async handling infos */
228 void (*send_fn)(struct ntvfs_request *);
231 /* the passthru module's per session private data */
232 struct ntvfs_module_context *ntvfs;
235 struct ntvfs_request {
236 /* the ntvfs_context this requests belongs to */
237 struct ntvfs_context *ctx;
239 /* ntvfs per request async states */
240 struct ntvfs_async_state *async_states;
242 /* the session_info, with security_token and maybe delegated credentials */
243 struct auth_session_info *session_info;
245 /* the smb pid is needed for locking contexts */
248 /* the smb mid is needed for matching requests */
251 /* some statictics for the management tools */
253 /* the system time when the request arrived */
254 struct timeval request_time;
258 /* this structure is used by backends to determine the size of some critical types */
259 struct ntvfs_critical_sizes {
260 int interface_version;
261 int sizeof_ntvfs_critical_sizes;
262 int sizeof_ntvfs_context;
263 int sizeof_ntvfs_module_context;
264 int sizeof_ntvfs_ops;
265 int sizeof_ntvfs_async_state;
266 int sizeof_ntvfs_request;
269 #define NTVFS_CURRENT_CRITICAL_SIZES(c) \
270 struct ntvfs_critical_sizes c = { \
271 .interface_version = NTVFS_INTERFACE_VERSION, \
272 .sizeof_ntvfs_critical_sizes = sizeof(struct ntvfs_critical_sizes), \
273 .sizeof_ntvfs_context = sizeof(struct ntvfs_context), \
274 .sizeof_ntvfs_module_context = sizeof(struct ntvfs_module_context), \
275 .sizeof_ntvfs_ops = sizeof(struct ntvfs_ops), \
276 .sizeof_ntvfs_async_state = sizeof(struct ntvfs_async_state), \
277 .sizeof_ntvfs_request = sizeof(struct ntvfs_request), \
280 struct messaging_context;
281 #include "librpc/gen_ndr/security.h"
282 #include "librpc/gen_ndr/notify.h"
283 #include "ntvfs/ntvfs_proto.h"