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