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 /* modules can use the following to determine if the interface has changed */
23 /* version 1 -> 0 - make module stacking easier -- metze */
24 #define NTVFS_INTERFACE_VERSION 0
26 struct ntvfs_module_context;
29 /* each backend has to be one one of the following 3 basic types. In
30 * earlier versions of Samba backends needed to handle all types, now
31 * we implement them separately. */
32 enum ntvfs_type {NTVFS_DISK, NTVFS_PRINT, NTVFS_IPC};
34 /* the ntvfs operations structure - contains function pointers to
35 the backend implementations of each operation */
41 NTSTATUS (*connect)(struct ntvfs_module_context *ntvfs,
42 struct ntvfs_request *req,
43 const char *sharename);
44 NTSTATUS (*disconnect)(struct ntvfs_module_context *ntvfs);
46 /* async_setup - called when a backend is processing a async request */
47 NTSTATUS (*async_setup)(struct ntvfs_module_context *ntvfs,
48 struct ntvfs_request *req,
51 /* filesystem operations */
52 NTSTATUS (*fsinfo)(struct ntvfs_module_context *ntvfs,
53 struct ntvfs_request *req,
54 union smb_fsinfo *fs);
57 NTSTATUS (*unlink)(struct ntvfs_module_context *ntvfs,
58 struct ntvfs_request *req,
59 union smb_unlink *unl);
60 NTSTATUS (*chkpath)(struct ntvfs_module_context *ntvfs,
61 struct ntvfs_request *req,
62 union smb_chkpath *cp);
63 NTSTATUS (*qpathinfo)(struct ntvfs_module_context *ntvfs,
64 struct ntvfs_request *req,
65 union smb_fileinfo *st);
66 NTSTATUS (*setpathinfo)(struct ntvfs_module_context *ntvfs,
67 struct ntvfs_request *req,
68 union smb_setfileinfo *st);
69 NTSTATUS (*mkdir)(struct ntvfs_module_context *ntvfs,
70 struct ntvfs_request *req,
72 NTSTATUS (*rmdir)(struct ntvfs_module_context *ntvfs,
73 struct ntvfs_request *req,
74 struct smb_rmdir *rd);
75 NTSTATUS (*rename)(struct ntvfs_module_context *ntvfs,
76 struct ntvfs_request *req,
77 union smb_rename *ren);
78 NTSTATUS (*copy)(struct ntvfs_module_context *ntvfs,
79 struct ntvfs_request *req,
81 NTSTATUS (*open)(struct ntvfs_module_context *ntvfs,
82 struct ntvfs_request *req,
85 /* directory search */
86 NTSTATUS (*search_first)(struct ntvfs_module_context *ntvfs,
87 struct ntvfs_request *req,
88 union smb_search_first *io, void *private,
89 BOOL (*callback)(void *private, union smb_search_data *file));
90 NTSTATUS (*search_next)(struct ntvfs_module_context *ntvfs,
91 struct ntvfs_request *req,
92 union smb_search_next *io, void *private,
93 BOOL (*callback)(void *private, union smb_search_data *file));
94 NTSTATUS (*search_close)(struct ntvfs_module_context *ntvfs,
95 struct ntvfs_request *req,
96 union smb_search_close *io);
98 /* operations on open files */
99 NTSTATUS (*ioctl)(struct ntvfs_module_context *ntvfs,
100 struct ntvfs_request *req,
101 union smb_ioctl *io);
102 NTSTATUS (*read)(struct ntvfs_module_context *ntvfs,
103 struct ntvfs_request *req,
105 NTSTATUS (*write)(struct ntvfs_module_context *ntvfs,
106 struct ntvfs_request *req,
107 union smb_write *io);
108 NTSTATUS (*seek)(struct ntvfs_module_context *ntvfs,
109 struct ntvfs_request *req,
111 NTSTATUS (*flush)(struct ntvfs_module_context *ntvfs,
112 struct ntvfs_request *req,
113 union smb_flush *flush);
114 NTSTATUS (*lock)(struct ntvfs_module_context *ntvfs,
115 struct ntvfs_request *req,
116 union smb_lock *lck);
117 NTSTATUS (*qfileinfo)(struct ntvfs_module_context *ntvfs,
118 struct ntvfs_request *req,
119 union smb_fileinfo *info);
120 NTSTATUS (*setfileinfo)(struct ntvfs_module_context *ntvfs,
121 struct ntvfs_request *req,
122 union smb_setfileinfo *info);
123 NTSTATUS (*close)(struct ntvfs_module_context *ntvfs,
124 struct ntvfs_request *req,
125 union smb_close *io);
127 /* trans interface - used by IPC backend for pipes and RAP calls */
128 NTSTATUS (*trans)(struct ntvfs_module_context *ntvfs,
129 struct ntvfs_request *req,
130 struct smb_trans2 *trans);
132 /* trans2 interface - only used by CIFS backend to prover complete passthru for testing */
133 NTSTATUS (*trans2)(struct ntvfs_module_context *ntvfs,
134 struct ntvfs_request *req,
135 struct smb_trans2 *trans2);
137 /* change notify request */
138 NTSTATUS (*notify)(struct ntvfs_module_context *ntvfs,
139 struct ntvfs_request *req,
140 struct smb_notify *info);
142 /* cancel - cancels any pending async request */
143 NTSTATUS (*cancel)(struct ntvfs_module_context *ntvfs,
144 struct ntvfs_request *req);
146 /* printing specific operations */
147 NTSTATUS (*lpq)(struct ntvfs_module_context *ntvfs,
148 struct ntvfs_request *req,
151 /* logoff - called when a vuid is closed */
152 NTSTATUS (*logoff)(struct ntvfs_module_context *ntvfs,
153 struct ntvfs_request *req);
154 NTSTATUS (*exit)(struct ntvfs_module_context *ntvfs,
155 struct ntvfs_request *req);
158 struct ntvfs_module_context {
159 struct ntvfs_module_context *prev, *next;
160 struct ntvfs_context *ctx;
162 const struct ntvfs_ops *ops;
166 struct ntvfs_context {
167 enum ntvfs_type type;
169 /* the reported filesystem type */
172 /* the reported device type */
175 enum protocol_types protocol;
178 * linked list of module contexts
180 struct ntvfs_module_context *modules;
187 struct event_context *event_ctx;
188 struct messaging_context *msg_ctx;
192 NTSTATUS (*handler)(void *private_data, uint16_t fnum, uint8_t level);
197 struct socket_address *(*get_my_addr)(void *private_data, TALLOC_CTX *mem_ctx);
198 struct socket_address *(*get_peer_addr)(void *private_data, TALLOC_CTX *mem_ctx);
203 /* a set of flags to control handling of request structures */
204 #define NTVFS_ASYNC_STATE_ASYNC (1<<1) /* the backend will answer this one later */
205 #define NTVFS_ASYNC_STATE_MAY_ASYNC (1<<2) /* the backend is allowed to answer async */
207 /* the ntvfs_async_state structure allows backend functions to
208 delay replying to requests. To use this, the front end must
209 set send_fn to a function to be called by the backend
210 when the reply is finally ready to be sent. The backend
211 must set status to the status it wants in the
212 reply. The backend must set the NTVFS_ASYNC_STATE_ASYNC
213 control_flag on the request to indicate that it wishes to
216 If NTVFS_ASYNC_STATE_MAY_ASYNC is not set then the backend cannot
217 ask for a delayed reply for this request
219 note that the private_data pointer is private to the layer which alloced this struct
221 struct ntvfs_async_state {
222 struct ntvfs_async_state *prev, *next;
223 /* the async handling infos */
226 void (*send_fn)(struct ntvfs_request *);
229 /* the passthru module's per session private data */
230 struct ntvfs_module_context *ntvfs;
233 struct ntvfs_request {
234 /* the ntvfs_context this requests belongs to */
235 struct ntvfs_context *ctx;
237 /* ntvfs per request async states */
238 struct ntvfs_async_state *async_states;
240 /* the session_info, with security_token and maybe delegated credentials */
241 struct auth_session_info *session_info;
243 /* the smb pid is needed for locking contexts */
246 /* the smb mid is needed for matching requests */
249 /* some statictics for the management tools */
251 /* the system time when the request arrived */
252 struct timeval request_time;
256 /* this structure is used by backends to determine the size of some critical types */
257 struct ntvfs_critical_sizes {
258 int interface_version;
259 int sizeof_ntvfs_critical_sizes;
260 int sizeof_ntvfs_context;
261 int sizeof_ntvfs_module_context;
262 int sizeof_ntvfs_ops;
263 int sizeof_ntvfs_async_state;
264 int sizeof_ntvfs_request;
267 struct messaging_context;
269 #include "ntvfs/ntvfs_proto.h"