vfs: Add dirfsp to connectpath_fn()
[samba.git] / source3 / include / vfs.h
1 /* 
2    Unix SMB/CIFS implementation.
3    VFS structures and parameters
4    Copyright (C) Jeremy Allison                         1999-2005
5    Copyright (C) Tim Potter                             1999
6    Copyright (C) Alexander Bokovoy                      2002-2005
7    Copyright (C) Stefan (metze) Metzmacher              2003
8    Copyright (C) Volker Lendecke                        2009
9
10    This program is free software; you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 3 of the License, or
13    (at your option) any later version.
14
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23    This work was sponsored by Optifacio Software Services, Inc.
24 */
25
26 #ifndef _VFS_H
27 #define _VFS_H
28
29 /* Avoid conflict with an AIX include file */
30
31 #ifdef vfs_ops
32 #undef vfs_ops
33 #endif
34
35 /*
36  * As we're now (thanks Andrew ! :-) using file_structs and connection
37  * structs in the vfs - then anyone writing a vfs must include includes.h...
38  */
39
40 /*
41  * This next constant specifies the version number of the VFS interface
42  * this smbd will load. Increment this if *ANY* changes are made to the
43  * vfs_ops below. JRA.
44  *
45  * If you change anything here, please also update modules/vfs_full_audit.c.
46  * VL.
47  */
48
49 /*
50  * Changed to version 2 for CIFS UNIX extensions (mknod and link added). JRA.
51  * Changed to version 3 for POSIX acl extensions. JRA.
52  * Changed to version 4 for cascaded VFS interface. Alexander Bokovoy.
53  * Changed to version 5 for sendfile addition. JRA.
54  * Changed to version 6 for the new module system, fixed cascading and quota functions. --metze
55  * Changed to version 7 to include the get_nt_acl info parameter. JRA.
56  * Changed to version 8 includes EA calls. JRA.
57  * Changed to version 9 to include the get_shadow_data call. --metze
58  * Changed to version 10 to include pread pwrite calls.
59  * Changed to version 11 to include seekdir telldir rewinddir calls. JRA
60  * Changed to version 12 to add mask and attributes to opendir(). JRA
61  * Also include aio calls. JRA.
62  * Changed to version 13 as the internal structure of files_struct has changed. JRA
63  * Changed to version 14 as we had to change DIR to SMB_STRUCT_DIR. JRA
64  * Changed to version 15 as we added the statvfs call. JRA
65  * Changed to version 16 as we added the getlock call. JRA
66  * Changed to version 17 as we removed redundant connection_struct parameters. --jpeach
67  * Changed to version 18 to add fsp parameter to the open call -- jpeach
68  * Also include kernel_flock call - jmcd
69  * Changed to version 19, kernel change notify has been merged
70  * Also included linux setlease call - jmcd
71  * Changed to version 20, use ntimes call instead of utime (greater
72  * timestamp resolition. JRA.
73  * Changed to version21 to add chflags operation -- jpeach
74  * Changed to version22 to add lchown operation -- jra
75  * Leave at 22 - not yet released. But change set_nt_acl to return an NTSTATUS. jra.
76  * Leave at 22 - not yet released. Add file_id_create operation. --metze
77  * Leave at 22 - not yet released. Change all BOOL parameters (int) to bool. jra.
78  * Leave at 22 - not yet released. Added recvfile.
79  * Leave at 22 - not yet released. Change get_nt_acl to return NTSTATUS - vl
80  * Leave at 22 - not yet released. Change get_nt_acl to *not* take a
81  * files_struct. - obnox.
82  * Leave at 22 - not yet released. Remove parameter fd from fget_nt_acl. - obnox
83  * Leave at 22 - not yet released. Remove parameter fd from gset_nt_acl. - obnox
84  * Leave at 22 - not yet released. Remove parameter fd from pread. - obnox
85  * Leave at 22 - not yet released. Remove parameter fd from pwrite. - obnox
86  * Leave at 22 - not yet released. Remove parameter fd from lseek. - obnox
87  * Leave at 22 - not yet released. Remove parameter fd from fsync. - obnox
88  * Leave at 22 - not yet released. Remove parameter fd from fstat. - obnox
89  * Leave at 22 - not yet released. Remove parameter fd from fchmod. - obnox
90  * Leave at 22 - not yet released. Remove parameter fd from fchown. - obnox
91  * Leave at 22 - not yet released. Remove parameter fd from ftruncate. - obnox
92  * Leave at 22 - not yet released. Remove parameter fd from lock. - obnox
93  * Leave at 22 - not yet released. Remove parameter fd from kernel_flock. - obnox
94  * Leave at 22 - not yet released. Remove parameter fd from linux_setlease. - obnox
95  * Leave at 22 - not yet released. Remove parameter fd from getlock. - obnox
96  * Leave at 22 - not yet released. Remove parameter fd from sys_acl_get_fd. - obnox
97  * Leave at 22 - not yet released. Remove parameter fd from fchmod_acl. - obnox
98  * Leave at 22 - not yet released. Remove parameter fd from sys_acl_set_fd. - obnox
99  * Leave at 22 - not yet released. Remove parameter fd from fgetxattr. - obnox
100  * Leave at 22 - not yet released. Remove parameter fd from flistxattr. - obnox
101  * Leave at 22 - not yet released. Remove parameter fd from fremovexattr. - obnox
102  * Leave at 22 - not yet released. Remove parameter fd from fsetxattr. - obnox
103  * Leave at 22 - not yet released. Remove parameter fd from aio_cancel. - obnox
104  * Leave at 22 - not yet released. Remove parameter fd from read. - obnox
105  * Leave at 22 - not yet released. Remove parameter fd from write. - obnox
106  * Leave at 22 - not yet released. Remove parameter fromfd from sendfile. - obnox
107  * Leave at 22 - not yet released. Remove parameter fromfd from recvfile. - obnox
108  * Leave at 22 - not yet released. Additional change: add operations for offline files -- ab
109  * Leave at 22 - not yet released. Add the streaminfo call. -- jpeach, vl
110  * Leave at 22 - not yet released. Remove parameter fd from close_fn. - obnox
111  * Changed to version 23 - remove set_nt_acl call. This can only be done via an
112  *                         open handle. JRA.
113  * Changed to version 24 - make security descriptor const in fset_nt_acl. JRA.
114  * Changed to version 25 - Jelmer's change from SMB_BIG_UINT to uint64_t.
115  * Leave at 25 - not yet released. Add create_file call. -- tprouty.
116  * Leave at 25 - not yet released. Add create time to ntimes. -- tstecher.
117  * Leave at 25 - not yet released. Add get_alloc_size call. -- tprouty.
118  * Leave at 25 - not yet released. Add SMB_STRUCT_STAT to readdir. - sdann
119  * Leave at 25 - not yet released. Add init_search_op call. - sdann
120  * Leave at 25 - not yet released. Add locking calls. -- zkirsch.
121  * Leave at 25 - not yet released. Add strict locking calls. -- drichards.
122  * Changed to version 26 - Plumb struct smb_filename to SMB_VFS_CREATE_FILE,
123  *                         SMB_VFS_OPEN, SMB_VFS_STAT, SMB_VFS_LSTAT,
124  *                         SMB_VFS_RENAME, SMB_VFS_UNLINK, SMB_VFS_NTIMES.
125  * Changed to version 27 - not yet released. Added enum timestamp_set_resolution
126  *                         return to fs_capabilities call. JRA.
127  * Leave at 27 - not yet released. Add translate_name VFS call to convert
128  *               UNIX names to Windows supported names -- asrinivasan.
129  * Changed to version 28 - Add private_flags uint32_t to CREATE call.
130  * Leave at 28 - not yet released. Change realpath to assume NULL and return a
131  *               malloc'ed path. JRA.
132  * Leave at 28 - not yet released. Move posix_fallocate into the VFS
133  *              where it belongs. JRA.
134  * Leave at 28 - not yet released. Rename posix_fallocate to fallocate
135  *              to split out the two possible uses. JRA.
136  * Leave at 28 - not yet released. Add fdopendir. JRA.
137  * Leave at 28 - not yet released. Rename open function to open_fn. - gd
138  * Leave at 28 - not yet released. Make getwd function always return malloced memory. JRA.
139  * Bump to version 29 - Samba 3.6.0 will ship with interface version 28.
140  * Leave at 29 - not yet releases. Add fsctl. Richard Sharpe
141  * Leave at 29 - not yet released. add SMB_VFS_GET_DFS_REFERRAL() - metze
142  * Leave at 29 - not yet released. Remove l{list,get,set,remove}xattr - abartlet
143  * Leave at 29 - not yet released. move to plain off_t - abartlet
144  * Leave at 29 - not yet released. Remove sys_acl functions other than set and get - abartlet
145  * Leave at 29 - not yet released. Added backup_intent bool to files_struct - JRA
146  * Leave at 29 - not yet released. Add durable handle functions - metze obnox
147  * Leave at 29 - not yet released. Added sys_acl_blob_get_file and sys_acl_blob_get_fd
148  * Bump to version 30 - Samba 4.0.0 will ship with interface version 30
149  * Leave at 30 - not yet released. Added conn->cwd to save vfs_GetWd() calls.
150  * Leave at 30 - not yet released. Changed sys_acl_blob_get_file interface to remove type
151  * Bump to version 31 - Samba 4.1.0 will ship with interface version 31
152  * Leave at 31 - not yet released. Make struct vuid_cache_entry in
153  *               connection_struct a pointer.
154  * Leave at 31 - not yet released. Add share_access to vuid_cache_entry.
155  * Leave at 31 - not yet released. add SMB_VFS_COPY_CHUNK()
156  * Leave at 31 - not yet released. Remove the unused
157  *               fsp->pending_break_messages array
158  * Leave at 31 - not yet released. add SMB_VFS_[GET SET]_COMPRESSION()
159  *
160  * Bump to version 32 - Samba 4.2 will ship with that.
161  * Version 32 - Add "lease" to CREATE_FILE operation
162  * Version 32 - Add "lease" to struct files_struct
163  * Version 32 - Add SMB_VFS_READDIR_ATTR()
164  * Version 32 - Add in and out create context blobs to create_file
165  * Version 32 - Remove unnecessary SMB_VFS_DISK_FREE() small_query parameter
166  * Bump to version 33 - Samba 4.3 will ship with that.
167  * Version 33 - change fallocate mode flags param from enum->uint32_t
168  * Version 33 - Add snapshot create delete calls
169  * Version 33 - Add OS X SMB2 AAPL copyfile extension flag to fsp
170  * Version 33 - Remove notify_watch_fn
171  * Bump to version 34 - Samba 4.4 will ship with that
172  * Version 34 - Remove bool posix_open, add uint64_t posix_flags
173  * Version 34 - Added bool posix_pathnames to struct smb_request
174  * Bump to version 35 - Samba 4.5 will ship with that
175  * Version 35 - Change get_nt_acl_fn from const char *, to
176  *              const struct smb_filename *
177  * Version 35 - Change mkdir from const char *, to
178  *              const struct smb_filename *
179  * Version 35 - Change rmdir from const char *, to
180  *              const struct smb_filename *
181  * Version 35 - Change opendir from const char *, to
182  *              const struct smb_filename *
183  * Version 35 - Wrap aio async funtions args in a struct vfs_aio_state
184  * Version 35 - Change chmod from const char *, to
185  *              const struct smb_filename *
186  * Version 35 - Change chmod_acl from const char *, to
187  *              const struct smb_filename *
188  * Version 35 - Change chown from const char *, to
189  *              const struct smb_filename *
190  * Version 35 - Change lchown from const char *, to
191  *              const struct smb_filename *
192  * Version 35 - Change streaminfo from const char *, to
193  *              const struct smb_filename *
194  * Version 35 - Add uint32_t flags to struct smb_filename
195  * Version 35 - Add get set fget fset dos attribute functions.
196  * Version 35 - Add bool use_ofd_locks to struct files_struct
197  * Bump to version 36 - Samba 4.6 will ship with that
198  * Version 36 - Remove is_offline and set_offline
199  * Version 37 - Module init functions now take a TALLOC_CTX * parameter.
200  * Version 37 - Add vfs_copy_chunk_flags for DUP_EXTENTS_TO_FILE
201  * Version 37 - Change sys_acl_delete_def_file from const char *
202  *              to const struct smb_filename *
203  * Version 37 - Change sys_acl_get_file from const char *
204  *              to const struct smb_filename *
205  * Version 37 - Change sys_acl_blob_get_file from const char *
206  *              to const struct smb_filename *
207  * Version 37 - Change sys_acl_set_file from const char *
208  *              to const struct smb_filename *
209  * Version 37 - Change listxattr from const char *
210  *              to const struct smb_filename *
211  * Version 37 - Change removexattr from const char *
212  *              to const struct smb_filename *
213  * Version 37 - Change setxattr from const char *
214  *              to const struct smb_filename *
215  * Version 37 - Change getxattr from const char *
216  *              to const struct smb_filename *
217  * Version 37 - Change mknod from const char * to const struct smb_filename *
218  * Version 37 - Change chflags from const char *
219  *              to const struct smb_filename *
220  * Version 37 - Change disk_free from const char *
221  *              to const struct smb_filename *
222  * Version 37 - Change get_quota from const char *
223  *              to const struct smb_filename *
224  * Version 37 - Change link from const char *
225  *              to const struct smb_filename *
226  * Version 37 - Change statvfs from const char *
227  *              to const struct smb_filename *
228  * Version 37 - Change readlink from const char *
229  *              to const struct smb_filename *
230  * Version 37 - Change symlink from const char *
231  *              to const struct smb_filename *
232  * Version 37 - Change chdir from const char *
233  *              to const struct smb_filename *
234  * Version 37 - Change getwd from char *
235  *              to const struct smb_filename *
236  * Version 37 - Change conn->cwd from char *
237  *              to struct smb_filename *
238  * Version 37 - Change realpath from char *
239  *              to struct smb_filename *
240  * Version 37 - Change connectpath from char *
241  *              to struct smb_filename *
242  * Version 37 - Add SMB_VFS_OFFLOAD_READ_SEND RECV
243  * Version 37 - Rename SMB_VFS_COPY_CHUNK_SEND RECV to
244  *              SMB_VFS_OFFLOAD_READ_SEND RECV
245  * Version 37 - Remove SMB_VFS_STRICT_UNLOCK
246  * Version 37 - Rename SMB_VFS_STRICT_LOCK to
247  *              SMB_VFS_STRICT_LOCK_CHECK
248  * Version 38 - Remove SMB_VFS_INIT_SEARCH_OP
249  * Bump to version 39, Samba 4.9 will ship with that
250  * Version 39 - Remove SMB_VFS_FSYNC
251  *              Only implement async versions.
252  * Version 39 - Remove SMB_VFS_READ
253  *              All users are now pread or async versions.
254  * Version 39 - Remove SMB_VFS_WRITE
255  *              All users are now pwrite or async versions.
256  * Version 39 - Remove SMB_VFS_CHMOD_ACL - no longer used.
257  * Version 39 - Remove SMB_VFS_FCHMOD_ACL - no longer used.
258  * Version 39 - Remove struct dfree_cached_info pointer from
259  *              connection struct
260  * Bump to version 40, Samba 4.10 will ship with that
261  * Version 40 - Add SMB_VFS_GETXATTRAT_SEND RECV
262  * Version 40 - Add SMB_VFS_GET_DOS_ATTRIBUTES_SEND RECV
263  * Bump to version 41, Samba 4.11 will ship with that
264  * Version 41 - Remove SMB_VFS_BRL_CANCEL_WINDOWS
265  * Version 41 - Remove unused st_ex_mask from struct stat_ex
266  * Version 41 - convert struct stat_ex.st_ex_calculated_birthtime to flags
267  * Version 41 - add st_ex_itime to struct stat_ex
268  * Version 41 - add st_ex_file_id to struct stat_ex
269  * Version 41 - add SMB_VFS_FS_FILE_ID
270  * Version 41 - Remove "blocking_lock" parameter from
271  *              SMB_VFS_BRL_LOCK_WINDOWS
272  * Version 41 - Remove "msg_ctx" parameter from SMB_VFS_BRL_UNLOCK_WINDOWS
273  * Bump to version 42, Samba 4.12 will ship with that
274  * Version 42 - Remove share_access member from struct files_struct
275  * Version 42 - Make "lease" a const* in create_file_fn
276  * Version 42 - Move SMB_VFS_RENAME -> SMB_VFS_RENAMEAT
277  * Version 42 - Move SMB_VFS_LINK -> SMB_VFS_LINKAT.
278  * Version 42 - Move SMB_VFS_MKNOD -> SMB_VFS_MKDNODAT.
279  * Version 42 - Move SMB_VFS_READLINK -> SMB_VFS_READLINKAT.
280  * Version 42 - Move SMB_VFS_SYMLINK -> SMB_VFS_SYMLINKAT.
281  * Version 42 - Move SMB_VFS_MKDIR -> SMB_VFS_MKDIRAT.
282  * Version 42 - Move change_to_user() -> change_to_user_and_service()
283  * Version 42 - Move change_to_user_by_fsp() -> change_to_user_and_service_by_fsp()
284  * Version 42 - Move [un]become_user*() -> [un]become_user_without_service*()
285  * Version 42 - Move SMB_VFS_UNLINK -> SMB_VFS_UNLINKAT.
286  * Version 42 - Add SMB_VFS_FCNTL
287  * Version 42 - Remove SMB_VFS_RMDIR.
288  *              Use SMB_VFS_UNLINKAT(.., AT_REMOVEDIR) instead.
289  * Version 42 - Remove SMB_VFS_CHOWN
290  * Version 42 - Remove struct write_cache *wcp from files_struct
291  * Version 42 - SMB_VFS_NTIMES() receives null times based on UTIMES_OMIT
292  * Version 42 - Add SMB_VFS_CREATE_DFS_PATHAT()
293  * Version 42 - Add SMB_VFS_READ_DFS_PATHAT()
294  * Change to Version 43 - will ship with 4.13.
295  * Version 43 - Remove deferred_close from struct files_struct
296  * Version 43 - Remove SMB_VFS_OPENDIR()
297  * Version 43 - Remove original_lcomp from struct smb_filename
298  * Version 43 - files_struct flags:
299  *              bool kernel_share_modes_taken
300  *              bool update_write_time_triggered
301  *              bool update_write_time_on_close
302  *              bool write_time_forced
303  *              bool can_lock
304  *              bool can_read
305  *              bool can_write
306  *              bool modified
307  *              bool is_directory
308  *              bool aio_write_behind
309  *              bool initial_delete_on_close
310  *              bool delete_on_close
311  *              bool is_sparse
312  *              bool backup_intent
313  *              bool use_ofd_locks
314  *              bool closing
315  *              bool lock_failure_seen
316  *              changed to bitfields.
317  * Version 43 - convert SMB_VFS_GET_REAL_FILENAME() arg path
318  *              to be a struct smb_filename
319  * Version 43 - convert link_contents arg of SMB_VFS_SYMLINKAT()
320  *              to struct smb_filename
321  * Version 43 - Move SMB_VFS_GET_NT_ACL() -> SMB_VFS_GET_NT_ACL_AT().
322  * Version 43 - Remove root_dir_fid from SMB_VFS_CREATE_FILE().
323  * Version 43 - Add dirfsp to struct files_struct
324  * Version 43 - Add dirfsp args to SMB_VFS_CREATE_FILE()
325  * Version 43 - Add SMB_VFS_OPENAT()
326  * Version 43 - Remove SMB_VFS_OPEN()
327  * Version 43 - SMB_VFS_READ_DFS_PATHAT() should take a non-const name.
328                 There's no easy way to return stat info for a DFS link
329                 otherwise.
330  * Change to Version 44 - will ship with 4.14.
331  * Version 44 - Remove dirfsp arg from struct files_struct
332  * Version 44 - Remove dirfsp arg to SMB_VFS_CREATE_FILE()
333  * Version 44 - Make dirfsp arg to SMB_VFS_READLINKAT() const
334  * Version 44 - Add a flag 'encryption_required' to files_struct that that
335  *              prevents that encrypted connections can be downgraded.
336  * Version 44 - Add a flag 'is_pathref' to struct files_struct.
337  * Version 44 - Add 'is_fsa' flag to struct files_struct.
338  * Version 44 - Add 'have_proc_fds' flag to struct connection_struct.
339  * Version 44 - Add 'have_proc_fds' flag to struct files_struct.
340  * Version 44 - Add dirfsp arg to SMB_VFS_READDIR()
341  * Version 44 - Replace SMB_VFS_GET_COMPRESSION() with SMB_VFS_FGET_COMPRESSION()
342  * Version 44 - Add type argument to SMB_VFS_SYS_ACL_SET_FD()
343  * Version 44 - Remove SMB_VFS_SYS_ACL_SET_FILE()
344  * Change to Version 45 - will ship with 4.15
345  * Version 45 - Remove SMB_VFS_LISTXATTR
346  * Version 45 - Remove SMB_VFS_SETXATTR
347  * Version 45 - Remove SMB_VFS_REMOVEXATTR
348  * Version 45 - Remove SMB_VFS_GET_DOS_ATTRIBUTES()
349  * Version 45 - Remove SMB_VFS_CHMOD
350  * Version 45 - Add SMB_VFS_FNTIMES
351  * Version 45 - Remove SMB_VFS_NTIMES
352  * Version 45 - ADD SMB_VFS_FSTREAMINFO
353  * Version 45 - Add SMB_VFS_FREADDIR_ATTR
354  * Version 45 - Remove SMB_VFS_READDIR_ATTR
355  * Version 45 - Add SMB_VFS_SYS_ACL_DELETE_DEF_FD
356  * Version 45 - Remove SMB_VFS_SYS_ACL_DELETE_DEF_FILE
357  * Version 45 - Add SMB_VFS_PARENT_PATHNAME
358  * Version 45 - Remove SMB_VFS_GET_NT_ACL_AT
359  * Version 45 - Remove SYS_ACL_GET_FILE
360  * Version 45 - Remove SYS_ACL_BLOB_GET_FILE
361  * Version 45 - Add SMB_VFS_FCHFLAGS
362  * Version 45 - Remove SMB_VFS_GETXATTR
363  * Change to Version 46 - will ship with 4.16
364  * Version 46 - Rename SMB_VFS_KERNEL_FLOCK to SMB_VFS_FILESYSTEM_SHAREMODE
365  * Version 46 - Add flags and xferlen args to SMB_VFS_OFFLOAD_READ_RECV
366  * Change to Version 47 - will ship with 4.17
367  * Version 47 - Add SMB_VFS_FSTATAT
368  * Version 47 - Change SMB_VFS_GET_REAL_FILENAME to return NTSTATUS
369  * Version 47 - remove st_ex_itime from struct stat_ex
370  * Version 47 - remove (unused) struct lock_struct last_lock_failure
371                 from files_struct.
372  * Version 47 - Add SMB_VFS_GET_REAL_FILENAME_AT
373  * Version 47 - Replace SMB_VFS_GET_REAL_FILENAME with SMB_VFS_GET_REAL_FILENAME_AT
374  * Version 47 - Re-add dirfsp to CREATE_FILE
375  * Version 47 - Add fsp flag fstat_before_close
376  * Version 47 - Change SMB_VFS_OPENAT() to match the Linux openat2 prototype, add vfs_open_how
377  * Version 47 - Add VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS for SMB_VFS_OPENAT()
378  * Change to Version 48 - will ship with 4.18
379  * Version 48 - Add cached_dos_attributes to struct stat_ex
380  * Version 48 - Add dirfsp to connectpath_fn()
381  */
382
383 #define SMB_VFS_INTERFACE_VERSION 48
384
385 /*
386     All intercepted VFS operations must be declared as static functions inside module source
387     in order to keep smbd namespace unpolluted. See source of audit, extd_audit, fake_perms and recycle
388     example VFS modules for more details.
389 */
390
391 /* VFS operations structure */
392
393 struct vfs_handle_struct;
394 struct connection_struct;
395 struct files_struct;
396 struct security_descriptor;
397 struct vfs_statvfs_struct;
398 struct smb_request;
399 struct ea_list;
400 struct smb_file_time;
401 struct smb_filename;
402 struct dfs_GetDFSReferral;
403
404 typedef union unid_t {
405         uid_t uid;
406         gid_t gid;
407 } unid_t;
408
409 struct fd_handle;
410
411 struct fsp_lease {
412         size_t ref_count;
413         struct smbd_server_connection *sconn;
414         struct tevent_timer *timeout;
415         struct smb2_lease lease;
416 };
417
418 typedef struct files_struct {
419         struct files_struct *next, *prev;
420         uint64_t fnum;
421         struct smbXsrv_open *op;
422         struct connection_struct *conn;
423         struct fd_handle *fh;
424         unsigned int num_smb_operations;
425         struct file_id file_id;
426         uint64_t initial_allocation_size; /* Faked up initial allocation on disk. */
427         uint16_t file_pid;
428         uint64_t vuid; /* SMB2 compat */
429         struct timeval open_time;
430         uint32_t access_mask;           /* NTCreateX access bits (FILE_READ_DATA etc.) */
431         struct {
432                 bool is_pathref : 1; /* See below */
433                 bool is_fsa : 1;     /* See below */
434                 bool have_proc_fds : 1;
435                 bool kernel_share_modes_taken : 1;
436                 bool update_write_time_triggered : 1;
437                 bool update_write_time_on_close : 1;
438                 bool write_time_forced : 1;
439                 bool can_lock : 1;
440                 bool can_read : 1;
441                 bool can_write : 1;
442                 bool modified : 1;
443                 bool is_directory : 1;
444                 bool is_dirfsp : 1;
445                 bool aio_write_behind : 1;
446                 bool initial_delete_on_close : 1;
447                 bool delete_on_close : 1;
448                 bool is_sparse : 1;
449                 bool backup_intent : 1;
450                 bool use_ofd_locks : 1;
451                 bool closing : 1;
452                 bool lock_failure_seen : 1;
453                 bool encryption_required : 1;
454                 bool fstat_before_close : 1;
455         } fsp_flags;
456
457         struct tevent_timer *update_write_time_event;
458         struct timespec close_write_time;
459
460         int oplock_type;
461
462         /*
463          * Cache of our lease_type, stored as "current_state" in
464          * leases.tdb
465          */
466         int leases_db_seqnum;
467         uint32_t lease_type;
468
469         struct fsp_lease *lease;
470         int sent_oplock_break;
471         struct tevent_timer *oplock_timeout;
472         int current_lock_count; /* Count the number of outstanding locks and pending locks. */
473
474         uint64_t posix_flags;
475         struct smb_filename *fsp_name;
476         uint32_t name_hash;             /* Jenkins hash of full pathname. */
477         uint64_t mid;                   /* Mid of the operation that created us. */
478
479         struct vfs_fsp_data *vfs_extension;
480         struct fake_file_handle *fake_file_handle;
481
482         struct notify_change_buf *notify;
483
484         struct files_struct *base_fsp; /* placeholder for delete on close */
485         struct files_struct *stream_fsp; /* backlink from base_fsp */
486
487         /*
488          * Cache of share_mode_data->flags
489          */
490         int share_mode_flags_seqnum;
491         uint16_t share_mode_flags;
492
493         /*
494          * Read-only cached brlock record, thrown away when the
495          * brlock.tdb seqnum changes. This avoids fetching data from
496          * the brlock.tdb on every read/write call.
497          */
498         int brlock_seqnum;
499         struct byte_range_lock *brlock_rec;
500
501         struct dptr_struct *dptr;
502
503         /* if not NULL, means this is a print file */
504         struct print_file_data *print_file;
505
506         /*
507          * Optimize the aio_requests array for high performance: Never
508          * shrink it, maintain num_aio_requests separately
509          */
510         unsigned num_aio_requests;
511         struct tevent_req **aio_requests;
512
513         /*
514          * Requests waiting for smb1 byte range locks. They are
515          * generated by smbd_smb1_do_locks_send and are required here,
516          * because lock cancel operations index through reply_lockingX
517          * not based on mid but on the lock type and range.
518          */
519         struct tevent_req **blocked_smb1_lock_reqs;
520
521         /*
522          * SMB1 remembers lock failures and delays repeated blocking
523          * lock attempts on the same offset.
524          */
525         uint64_t lock_failure_offset;
526 } files_struct;
527
528 /*
529  * The fsp flags "is_pathref" and "is_fsa"
530  * =======================================
531  *
532  * Summary
533  * -------
534  *
535  * The flag "is_pathref" is a property of the low-level VFS-layer file
536  * handle. If "is_pathref" is true, only a subset of VFS calls are allowed
537  * on the handle and on systems that support it, the low-level fd is open
538  * with O_PATH. If "is_pathref" is false, the low-level fd is a "normal"
539  * file descriptor that can be used with all VFS calls.
540  *
541  * The flag "is_fsa" is a property of the FSA layer in Samba. The term FSA
542  * layer refers to the parts of smbd that implement Windows NTFS semantics
543  * on-top of a POSIX filesystem. If "is_fsa" is true, the fsp was
544  * processed by the SMB_VFS_CREATE_FILE() VFS call, otherwise the fsp was
545  * created by openat_pathref_fsp() which only connected the low-level
546  * handle by calling into VFS SMB_VFS_OPENAT(), but the whole FSA layer
547  * logic is skipped.
548  *
549  * Note that only three possible combinations of "is_pathref" and "is_fsa"
550  * are possible:
551  *
552  * | is_fsa \ is_pathref | + | - |
553  * |---------------------+---+---|
554  * | +                   | + | + |
555  * | -                   | + | - |
556  *
557  * So a fsp can't be a full low-level fd (is_pathref=false) and not be
558  * processed by the FSA layer.
559  *
560  * Details
561  * -------
562  *
563  * On Linux the O_PATH flag to open() can be used to open a filehandle on
564  * a file or directory with interesting properties:
565  *
566  * - the file-handle indicates a location in the filesystem tree,
567  * - no permission checks are done by the kernel and
568  * - only operations that act purely at the file descriptor level are
569  *   allowed.
570  *
571  * The file itself is not opened, and other file operations (e.g.,
572  * read(2), write(2), fchmod(2), fchown(2), fgetxattr(2), ioctl(2),
573  * mmap(2)) fail with the error EBADF.
574  *
575  * The following subset of operations that is relevant to Samba is allowed:
576  *
577  * - close(2),
578  * - fchdir(2), if the file descriptor refers to a directory,
579  * - fstat(2),
580  * - fstatfs(2) and
581  * - passing the file descriptor as the dirfd argument of openat() and the
582  *   other "*at()" system calls. This includes linkat(2) with
583  *   AT_EMPTY_PATH (or via procfs using AT_SYMLINK_FOLLOW) even if the
584  *   file is not a directory.
585  *
586  * Opening a file or directory with the O_PATH flag requires no
587  * permissions on the object itself (but does require execute permission
588  * on the directories in the path prefix). By contrast, obtaining a
589  * reference to a filesystem object by opening it with the O_RDONLY flag
590  * requires that the caller have read permission on the object, even when
591  * the subsequent operation (e.g., fchdir(2), fstat(2)) does not require
592  * read permission on the object. [1]
593  *
594  * If for example Samba receives an SMB request to open a file requesting
595  * SEC_FILE_READ_ATTRIBUTE access rights because the client wants to read
596  * the file's metadata from the handle, Samba will have to call POSIX
597  * open() with at least O_RDONLY access rights.
598  *
599  * Usecase for O_PATH in Samba
600  * ---------------------------
601  *
602  * By leveraging this Linux specific flags we can avoid permission
603  * mismatches as described above. Additionally O_PATH allows basing all
604  * filesystem accesses done by the fileserver on handle based syscalls by
605  * opening all client pathnames with O_PATH and consistently using for
606  * example fstat() instead of stat() throughout the codebase.
607  *
608  * Subsequently we will refer to Samba file-handles (fsp's) opened with
609  * O_PATH "path referencing fsp's" or "pathref" fsp's for short.
610  *
611  * Currently Samba bases the decision whether to call POSIX open() on a
612  * client pathname or whether to leave the low-level handle at -1, what we
613  * call a stat-open, in the function open_file() and it is based on the
614  * client requested SMB acccess mask.
615  *
616  * The set of rights that trigger an open() include READ_CONTROL_ACCESS,
617  * resulting in a call to open() with at least O_RDONLY. If the filesystem
618  * supports NT style ACLs natively (like GPFS or ZFS), the filesystem may
619  * grant the user requested right READ_CONTROL_ACCESS, but it may not
620  * grant READ_DATA (O_RDONLY), resulting in a permission denied error.
621  *
622  * Historically the set of access rights that triggered opening a file was:
623  *
624  *   FILE_READ_DATA
625  *   FILE_WRITE_DATA
626  *   FILE_APPEND_DATA
627  *   FILE_EXECUTE
628  *   WRITE_DAC_ACCESS
629  *   WRITE_OWNER_ACCESS
630  *   SEC_FLAG_SYSTEM_SECURITY
631  *   READ_CONTROL_ACCESS
632  *
633  * By using O_PATH this can be trimmed down to
634  *
635  *   FILE_READ_DATA
636  *   FILE_WRITE_DATA
637  *   FILE_APPEND_DATA
638  *   FILE_EXECUTE
639  *
640  * Fallback on systems without O_PATH support
641  * ------------------------------------------
642  *
643  * A fallback is needed that allows opening a file-handle with the same
644  * higher level semantics even if the system doesn't support O_PATH. This
645  * is implemented by impersonating the root user for the open()
646  * syscall. To avoid bypassing restrictive permissions on intermediate
647  * directories components of a path, the root user is only impersonated
648  * after changing directory to the parent directory of the client
649  * requested pathname.
650  *
651  * In order to avoid privilege escalation security issues with these root
652  * opened file-handles we must carefully control their usage throughout
653  * the codebase. Therefore we
654  *
655  * - tag the pathref fsp's with the flag "is_pathref" and
656  *
657  * - control access to the file-handle by making the structure private and only
658  *   allowing access with accessor functions.
659  *
660  * Two functions are used to fetch the low-level system file-handle from an fsp
661  *
662  * - fsp_get_io_fd(fsp): enforces fsp is NOT a pathref file-handle and
663  *
664  * - fsp_get_pathref_fd(fsp): allows fsp to be either a pathref file-handle or a
665  *   traditional POSIX file-handle opened with O_RDONLY or any other POSIX open
666  *   flag.
667  *
668  * The general guideline when to use which function is:
669  *
670  * - if you do something like fstat(fd), use fsp_get_pathref_fd(fsp),
671  * - if you do something like *at(dirfd, ...), use fsp_get_pathref_fd(fsp),
672  * - if you want to print the fd for example in DEBUG messages, use
673  *   fsp_get_pathref_fd(fsp),
674  * - if you want to call close(fd), use fsp_get_pathref_fd(fsp),
675  * - if you're doing a logical comparison of fd values, use
676  *   fsp_get_pathref_fd().
677  *
678  * In any other case use fsp_get_io_fd().
679  */
680
681 #define FSP_POSIX_FLAGS_OPEN            0x01
682 #define FSP_POSIX_FLAGS_RENAME          0x02
683 #define FSP_POSIX_FLAGS_PATHNAMES       0x04
684
685 #define FSP_POSIX_FLAGS_ALL                     \
686         (FSP_POSIX_FLAGS_OPEN |                 \
687          FSP_POSIX_FLAGS_PATHNAMES |            \
688          FSP_POSIX_FLAGS_RENAME)
689
690 struct vuid_cache_entry {
691         struct auth_session_info *session_info;
692         uint64_t vuid; /* SMB2 compat */
693         bool read_only;
694         uint32_t share_access;
695 };
696
697 struct vuid_cache {
698         unsigned int next_entry;
699         struct vuid_cache_entry array[VUID_CACHE_SIZE];
700 };
701
702 typedef struct {
703         char *name;
704         bool is_wild;
705 } name_compare_entry;
706
707 struct share_params {
708         int service;
709 };
710
711 typedef struct connection_struct {
712         struct connection_struct *next, *prev;
713         struct smbd_server_connection *sconn; /* can be NULL */
714         struct smbXsrv_tcon *tcon; /* can be NULL */
715         uint32_t cnum; /* an index passed over the wire */
716         struct share_params *params;
717         bool force_user;
718         struct vuid_cache *vuid_cache;
719         bool printer;
720         bool ipc;
721         bool read_only; /* Attributes for the current user of the share. */
722         bool have_proc_fds;
723         uint64_t open_how_resolve; /* supported vfs_open_how.resolve features */
724         uint32_t share_access;
725         /* Does this filesystem honor
726            sub second timestamps on files
727            and directories when setting time ? */
728         enum timestamp_set_resolution ts_res;
729         char *connectpath;
730         struct files_struct *cwd_fsp; /* Working directory. */
731         bool tcon_done;
732
733         struct vfs_handle_struct *vfs_handles;          /* for the new plugins */
734
735         /*
736          * This represents the user information on this connection. Depending
737          * on the vuid using this tid, this might change per SMB request.
738          */
739         struct auth_session_info *session_info;
740
741         /*
742          * If the "force group" parameter is set, this is the primary gid that
743          * may be used in the users token, depending on the vuid using this tid.
744          */
745         gid_t force_group_gid;
746
747         uint64_t vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
748
749         time_t lastused;
750         time_t lastused_count;
751         int num_files_open;
752         unsigned int num_smb_operations; /* Count of smb operations on this tree. */
753         int encrypt_level;
754         bool encrypted_tid;
755
756         /* Semantics requested by the client or forced by the server config. */
757         bool case_sensitive;
758         bool case_preserve;
759         bool short_case_preserve;
760
761         /* Semantics provided by the underlying filesystem. */
762         int fs_capabilities;
763         /* Device number of the directory of the share mount.
764            Used to ensure unique FileIndex returns. */
765         SMB_DEV_T base_share_dev;
766
767         name_compare_entry *hide_list; /* Per-share list of files to return as hidden. */
768         name_compare_entry *veto_list; /* Per-share list of files to veto (never show). */
769         name_compare_entry *veto_oplock_list; /* Per-share list of files to refuse oplocks on. */       
770         name_compare_entry *aio_write_behind_list; /* Per-share list of files to use aio write behind on. */       
771         struct trans_state *pending_trans;
772
773         struct rpc_pipe_client *spoolss_pipe;
774
775 } connection_struct;
776
777 struct smbd_smb2_request;
778 struct referral;
779
780 struct smb_request {
781         uint8_t cmd;
782         uint16_t flags2;
783         uint16_t smbpid;
784         uint64_t mid; /* For compatibility with SMB2. */
785         uint32_t seqnum;
786         uint64_t vuid; /* For compatibility with SMB2. */
787         uint32_t tid;
788         uint8_t  wct;
789         const uint16_t *vwv;
790         uint16_t buflen;
791         const uint8_t *buf;
792         const uint8_t *inbuf;
793
794         /*
795          * Async handling in the main smb processing loop is directed by
796          * outbuf: reply_xxx routines indicate sync behaviour by putting their
797          * reply into "outbuf". If they leave it as NULL, they take care of it
798          * themselves, possibly later.
799          *
800          * If async handling is wanted, the reply_xxx routine must make sure
801          * that it talloc_move()s the smb_req somewhere else.
802          */
803         uint8_t *outbuf;
804
805         size_t unread_bytes;
806         bool encrypted;
807         connection_struct *conn;
808         struct smbd_server_connection *sconn;
809         struct smbXsrv_connection *xconn;
810
811         /*
812          * Pointer to session, can be NULL,
813          * eg during negprot and session setup.
814          */
815         struct smbXsrv_session *session;
816
817         struct smb_perfcount_data pcd;
818
819         /*
820          * Chained request handling
821          */
822         struct files_struct *chain_fsp;
823
824         /*
825          * state information for async smb handling
826          */
827         void *async_priv;
828
829         /*
830          * Back pointer to smb2 request.
831          */
832         struct smbd_smb2_request *smb2req;
833
834         /*
835          * Request list for chained requests, we're part of it.
836          */
837         struct smb_request **chain;
838
839         struct timeval request_time;
840
841         bool posix_pathnames;
842 };
843
844 /*
845  * Info about an alternate data stream
846  */
847
848 struct stream_struct {
849         off_t size;
850         off_t alloc_size;
851         char *name;
852 };
853
854 /* time info */
855 struct smb_file_time {
856         struct timespec mtime;
857         struct timespec atime;
858         struct timespec ctime;
859         struct timespec create_time;
860 };
861
862 /*
863  * smb_filename
864  */
865 struct smb_filename {
866         char *base_name;
867         char *stream_name;
868         uint32_t flags;
869         SMB_STRUCT_STAT st;
870         NTTIME twrp;
871
872         /*
873          * Internal file handle, O_PATH based if available,
874          * otherwise O_RDONLY as root.
875          */
876         struct files_struct *fsp;
877
878         /*
879          * Link between the struct smb_filename and the above
880          * fsp. fsp_link is a talloc child of the fsp. Ensures a possible
881          * talloc_free(fsp) resets the smb_fname->fsp pointer to NULL in
882          * the is fsp_link talloc destructor.
883          */
884         struct fsp_smb_fname_link *fsp_link;
885 };
886
887 /*
888  * smb_filename flags. Define in terms of the FSP_POSIX_FLAGS_XX
889  * to keep the numeric values consistent.
890  */
891
892 #define SMB_FILENAME_POSIX_PATH         FSP_POSIX_FLAGS_PATHNAMES
893
894 #define VFS_FIND(__fn__) while (handle->fns->__fn__##_fn==NULL) { \
895                                 handle = handle->next; \
896                          }
897
898 enum vfs_translate_direction {
899         vfs_translate_to_unix = 0,
900         vfs_translate_to_windows
901 };
902
903 enum vfs_fallocate_flags {
904         VFS_FALLOCATE_FL_KEEP_SIZE              = 0x0001,
905         VFS_FALLOCATE_FL_PUNCH_HOLE             = 0x0002,
906 };
907
908 struct vfs_aio_state {
909         int error;
910         uint64_t duration;
911 };
912
913 #define VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS 1
914
915 struct vfs_open_how {
916         int flags;
917         mode_t mode;
918         uint64_t resolve;
919 };
920
921 /*
922     Available VFS operations. These values must be in sync with vfs_ops struct
923     (struct vfs_fn_pointers and struct vfs_handle_pointers inside of struct vfs_ops).
924     In particular, if new operations are added to vfs_ops, appropriate constants
925     should be added to vfs_op_type so that order of them kept same as in vfs_ops.
926 */
927 struct shadow_copy_data;
928
929 struct vfs_fn_pointers {
930         /* Disk operations */
931
932         int (*connect_fn)(struct vfs_handle_struct *handle, const char *service, const char *user);
933         void (*disconnect_fn)(struct vfs_handle_struct *handle);
934         uint64_t (*disk_free_fn)(struct vfs_handle_struct *handle,
935                                 const struct smb_filename *smb_fname,
936                                 uint64_t *bsize,
937                                 uint64_t *dfree,
938                                 uint64_t *dsize);
939         int (*get_quota_fn)(struct vfs_handle_struct *handle,
940                                 const struct smb_filename *smb_fname,
941                                 enum SMB_QUOTA_TYPE qtype,
942                                 unid_t id,
943                                 SMB_DISK_QUOTA *qt);
944         int (*set_quota_fn)(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt);
945         int (*get_shadow_copy_data_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, struct shadow_copy_data *shadow_copy_data, bool labels);
946         int (*statvfs_fn)(struct vfs_handle_struct *handle,
947                                 const struct smb_filename *smb_fname,
948                                 struct vfs_statvfs_struct *statbuf);
949         uint32_t (*fs_capabilities_fn)(struct vfs_handle_struct *handle, enum timestamp_set_resolution *p_ts_res);
950
951         /*
952          * Note: that "struct dfs_GetDFSReferral *r"
953          * needs to be a valid TALLOC_CTX
954          */
955         NTSTATUS (*get_dfs_referrals_fn)(struct vfs_handle_struct *handle,
956                                          struct dfs_GetDFSReferral *r);
957         NTSTATUS (*create_dfs_pathat_fn)(struct vfs_handle_struct *handle,
958                                 struct files_struct *dirfsp,
959                                 const struct smb_filename *smb_fname,
960                                 const struct referral *reflist,
961                                 size_t referral_count);
962         NTSTATUS (*read_dfs_pathat_fn)(struct vfs_handle_struct *handle,
963                                 TALLOC_CTX *mem_ctx,
964                                 struct files_struct *dirfsp,
965                                 struct smb_filename *smb_fname,
966                                 struct referral **ppreflist,
967                                 size_t *preferral_count);
968
969         /* Directory operations */
970
971         DIR *(*fdopendir_fn)(struct vfs_handle_struct *handle, files_struct *fsp, const char *mask, uint32_t attributes);
972         struct dirent *(*readdir_fn)(struct vfs_handle_struct *handle,
973                                      struct files_struct *dirfsp,
974                                      DIR *dirp,
975                                      SMB_STRUCT_STAT *sbuf);
976         void (*seekdir_fn)(struct vfs_handle_struct *handle, DIR *dirp, long offset);
977         long (*telldir_fn)(struct vfs_handle_struct *handle, DIR *dirp);
978         void (*rewind_dir_fn)(struct vfs_handle_struct *handle, DIR *dirp);
979         int (*mkdirat_fn)(struct vfs_handle_struct *handle,
980                         struct files_struct *dirfsp,
981                         const struct smb_filename *smb_fname,
982                         mode_t mode);
983         int (*closedir_fn)(struct vfs_handle_struct *handle, DIR *dir);
984
985         /* File operations */
986
987         int (*openat_fn)(struct vfs_handle_struct *handle,
988                          const struct files_struct *dirfsp,
989                          const struct smb_filename *smb_fname,
990                          struct files_struct *fsp,
991                          const struct vfs_open_how *how);
992         NTSTATUS (*create_file_fn)(struct vfs_handle_struct *handle,
993                                    struct smb_request *req,
994                                    struct files_struct *dirfsp,
995                                    struct smb_filename *smb_fname,
996                                    uint32_t access_mask,
997                                    uint32_t share_access,
998                                    uint32_t create_disposition,
999                                    uint32_t create_options,
1000                                    uint32_t file_attributes,
1001                                    uint32_t oplock_request,
1002                                    const struct smb2_lease *lease,
1003                                    uint64_t allocation_size,
1004                                    uint32_t private_flags,
1005                                    struct security_descriptor *sd,
1006                                    struct ea_list *ea_list,
1007                                    files_struct **result,
1008                                    int *pinfo,
1009                                    const struct smb2_create_blobs *in_context_blobs,
1010                                    struct smb2_create_blobs *out_context_blobs);
1011         int (*close_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp);
1012         ssize_t (*pread_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n, off_t offset);
1013         struct tevent_req *(*pread_send_fn)(struct vfs_handle_struct *handle,
1014                                             TALLOC_CTX *mem_ctx,
1015                                             struct tevent_context *ev,
1016                                             struct files_struct *fsp,
1017                                             void *data,
1018                                             size_t n, off_t offset);
1019         ssize_t (*pread_recv_fn)(struct tevent_req *req, struct vfs_aio_state *state);
1020         ssize_t (*pwrite_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const void *data, size_t n, off_t offset);
1021         struct tevent_req *(*pwrite_send_fn)(struct vfs_handle_struct *handle,
1022                                              TALLOC_CTX *mem_ctx,
1023                                              struct tevent_context *ev,
1024                                              struct files_struct *fsp,
1025                                              const void *data,
1026                                              size_t n, off_t offset);
1027         ssize_t (*pwrite_recv_fn)(struct tevent_req *req, struct vfs_aio_state *state);
1028         off_t (*lseek_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, off_t offset, int whence);
1029         ssize_t (*sendfile_fn)(struct vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *header, off_t offset, size_t count);
1030         ssize_t (*recvfile_fn)(struct vfs_handle_struct *handle, int fromfd, files_struct *tofsp, off_t offset, size_t count);
1031         int (*renameat_fn)(struct vfs_handle_struct *handle,
1032                          struct files_struct *srcdir_fsp,
1033                          const struct smb_filename *smb_fname_src,
1034                          struct files_struct *dstdir_fsp,
1035                          const struct smb_filename *smb_fname_dst);
1036         struct tevent_req *(*fsync_send_fn)(struct vfs_handle_struct *handle,
1037                                             TALLOC_CTX *mem_ctx,
1038                                             struct tevent_context *ev,
1039                                             struct files_struct *fsp);
1040         int (*fsync_recv_fn)(struct tevent_req *req, struct vfs_aio_state *state);
1041         int (*stat_fn)(struct vfs_handle_struct *handle, struct smb_filename *smb_fname);
1042         int (*fstat_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_STAT *sbuf);
1043         int (*lstat_fn)(struct vfs_handle_struct *handle, struct smb_filename *smb_filename);
1044         int (*fstatat_fn)(
1045                 struct vfs_handle_struct *handle,
1046                 const struct files_struct *dirfsp,
1047                 const struct smb_filename *smb_fname,
1048                 SMB_STRUCT_STAT *sbuf,
1049                 int flags);
1050         uint64_t (*get_alloc_size_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_STAT *sbuf);
1051         int (*unlinkat_fn)(struct vfs_handle_struct *handle,
1052                         struct files_struct *srcdir_fsp,
1053                         const struct smb_filename *smb_fname,
1054                         int flags);
1055         int (*fchmod_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, mode_t mode);
1056         int (*fchown_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, uid_t uid, gid_t gid);
1057         int (*lchown_fn)(struct vfs_handle_struct *handle,
1058                         const struct smb_filename *smb_fname,
1059                         uid_t uid,
1060                         gid_t gid);
1061         int (*chdir_fn)(struct vfs_handle_struct *handle,
1062                          const struct smb_filename *smb_fname);
1063         struct smb_filename *(*getwd_fn)(struct vfs_handle_struct *handle,
1064                                 TALLOC_CTX *mem_ctx);
1065         int (*fntimes_fn)(struct vfs_handle_struct *handle,
1066                           struct files_struct *fsp,
1067                           struct smb_file_time *ft);
1068         int (*ftruncate_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, off_t offset);
1069         int (*fallocate_fn)(struct vfs_handle_struct *handle,
1070                             struct files_struct *fsp,
1071                             uint32_t mode,
1072                             off_t offset,
1073                             off_t len);
1074         bool (*lock_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, off_t offset, off_t count, int type);
1075         int (*filesystem_sharemode_fn)(struct vfs_handle_struct *handle,
1076                                        struct files_struct *fsp,
1077                                        uint32_t share_access, uint32_t
1078                                        access_mask);
1079         int (*fcntl_fn)(struct vfs_handle_struct *handle,
1080                         struct files_struct *fsp, int cmd, va_list cmd_arg);
1081         int (*linux_setlease_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, int leasetype);
1082         bool (*getlock_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, off_t *poffset, off_t *pcount, int *ptype, pid_t *ppid);
1083         int (*symlinkat_fn)(struct vfs_handle_struct *handle,
1084                                 const struct smb_filename *link_contents,
1085                                 struct files_struct *dirfsp,
1086                                 const struct smb_filename *new_smb_fname);
1087         int (*readlinkat_fn)(struct vfs_handle_struct *handle,
1088                                 const struct files_struct *dirfsp,
1089                                 const struct smb_filename *smb_fname,
1090                                 char *buf,
1091                                 size_t bufsiz);
1092         int (*linkat_fn)(struct vfs_handle_struct *handle,
1093                                 struct files_struct *srcfsp,
1094                                 const struct smb_filename *old_smb_fname,
1095                                 struct files_struct *dstfsp,
1096                                 const struct smb_filename *new_smb_fname,
1097                                 int flags);
1098         int (*mknodat_fn)(struct vfs_handle_struct *handle,
1099                                 struct files_struct *dirfsp,
1100                                 const struct smb_filename *smb_fname,
1101                                 mode_t mode,
1102                                 SMB_DEV_T dev);
1103         struct smb_filename *(*realpath_fn)(struct vfs_handle_struct *handle,
1104                                 TALLOC_CTX *ctx,
1105                                 const struct smb_filename *smb_fname);
1106         int (*fchflags_fn)(struct vfs_handle_struct *handle,
1107                                 struct files_struct *fsp,
1108                                 unsigned int flags);
1109         struct file_id (*file_id_create_fn)(struct vfs_handle_struct *handle,
1110                                             const SMB_STRUCT_STAT *sbuf);
1111         uint64_t (*fs_file_id_fn)(struct vfs_handle_struct *handle,
1112                                   const SMB_STRUCT_STAT *sbuf);
1113         struct tevent_req *(*offload_read_send_fn)(TALLOC_CTX *mem_ctx,
1114                                                    struct tevent_context *ev,
1115                                                    struct vfs_handle_struct *handle,
1116                                                    struct files_struct *fsp,
1117                                                    uint32_t fsctl,
1118                                                    uint32_t ttl,
1119                                                    off_t offset,
1120                                                    size_t to_copy);
1121         NTSTATUS (*offload_read_recv_fn)(struct tevent_req *req,
1122                                          struct vfs_handle_struct *handle,
1123                                          TALLOC_CTX *mem_ctx,
1124                                          uint32_t *flags,
1125                                          uint64_t *xferlen,
1126                                          DATA_BLOB *token_blob);
1127         struct tevent_req *(*offload_write_send_fn)(struct vfs_handle_struct *handle,
1128                                                     TALLOC_CTX *mem_ctx,
1129                                                     struct tevent_context *ev,
1130                                                     uint32_t fsctl,
1131                                                     DATA_BLOB *token,
1132                                                     off_t transfer_offset,
1133                                                     struct files_struct *dest_fsp,
1134                                                     off_t dest_off,
1135                                                     off_t to_copy);
1136         NTSTATUS (*offload_write_recv_fn)(struct vfs_handle_struct *handle,
1137                                           struct tevent_req *req,
1138                                           off_t *copied);
1139         NTSTATUS (*fget_compression_fn)(struct vfs_handle_struct *handle,
1140                                        TALLOC_CTX *mem_ctx,
1141                                        struct files_struct *fsp,
1142                                        uint16_t *_compression_fmt);
1143         NTSTATUS (*set_compression_fn)(struct vfs_handle_struct *handle,
1144                                        TALLOC_CTX *mem_ctx,
1145                                        struct files_struct *fsp,
1146                                        uint16_t compression_fmt);
1147         NTSTATUS (*snap_check_path_fn)(struct vfs_handle_struct *handle,
1148                                        TALLOC_CTX *mem_ctx,
1149                                        const char *service_path,
1150                                        char **base_volume);
1151         NTSTATUS (*snap_create_fn)(struct vfs_handle_struct *handle,
1152                                    TALLOC_CTX *mem_ctx,
1153                                    const char *base_volume,
1154                                    time_t *tstamp,
1155                                    bool rw,
1156                                    char **base_path,
1157                                    char **snap_path);
1158         NTSTATUS (*snap_delete_fn)(struct vfs_handle_struct *handle,
1159                                    TALLOC_CTX *mem_ctx,
1160                                    char *base_path,
1161                                    char *snap_path);
1162
1163         NTSTATUS (*fstreaminfo_fn)(struct vfs_handle_struct *handle,
1164                                    struct files_struct *fsp,
1165                                    TALLOC_CTX *mem_ctx,
1166                                    unsigned int *num_streams,
1167                                    struct stream_struct **streams);
1168
1169         NTSTATUS (*get_real_filename_at_fn)(struct vfs_handle_struct *handle,
1170                                             struct files_struct *dirfsp,
1171                                             const char *name,
1172                                             TALLOC_CTX *mem_ctx,
1173                                             char **found_name);
1174
1175         const char *(*connectpath_fn)(struct vfs_handle_struct *handle,
1176                                       const struct files_struct *dirfsp,
1177                                       const struct smb_filename *smb_fname);
1178
1179         NTSTATUS (*brl_lock_windows_fn)(struct vfs_handle_struct *handle,
1180                                         struct byte_range_lock *br_lck,
1181                                         struct lock_struct *plock);
1182
1183         bool (*brl_unlock_windows_fn)(struct vfs_handle_struct *handle,
1184                                       struct byte_range_lock *br_lck,
1185                                       const struct lock_struct *plock);
1186
1187         bool (*strict_lock_check_fn)(struct vfs_handle_struct *handle,
1188                                      struct files_struct *fsp,
1189                                      struct lock_struct *plock);
1190
1191         NTSTATUS (*translate_name_fn)(struct vfs_handle_struct *handle,
1192                                       const char *name,
1193                                       enum vfs_translate_direction direction,
1194                                       TALLOC_CTX *mem_ctx,
1195                                       char **mapped_name);
1196
1197         NTSTATUS (*parent_pathname_fn)(struct vfs_handle_struct *handle,
1198                                        TALLOC_CTX *mem_ctx,
1199                                        const struct smb_filename *smb_fname_in,
1200                                        struct smb_filename **parent_dir_out,
1201                                        struct smb_filename **atname_out);
1202
1203         NTSTATUS (*fsctl_fn)(struct vfs_handle_struct *handle,
1204                              struct files_struct *fsp,
1205                              TALLOC_CTX *ctx,
1206                              uint32_t function,
1207                              uint16_t req_flags,
1208                              const uint8_t *_in_data,
1209                              uint32_t in_len,
1210                              uint8_t **_out_data,
1211                              uint32_t max_out_len,
1212                              uint32_t *out_len); 
1213
1214         NTSTATUS (*fget_dos_attributes_fn)(struct vfs_handle_struct *handle,
1215                                            struct files_struct *fsp,
1216                                            uint32_t *dosmode);
1217
1218         NTSTATUS (*fset_dos_attributes_fn)(struct vfs_handle_struct *hande,
1219                                            struct files_struct *fsp,
1220                                            uint32_t dosmode);
1221
1222         struct tevent_req *(*get_dos_attributes_send_fn)(
1223                                 TALLOC_CTX *mem_ctx,
1224                                 struct tevent_context *ev,
1225                                 struct vfs_handle_struct *handle,
1226                                 files_struct *dir_fsp,
1227                                 struct smb_filename *smb_fname);
1228
1229         NTSTATUS (*get_dos_attributes_recv_fn)(
1230                                 struct tevent_req *req,
1231                                 struct vfs_aio_state *aio_state,
1232                                 uint32_t *dosmode);
1233
1234         /* NT ACL operations. */
1235
1236         NTSTATUS (*fget_nt_acl_fn)(struct vfs_handle_struct *handle,
1237                                    struct files_struct *fsp,
1238                                    uint32_t security_info,
1239                                    TALLOC_CTX *mem_ctx,
1240                                    struct security_descriptor **ppdesc);
1241         NTSTATUS (*fset_nt_acl_fn)(struct vfs_handle_struct *handle,
1242                                    struct files_struct *fsp,
1243                                    uint32_t security_info_sent,
1244                                    const struct security_descriptor *psd);
1245
1246         NTSTATUS (*audit_file_fn)(struct vfs_handle_struct *handle,
1247                                   struct smb_filename *file,
1248                                   struct security_acl *sacl,
1249                                   uint32_t access_requested,
1250                                   uint32_t access_denied);
1251
1252         /* POSIX ACL operations. */
1253
1254         SMB_ACL_T (*sys_acl_get_fd_fn)(struct vfs_handle_struct *handle,
1255                                        struct files_struct *fsp,
1256                                        SMB_ACL_TYPE_T type,
1257                                        TALLOC_CTX *mem_ctx);
1258         int (*sys_acl_blob_get_fd_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp,
1259                                       TALLOC_CTX *mem_ctx, char **blob_description,
1260                                       DATA_BLOB *blob);
1261         int (*sys_acl_set_fd_fn)(struct vfs_handle_struct *handle,
1262                                  struct files_struct *fsp,
1263                                  SMB_ACL_TYPE_T type,
1264                                  SMB_ACL_T theacl);
1265         int (*sys_acl_delete_def_fd_fn)(struct vfs_handle_struct *handle,
1266                                         struct files_struct *fsp);
1267
1268         /* EA operations. */
1269         struct tevent_req *(*getxattrat_send_fn)(
1270                                 TALLOC_CTX *mem_ctx,
1271                                 struct tevent_context *ev,
1272                                 struct vfs_handle_struct *handle,
1273                                 files_struct *dir_fsp,
1274                                 const struct smb_filename *smb_fname,
1275                                 const char *xattr_name,
1276                                 size_t alloc_hint);
1277         ssize_t (*getxattrat_recv_fn)(struct tevent_req *req,
1278                                       struct vfs_aio_state *aio_state,
1279                                       TALLOC_CTX *mem_ctx,
1280                                       uint8_t **xattr_value);
1281         ssize_t (*fgetxattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size);
1282         ssize_t (*flistxattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size);
1283         int (*fremovexattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name);
1284         int (*fsetxattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags);
1285
1286         /* aio operations */
1287         bool (*aio_force_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp);
1288
1289         /* durable handle operations */
1290         NTSTATUS (*durable_cookie_fn)(struct vfs_handle_struct *handle,
1291                                       struct files_struct *fsp,
1292                                       TALLOC_CTX *mem_ctx,
1293                                       DATA_BLOB *cookie);
1294         NTSTATUS (*durable_disconnect_fn)(struct vfs_handle_struct *handle,
1295                                           struct files_struct *fsp,
1296                                           const DATA_BLOB old_cookie,
1297                                           TALLOC_CTX *mem_ctx,
1298                                           DATA_BLOB *new_cookie);
1299         NTSTATUS (*durable_reconnect_fn)(struct vfs_handle_struct *handle,
1300                                          struct smb_request *smb1req,
1301                                          struct smbXsrv_open *op,
1302                                          const DATA_BLOB old_cookie,
1303                                          TALLOC_CTX *mem_ctx,
1304                                          struct files_struct **fsp,
1305                                          DATA_BLOB *new_cookie);
1306
1307         NTSTATUS (*freaddir_attr_fn)(struct vfs_handle_struct *handle,
1308                                      struct files_struct *fsp,
1309                                      TALLOC_CTX *mem_ctx,
1310                                      struct readdir_attr_data **attr_data);
1311 };
1312
1313 /*
1314     VFS operation description. Each VFS module registers an array of vfs_op_tuple to VFS subsystem,
1315     which describes all operations this module is willing to intercept.
1316     VFS subsystem initializes then the conn->vfs_ops and conn->vfs_opaque_ops structs
1317     using this information.
1318 */
1319
1320 typedef struct vfs_handle_struct {
1321         struct vfs_handle_struct  *next, *prev;
1322         const char *param;
1323         struct connection_struct *conn;
1324         const struct vfs_fn_pointers *fns;
1325         void *data;
1326         void (*free_data)(void **data);
1327 } vfs_handle_struct;
1328
1329
1330 struct vfs_statvfs_struct {
1331         /* For undefined recommended transfer size return -1 in that field */
1332         uint32_t OptimalTransferSize;  /* bsize on some os, iosize on other os */
1333         uint32_t BlockSize;
1334
1335         /*
1336          The next three fields are in terms of the block size.
1337          (above). If block size is unknown, 4096 would be a
1338          reasonable block size for a server to report.
1339          Note that returning the blocks/blocksavail removes need
1340          to make a second call (to QFSInfo level 0x103 to get this info.
1341          UserBlockAvail is typically less than or equal to BlocksAvail,
1342          if no distinction is made return the same value in each.
1343         */
1344
1345         uint64_t TotalBlocks;
1346         uint64_t BlocksAvail;       /* bfree */
1347         uint64_t UserBlocksAvail;   /* bavail */
1348
1349         /* For undefined Node fields or FSID return -1 */
1350         uint64_t TotalFileNodes;
1351         uint64_t FreeFileNodes;
1352         uint64_t FsIdentifier;   /* fsid */
1353         /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
1354         /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call   */
1355
1356         int FsCapabilities;
1357 };
1358
1359 /* Add a new FSP extension of the given type. Returns a pointer to the
1360  * extenstion data.
1361  */
1362 #define VFS_ADD_FSP_EXTENSION(handle, fsp, type, destroy_fn)            \
1363     (type *)vfs_add_fsp_extension_notype(handle, (fsp), sizeof(type), (destroy_fn))
1364
1365 /* Return a pointer to the existing FSP extension data. */
1366 #define VFS_FETCH_FSP_EXTENSION(handle, fsp) \
1367     vfs_fetch_fsp_extension(handle, (fsp))
1368
1369 /* Return the talloc context associated with an FSP extension. */
1370 #define VFS_MEMCTX_FSP_EXTENSION(handle, fsp) \
1371     vfs_memctx_fsp_extension(handle, (fsp))
1372
1373 /* Remove and destroy an FSP extension. */
1374 #define VFS_REMOVE_FSP_EXTENSION(handle, fsp) \
1375     vfs_remove_fsp_extension((handle), (fsp))
1376
1377 #define SMB_VFS_HANDLE_GET_DATA(handle, datap, type, ret) { \
1378         if (!(handle)||((datap=(type *)(handle)->data)==NULL)) { \
1379                 DEBUG(0,("%s() failed to get vfs_handle->data!\n",__FUNCTION__)); \
1380                 ret; \
1381         } \
1382 }
1383
1384 #define SMB_VFS_HANDLE_SET_DATA(handle, datap, free_fn, type, ret) { \
1385         if (!(handle)) { \
1386                 DEBUG(0,("%s() failed to set handle->data!\n",__FUNCTION__)); \
1387                 ret; \
1388         } else { \
1389                 if ((handle)->free_data) { \
1390                         (handle)->free_data(&(handle)->data); \
1391                 } \
1392                 (handle)->data = (void *)datap; \
1393                 (handle)->free_data = free_fn; \
1394         } \
1395 }
1396
1397 #define SMB_VFS_HANDLE_FREE_DATA(handle) { \
1398         if ((handle) && (handle)->free_data) { \
1399                 (handle)->free_data(&(handle)->data); \
1400         } \
1401 }
1402
1403 /* Check whether module-specific data handle was already allocated or not */
1404 #define SMB_VFS_HANDLE_TEST_DATA(handle)  ( !(handle) || !(handle)->data ? False : True )
1405
1406 #define SMB_VFS_OP(x) ((void *) x)
1407
1408 #define DEFAULT_VFS_MODULE_NAME "/[Default VFS]/"
1409
1410 #include "vfs_macros.h"
1411
1412 int smb_vfs_call_connect(struct vfs_handle_struct *handle,
1413                          const char *service, const char *user);
1414 void smb_vfs_call_disconnect(struct vfs_handle_struct *handle);
1415 uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
1416                                 const struct smb_filename *smb_filename,
1417                                 uint64_t *bsize,
1418                                 uint64_t *dfree,
1419                                 uint64_t *dsize);
1420 int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
1421                                 const struct smb_filename *smb_filename,
1422                                 enum SMB_QUOTA_TYPE qtype,
1423                                 unid_t id,
1424                                 SMB_DISK_QUOTA *qt);
1425 int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,
1426                            enum SMB_QUOTA_TYPE qtype, unid_t id,
1427                            SMB_DISK_QUOTA *qt);
1428 int smb_vfs_call_get_shadow_copy_data(struct vfs_handle_struct *handle,
1429                                       struct files_struct *fsp,
1430                                       struct shadow_copy_data *shadow_copy_data,
1431                                       bool labels);
1432 int smb_vfs_call_statvfs(struct vfs_handle_struct *handle,
1433                         const struct smb_filename *smb_fname,
1434                         struct vfs_statvfs_struct *statbuf);
1435 uint32_t smb_vfs_call_fs_capabilities(struct vfs_handle_struct *handle,
1436                                       enum timestamp_set_resolution *p_ts_res);
1437 /*
1438  * Note: that "struct dfs_GetDFSReferral *r" needs to be a valid TALLOC_CTX
1439  */
1440 NTSTATUS smb_vfs_call_get_dfs_referrals(struct vfs_handle_struct *handle,
1441                                         struct dfs_GetDFSReferral *r);
1442 NTSTATUS smb_vfs_call_create_dfs_pathat(struct vfs_handle_struct *handle,
1443                                 struct files_struct *dirfsp,
1444                                 const struct smb_filename *smb_fname,
1445                                 const struct referral *reflist,
1446                                 size_t referral_count);
1447 NTSTATUS smb_vfs_call_read_dfs_pathat(struct vfs_handle_struct *handle,
1448                                 TALLOC_CTX *mem_ctx,
1449                                 struct files_struct *dirfsp,
1450                                 struct smb_filename *smb_fname,
1451                                 struct referral **ppreflist,
1452                                 size_t *preferral_count);
1453 DIR *smb_vfs_call_fdopendir(struct vfs_handle_struct *handle,
1454                                         struct files_struct *fsp,
1455                                         const char *mask,
1456                                         uint32_t attributes);
1457 struct dirent *smb_vfs_call_readdir(struct vfs_handle_struct *handle,
1458                                     struct files_struct *dirfsp,
1459                                     DIR *dirp,
1460                                     SMB_STRUCT_STAT *sbuf);
1461 void smb_vfs_call_seekdir(struct vfs_handle_struct *handle,
1462                           DIR *dirp, long offset);
1463 long smb_vfs_call_telldir(struct vfs_handle_struct *handle,
1464                           DIR *dirp);
1465 void smb_vfs_call_rewind_dir(struct vfs_handle_struct *handle,
1466                              DIR *dirp);
1467 int smb_vfs_call_mkdirat(struct vfs_handle_struct *handle,
1468                         struct files_struct *dirfsp,
1469                         const struct smb_filename *smb_fname,
1470                         mode_t mode);
1471 int smb_vfs_call_closedir(struct vfs_handle_struct *handle,
1472                           DIR *dir);
1473 int smb_vfs_call_openat(struct vfs_handle_struct *handle,
1474                         const struct files_struct *dirfsp,
1475                         const struct smb_filename *smb_fname,
1476                         struct files_struct *fsp,
1477                         const struct vfs_open_how *how);
1478 NTSTATUS smb_vfs_call_create_file(struct vfs_handle_struct *handle,
1479                                   struct smb_request *req,
1480                                   struct files_struct *dirfsp,
1481                                   struct smb_filename *smb_fname,
1482                                   uint32_t access_mask,
1483                                   uint32_t share_access,
1484                                   uint32_t create_disposition,
1485                                   uint32_t create_options,
1486                                   uint32_t file_attributes,
1487                                   uint32_t oplock_request,
1488                                   const struct smb2_lease *lease,
1489                                   uint64_t allocation_size,
1490                                   uint32_t private_flags,
1491                                   struct security_descriptor *sd,
1492                                   struct ea_list *ea_list,
1493                                   files_struct **result,
1494                                   int *pinfo,
1495                                   const struct smb2_create_blobs *in_context_blobs,
1496                                   struct smb2_create_blobs *out_context_blobs);
1497 int smb_vfs_call_close(struct vfs_handle_struct *handle,
1498                        struct files_struct *fsp);
1499 ssize_t smb_vfs_call_pread(struct vfs_handle_struct *handle,
1500                            struct files_struct *fsp, void *data, size_t n,
1501                            off_t offset);
1502 struct tevent_req *smb_vfs_call_pread_send(struct vfs_handle_struct *handle,
1503                                            TALLOC_CTX *mem_ctx,
1504                                            struct tevent_context *ev,
1505                                            struct files_struct *fsp,
1506                                            void *data,
1507                                            size_t n, off_t offset);
1508 ssize_t SMB_VFS_PREAD_RECV(struct tevent_req *req, struct vfs_aio_state *state);
1509
1510 ssize_t smb_vfs_call_pwrite(struct vfs_handle_struct *handle,
1511                             struct files_struct *fsp, const void *data,
1512                             size_t n, off_t offset);
1513 struct tevent_req *smb_vfs_call_pwrite_send(struct vfs_handle_struct *handle,
1514                                             TALLOC_CTX *mem_ctx,
1515                                             struct tevent_context *ev,
1516                                             struct files_struct *fsp,
1517                                             const void *data,
1518                                             size_t n, off_t offset);
1519 ssize_t SMB_VFS_PWRITE_RECV(struct tevent_req *req, struct vfs_aio_state *state);
1520
1521 off_t smb_vfs_call_lseek(struct vfs_handle_struct *handle,
1522                              struct files_struct *fsp, off_t offset,
1523                              int whence);
1524 ssize_t smb_vfs_call_sendfile(struct vfs_handle_struct *handle, int tofd,
1525                               files_struct *fromfsp, const DATA_BLOB *header,
1526                               off_t offset, size_t count);
1527 ssize_t smb_vfs_call_recvfile(struct vfs_handle_struct *handle, int fromfd,
1528                               files_struct *tofsp, off_t offset,
1529                               size_t count);
1530 int smb_vfs_call_renameat(struct vfs_handle_struct *handle,
1531                         struct files_struct *srcfsp,
1532                         const struct smb_filename *smb_fname_src,
1533                         struct files_struct *dstfsp,
1534                         const struct smb_filename *smb_fname_dst);
1535
1536 struct tevent_req *smb_vfs_call_fsync_send(struct vfs_handle_struct *handle,
1537                                            TALLOC_CTX *mem_ctx,
1538                                            struct tevent_context *ev,
1539                                            struct files_struct *fsp);
1540 int SMB_VFS_FSYNC_RECV(struct tevent_req *req, struct vfs_aio_state *state);
1541
1542 int smb_vfs_fsync_sync(files_struct *fsp);
1543 int smb_vfs_call_stat(struct vfs_handle_struct *handle,
1544                       struct smb_filename *smb_fname);
1545 int smb_vfs_call_fstat(struct vfs_handle_struct *handle,
1546                        struct files_struct *fsp, SMB_STRUCT_STAT *sbuf);
1547 int smb_vfs_call_lstat(struct vfs_handle_struct *handle,
1548                        struct smb_filename *smb_filename);
1549 int smb_vfs_call_fstatat(
1550         struct vfs_handle_struct *handle,
1551         const struct files_struct *dirfsp,
1552         const struct smb_filename *smb_fname,
1553         SMB_STRUCT_STAT *sbuf,
1554         int flags);
1555 uint64_t smb_vfs_call_get_alloc_size(struct vfs_handle_struct *handle,
1556                                      struct files_struct *fsp,
1557                                      const SMB_STRUCT_STAT *sbuf);
1558 int smb_vfs_call_unlinkat(struct vfs_handle_struct *handle,
1559                         struct files_struct *dirfsp,
1560                         const struct smb_filename *smb_fname,
1561                         int flags);
1562 int smb_vfs_call_fchmod(struct vfs_handle_struct *handle,
1563                         struct files_struct *fsp, mode_t mode);
1564 int smb_vfs_call_fchown(struct vfs_handle_struct *handle,
1565                         struct files_struct *fsp, uid_t uid, gid_t gid);
1566 int smb_vfs_call_lchown(struct vfs_handle_struct *handle,
1567                         const struct smb_filename *smb_fname,
1568                         uid_t uid,
1569                         gid_t gid);
1570 int smb_vfs_call_chdir(struct vfs_handle_struct *handle,
1571                         const struct smb_filename *smb_fname);
1572 struct smb_filename *smb_vfs_call_getwd(struct vfs_handle_struct *handle,
1573                                 TALLOC_CTX *ctx);
1574 int smb_vfs_call_ntimes(struct vfs_handle_struct *handle,
1575                         const struct smb_filename *smb_fname,
1576                         struct smb_file_time *ft);
1577 int smb_vfs_call_fntimes(struct vfs_handle_struct *handle,
1578                          struct files_struct *fsp,
1579                          struct smb_file_time *ft);
1580 int smb_vfs_call_ftruncate(struct vfs_handle_struct *handle,
1581                            struct files_struct *fsp, off_t offset);
1582 int smb_vfs_call_fallocate(struct vfs_handle_struct *handle,
1583                            struct files_struct *fsp,
1584                            uint32_t mode,
1585                            off_t offset,
1586                            off_t len);
1587 bool smb_vfs_call_lock(struct vfs_handle_struct *handle,
1588                        struct files_struct *fsp, int op, off_t offset,
1589                        off_t count, int type);
1590 int smb_vfs_call_filesystem_sharemode(struct vfs_handle_struct *handle,
1591                                       struct files_struct *fsp,
1592                                       uint32_t share_access,
1593                                       uint32_t access_mask);
1594 int smb_vfs_call_fcntl(struct vfs_handle_struct *handle,
1595                        struct files_struct *fsp, int cmd, ...);
1596 int smb_vfs_call_linux_setlease(struct vfs_handle_struct *handle,
1597                                 struct files_struct *fsp, int leasetype);
1598 bool smb_vfs_call_getlock(struct vfs_handle_struct *handle,
1599                           struct files_struct *fsp, off_t *poffset,
1600                           off_t *pcount, int *ptype, pid_t *ppid);
1601 int smb_vfs_call_symlinkat(struct vfs_handle_struct *handle,
1602                         const struct smb_filename *link_contents,
1603                         struct files_struct *dirfsp,
1604                         const struct smb_filename *new_smb_fname);
1605 int smb_vfs_call_readlinkat(struct vfs_handle_struct *handle,
1606                         const struct files_struct *dirfsp,
1607                         const struct smb_filename *smb_fname,
1608                         char *buf,
1609                         size_t bufsiz);
1610 int smb_vfs_call_linkat(struct vfs_handle_struct *handle,
1611                         struct files_struct *srcfsp,
1612                         const struct smb_filename *old_smb_fname,
1613                         struct files_struct *dstfsp,
1614                         const struct smb_filename *new_smb_fname,
1615                         int flags);
1616 int smb_vfs_call_mknodat(struct vfs_handle_struct *handle,
1617                         struct files_struct *dirfsp,
1618                         const struct smb_filename *smb_fname,
1619                         mode_t mode,
1620                         SMB_DEV_T dev);
1621 struct smb_filename *smb_vfs_call_realpath(struct vfs_handle_struct *handle,
1622                         TALLOC_CTX *ctx,
1623                         const struct smb_filename *smb_fname);
1624 int smb_vfs_call_chflags(struct vfs_handle_struct *handle,
1625                         const struct smb_filename *smb_fname,
1626                         unsigned int flags);
1627 int smb_vfs_call_fchflags(struct vfs_handle_struct *handle,
1628                         struct files_struct *fsp,
1629                         unsigned int flags);
1630 struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,
1631                                            const SMB_STRUCT_STAT *sbuf);
1632 uint64_t smb_vfs_call_fs_file_id(struct vfs_handle_struct *handle,
1633                                  const SMB_STRUCT_STAT *sbuf);
1634 NTSTATUS smb_vfs_call_fstreaminfo(struct vfs_handle_struct *handle,
1635                                   struct files_struct *fsp,
1636                                   TALLOC_CTX *mem_ctx,
1637                                   unsigned int *num_streams,
1638                                   struct stream_struct **streams);
1639 NTSTATUS smb_vfs_call_get_real_filename_at(struct vfs_handle_struct *handle,
1640                                            struct files_struct *dirfsp,
1641                                            const char *name,
1642                                            TALLOC_CTX *mem_ctx,
1643                                            char **found_name);
1644 const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,
1645                                  const struct files_struct *dirfsp,
1646                                  const struct smb_filename *smb_fname);
1647 NTSTATUS smb_vfs_call_brl_lock_windows(struct vfs_handle_struct *handle,
1648                                        struct byte_range_lock *br_lck,
1649                                        struct lock_struct *plock);
1650 bool smb_vfs_call_brl_unlock_windows(struct vfs_handle_struct *handle,
1651                                      struct byte_range_lock *br_lck,
1652                                      const struct lock_struct *plock);
1653 bool smb_vfs_call_strict_lock_check(struct vfs_handle_struct *handle,
1654                                     struct files_struct *fsp,
1655                                     struct lock_struct *plock);
1656 NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle,
1657                                      const char *name,
1658                                      enum vfs_translate_direction direction,
1659                                      TALLOC_CTX *mem_ctx,
1660                                      char **mapped_name);
1661 NTSTATUS smb_vfs_call_parent_pathname(struct vfs_handle_struct *handle,
1662                                       TALLOC_CTX *mem_ctx,
1663                                       const struct smb_filename *smb_fname_in,
1664                                       struct smb_filename **parent_dir_out,
1665                                       struct smb_filename **atname_out);
1666 NTSTATUS smb_vfs_call_fsctl(struct vfs_handle_struct *handle,
1667                             struct files_struct *fsp,
1668                             TALLOC_CTX *ctx,
1669                             uint32_t function,
1670                             uint16_t req_flags,
1671                             const uint8_t *_in_data,
1672                             uint32_t in_len,
1673                             uint8_t **_out_data,
1674                             uint32_t max_out_len,
1675                             uint32_t *out_len);
1676 NTSTATUS smb_vfs_call_fget_dos_attributes(struct vfs_handle_struct *handle,
1677                                           struct files_struct *fsp,
1678                                           uint32_t *dosmode);
1679 NTSTATUS smb_vfs_call_fset_dos_attributes(struct vfs_handle_struct *handle,
1680                                           struct files_struct *fsp,
1681                                           uint32_t dosmode);
1682 struct tevent_req *smb_vfs_call_get_dos_attributes_send(
1683                         TALLOC_CTX *mem_ctx,
1684                         struct tevent_context *ev,
1685                         struct vfs_handle_struct *handle,
1686                         files_struct *dir_fsp,
1687                         struct smb_filename *smb_fname);
1688 NTSTATUS smb_vfs_call_get_dos_attributes_recv(
1689                         struct tevent_req *req,
1690                         struct vfs_aio_state *aio_state,
1691                         uint32_t *dosmode);
1692 struct tevent_req *smb_vfs_call_offload_read_send(
1693         TALLOC_CTX *mem_ctx,
1694         struct tevent_context *ev,
1695         struct vfs_handle_struct *handle,
1696         struct files_struct *fsp,
1697         uint32_t fsctl,
1698         uint32_t ttl,
1699         off_t offset,
1700         size_t to_copy);
1701 NTSTATUS smb_vfs_call_offload_read_recv(struct tevent_req *req,
1702                                         struct vfs_handle_struct *handle,
1703                                         TALLOC_CTX *mem_ctx,
1704                                         uint32_t *flags,
1705                                         uint64_t *xferlen,
1706                                         DATA_BLOB *token_blob);
1707 struct tevent_req *smb_vfs_call_offload_write_send(struct vfs_handle_struct *handle,
1708                                                    TALLOC_CTX *mem_ctx,
1709                                                    struct tevent_context *ev,
1710                                                    uint32_t fsctl,
1711                                                    DATA_BLOB *token,
1712                                                    off_t transfer_offset,
1713                                                    struct files_struct *dest_fsp,
1714                                                    off_t dest_off,
1715                                                    off_t num);
1716 NTSTATUS smb_vfs_call_offload_write_recv(struct vfs_handle_struct *handle,
1717                                          struct tevent_req *req,
1718                                          off_t *copied);
1719 NTSTATUS smb_vfs_call_fget_compression(struct vfs_handle_struct *handle,
1720                                       TALLOC_CTX *mem_ctx,
1721                                       struct files_struct *fsp,
1722                                       uint16_t *_compression_fmt);
1723 NTSTATUS smb_vfs_call_set_compression(struct vfs_handle_struct *handle,
1724                                       TALLOC_CTX *mem_ctx,
1725                                       struct files_struct *fsp,
1726                                       uint16_t compression_fmt);
1727 NTSTATUS smb_vfs_call_snap_check_path(vfs_handle_struct *handle,
1728                                       TALLOC_CTX *mem_ctx,
1729                                       const char *service_path,
1730                                       char **base_volume);
1731 NTSTATUS smb_vfs_call_snap_create(struct vfs_handle_struct *handle,
1732                                   TALLOC_CTX *mem_ctx,
1733                                   const char *base_volume,
1734                                   time_t *tstamp,
1735                                   bool rw,
1736                                   char **base_path,
1737                                   char **snap_path);
1738 NTSTATUS smb_vfs_call_snap_delete(struct vfs_handle_struct *handle,
1739                                   TALLOC_CTX *mem_ctx,
1740                                   char *base_path,
1741                                   char *snap_path);
1742 NTSTATUS smb_vfs_call_fget_nt_acl(struct vfs_handle_struct *handle,
1743                                   struct files_struct *fsp,
1744                                   uint32_t security_info,
1745                                   TALLOC_CTX *mem_ctx,
1746                                   struct security_descriptor **ppdesc);
1747 NTSTATUS smb_vfs_call_get_nt_acl_at(struct vfs_handle_struct *handle,
1748                                 struct files_struct *dirfsp,
1749                                 const struct smb_filename *smb_fname,
1750                                 uint32_t security_info,
1751                                 TALLOC_CTX *mem_ctx,
1752                                 struct security_descriptor **ppdesc);
1753 NTSTATUS smb_vfs_call_fset_nt_acl(struct vfs_handle_struct *handle,
1754                                   struct files_struct *fsp,
1755                                   uint32_t security_info_sent,
1756                                   const struct security_descriptor *psd);
1757 NTSTATUS smb_vfs_call_audit_file(struct vfs_handle_struct *handle,
1758                                  struct smb_filename *file,
1759                                  struct security_acl *sacl,
1760                                  uint32_t access_requested,
1761                                  uint32_t access_denied);
1762 int smb_vfs_call_chmod_acl(struct vfs_handle_struct *handle,
1763                                 const struct smb_filename *file,
1764                                 mode_t mode);
1765 SMB_ACL_T smb_vfs_call_sys_acl_get_fd(struct vfs_handle_struct *handle,
1766                                       struct files_struct *fsp,
1767                                       SMB_ACL_TYPE_T type,
1768                                       TALLOC_CTX *mem_ctx);
1769 int smb_vfs_call_sys_acl_blob_get_fd(struct vfs_handle_struct *handle,
1770                                      struct files_struct *fsp,  
1771                                      TALLOC_CTX *mem_ctx,
1772                                      char **blob_description,
1773                                      DATA_BLOB *blob);
1774 int smb_vfs_call_sys_acl_set_fd(struct vfs_handle_struct *handle,
1775                                 struct files_struct *fsp,
1776                                 SMB_ACL_TYPE_T type,
1777                                 SMB_ACL_T theacl);
1778 int smb_vfs_call_sys_acl_delete_def_fd(struct vfs_handle_struct *handle,
1779                                 struct files_struct *fsp);
1780 struct tevent_req *smb_vfs_call_getxattrat_send(
1781                         TALLOC_CTX *mem_ctx,
1782                         struct tevent_context *ev,
1783                         struct vfs_handle_struct *handle,
1784                         files_struct *dir_fsp,
1785                         const struct smb_filename *smb_fname,
1786                         const char *xattr_name,
1787                         size_t alloc_hint);
1788 ssize_t smb_vfs_call_getxattrat_recv(struct tevent_req *req,
1789                                      struct vfs_aio_state *aio_state,
1790                                      TALLOC_CTX *mem_ctx,
1791                                      uint8_t **xattr_value);
1792 ssize_t smb_vfs_call_fgetxattr(struct vfs_handle_struct *handle,
1793                                struct files_struct *fsp, const char *name,
1794                                void *value, size_t size);
1795 ssize_t smb_vfs_call_flistxattr(struct vfs_handle_struct *handle,
1796                                 struct files_struct *fsp, char *list,
1797                                 size_t size);
1798 int smb_vfs_call_fremovexattr(struct vfs_handle_struct *handle,
1799                               struct files_struct *fsp, const char *name);
1800 int smb_vfs_call_lsetxattr(struct vfs_handle_struct *handle, const char *path,
1801                            const char *name, const void *value, size_t size,
1802                            int flags);
1803 int smb_vfs_call_fsetxattr(struct vfs_handle_struct *handle,
1804                            struct files_struct *fsp, const char *name,
1805                            const void *value, size_t size, int flags);
1806 bool smb_vfs_call_aio_force(struct vfs_handle_struct *handle,
1807                             struct files_struct *fsp);
1808 NTSTATUS smb_vfs_call_durable_cookie(struct vfs_handle_struct *handle,
1809                                      struct files_struct *fsp,
1810                                      TALLOC_CTX *mem_ctx,
1811                                      DATA_BLOB *cookie);
1812 NTSTATUS smb_vfs_call_durable_disconnect(struct vfs_handle_struct *handle,
1813                                          struct files_struct *fsp,
1814                                          const DATA_BLOB old_cookie,
1815                                          TALLOC_CTX *mem_ctx,
1816                                          DATA_BLOB *new_cookie);
1817 NTSTATUS smb_vfs_call_durable_reconnect(struct vfs_handle_struct *handle,
1818                                         struct smb_request *smb1req,
1819                                         struct smbXsrv_open *op,
1820                                         const DATA_BLOB old_cookie,
1821                                         TALLOC_CTX *mem_ctx,
1822                                         struct files_struct **fsp,
1823                                         DATA_BLOB *new_cookie);
1824 NTSTATUS smb_vfs_call_freaddir_attr(struct vfs_handle_struct *handle,
1825                                     struct files_struct *fsp,
1826                                     TALLOC_CTX *mem_ctx,
1827                                     struct readdir_attr_data **attr_data);
1828
1829 NTSTATUS smb_register_vfs(int version, const char *name,
1830                           const struct vfs_fn_pointers *fns);
1831 void *vfs_add_fsp_extension_notype(vfs_handle_struct *handle,
1832                                    files_struct *fsp, size_t ext_size,
1833                                    void (*destroy_fn)(void *p_data));
1834 void vfs_remove_fsp_extension(vfs_handle_struct *handle, files_struct *fsp);
1835 void vfs_remove_all_fsp_extensions(struct files_struct *fsp);
1836 void *vfs_memctx_fsp_extension(vfs_handle_struct *handle,
1837                                const struct files_struct *fsp);
1838 void *vfs_fetch_fsp_extension(vfs_handle_struct *handle, const struct files_struct *fsp);
1839
1840 void smb_vfs_assert_all_fns(const struct vfs_fn_pointers* fns,
1841                             const char *module);
1842
1843 /*
1844  * Helper functions from source3/modules/vfs_not_implemented.c
1845  */
1846 int vfs_not_implemented_connect(
1847                         vfs_handle_struct *handle,
1848                         const char *service,
1849                         const char *user);
1850 void vfs_not_implemented_disconnect(vfs_handle_struct *handle);
1851 uint64_t vfs_not_implemented_disk_free(vfs_handle_struct *handle,
1852                                 const struct smb_filename *smb_fname,
1853                                 uint64_t *bsize,
1854                                 uint64_t *dfree,
1855                                 uint64_t *dsize);
1856 int vfs_not_implemented_get_quota(vfs_handle_struct *handle,
1857                                 const struct smb_filename *smb_fname,
1858                                 enum SMB_QUOTA_TYPE qtype,
1859                                 unid_t id,
1860                                 SMB_DISK_QUOTA *dq);
1861 int vfs_not_implemented_set_quota(vfs_handle_struct *handle,
1862                                   enum SMB_QUOTA_TYPE qtype,
1863                                   unid_t id, SMB_DISK_QUOTA *dq);
1864 int vfs_not_implemented_get_shadow_copy_data(vfs_handle_struct *handle,
1865                                 files_struct *fsp,
1866                                 struct shadow_copy_data *shadow_copy_data,
1867                                 bool labels);
1868 int vfs_not_implemented_statvfs(struct vfs_handle_struct *handle,
1869                                 const struct smb_filename *smb_fname,
1870                                 struct vfs_statvfs_struct *statbuf);
1871 uint32_t vfs_not_implemented_fs_capabilities(struct vfs_handle_struct *handle,
1872                                 enum timestamp_set_resolution *p_ts_res);
1873 NTSTATUS vfs_not_implemented_get_dfs_referrals(struct vfs_handle_struct *handle,
1874                                                struct dfs_GetDFSReferral *r);
1875 NTSTATUS vfs_not_implemented_create_dfs_pathat(struct vfs_handle_struct *handle,
1876                                 struct files_struct *dirfsp,
1877                                 const struct smb_filename *smb_fname,
1878                                 const struct referral *reflist,
1879                                 size_t referral_count);
1880 NTSTATUS vfs_not_implemented_read_dfs_pathat(struct vfs_handle_struct *handle,
1881                                 TALLOC_CTX *mem_ctx,
1882                                 struct files_struct *dirfsp,
1883                                 struct smb_filename *smb_fname,
1884                                 struct referral **ppreflist,
1885                                 size_t *preferral_count);
1886 NTSTATUS vfs_not_implemented_snap_check_path(struct vfs_handle_struct *handle,
1887                                 TALLOC_CTX *mem_ctx,
1888                                 const char *service_path,
1889                                 char **base_volume);
1890 NTSTATUS vfs_not_implemented_snap_create(struct vfs_handle_struct *handle,
1891                                          TALLOC_CTX *mem_ctx,
1892                                          const char *base_volume,
1893                                          time_t *tstamp,
1894                                          bool rw,
1895                                          char **base_path,
1896                                          char **snap_path);
1897 NTSTATUS vfs_not_implemented_snap_delete(struct vfs_handle_struct *handle,
1898                                          TALLOC_CTX *mem_ctx,
1899                                          char *base_path,
1900                                          char *snap_path);
1901 DIR *vfs_not_implemented_fdopendir(vfs_handle_struct *handle, files_struct *fsp,
1902                                    const char *mask, uint32_t attr);
1903 struct dirent *vfs_not_implemented_readdir(vfs_handle_struct *handle,
1904                                            struct files_struct *dirfsp,
1905                                            DIR *dirp,
1906                                            SMB_STRUCT_STAT *sbuf);
1907 void vfs_not_implemented_seekdir(vfs_handle_struct *handle, DIR *dirp, long offset);
1908 long vfs_not_implemented_telldir(vfs_handle_struct *handle, DIR *dirp);
1909 void vfs_not_implemented_rewind_dir(vfs_handle_struct *handle, DIR *dirp);
1910 int vfs_not_implemented_mkdirat(vfs_handle_struct *handle,
1911                 struct files_struct *dirfsp,
1912                 const struct smb_filename *smb_fname,
1913                 mode_t mode);
1914 int vfs_not_implemented_closedir(vfs_handle_struct *handle, DIR *dir);
1915 int vfs_not_implemented_open(vfs_handle_struct *handle,
1916                              struct smb_filename *smb_fname,
1917                              files_struct *fsp, int flags, mode_t mode);
1918 int vfs_not_implemented_openat(vfs_handle_struct *handle,
1919                                const struct files_struct *dirfsp,
1920                                const struct smb_filename *smb_fname,
1921                                struct files_struct *fsp,
1922                                const struct vfs_open_how *how);
1923 NTSTATUS vfs_not_implemented_create_file(struct vfs_handle_struct *handle,
1924                                 struct smb_request *req,
1925                                 struct files_struct *dirfsp,
1926                                 struct smb_filename *smb_fname,
1927                                 uint32_t access_mask,
1928                                 uint32_t share_access,
1929                                 uint32_t create_disposition,
1930                                 uint32_t create_options,
1931                                 uint32_t file_attributes,
1932                                 uint32_t oplock_request,
1933                                 const struct smb2_lease *lease,
1934                                 uint64_t allocation_size,
1935                                 uint32_t private_flags,
1936                                 struct security_descriptor *sd,
1937                                 struct ea_list *ea_list,
1938                                 files_struct **result, int *pinfo,
1939                                 const struct smb2_create_blobs *in_context_blobs,
1940                                 struct smb2_create_blobs *out_context_blobs);
1941 int vfs_not_implemented_close_fn(vfs_handle_struct *handle, files_struct *fsp);
1942 ssize_t vfs_not_implemented_pread(vfs_handle_struct *handle, files_struct *fsp,
1943                                   void *data, size_t n, off_t offset);
1944 struct tevent_req *vfs_not_implemented_pread_send(struct vfs_handle_struct *handle,
1945                                                   TALLOC_CTX *mem_ctx,
1946                                                   struct tevent_context *ev,
1947                                                   struct files_struct *fsp,
1948                                                   void *data, size_t n, off_t offset);
1949 ssize_t vfs_not_implemented_pread_recv(struct tevent_req *req,
1950                                        struct vfs_aio_state *vfs_aio_state);
1951 ssize_t vfs_not_implemented_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1952                                    const void *data, size_t n, off_t offset);
1953 struct tevent_req *vfs_not_implemented_pwrite_send(struct vfs_handle_struct *handle,
1954                                                    TALLOC_CTX *mem_ctx,
1955                                                    struct tevent_context *ev,
1956                                                    struct files_struct *fsp,
1957                                                    const void *data,
1958                                                    size_t n, off_t offset);
1959 ssize_t vfs_not_implemented_pwrite_recv(struct tevent_req *req,
1960                                 struct vfs_aio_state *vfs_aio_state);
1961 off_t vfs_not_implemented_lseek(vfs_handle_struct *handle, files_struct *fsp,
1962                         off_t offset, int whence);
1963 ssize_t vfs_not_implemented_sendfile(vfs_handle_struct *handle, int tofd,
1964                                      files_struct *fromfsp, const DATA_BLOB *hdr,
1965                                      off_t offset, size_t n);
1966 ssize_t vfs_not_implemented_recvfile(vfs_handle_struct *handle, int fromfd,
1967                                      files_struct *tofsp, off_t offset, size_t n);
1968 int vfs_not_implemented_renameat(vfs_handle_struct *handle,
1969                                files_struct *srcfsp,
1970                                const struct smb_filename *smb_fname_src,
1971                                files_struct *dstfsp,
1972                                const struct smb_filename *smb_fname_dst);
1973 struct tevent_req *vfs_not_implemented_fsync_send(struct vfs_handle_struct *handle,
1974                                                   TALLOC_CTX *mem_ctx,
1975                                                   struct tevent_context *ev,
1976                                                   struct files_struct *fsp);
1977 int vfs_not_implemented_fsync_recv(struct tevent_req *req,
1978                                    struct vfs_aio_state *vfs_aio_state);
1979 int vfs_not_implemented_stat(vfs_handle_struct *handle, struct smb_filename *smb_fname);
1980 int vfs_not_implemented_fstat(vfs_handle_struct *handle, files_struct *fsp,
1981                         SMB_STRUCT_STAT *sbuf);
1982 int vfs_not_implemented_lstat(vfs_handle_struct *handle,
1983                               struct smb_filename *smb_fname);
1984 int vfs_not_implemented_fstatat(
1985         struct vfs_handle_struct *handle,
1986         const struct files_struct *dirfsp,
1987         const struct smb_filename *smb_fname,
1988         SMB_STRUCT_STAT *sbuf,
1989         int flags);
1990 uint64_t vfs_not_implemented_get_alloc_size(struct vfs_handle_struct *handle,
1991                                             struct files_struct *fsp,
1992                                             const SMB_STRUCT_STAT *sbuf);
1993 int vfs_not_implemented_unlinkat(vfs_handle_struct *handle,
1994                                 struct files_struct *dirfsp,
1995                                 const struct smb_filename *smb_fname,
1996                                 int flags);
1997 int vfs_not_implemented_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1998                                mode_t mode);
1999 int vfs_not_implemented_fchown(vfs_handle_struct *handle, files_struct *fsp,
2000                                uid_t uid, gid_t gid);
2001 int vfs_not_implemented_lchown(vfs_handle_struct *handle,
2002                                const struct smb_filename *smb_fname,
2003                                uid_t uid,
2004                                gid_t gid);
2005 int vfs_not_implemented_chdir(vfs_handle_struct *handle,
2006                               const struct smb_filename *smb_fname);
2007 struct smb_filename *vfs_not_implemented_getwd(vfs_handle_struct *handle,
2008                                                TALLOC_CTX *ctx);
2009 int vfs_not_implemented_ntimes(vfs_handle_struct *handle,
2010                                const struct smb_filename *smb_fname,
2011                                struct smb_file_time *ft);
2012 int vfs_not_implemented_fntimes(vfs_handle_struct *handle,
2013                                 files_struct *fsp,
2014                                 struct smb_file_time *ft);
2015 int vfs_not_implemented_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
2016                                   off_t offset);
2017 int vfs_not_implemented_fallocate(vfs_handle_struct *handle, files_struct *fsp,
2018                                   uint32_t mode, off_t offset, off_t len);
2019 bool vfs_not_implemented_lock(vfs_handle_struct *handle, files_struct *fsp, int op,
2020                               off_t offset, off_t count, int type);
2021 int vfs_not_implemented_filesystem_sharemode(struct vfs_handle_struct *handle,
2022                                              struct files_struct *fsp,
2023                                              uint32_t share_access,
2024                                              uint32_t access_mask);
2025 int vfs_not_implemented_fcntl(struct vfs_handle_struct *handle,
2026                               struct files_struct *fsp, int cmd, va_list cmd_arg);
2027 int vfs_not_implemented_linux_setlease(struct vfs_handle_struct *handle,
2028                                        struct files_struct *fsp, int leasetype);
2029 bool vfs_not_implemented_getlock(vfs_handle_struct *handle, files_struct *fsp,
2030                                  off_t *poffset, off_t *pcount, int *ptype,
2031                                  pid_t *ppid);
2032 int vfs_not_implemented_symlinkat(vfs_handle_struct *handle,
2033                                 const struct smb_filename *link_contents,
2034                                 struct files_struct *dirfsp,
2035                                 const struct smb_filename *new_smb_fname);
2036 int vfs_not_implemented_vfs_readlinkat(vfs_handle_struct *handle,
2037                         const struct files_struct *dirfsp,
2038                         const struct smb_filename *smb_fname,
2039                         char *buf,
2040                         size_t bufsiz);
2041 int vfs_not_implemented_linkat(vfs_handle_struct *handle,
2042                         struct files_struct *srcfsp,
2043                         const struct smb_filename *old_smb_fname,
2044                         struct files_struct *dstfsp,
2045                         const struct smb_filename *new_smb_fname,
2046                         int flags);
2047 int vfs_not_implemented_mknodat(vfs_handle_struct *handle,
2048                         struct files_struct *dirfsp,
2049                         const struct smb_filename *smb_fname,
2050                         mode_t mode,
2051                         SMB_DEV_T dev);
2052 struct smb_filename *vfs_not_implemented_realpath(vfs_handle_struct *handle,
2053                                                   TALLOC_CTX *ctx,
2054                                                   const struct smb_filename *smb_fname);
2055 int vfs_not_implemented_chflags(vfs_handle_struct *handle,
2056                                 const struct smb_filename *smb_fname,
2057                                 uint flags);
2058 int vfs_not_implemented_fchflags(vfs_handle_struct *handle,
2059                                 struct files_struct *fst,
2060                                 uint flags);
2061 struct file_id vfs_not_implemented_file_id_create(vfs_handle_struct *handle,
2062                                                   const SMB_STRUCT_STAT *sbuf);
2063 uint64_t vfs_not_implemented_fs_file_id(vfs_handle_struct *handle,
2064                                         const SMB_STRUCT_STAT *sbuf);
2065 struct tevent_req *vfs_not_implemented_offload_read_send(
2066                         TALLOC_CTX *mem_ctx,
2067                         struct tevent_context *ev,
2068                         struct vfs_handle_struct *handle,
2069                         struct files_struct *fsp,
2070                         uint32_t fsctl,
2071                         uint32_t ttl,
2072                         off_t offset,
2073                         size_t to_copy);
2074 NTSTATUS vfs_not_implemented_offload_read_recv(struct tevent_req *req,
2075                                        struct vfs_handle_struct *handle,
2076                                        TALLOC_CTX *mem_ctx,
2077                                        uint32_t *flags,
2078                                        uint64_t *xferlen,
2079                                        DATA_BLOB *_token_blob);
2080 struct tevent_req *vfs_not_implemented_offload_write_send(
2081                         struct vfs_handle_struct *handle,
2082                         TALLOC_CTX *mem_ctx,
2083                         struct tevent_context *ev,
2084                         uint32_t fsctl,
2085                         DATA_BLOB *token,
2086                         off_t transfer_offset,
2087                         struct files_struct *dest_fsp,
2088                         off_t dest_off,
2089                         off_t num);
2090 NTSTATUS vfs_not_implemented_offload_write_recv(struct vfs_handle_struct *handle,
2091                                                 struct tevent_req *req,
2092                                                 off_t *copied);
2093 NTSTATUS vfs_not_implemented_fget_compression(struct vfs_handle_struct *handle,
2094                                              TALLOC_CTX *mem_ctx,
2095                                              struct files_struct *fsp,
2096                                              uint16_t *_compression_fmt);
2097 NTSTATUS vfs_not_implemented_set_compression(struct vfs_handle_struct *handle,
2098                                              TALLOC_CTX *mem_ctx,
2099                                              struct files_struct *fsp,
2100                                              uint16_t compression_fmt);
2101 NTSTATUS vfs_not_implemented_fstreaminfo(struct vfs_handle_struct *handle,
2102                                          struct files_struct *fsp,
2103                                          TALLOC_CTX *mem_ctx,
2104                                          unsigned int *num_streams,
2105                                          struct stream_struct **streams);
2106 NTSTATUS vfs_not_implemented_get_real_filename(
2107         struct vfs_handle_struct *handle,
2108         const struct smb_filename *path,
2109         const char *name,
2110         TALLOC_CTX *mem_ctx,
2111         char **found_name);
2112 NTSTATUS vfs_not_implemented_get_real_filename_at(
2113         struct vfs_handle_struct *handle,
2114         struct files_struct *dirfsp,
2115         const char *name,
2116         TALLOC_CTX *mem_ctx,
2117         char **found_name);
2118 const char *vfs_not_implemented_connectpath(
2119         struct vfs_handle_struct *handle,
2120         const struct files_struct *dirfsp,
2121         const struct smb_filename *smb_fname);
2122 NTSTATUS vfs_not_implemented_brl_lock_windows(struct vfs_handle_struct *handle,
2123                                               struct byte_range_lock *br_lck,
2124                                               struct lock_struct *plock);
2125 bool vfs_not_implemented_brl_unlock_windows(struct vfs_handle_struct *handle,
2126                                             struct byte_range_lock *br_lck,
2127                                             const struct lock_struct *plock);
2128 bool vfs_not_implemented_strict_lock_check(struct vfs_handle_struct *handle,
2129                                            struct files_struct *fsp,
2130                                            struct lock_struct *plock);
2131 NTSTATUS vfs_not_implemented_translate_name(struct vfs_handle_struct *handle,
2132                                             const char *mapped_name,
2133                                             enum vfs_translate_direction direction,
2134                                             TALLOC_CTX *mem_ctx, char **pmapped_name);
2135 NTSTATUS vfs_not_implemented_parent_pathname(struct vfs_handle_struct *handle,
2136                                              TALLOC_CTX *mem_ctx,
2137                                              const struct smb_filename *smb_fname_in,
2138                                              struct smb_filename **parent_dir_out,
2139                                              struct smb_filename **atname_out);
2140 NTSTATUS vfs_not_implemented_fsctl(struct vfs_handle_struct *handle,
2141                                    struct files_struct *fsp,
2142                                    TALLOC_CTX *ctx,
2143                                    uint32_t function,
2144                                    uint16_t req_flags,  /* Needed for UNICODE ... */
2145                                    const uint8_t *_in_data,
2146                                    uint32_t in_len,
2147                                    uint8_t **_out_data,
2148                                    uint32_t max_out_len, uint32_t *out_len);
2149 NTSTATUS vfs_not_implemented_freaddir_attr(struct vfs_handle_struct *handle,
2150                                            struct files_struct *dirfsp,
2151                                            TALLOC_CTX *mem_ctx,
2152                                            struct readdir_attr_data **pattr_data);
2153 struct tevent_req *vfs_not_implemented_get_dos_attributes_send(
2154                         TALLOC_CTX *mem_ctx,
2155                         struct tevent_context *ev,
2156                         struct vfs_handle_struct *handle,
2157                         files_struct *dir_fsp,
2158                         struct smb_filename *smb_fname);
2159 NTSTATUS vfs_not_implemented_get_dos_attributes_recv(
2160                         struct tevent_req *req,
2161                         struct vfs_aio_state *aio_state,
2162                         uint32_t *dosmode);
2163 NTSTATUS vfs_not_implemented_fget_dos_attributes(struct vfs_handle_struct *handle,
2164                                                  struct files_struct *fsp,
2165                                                  uint32_t *dosmode);
2166 NTSTATUS vfs_not_implemented_set_dos_attributes(struct vfs_handle_struct *handle,
2167                                                 const struct smb_filename *smb_fname,
2168                                                 uint32_t dosmode);
2169 NTSTATUS vfs_not_implemented_fset_dos_attributes(struct vfs_handle_struct *handle,
2170                                                  struct files_struct *fsp,
2171                                                  uint32_t dosmode);
2172 NTSTATUS vfs_not_implemented_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
2173                                          uint32_t security_info,
2174                                          TALLOC_CTX *mem_ctx,
2175                                          struct security_descriptor **ppdesc);
2176 NTSTATUS vfs_not_implemented_get_nt_acl_at(vfs_handle_struct *handle,
2177                         struct files_struct *dirfsp,
2178                         const struct smb_filename *smb_fname,
2179                         uint32_t security_info,
2180                         TALLOC_CTX *mem_ctx,
2181                         struct security_descriptor **ppdesc);
2182 NTSTATUS vfs_not_implemented_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
2183                                          uint32_t security_info_sent,
2184                                          const struct security_descriptor *psd);
2185 SMB_ACL_T vfs_not_implemented_sys_acl_get_fd(vfs_handle_struct *handle,
2186                                              files_struct *fsp,
2187                                              SMB_ACL_TYPE_T type,
2188                                              TALLOC_CTX *mem_ctx);
2189 int vfs_not_implemented_sys_acl_blob_get_fd(vfs_handle_struct *handle,
2190                                 files_struct *fsp, TALLOC_CTX *mem_ctx,
2191                                 char **blob_description, DATA_BLOB *blob);
2192 int vfs_not_implemented_sys_acl_set_fd(vfs_handle_struct *handle,
2193                                        struct files_struct *fsp,
2194                                        SMB_ACL_TYPE_T type,
2195                                        SMB_ACL_T theacl);
2196 int vfs_not_implemented_sys_acl_delete_def_fd(vfs_handle_struct *handle,
2197                                         files_struct *fsp);
2198 struct tevent_req *vfs_not_implemented_getxattrat_send(
2199                         TALLOC_CTX *mem_ctx,
2200                         struct tevent_context *ev,
2201                         struct vfs_handle_struct *handle,
2202                         files_struct *dir_fsp,
2203                         const struct smb_filename *smb_fname,
2204                         const char *xattr_name,
2205                         size_t alloc_hint);
2206 ssize_t vfs_not_implemented_getxattrat_recv(struct tevent_req *req,
2207                                     struct vfs_aio_state *aio_state,
2208                                     TALLOC_CTX *mem_ctx,
2209                                     uint8_t **xattr_value);
2210 ssize_t vfs_not_implemented_fgetxattr(vfs_handle_struct *handle,
2211                               struct files_struct *fsp, const char *name,
2212                               void *value, size_t size);
2213 ssize_t vfs_not_implemented_listxattr(vfs_handle_struct *handle,
2214                                       const struct smb_filename *smb_fname,
2215                                       char *list,
2216                                       size_t size);
2217 ssize_t vfs_not_implemented_flistxattr(vfs_handle_struct *handle,
2218                                        struct files_struct *fsp, char *list,
2219                                        size_t size);
2220 int vfs_not_implemented_fremovexattr(vfs_handle_struct *handle,
2221                                      struct files_struct *fsp, const char *name);
2222 int vfs_not_implemented_setxattr(vfs_handle_struct *handle,
2223                                  const struct smb_filename *smb_fname,
2224                                  const char *name,
2225                                  const void *value,
2226                                  size_t size,
2227                                  int flags);
2228 int vfs_not_implemented_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,
2229                                   const char *name, const void *value, size_t size,
2230                                   int flags);
2231 bool vfs_not_implemented_aio_force(struct vfs_handle_struct *handle,
2232                                    struct files_struct *fsp);
2233 NTSTATUS vfs_not_implemented_audit_file(struct vfs_handle_struct *handle,
2234                                         struct smb_filename *file,
2235                                         struct security_acl *sacl,
2236                                         uint32_t access_requested,
2237                                         uint32_t access_denied);
2238 NTSTATUS vfs_not_implemented_durable_cookie(struct vfs_handle_struct *handle,
2239                                             struct files_struct *fsp,
2240                                             TALLOC_CTX *mem_ctx,
2241                                             DATA_BLOB *cookie);
2242 NTSTATUS vfs_not_implemented_durable_disconnect(struct vfs_handle_struct *handle,
2243                                                 struct files_struct *fsp,
2244                                                 const DATA_BLOB old_cookie,
2245                                                 TALLOC_CTX *mem_ctx,
2246                                                 DATA_BLOB *new_cookie);
2247 NTSTATUS vfs_not_implemented_durable_reconnect(struct vfs_handle_struct *handle,
2248                                                struct smb_request *smb1req,
2249                                                struct smbXsrv_open *op,
2250                                                const DATA_BLOB old_cookie,
2251                                                TALLOC_CTX *mem_ctx,
2252                                                struct files_struct **fsp,
2253                                                DATA_BLOB *new_cookie);
2254 #endif /* _VFS_H */