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