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