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 /* each backend has to be one one of the following 3 basic types. In
29 * earlier versions of Samba backends needed to handle all types, now
30 * we implement them separately. */
31 enum ntvfs_type {NTVFS_DISK, NTVFS_PRINT, NTVFS_IPC};
33 /* the ntvfs operations structure - contains function pointers to
34 the backend implementations of each operation */
40 NTSTATUS (*connect)(struct ntvfs_module_context *ntvfs,
41 struct smbsrv_request *req, const char *sharename);
42 NTSTATUS (*disconnect)(struct ntvfs_module_context *ntvfs,
43 struct smbsrv_tcon *tcon);
46 NTSTATUS (*unlink)(struct ntvfs_module_context *ntvfs,
47 struct smbsrv_request *req, struct smb_unlink *unl);
48 NTSTATUS (*chkpath)(struct ntvfs_module_context *ntvfs,
49 struct smbsrv_request *req, struct smb_chkpath *cp);
50 NTSTATUS (*qpathinfo)(struct ntvfs_module_context *ntvfs,
51 struct smbsrv_request *req, union smb_fileinfo *st);
52 NTSTATUS (*setpathinfo)(struct ntvfs_module_context *ntvfs,
53 struct smbsrv_request *req, union smb_setfileinfo *st);
54 NTSTATUS (*openfile)(struct ntvfs_module_context *ntvfs,
55 struct smbsrv_request *req, union smb_open *oi);
56 NTSTATUS (*mkdir)(struct ntvfs_module_context *ntvfs,
57 struct smbsrv_request *req, union smb_mkdir *md);
58 NTSTATUS (*rmdir)(struct ntvfs_module_context *ntvfs,
59 struct smbsrv_request *req, struct smb_rmdir *rd);
60 NTSTATUS (*rename)(struct ntvfs_module_context *ntvfs,
61 struct smbsrv_request *req, union smb_rename *ren);
62 NTSTATUS (*copy)(struct ntvfs_module_context *ntvfs,
63 struct smbsrv_request *req, struct smb_copy *cp);
65 /* directory search */
66 NTSTATUS (*search_first)(struct ntvfs_module_context *ntvfs,
67 struct smbsrv_request *req, union smb_search_first *io, void *private,
68 BOOL (*callback)(void *private, union smb_search_data *file));
69 NTSTATUS (*search_next)(struct ntvfs_module_context *ntvfs,
70 struct smbsrv_request *req, union smb_search_next *io, void *private,
71 BOOL (*callback)(void *private, union smb_search_data *file));
72 NTSTATUS (*search_close)(struct ntvfs_module_context *ntvfs,
73 struct smbsrv_request *req, union smb_search_close *io);
75 /* operations on open files */
76 NTSTATUS (*ioctl)(struct ntvfs_module_context *ntvfs,
77 struct smbsrv_request *req, union smb_ioctl *io);
78 NTSTATUS (*read)(struct ntvfs_module_context *ntvfs,
79 struct smbsrv_request *req, union smb_read *io);
80 NTSTATUS (*write)(struct ntvfs_module_context *ntvfs,
81 struct smbsrv_request *req, union smb_write *io);
82 NTSTATUS (*seek)(struct ntvfs_module_context *ntvfs,
83 struct smbsrv_request *req, struct smb_seek *io);
84 NTSTATUS (*flush)(struct ntvfs_module_context *ntvfs,
85 struct smbsrv_request *req, struct smb_flush *flush);
86 NTSTATUS (*close)(struct ntvfs_module_context *ntvfs,
87 struct smbsrv_request *req, union smb_close *io);
88 NTSTATUS (*exit)(struct ntvfs_module_context *ntvfs,
89 struct smbsrv_request *req);
90 NTSTATUS (*lock)(struct ntvfs_module_context *ntvfs,
91 struct smbsrv_request *req, union smb_lock *lck);
92 NTSTATUS (*setfileinfo)(struct ntvfs_module_context *ntvfs,
93 struct smbsrv_request *req, union smb_setfileinfo *info);
94 NTSTATUS (*qfileinfo)(struct ntvfs_module_context *ntvfs,
95 struct smbsrv_request *req, union smb_fileinfo *info);
97 /* filesystem operations */
98 NTSTATUS (*fsinfo)(struct ntvfs_module_context *ntvfs,
99 struct smbsrv_request *req, union smb_fsinfo *fs);
101 /* printing specific operations */
102 NTSTATUS (*lpq)(struct ntvfs_module_context *ntvfs,
103 struct smbsrv_request *req, union smb_lpq *lpq);
105 /* trans2 interface - only used by CIFS backend to prover complete passthru for testing */
106 NTSTATUS (*trans2)(struct ntvfs_module_context *ntvfs,
107 struct smbsrv_request *req, struct smb_trans2 *trans2);
109 /* trans interface - used by IPC backend for pipes and RAP calls */
110 NTSTATUS (*trans)(struct ntvfs_module_context *ntvfs,
111 struct smbsrv_request *req, struct smb_trans2 *trans);
113 /* logoff - called when a vuid is closed */
114 NTSTATUS (*logoff)(struct ntvfs_module_context *ntvfs,
115 struct smbsrv_request *req);
117 /* async_setup - called when a backend is processing a async request */
118 NTSTATUS (*async_setup)(struct ntvfs_module_context *ntvfs,
119 struct smbsrv_request *req, void *private);
121 /* cancel - cancels any pending async request */
122 NTSTATUS (*cancel)(struct ntvfs_module_context *ntvfs,
123 struct smbsrv_request *req);
126 struct ntvfs_module_context {
127 struct ntvfs_module_context *prev, *next;
129 const struct ntvfs_ops *ops;
133 struct ntvfs_context {
134 enum ntvfs_type type;
136 * linked list of module contexts
138 struct ntvfs_module_context *modules;
142 /* a set of flags to control handling of request structures */
143 #define NTVFS_ASYNC_STATE_ASYNC (1<<1) /* the backend will answer this one later */
144 #define NTVFS_ASYNC_STATE_MAY_ASYNC (1<<2) /* the backend is allowed to answer async */
146 /* the ntvfs_async_state structure allows backend functions to
147 delay replying to requests. To use this, the front end must
148 set send_fn to a function to be called by the backend
149 when the reply is finally ready to be sent. The backend
150 must set status to the status it wants in the
151 reply. The backend must set the NTVFS_ASYNC_STATE_ASYNC
152 control_flag on the request to indicate that it wishes to
155 If NTVFS_ASYNC_STATE_MAY_ASYNC is not set then the backend cannot
156 ask for a delayed reply for this request
158 note that the private_data pointer is private to the layer which alloced this struct
160 struct ntvfs_async_state {
161 struct ntvfs_async_state *prev, *next;
162 /* the async handling infos */
165 void (*send_fn)(struct smbsrv_request *);
168 /* the passthru module's per session private data */
169 struct ntvfs_module_context *ntvfs;
172 /* this structure is used by backends to determine the size of some critical types */
173 struct ntvfs_critical_sizes {
174 int interface_version;
175 int sizeof_ntvfs_critical_sizes;
176 int sizeof_ntvfs_context;
177 int sizeof_ntvfs_module_context;
178 int sizeof_ntvfs_ops;
179 int sizeof_ntvfs_async_state;
180 int sizeof_smbsrv_tcon;
181 int sizeof_smbsrv_request;