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;
28 #define ntvfs_request smbsrv_request
30 /* each backend has to be one one of the following 3 basic types. In
31 * earlier versions of Samba backends needed to handle all types, now
32 * we implement them separately. */
33 enum ntvfs_type {NTVFS_DISK, NTVFS_PRINT, NTVFS_IPC};
35 /* the ntvfs operations structure - contains function pointers to
36 the backend implementations of each operation */
42 NTSTATUS (*connect)(struct ntvfs_module_context *ntvfs,
43 struct ntvfs_request *req,
44 const char *sharename);
45 NTSTATUS (*disconnect)(struct ntvfs_module_context *ntvfs);
47 /* async_setup - called when a backend is processing a async request */
48 NTSTATUS (*async_setup)(struct ntvfs_module_context *ntvfs,
49 struct ntvfs_request *req,
52 /* filesystem operations */
53 NTSTATUS (*fsinfo)(struct ntvfs_module_context *ntvfs,
54 struct ntvfs_request *req,
55 union smb_fsinfo *fs);
58 NTSTATUS (*unlink)(struct ntvfs_module_context *ntvfs,
59 struct ntvfs_request *req,
60 struct smb_unlink *unl);
61 NTSTATUS (*chkpath)(struct ntvfs_module_context *ntvfs,
62 struct ntvfs_request *req,
63 struct smb_chkpath *cp);
64 NTSTATUS (*qpathinfo)(struct ntvfs_module_context *ntvfs,
65 struct ntvfs_request *req,
66 union smb_fileinfo *st);
67 NTSTATUS (*setpathinfo)(struct ntvfs_module_context *ntvfs,
68 struct ntvfs_request *req,
69 union smb_setfileinfo *st);
70 NTSTATUS (*mkdir)(struct ntvfs_module_context *ntvfs,
71 struct ntvfs_request *req,
73 NTSTATUS (*rmdir)(struct ntvfs_module_context *ntvfs,
74 struct ntvfs_request *req,
75 struct smb_rmdir *rd);
76 NTSTATUS (*rename)(struct ntvfs_module_context *ntvfs,
77 struct ntvfs_request *req,
78 union smb_rename *ren);
79 NTSTATUS (*copy)(struct ntvfs_module_context *ntvfs,
80 struct ntvfs_request *req,
82 NTSTATUS (*open)(struct ntvfs_module_context *ntvfs,
83 struct ntvfs_request *req,
86 /* directory search */
87 NTSTATUS (*search_first)(struct ntvfs_module_context *ntvfs,
88 struct ntvfs_request *req,
89 union smb_search_first *io, void *private,
90 BOOL (*callback)(void *private, union smb_search_data *file));
91 NTSTATUS (*search_next)(struct ntvfs_module_context *ntvfs,
92 struct ntvfs_request *req,
93 union smb_search_next *io, void *private,
94 BOOL (*callback)(void *private, union smb_search_data *file));
95 NTSTATUS (*search_close)(struct ntvfs_module_context *ntvfs,
96 struct ntvfs_request *req,
97 union smb_search_close *io);
99 /* operations on open files */
100 NTSTATUS (*ioctl)(struct ntvfs_module_context *ntvfs,
101 struct ntvfs_request *req,
102 union smb_ioctl *io);
103 NTSTATUS (*read)(struct ntvfs_module_context *ntvfs,
104 struct ntvfs_request *req,
106 NTSTATUS (*write)(struct ntvfs_module_context *ntvfs,
107 struct ntvfs_request *req,
108 union smb_write *io);
109 NTSTATUS (*seek)(struct ntvfs_module_context *ntvfs,
110 struct ntvfs_request *req,
111 struct smb_seek *io);
112 NTSTATUS (*flush)(struct ntvfs_module_context *ntvfs,
113 struct ntvfs_request *req,
114 struct smb_flush *flush);
115 NTSTATUS (*lock)(struct ntvfs_module_context *ntvfs,
116 struct ntvfs_request *req,
117 union smb_lock *lck);
118 NTSTATUS (*qfileinfo)(struct ntvfs_module_context *ntvfs,
119 struct ntvfs_request *req,
120 union smb_fileinfo *info);
121 NTSTATUS (*setfileinfo)(struct ntvfs_module_context *ntvfs,
122 struct ntvfs_request *req,
123 union smb_setfileinfo *info);
124 NTSTATUS (*close)(struct ntvfs_module_context *ntvfs,
125 struct ntvfs_request *req,
126 union smb_close *io);
128 /* trans interface - used by IPC backend for pipes and RAP calls */
129 NTSTATUS (*trans)(struct ntvfs_module_context *ntvfs,
130 struct ntvfs_request *req,
131 struct smb_trans2 *trans);
133 /* trans2 interface - only used by CIFS backend to prover complete passthru for testing */
134 NTSTATUS (*trans2)(struct ntvfs_module_context *ntvfs,
135 struct ntvfs_request *req,
136 struct smb_trans2 *trans2);
138 /* change notify request */
139 NTSTATUS (*notify)(struct ntvfs_module_context *ntvfs,
140 struct ntvfs_request *req,
141 struct smb_notify *info);
143 /* cancel - cancels any pending async request */
144 NTSTATUS (*cancel)(struct ntvfs_module_context *ntvfs,
145 struct ntvfs_request *req);
147 /* printing specific operations */
148 NTSTATUS (*lpq)(struct ntvfs_module_context *ntvfs,
149 struct ntvfs_request *req,
152 /* logoff - called when a vuid is closed */
153 NTSTATUS (*logoff)(struct ntvfs_module_context *ntvfs,
154 struct ntvfs_request *req);
155 NTSTATUS (*exit)(struct ntvfs_module_context *ntvfs,
156 struct ntvfs_request *req);
159 struct ntvfs_module_context {
160 struct ntvfs_module_context *prev, *next;
162 const struct ntvfs_ops *ops;
166 struct ntvfs_context {
167 enum ntvfs_type type;
169 * linked list of module contexts
171 struct ntvfs_module_context *modules;
175 /* a set of flags to control handling of request structures */
176 #define NTVFS_ASYNC_STATE_ASYNC (1<<1) /* the backend will answer this one later */
177 #define NTVFS_ASYNC_STATE_MAY_ASYNC (1<<2) /* the backend is allowed to answer async */
179 /* the ntvfs_async_state structure allows backend functions to
180 delay replying to requests. To use this, the front end must
181 set send_fn to a function to be called by the backend
182 when the reply is finally ready to be sent. The backend
183 must set status to the status it wants in the
184 reply. The backend must set the NTVFS_ASYNC_STATE_ASYNC
185 control_flag on the request to indicate that it wishes to
188 If NTVFS_ASYNC_STATE_MAY_ASYNC is not set then the backend cannot
189 ask for a delayed reply for this request
191 note that the private_data pointer is private to the layer which alloced this struct
193 struct ntvfs_async_state {
194 struct ntvfs_async_state *prev, *next;
195 /* the async handling infos */
198 void (*send_fn)(struct ntvfs_request *);
201 /* the passthru module's per session private data */
202 struct ntvfs_module_context *ntvfs;
205 /* this structure is used by backends to determine the size of some critical types */
206 struct ntvfs_critical_sizes {
207 int interface_version;
208 int sizeof_ntvfs_critical_sizes;
209 int sizeof_ntvfs_context;
210 int sizeof_ntvfs_module_context;
211 int sizeof_ntvfs_ops;
212 int sizeof_ntvfs_async_state;
213 int sizeof_ntvfs_request;
216 #include "ntvfs/ntvfs_proto.h"