s4:dsdb/password_hash: split out a password_hash_needed() function
[Samba.git] / source3 / include / vfs.h
blobdca6cef8704c297ffcb803529b4b8e0a8773f594
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
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.
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.
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/>.
23 This work was sponsored by Optifacio Software Services, Inc.
26 #ifndef _VFS_H
27 #define _VFS_H
29 /* Avoid conflict with an AIX include file */
31 #ifdef vfs_ops
32 #undef vfs_ops
33 #endif
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...
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.
45 * If you change anything here, please also update modules/vfs_full_audit.c.
46 * VL.
49 /* Changed to version 2 for CIFS UNIX extensions (mknod and link added). JRA. */
50 /* Changed to version 3 for POSIX acl extensions. JRA. */
51 /* Changed to version 4 for cascaded VFS interface. Alexander Bokovoy. */
52 /* Changed to version 5 for sendfile addition. JRA. */
53 /* Changed to version 6 for the new module system, fixed cascading and quota functions. --metze */
54 /* Changed to version 7 to include the get_nt_acl info parameter. JRA. */
55 /* Changed to version 8 includes EA calls. JRA. */
56 /* Changed to version 9 to include the get_shadow_data call. --metze */
57 /* Changed to version 10 to include pread/pwrite calls. */
58 /* Changed to version 11 to include seekdir/telldir/rewinddir calls. JRA */
59 /* Changed to version 12 to add mask and attributes to opendir(). JRA
60 Also include aio calls. JRA. */
61 /* Changed to version 13 as the internal structure of files_struct has changed. JRA */
62 /* Changed to version 14 as we had to change DIR to SMB_STRUCT_DIR. JRA */
63 /* Changed to version 15 as we added the statvfs call. JRA */
64 /* Changed to version 16 as we added the getlock call. JRA */
65 /* Changed to version 17 as we removed redundant connection_struct parameters. --jpeach */
66 /* Changed to version 18 to add fsp parameter to the open call -- jpeach
67 Also include kernel_flock call - jmcd */
68 /* Changed to version 19, kernel change notify has been merged
69 Also included linux setlease call - jmcd */
70 /* Changed to version 20, use ntimes call instead of utime (greater
71 * timestamp resolition. JRA. */
72 /* Changed to version21 to add chflags operation -- jpeach */
73 /* Changed to version22 to add lchown operation -- jra */
74 /* Leave at 22 - not yet released. But change set_nt_acl to return an NTSTATUS. jra. */
75 /* Leave at 22 - not yet released. Add file_id_create operation. --metze */
76 /* Leave at 22 - not yet released. Change all BOOL parameters (int) to bool. jra. */
77 /* Leave at 22 - not yet released. Added recvfile. */
78 /* Leave at 22 - not yet released. Change get_nt_acl to return NTSTATUS - vl */
79 /* Leave at 22 - not yet released. Change get_nt_acl to *not* take a
80 * files_struct. - obnox.*/
81 /* Leave at 22 - not yet released. Remove parameter fd from fget_nt_acl. - obnox */
82 /* Leave at 22 - not yet released. Remove parameter fd from gset_nt_acl. - obnox */
83 /* Leave at 22 - not yet released. Remove parameter fd from pread. - obnox */
84 /* Leave at 22 - not yet released. Remove parameter fd from pwrite. - obnox */
85 /* Leave at 22 - not yet released. Remove parameter fd from lseek. - obnox */
86 /* Leave at 22 - not yet released. Remove parameter fd from fsync. - obnox */
87 /* Leave at 22 - not yet released. Remove parameter fd from fstat. - obnox */
88 /* Leave at 22 - not yet released. Remove parameter fd from fchmod. - obnox */
89 /* Leave at 22 - not yet released. Remove parameter fd from fchown. - obnox */
90 /* Leave at 22 - not yet released. Remove parameter fd from ftruncate. - obnox */
91 /* Leave at 22 - not yet released. Remove parameter fd from lock. - obnox */
92 /* Leave at 22 - not yet released. Remove parameter fd from kernel_flock. - obnox */
93 /* Leave at 22 - not yet released. Remove parameter fd from linux_setlease. - obnox */
94 /* Leave at 22 - not yet released. Remove parameter fd from getlock. - obnox */
95 /* Leave at 22 - not yet released. Remove parameter fd from sys_acl_get_fd. - obnox */
96 /* Leave at 22 - not yet released. Remove parameter fd from fchmod_acl. - obnox */
97 /* Leave at 22 - not yet released. Remove parameter fd from sys_acl_set_fd. - obnox */
98 /* Leave at 22 - not yet released. Remove parameter fd from fgetxattr. - obnox */
99 /* Leave at 22 - not yet released. Remove parameter fd from flistxattr. - obnox */
100 /* Leave at 22 - not yet released. Remove parameter fd from fremovexattr. - obnox */
101 /* Leave at 22 - not yet released. Remove parameter fd from fsetxattr. - obnox */
102 /* Leave at 22 - not yet released. Remove parameter fd from aio_cancel. - obnox */
103 /* Leave at 22 - not yet released. Remove parameter fd from read. - obnox */
104 /* Leave at 22 - not yet released. Remove parameter fd from write. - obnox */
105 /* Leave at 22 - not yet released. Remove parameter fromfd from sendfile. - obnox */
106 /* Leave at 22 - not yet released. Remove parameter fromfd from recvfile. - obnox */
107 /* Leave at 22 - not yet released. Additional change: add operations for offline files -- ab */
108 /* Leave at 22 - not yet released. Add the streaminfo call. -- jpeach, vl */
109 /* Leave at 22 - not yet released. Remove parameter fd from close_fn. - obnox */
110 /* Changed to version 23 - remove set_nt_acl call. This can only be done via an
111 open handle. JRA. */
112 /* Changed to version 24 - make security descriptor const in fset_nt_acl. JRA. */
113 /* Changed to version 25 - Jelmer's change from SMB_BIG_UINT to uint64_t. */
114 /* Leave at 25 - not yet released. Add create_file call. -- tprouty. */
115 /* Leave at 25 - not yet released. Add create time to ntimes. -- tstecher. */
116 /* Leave at 25 - not yet released. Add get_alloc_size call. -- tprouty. */
117 /* Leave at 25 - not yet released. Add SMB_STRUCT_STAT to readdir. - sdann */
118 /* Leave at 25 - not yet released. Add init_search_op call. - sdann */
119 /* Leave at 25 - not yet released. Add locking calls. -- zkirsch. */
120 /* Leave at 25 - not yet released. Add strict locking calls. -- drichards. */
121 /* Changed to version 26 - Plumb struct smb_filename to SMB_VFS_CREATE_FILE,
122 SMB_VFS_OPEN, SMB_VFS_STAT, SMB_VFS_LSTAT,
123 SMB_VFS_RENAME, SMB_VFS_UNLINK, SMB_VFS_NTIMES. */
124 /* Changed to version 27 - not yet released. Added enum timestamp_set_resolution
125 * return to fs_capabilities call. JRA. */
126 /* Leave at 27 - not yet released. Add translate_name VFS call to convert
127 UNIX names to Windows supported names -- asrinivasan. */
128 /* Changed to version 28 - Add private_flags uint32_t to CREATE call. */
129 /* Leave at 28 - not yet released. Change realpath to assume NULL and return a
130 malloc'ed path. JRA. */
131 /* Leave at 28 - not yet released. Move posix_fallocate into the VFS
132 where it belongs. JRA. */
133 /* Leave at 28 - not yet released. Rename posix_fallocate to fallocate
134 to split out the two possible uses. JRA. */
135 /* Leave at 28 - not yet released. Add fdopendir. JRA. */
136 /* Leave at 28 - not yet released. Rename open function to open_fn. - gd */
137 /* Leave at 28 - not yet released. Make getwd function always return malloced memory. JRA. */
138 /* Bump to version 29 - Samba 3.6.0 will ship with interface version 28. */
139 /* Leave at 29 - not yet releases. Add fsctl. Richard Sharpe */
140 /* Leave at 29 - not yet released. add SMB_VFS_GET_DFS_REFERRAL() - metze */
141 /* Leave at 29 - not yet released. Remove l{list,get,set,remove}xattr - abartlet */
142 /* Leave at 29 - not yet released. move to plain off_t - abartlet */
143 /* Leave at 29 - not yet released. Remove sys_acl functions other than set and get - abartlet */
144 /* Leave at 29 - not yet released. Added backup_intent bool to files_struct - JRA */
145 /* Leave at 29 - not yet released. Add durable handle functions - metze/obnox */
146 /* Leave at 29 - not yet released. Added sys_acl_blob_get_file and sys_acl_blob_get_fd */
147 /* Bump to version 30 - Samba 4.0.0 will ship with interface version 30 */
148 /* Leave at 30 - not yet released. Added conn->cwd to save vfs_GetWd() calls. */
149 /* Leave at 30 - not yet released. Changed sys_acl_blob_get_file interface to remove type */
150 /* Bump to version 31 - Samba 4.1.0 will ship with interface version 31 */
151 /* Leave at 31 - not yet released. Make struct vuid_cache_entry in
152 connection_struct a pointer. */
153 /* Leave at 31 - not yet released. Add share_access to vuid_cache_entry. */
154 /* Leave at 31 - not yet released. add SMB_VFS_COPY_CHUNK() */
155 /* Leave at 31 - not yet released. Remove the unused
156 fsp->pending_break_messages array */
157 /* Leave at 31 - not yet released. add SMB_VFS_[GET/SET]_COMPRESSION() */
159 /* Bump to version 32 - Samba 4.2 will ship with that. */
160 /* Version 32 - Add "lease" to CREATE_FILE operation */
161 /* Version 32 - Add "lease" to struct files_struct */
162 /* Version 32 - Add SMB_VFS_READDIR_ATTR() */
163 /* Version 32 - Add in and out create context blobs to create_file */
164 /* Version 32 - Remove unnecessary SMB_VFS_DISK_FREE() small_query parameter */
165 /* Bump to version 33 - Samba 4.3 will ship with that. */
166 /* Version 33 - change fallocate mode flags param from enum->uint32_t */
167 /* Version 33 - Add snapshot create/delete calls */
168 /* Version 33 - Add OS X SMB2 AAPL copyfile extension flag to fsp */
169 /* Version 33 - Remove notify_watch_fn */
170 /* Bump to version 34 - Samba 4.4 will ship with that */
171 /* Version 34 - Remove bool posix_open, add uint64_t posix_flags */
172 /* Version 34 - Added bool posix_pathnames to struct smb_request */
173 /* Bump to version 35 - Samba 4.5 will ship with that */
174 /* Version 35 - Change get_nt_acl_fn from const char *, to
175 const struct smb_filename * */
176 /* Version 35 - Change mkdir from const char *, to
177 const struct smb_filename * */
178 /* Version 35 - Change rmdir from const char *, to
179 const struct smb_filename * */
180 /* Version 35 - Change opendir from const char *, to
181 const struct smb_filename * */
182 /* Version 35 - Wrap aio async funtions args in a struct vfs_aio_state */
183 /* Version 35 - Change chmod from const char *, to
184 const struct smb_filename * */
185 /* Version 35 - Change chmod_acl from const char *, to
186 const struct smb_filename * */
187 /* Version 35 - Change chown from const char *, to
188 const struct smb_filename * */
189 /* Version 35 - Change lchown from const char *, to
190 const struct smb_filename * */
191 /* Version 35 - Change streaminfo from const char *, to
192 const struct smb_filename * */
193 /* Version 35 - Add uint32_t flags to struct smb_filename */
194 /* Version 35 - Add get/set/fget/fset dos attribute functions. */
195 /* Version 35 - Add bool use_ofd_locks to struct files_struct */
197 #define SMB_VFS_INTERFACE_VERSION 35
200 All intercepted VFS operations must be declared as static functions inside module source
201 in order to keep smbd namespace unpolluted. See source of audit, extd_audit, fake_perms and recycle
202 example VFS modules for more details.
205 /* VFS operations structure */
207 struct vfs_handle_struct;
208 struct connection_struct;
209 struct files_struct;
210 struct security_descriptor;
211 struct vfs_statvfs_struct;
212 struct smb_request;
213 struct ea_list;
214 struct smb_file_time;
215 struct blocking_lock_record;
216 struct smb_filename;
217 struct dfs_GetDFSReferral;
219 typedef union unid_t {
220 uid_t uid;
221 gid_t gid;
222 } unid_t;
224 struct fd_handle {
225 size_t ref_count;
226 int fd;
227 uint64_t position_information;
228 off_t pos;
229 uint32_t private_options; /* NT Create options, but we only look at
230 * NTCREATEX_OPTIONS_PRIVATE_DENY_DOS and
231 * NTCREATEX_OPTIONS_PRIVATE_DENY_FCB and
232 * NTCREATEX_OPTIONS_PRIVATE_DELETE_ON_CLOSE
233 * for print files *only*, where
234 * DELETE_ON_CLOSE is not stored in the share
235 * mode database.
237 unsigned long gen_id;
240 struct fsp_lease {
241 size_t ref_count;
242 struct smbd_server_connection *sconn;
243 struct tevent_timer *timeout;
244 struct smb2_lease lease;
247 typedef struct files_struct {
248 struct files_struct *next, *prev;
249 uint64_t fnum;
250 struct smbXsrv_open *op;
251 struct connection_struct *conn;
252 struct fd_handle *fh;
253 unsigned int num_smb_operations;
254 struct file_id file_id;
255 uint64_t initial_allocation_size; /* Faked up initial allocation on disk. */
256 uint16_t file_pid;
257 uint64_t vuid; /* SMB2 compat */
258 struct write_cache *wcp;
259 struct timeval open_time;
260 uint32_t access_mask; /* NTCreateX access bits (FILE_READ_DATA etc.) */
261 uint32_t share_access; /* NTCreateX share constants (FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE). */
263 bool kernel_share_modes_taken;
265 bool update_write_time_triggered;
266 struct tevent_timer *update_write_time_event;
267 bool update_write_time_on_close;
268 struct timespec close_write_time;
269 bool write_time_forced;
271 int oplock_type;
272 struct fsp_lease *lease;
273 int sent_oplock_break;
274 struct tevent_timer *oplock_timeout;
275 struct lock_struct last_lock_failure;
276 int current_lock_count; /* Count the number of outstanding locks and pending locks. */
278 bool can_lock;
279 bool can_read;
280 bool can_write;
281 bool modified;
282 bool is_directory;
283 bool aio_write_behind;
284 bool initial_delete_on_close; /* Only set at NTCreateX if file was created. */
285 bool delete_on_close;
286 uint64_t posix_flags;
287 bool is_sparse;
288 bool backup_intent; /* Handle was successfully opened with backup intent
289 and opener has privilege to do so. */
290 bool aapl_copyfile_supported;
291 bool use_ofd_locks; /* Are we using open file description locks ? */
292 struct smb_filename *fsp_name;
293 uint32_t name_hash; /* Jenkins hash of full pathname. */
294 uint64_t mid; /* Mid of the operation that created us. */
296 struct vfs_fsp_data *vfs_extension;
297 struct fake_file_handle *fake_file_handle;
299 struct notify_change_buf *notify;
301 struct files_struct *base_fsp; /* placeholder for delete on close */
304 * Read-only cached brlock record, thrown away when the
305 * brlock.tdb seqnum changes. This avoids fetching data from
306 * the brlock.tdb on every read/write call.
308 int brlock_seqnum;
309 struct byte_range_lock *brlock_rec;
311 struct dptr_struct *dptr;
313 /* if not NULL, means this is a print file */
314 struct print_file_data *print_file;
316 unsigned num_aio_requests;
317 struct tevent_req **aio_requests;
320 * If a close request comes in while we still have aio_requests
321 * around, we need to hold back the close. When all aio_requests are
322 * done, the aio completion routines need tevent_wait_done() on
323 * this. A bit ugly, but before we have close_file() fully async
324 * possibly the simplest approach. Thanks, Jeremy for the idea.
326 struct tevent_req *deferred_close;
327 } files_struct;
329 #define FSP_POSIX_FLAGS_OPEN 0x01
330 #define FSP_POSIX_FLAGS_RENAME 0x02
331 #define FSP_POSIX_FLAGS_PATHNAMES 0x04
333 #define FSP_POSIX_FLAGS_ALL \
334 (FSP_POSIX_FLAGS_OPEN | \
335 FSP_POSIX_FLAGS_PATHNAMES | \
336 FSP_POSIX_FLAGS_RENAME)
338 struct vuid_cache_entry {
339 struct auth_session_info *session_info;
340 uint64_t vuid; /* SMB2 compat */
341 bool read_only;
342 uint32_t share_access;
345 struct vuid_cache {
346 unsigned int next_entry;
347 struct vuid_cache_entry array[VUID_CACHE_SIZE];
350 typedef struct {
351 char *name;
352 bool is_wild;
353 } name_compare_entry;
355 struct dfree_cached_info {
356 time_t last_dfree_time;
357 uint64_t dfree_ret;
358 uint64_t bsize;
359 uint64_t dfree;
360 uint64_t dsize;
363 struct share_params {
364 int service;
367 typedef struct connection_struct {
368 struct connection_struct *next, *prev;
369 struct smbd_server_connection *sconn; /* can be NULL */
370 struct smbXsrv_tcon *tcon; /* can be NULL */
371 uint32_t cnum; /* an index passed over the wire */
372 struct share_params *params;
373 bool force_user;
374 struct vuid_cache *vuid_cache;
375 bool printer;
376 bool ipc;
377 bool read_only; /* Attributes for the current user of the share. */
378 uint32_t share_access;
379 /* Does this filesystem honor
380 sub second timestamps on files
381 and directories when setting time ? */
382 enum timestamp_set_resolution ts_res;
383 char *connectpath;
384 char *origpath;
385 char *cwd; /* Working directory. */
387 struct vfs_handle_struct *vfs_handles; /* for the new plugins */
390 * This represents the user information on this connection. Depending
391 * on the vuid using this tid, this might change per SMB request.
393 struct auth_session_info *session_info;
396 * If the "force group" parameter is set, this is the primary gid that
397 * may be used in the users token, depending on the vuid using this tid.
399 gid_t force_group_gid;
401 uint64_t vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
403 time_t lastused;
404 time_t lastused_count;
405 int num_files_open;
406 unsigned int num_smb_operations; /* Count of smb operations on this tree. */
407 int encrypt_level;
408 bool encrypted_tid;
410 /* Semantics requested by the client or forced by the server config. */
411 bool case_sensitive;
412 bool case_preserve;
413 bool short_case_preserve;
415 /* Semantics provided by the underlying filesystem. */
416 int fs_capabilities;
417 /* Device number of the directory of the share mount.
418 Used to ensure unique FileIndex returns. */
419 SMB_DEV_T base_share_dev;
421 name_compare_entry *hide_list; /* Per-share list of files to return as hidden. */
422 name_compare_entry *veto_list; /* Per-share list of files to veto (never show). */
423 name_compare_entry *veto_oplock_list; /* Per-share list of files to refuse oplocks on. */
424 name_compare_entry *aio_write_behind_list; /* Per-share list of files to use aio write behind on. */
425 struct dfree_cached_info *dfree_info;
426 struct trans_state *pending_trans;
428 struct rpc_pipe_client *spoolss_pipe;
430 } connection_struct;
432 struct smbd_smb2_request;
433 struct privilege_paths;
435 struct smb_request {
436 uint8_t cmd;
437 uint16_t flags2;
438 uint16_t smbpid;
439 uint64_t mid; /* For compatibility with SMB2. */
440 uint32_t seqnum;
441 uint64_t vuid; /* For compatibility with SMB2. */
442 uint32_t tid;
443 uint8_t wct;
444 const uint16_t *vwv;
445 uint16_t buflen;
446 const uint8_t *buf;
447 const uint8_t *inbuf;
450 * Async handling in the main smb processing loop is directed by
451 * outbuf: reply_xxx routines indicate sync behaviour by putting their
452 * reply into "outbuf". If they leave it as NULL, they take care of it
453 * themselves, possibly later.
455 * If async handling is wanted, the reply_xxx routine must make sure
456 * that it talloc_move()s the smb_req somewhere else.
458 uint8_t *outbuf;
460 size_t unread_bytes;
461 bool encrypted;
462 connection_struct *conn;
463 struct smbd_server_connection *sconn;
464 struct smbXsrv_connection *xconn;
465 struct smb_perfcount_data pcd;
468 * Chained request handling
470 struct files_struct *chain_fsp;
473 * state information for async smb handling
475 void *async_priv;
478 * Back pointer to smb2 request.
480 struct smbd_smb2_request *smb2req;
483 * Pathnames used if request done
484 * under privilege.
486 struct privilege_paths *priv_paths;
489 * Request list for chained requests, we're part of it.
491 struct smb_request **chain;
493 struct timeval request_time;
495 bool posix_pathnames;
499 * Info about an alternate data stream
502 struct stream_struct {
503 off_t size;
504 off_t alloc_size;
505 char *name;
508 /* time info */
509 struct smb_file_time {
510 struct timespec mtime;
511 struct timespec atime;
512 struct timespec ctime;
513 struct timespec create_time;
517 * smb_filename
519 struct smb_filename {
520 char *base_name;
521 char *stream_name;
522 char *original_lcomp;
523 uint32_t flags;
524 SMB_STRUCT_STAT st;
528 * smb_filename flags. Define in terms of the FSP_POSIX_FLAGS_XX
529 * to keep the numeric values consistent.
532 #define SMB_FILENAME_POSIX_PATH FSP_POSIX_FLAGS_PATHNAMES
534 #define VFS_FIND(__fn__) while (handle->fns->__fn__##_fn==NULL) { \
535 handle = handle->next; \
538 enum vfs_translate_direction {
539 vfs_translate_to_unix = 0,
540 vfs_translate_to_windows
543 enum vfs_fallocate_flags {
544 VFS_FALLOCATE_FL_KEEP_SIZE = 0x0001,
545 VFS_FALLOCATE_FL_PUNCH_HOLE = 0x0002,
548 struct vfs_aio_state {
549 int error;
550 uint64_t duration;
554 Available VFS operations. These values must be in sync with vfs_ops struct
555 (struct vfs_fn_pointers and struct vfs_handle_pointers inside of struct vfs_ops).
556 In particular, if new operations are added to vfs_ops, appropriate constants
557 should be added to vfs_op_type so that order of them kept same as in vfs_ops.
559 struct shadow_copy_data;
561 struct vfs_fn_pointers {
562 /* Disk operations */
564 int (*connect_fn)(struct vfs_handle_struct *handle, const char *service, const char *user);
565 void (*disconnect_fn)(struct vfs_handle_struct *handle);
566 uint64_t (*disk_free_fn)(struct vfs_handle_struct *handle, const char *path, uint64_t *bsize,
567 uint64_t *dfree, uint64_t *dsize);
568 int (*get_quota_fn)(struct vfs_handle_struct *handle, const char *path,
569 enum SMB_QUOTA_TYPE qtype, unid_t id,
570 SMB_DISK_QUOTA *qt);
571 int (*set_quota_fn)(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt);
572 int (*get_shadow_copy_data_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, struct shadow_copy_data *shadow_copy_data, bool labels);
573 int (*statvfs_fn)(struct vfs_handle_struct *handle, const char *path, struct vfs_statvfs_struct *statbuf);
574 uint32_t (*fs_capabilities_fn)(struct vfs_handle_struct *handle, enum timestamp_set_resolution *p_ts_res);
577 * Note: that "struct dfs_GetDFSReferral *r"
578 * needs to be a valid TALLOC_CTX
580 NTSTATUS (*get_dfs_referrals_fn)(struct vfs_handle_struct *handle,
581 struct dfs_GetDFSReferral *r);
583 /* Directory operations */
585 DIR *(*opendir_fn)(struct vfs_handle_struct *handle,
586 const struct smb_filename *smb_fname,
587 const char *mask,
588 uint32_t attributes);
589 DIR *(*fdopendir_fn)(struct vfs_handle_struct *handle, files_struct *fsp, const char *mask, uint32_t attributes);
590 struct dirent *(*readdir_fn)(struct vfs_handle_struct *handle,
591 DIR *dirp,
592 SMB_STRUCT_STAT *sbuf);
593 void (*seekdir_fn)(struct vfs_handle_struct *handle, DIR *dirp, long offset);
594 long (*telldir_fn)(struct vfs_handle_struct *handle, DIR *dirp);
595 void (*rewind_dir_fn)(struct vfs_handle_struct *handle, DIR *dirp);
596 int (*mkdir_fn)(struct vfs_handle_struct *handle,
597 const struct smb_filename *smb_fname,
598 mode_t mode);
599 int (*rmdir_fn)(struct vfs_handle_struct *handle,
600 const struct smb_filename *smb_fname);
601 int (*closedir_fn)(struct vfs_handle_struct *handle, DIR *dir);
602 void (*init_search_op_fn)(struct vfs_handle_struct *handle, DIR *dirp);
604 /* File operations */
606 int (*open_fn)(struct vfs_handle_struct *handle,
607 struct smb_filename *smb_fname, files_struct *fsp,
608 int flags, mode_t mode);
609 NTSTATUS (*create_file_fn)(struct vfs_handle_struct *handle,
610 struct smb_request *req,
611 uint16_t root_dir_fid,
612 struct smb_filename *smb_fname,
613 uint32_t access_mask,
614 uint32_t share_access,
615 uint32_t create_disposition,
616 uint32_t create_options,
617 uint32_t file_attributes,
618 uint32_t oplock_request,
619 struct smb2_lease *lease,
620 uint64_t allocation_size,
621 uint32_t private_flags,
622 struct security_descriptor *sd,
623 struct ea_list *ea_list,
624 files_struct **result,
625 int *pinfo,
626 const struct smb2_create_blobs *in_context_blobs,
627 struct smb2_create_blobs *out_context_blobs);
628 int (*close_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp);
629 ssize_t (*read_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n);
630 ssize_t (*pread_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n, off_t offset);
631 struct tevent_req *(*pread_send_fn)(struct vfs_handle_struct *handle,
632 TALLOC_CTX *mem_ctx,
633 struct tevent_context *ev,
634 struct files_struct *fsp,
635 void *data,
636 size_t n, off_t offset);
637 ssize_t (*pread_recv_fn)(struct tevent_req *req, struct vfs_aio_state *state);
638 ssize_t (*write_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const void *data, size_t n);
639 ssize_t (*pwrite_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const void *data, size_t n, off_t offset);
640 struct tevent_req *(*pwrite_send_fn)(struct vfs_handle_struct *handle,
641 TALLOC_CTX *mem_ctx,
642 struct tevent_context *ev,
643 struct files_struct *fsp,
644 const void *data,
645 size_t n, off_t offset);
646 ssize_t (*pwrite_recv_fn)(struct tevent_req *req, struct vfs_aio_state *state);
647 off_t (*lseek_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, off_t offset, int whence);
648 ssize_t (*sendfile_fn)(struct vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *header, off_t offset, size_t count);
649 ssize_t (*recvfile_fn)(struct vfs_handle_struct *handle, int fromfd, files_struct *tofsp, off_t offset, size_t count);
650 int (*rename_fn)(struct vfs_handle_struct *handle,
651 const struct smb_filename *smb_fname_src,
652 const struct smb_filename *smb_fname_dst);
653 int (*fsync_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp);
654 struct tevent_req *(*fsync_send_fn)(struct vfs_handle_struct *handle,
655 TALLOC_CTX *mem_ctx,
656 struct tevent_context *ev,
657 struct files_struct *fsp);
658 int (*fsync_recv_fn)(struct tevent_req *req, struct vfs_aio_state *state);
659 int (*stat_fn)(struct vfs_handle_struct *handle, struct smb_filename *smb_fname);
660 int (*fstat_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_STAT *sbuf);
661 int (*lstat_fn)(struct vfs_handle_struct *handle, struct smb_filename *smb_filename);
662 uint64_t (*get_alloc_size_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_STAT *sbuf);
663 int (*unlink_fn)(struct vfs_handle_struct *handle,
664 const struct smb_filename *smb_fname);
665 int (*chmod_fn)(struct vfs_handle_struct *handle,
666 const struct smb_filename *smb_fname,
667 mode_t mode);
668 int (*fchmod_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, mode_t mode);
669 int (*chown_fn)(struct vfs_handle_struct *handle,
670 const struct smb_filename *smb_fname,
671 uid_t uid,
672 gid_t gid);
673 int (*fchown_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, uid_t uid, gid_t gid);
674 int (*lchown_fn)(struct vfs_handle_struct *handle,
675 const struct smb_filename *smb_fname,
676 uid_t uid,
677 gid_t gid);
678 int (*chdir_fn)(struct vfs_handle_struct *handle, const char *path);
679 char *(*getwd_fn)(struct vfs_handle_struct *handle);
680 int (*ntimes_fn)(struct vfs_handle_struct *handle,
681 const struct smb_filename *smb_fname,
682 struct smb_file_time *ft);
683 int (*ftruncate_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, off_t offset);
684 int (*fallocate_fn)(struct vfs_handle_struct *handle,
685 struct files_struct *fsp,
686 uint32_t mode,
687 off_t offset,
688 off_t len);
689 bool (*lock_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, off_t offset, off_t count, int type);
690 int (*kernel_flock_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp,
691 uint32_t share_mode, uint32_t access_mask);
692 int (*linux_setlease_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, int leasetype);
693 bool (*getlock_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, off_t *poffset, off_t *pcount, int *ptype, pid_t *ppid);
694 int (*symlink_fn)(struct vfs_handle_struct *handle, const char *oldpath, const char *newpath);
695 int (*readlink_fn)(struct vfs_handle_struct *handle, const char *path, char *buf, size_t bufsiz);
696 int (*link_fn)(struct vfs_handle_struct *handle, const char *oldpath, const char *newpath);
697 int (*mknod_fn)(struct vfs_handle_struct *handle, const char *path, mode_t mode, SMB_DEV_T dev);
698 char *(*realpath_fn)(struct vfs_handle_struct *handle, const char *path);
699 int (*chflags_fn)(struct vfs_handle_struct *handle, const char *path, unsigned int flags);
700 struct file_id (*file_id_create_fn)(struct vfs_handle_struct *handle,
701 const SMB_STRUCT_STAT *sbuf);
702 struct tevent_req *(*copy_chunk_send_fn)(struct vfs_handle_struct *handle,
703 TALLOC_CTX *mem_ctx,
704 struct tevent_context *ev,
705 struct files_struct *src_fsp,
706 off_t src_off,
707 struct files_struct *dest_fsp,
708 off_t dest_off,
709 off_t num);
710 NTSTATUS (*copy_chunk_recv_fn)(struct vfs_handle_struct *handle,
711 struct tevent_req *req,
712 off_t *copied);
713 NTSTATUS (*get_compression_fn)(struct vfs_handle_struct *handle,
714 TALLOC_CTX *mem_ctx,
715 struct files_struct *fsp,
716 struct smb_filename *smb_fname,
717 uint16_t *_compression_fmt);
718 NTSTATUS (*set_compression_fn)(struct vfs_handle_struct *handle,
719 TALLOC_CTX *mem_ctx,
720 struct files_struct *fsp,
721 uint16_t compression_fmt);
722 NTSTATUS (*snap_check_path_fn)(struct vfs_handle_struct *handle,
723 TALLOC_CTX *mem_ctx,
724 const char *service_path,
725 char **base_volume);
726 NTSTATUS (*snap_create_fn)(struct vfs_handle_struct *handle,
727 TALLOC_CTX *mem_ctx,
728 const char *base_volume,
729 time_t *tstamp,
730 bool rw,
731 char **base_path,
732 char **snap_path);
733 NTSTATUS (*snap_delete_fn)(struct vfs_handle_struct *handle,
734 TALLOC_CTX *mem_ctx,
735 char *base_path,
736 char *snap_path);
738 NTSTATUS (*streaminfo_fn)(struct vfs_handle_struct *handle,
739 struct files_struct *fsp,
740 const struct smb_filename *smb_fname,
741 TALLOC_CTX *mem_ctx,
742 unsigned int *num_streams,
743 struct stream_struct **streams);
745 int (*get_real_filename_fn)(struct vfs_handle_struct *handle,
746 const char *path,
747 const char *name,
748 TALLOC_CTX *mem_ctx,
749 char **found_name);
751 const char *(*connectpath_fn)(struct vfs_handle_struct *handle,
752 const char *filename);
754 NTSTATUS (*brl_lock_windows_fn)(struct vfs_handle_struct *handle,
755 struct byte_range_lock *br_lck,
756 struct lock_struct *plock,
757 bool blocking_lock);
759 bool (*brl_unlock_windows_fn)(struct vfs_handle_struct *handle,
760 struct messaging_context *msg_ctx,
761 struct byte_range_lock *br_lck,
762 const struct lock_struct *plock);
764 bool (*brl_cancel_windows_fn)(struct vfs_handle_struct *handle,
765 struct byte_range_lock *br_lck,
766 struct lock_struct *plock);
768 bool (*strict_lock_fn)(struct vfs_handle_struct *handle,
769 struct files_struct *fsp,
770 struct lock_struct *plock);
772 void (*strict_unlock_fn)(struct vfs_handle_struct *handle,
773 struct files_struct *fsp,
774 struct lock_struct *plock);
776 NTSTATUS (*translate_name_fn)(struct vfs_handle_struct *handle,
777 const char *name,
778 enum vfs_translate_direction direction,
779 TALLOC_CTX *mem_ctx,
780 char **mapped_name);
782 NTSTATUS (*fsctl_fn)(struct vfs_handle_struct *handle,
783 struct files_struct *fsp,
784 TALLOC_CTX *ctx,
785 uint32_t function,
786 uint16_t req_flags,
787 const uint8_t *_in_data,
788 uint32_t in_len,
789 uint8_t **_out_data,
790 uint32_t max_out_len,
791 uint32_t *out_len);
793 NTSTATUS (*get_dos_attributes_fn)(struct vfs_handle_struct *handle,
794 struct smb_filename *smb_fname,
795 uint32_t *dosmode);
797 NTSTATUS (*fget_dos_attributes_fn)(struct vfs_handle_struct *handle,
798 struct files_struct *fsp,
799 uint32_t *dosmode);
801 NTSTATUS (*set_dos_attributes_fn)(struct vfs_handle_struct *handle,
802 const struct smb_filename *smb_fname,
803 uint32_t dosmode);
805 NTSTATUS (*fset_dos_attributes_fn)(struct vfs_handle_struct *hande,
806 struct files_struct *fsp,
807 uint32_t dosmode);
809 /* NT ACL operations. */
811 NTSTATUS (*fget_nt_acl_fn)(struct vfs_handle_struct *handle,
812 struct files_struct *fsp,
813 uint32_t security_info,
814 TALLOC_CTX *mem_ctx,
815 struct security_descriptor **ppdesc);
816 NTSTATUS (*get_nt_acl_fn)(struct vfs_handle_struct *handle,
817 const struct smb_filename *smb_fname,
818 uint32_t security_info,
819 TALLOC_CTX *mem_ctx,
820 struct security_descriptor **ppdesc);
821 NTSTATUS (*fset_nt_acl_fn)(struct vfs_handle_struct *handle,
822 struct files_struct *fsp,
823 uint32_t security_info_sent,
824 const struct security_descriptor *psd);
826 NTSTATUS (*audit_file_fn)(struct vfs_handle_struct *handle,
827 struct smb_filename *file,
828 struct security_acl *sacl,
829 uint32_t access_requested,
830 uint32_t access_denied);
832 /* POSIX ACL operations. */
834 int (*chmod_acl_fn)(struct vfs_handle_struct *handle,
835 const struct smb_filename *smb_fname,
836 mode_t mode);
837 int (*fchmod_acl_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, mode_t mode);
839 SMB_ACL_T (*sys_acl_get_file_fn)(struct vfs_handle_struct *handle,
840 const char *path_p,
841 SMB_ACL_TYPE_T type,
842 TALLOC_CTX *mem_ctx);
843 SMB_ACL_T (*sys_acl_get_fd_fn)(struct vfs_handle_struct *handle,
844 struct files_struct *fsp,
845 TALLOC_CTX *mem_ctx);
846 int (*sys_acl_blob_get_file_fn)(struct vfs_handle_struct *handle,
847 const char *path_p,
848 TALLOC_CTX *mem_ctx,
849 char **blob_description,
850 DATA_BLOB *blob);
851 int (*sys_acl_blob_get_fd_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp,
852 TALLOC_CTX *mem_ctx, char **blob_description,
853 DATA_BLOB *blob);
854 int (*sys_acl_set_file_fn)(struct vfs_handle_struct *handle, const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
855 int (*sys_acl_set_fd_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_ACL_T theacl);
856 int (*sys_acl_delete_def_file_fn)(struct vfs_handle_struct *handle, const char *path);
858 /* EA operations. */
859 ssize_t (*getxattr_fn)(struct vfs_handle_struct *handle,const char *path, const char *name, void *value, size_t size);
860 ssize_t (*fgetxattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size);
861 ssize_t (*listxattr_fn)(struct vfs_handle_struct *handle, const char *path, char *list, size_t size);
862 ssize_t (*flistxattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size);
863 int (*removexattr_fn)(struct vfs_handle_struct *handle, const char *path, const char *name);
864 int (*fremovexattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name);
865 int (*setxattr_fn)(struct vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags);
866 int (*fsetxattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags);
868 /* aio operations */
869 bool (*aio_force_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp);
871 /* offline operations */
872 bool (*is_offline_fn)(struct vfs_handle_struct *handle,
873 const struct smb_filename *fname,
874 SMB_STRUCT_STAT *sbuf);
875 int (*set_offline_fn)(struct vfs_handle_struct *handle,
876 const struct smb_filename *fname);
878 /* durable handle operations */
879 NTSTATUS (*durable_cookie_fn)(struct vfs_handle_struct *handle,
880 struct files_struct *fsp,
881 TALLOC_CTX *mem_ctx,
882 DATA_BLOB *cookie);
883 NTSTATUS (*durable_disconnect_fn)(struct vfs_handle_struct *handle,
884 struct files_struct *fsp,
885 const DATA_BLOB old_cookie,
886 TALLOC_CTX *mem_ctx,
887 DATA_BLOB *new_cookie);
888 NTSTATUS (*durable_reconnect_fn)(struct vfs_handle_struct *handle,
889 struct smb_request *smb1req,
890 struct smbXsrv_open *op,
891 const DATA_BLOB old_cookie,
892 TALLOC_CTX *mem_ctx,
893 struct files_struct **fsp,
894 DATA_BLOB *new_cookie);
896 NTSTATUS (*readdir_attr_fn)(struct vfs_handle_struct *handle,
897 const struct smb_filename *fname,
898 TALLOC_CTX *mem_ctx,
899 struct readdir_attr_data **attr_data);
903 VFS operation description. Each VFS module registers an array of vfs_op_tuple to VFS subsystem,
904 which describes all operations this module is willing to intercept.
905 VFS subsystem initializes then the conn->vfs_ops and conn->vfs_opaque_ops structs
906 using this information.
909 typedef struct vfs_handle_struct {
910 struct vfs_handle_struct *next, *prev;
911 const char *param;
912 struct connection_struct *conn;
913 const struct vfs_fn_pointers *fns;
914 void *data;
915 void (*free_data)(void **data);
916 } vfs_handle_struct;
919 typedef struct vfs_statvfs_struct {
920 /* For undefined recommended transfer size return -1 in that field */
921 uint32_t OptimalTransferSize; /* bsize on some os, iosize on other os */
922 uint32_t BlockSize;
925 The next three fields are in terms of the block size.
926 (above). If block size is unknown, 4096 would be a
927 reasonable block size for a server to report.
928 Note that returning the blocks/blocksavail removes need
929 to make a second call (to QFSInfo level 0x103 to get this info.
930 UserBlockAvail is typically less than or equal to BlocksAvail,
931 if no distinction is made return the same value in each.
934 uint64_t TotalBlocks;
935 uint64_t BlocksAvail; /* bfree */
936 uint64_t UserBlocksAvail; /* bavail */
938 /* For undefined Node fields or FSID return -1 */
939 uint64_t TotalFileNodes;
940 uint64_t FreeFileNodes;
941 uint64_t FsIdentifier; /* fsid */
942 /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
943 /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
945 int FsCapabilities;
946 } vfs_statvfs_struct;
948 /* Add a new FSP extension of the given type. Returns a pointer to the
949 * extenstion data.
951 #define VFS_ADD_FSP_EXTENSION(handle, fsp, type, destroy_fn) \
952 vfs_add_fsp_extension_notype(handle, (fsp), sizeof(type), (destroy_fn))
954 /* Return a pointer to the existing FSP extension data. */
955 #define VFS_FETCH_FSP_EXTENSION(handle, fsp) \
956 vfs_fetch_fsp_extension(handle, (fsp))
958 /* Return the talloc context associated with an FSP extension. */
959 #define VFS_MEMCTX_FSP_EXTENSION(handle, fsp) \
960 vfs_memctx_fsp_extension(handle, (fsp))
962 /* Remove and destroy an FSP extension. */
963 #define VFS_REMOVE_FSP_EXTENSION(handle, fsp) \
964 vfs_remove_fsp_extension((handle), (fsp))
966 #define SMB_VFS_HANDLE_GET_DATA(handle, datap, type, ret) { \
967 if (!(handle)||((datap=(type *)(handle)->data)==NULL)) { \
968 DEBUG(0,("%s() failed to get vfs_handle->data!\n",__FUNCTION__)); \
969 ret; \
973 #define SMB_VFS_HANDLE_SET_DATA(handle, datap, free_fn, type, ret) { \
974 if (!(handle)) { \
975 DEBUG(0,("%s() failed to set handle->data!\n",__FUNCTION__)); \
976 ret; \
977 } else { \
978 if ((handle)->free_data) { \
979 (handle)->free_data(&(handle)->data); \
981 (handle)->data = (void *)datap; \
982 (handle)->free_data = free_fn; \
986 #define SMB_VFS_HANDLE_FREE_DATA(handle) { \
987 if ((handle) && (handle)->free_data) { \
988 (handle)->free_data(&(handle)->data); \
992 /* Check whether module-specific data handle was already allocated or not */
993 #define SMB_VFS_HANDLE_TEST_DATA(handle) ( !(handle) || !(handle)->data ? False : True )
995 #define SMB_VFS_OP(x) ((void *) x)
997 #define DEFAULT_VFS_MODULE_NAME "/[Default VFS]/"
999 #include "vfs_macros.h"
1001 int smb_vfs_call_connect(struct vfs_handle_struct *handle,
1002 const char *service, const char *user);
1003 void smb_vfs_call_disconnect(struct vfs_handle_struct *handle);
1004 uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
1005 const char *path, uint64_t *bsize,
1006 uint64_t *dfree, uint64_t *dsize);
1007 int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, const char *path,
1008 enum SMB_QUOTA_TYPE qtype, unid_t id,
1009 SMB_DISK_QUOTA *qt);
1010 int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,
1011 enum SMB_QUOTA_TYPE qtype, unid_t id,
1012 SMB_DISK_QUOTA *qt);
1013 int smb_vfs_call_get_shadow_copy_data(struct vfs_handle_struct *handle,
1014 struct files_struct *fsp,
1015 struct shadow_copy_data *shadow_copy_data,
1016 bool labels);
1017 int smb_vfs_call_statvfs(struct vfs_handle_struct *handle, const char *path,
1018 struct vfs_statvfs_struct *statbuf);
1019 uint32_t smb_vfs_call_fs_capabilities(struct vfs_handle_struct *handle,
1020 enum timestamp_set_resolution *p_ts_res);
1022 * Note: that "struct dfs_GetDFSReferral *r" needs to be a valid TALLOC_CTX
1024 NTSTATUS smb_vfs_call_get_dfs_referrals(struct vfs_handle_struct *handle,
1025 struct dfs_GetDFSReferral *r);
1026 DIR *smb_vfs_call_opendir(struct vfs_handle_struct *handle,
1027 const struct smb_filename *smb_fname,
1028 const char *mask,
1029 uint32_t attributes);
1030 DIR *smb_vfs_call_fdopendir(struct vfs_handle_struct *handle,
1031 struct files_struct *fsp,
1032 const char *mask,
1033 uint32_t attributes);
1034 struct dirent *smb_vfs_call_readdir(struct vfs_handle_struct *handle,
1035 DIR *dirp,
1036 SMB_STRUCT_STAT *sbuf);
1037 void smb_vfs_call_seekdir(struct vfs_handle_struct *handle,
1038 DIR *dirp, long offset);
1039 long smb_vfs_call_telldir(struct vfs_handle_struct *handle,
1040 DIR *dirp);
1041 void smb_vfs_call_rewind_dir(struct vfs_handle_struct *handle,
1042 DIR *dirp);
1043 int smb_vfs_call_mkdir(struct vfs_handle_struct *handle,
1044 const struct smb_filename *smb_fname,
1045 mode_t mode);
1046 int smb_vfs_call_rmdir(struct vfs_handle_struct *handle,
1047 const struct smb_filename *smb_fname);
1048 int smb_vfs_call_closedir(struct vfs_handle_struct *handle,
1049 DIR *dir);
1050 void smb_vfs_call_init_search_op(struct vfs_handle_struct *handle,
1051 DIR *dirp);
1052 int smb_vfs_call_open(struct vfs_handle_struct *handle,
1053 struct smb_filename *smb_fname, struct files_struct *fsp,
1054 int flags, mode_t mode);
1055 NTSTATUS smb_vfs_call_create_file(struct vfs_handle_struct *handle,
1056 struct smb_request *req,
1057 uint16_t root_dir_fid,
1058 struct smb_filename *smb_fname,
1059 uint32_t access_mask,
1060 uint32_t share_access,
1061 uint32_t create_disposition,
1062 uint32_t create_options,
1063 uint32_t file_attributes,
1064 uint32_t oplock_request,
1065 struct smb2_lease *lease,
1066 uint64_t allocation_size,
1067 uint32_t private_flags,
1068 struct security_descriptor *sd,
1069 struct ea_list *ea_list,
1070 files_struct **result,
1071 int *pinfo,
1072 const struct smb2_create_blobs *in_context_blobs,
1073 struct smb2_create_blobs *out_context_blobs);
1074 int smb_vfs_call_close(struct vfs_handle_struct *handle,
1075 struct files_struct *fsp);
1076 ssize_t smb_vfs_call_read(struct vfs_handle_struct *handle,
1077 struct files_struct *fsp, void *data, size_t n);
1078 ssize_t smb_vfs_call_pread(struct vfs_handle_struct *handle,
1079 struct files_struct *fsp, void *data, size_t n,
1080 off_t offset);
1081 struct tevent_req *smb_vfs_call_pread_send(struct vfs_handle_struct *handle,
1082 TALLOC_CTX *mem_ctx,
1083 struct tevent_context *ev,
1084 struct files_struct *fsp,
1085 void *data,
1086 size_t n, off_t offset);
1087 ssize_t SMB_VFS_PREAD_RECV(struct tevent_req *req, struct vfs_aio_state *state);
1089 ssize_t smb_vfs_call_write(struct vfs_handle_struct *handle,
1090 struct files_struct *fsp, const void *data,
1091 size_t n);
1092 ssize_t smb_vfs_call_pwrite(struct vfs_handle_struct *handle,
1093 struct files_struct *fsp, const void *data,
1094 size_t n, off_t offset);
1095 struct tevent_req *smb_vfs_call_pwrite_send(struct vfs_handle_struct *handle,
1096 TALLOC_CTX *mem_ctx,
1097 struct tevent_context *ev,
1098 struct files_struct *fsp,
1099 const void *data,
1100 size_t n, off_t offset);
1101 ssize_t SMB_VFS_PWRITE_RECV(struct tevent_req *req, struct vfs_aio_state *state);
1103 off_t smb_vfs_call_lseek(struct vfs_handle_struct *handle,
1104 struct files_struct *fsp, off_t offset,
1105 int whence);
1106 ssize_t smb_vfs_call_sendfile(struct vfs_handle_struct *handle, int tofd,
1107 files_struct *fromfsp, const DATA_BLOB *header,
1108 off_t offset, size_t count);
1109 ssize_t smb_vfs_call_recvfile(struct vfs_handle_struct *handle, int fromfd,
1110 files_struct *tofsp, off_t offset,
1111 size_t count);
1112 int smb_vfs_call_rename(struct vfs_handle_struct *handle,
1113 const struct smb_filename *smb_fname_src,
1114 const struct smb_filename *smb_fname_dst);
1115 int smb_vfs_call_fsync(struct vfs_handle_struct *handle,
1116 struct files_struct *fsp);
1118 struct tevent_req *smb_vfs_call_fsync_send(struct vfs_handle_struct *handle,
1119 TALLOC_CTX *mem_ctx,
1120 struct tevent_context *ev,
1121 struct files_struct *fsp);
1122 int SMB_VFS_FSYNC_RECV(struct tevent_req *req, struct vfs_aio_state *state);
1124 int smb_vfs_call_stat(struct vfs_handle_struct *handle,
1125 struct smb_filename *smb_fname);
1126 int smb_vfs_call_fstat(struct vfs_handle_struct *handle,
1127 struct files_struct *fsp, SMB_STRUCT_STAT *sbuf);
1128 int smb_vfs_call_lstat(struct vfs_handle_struct *handle,
1129 struct smb_filename *smb_filename);
1130 uint64_t smb_vfs_call_get_alloc_size(struct vfs_handle_struct *handle,
1131 struct files_struct *fsp,
1132 const SMB_STRUCT_STAT *sbuf);
1133 int smb_vfs_call_unlink(struct vfs_handle_struct *handle,
1134 const struct smb_filename *smb_fname);
1135 int smb_vfs_call_chmod(struct vfs_handle_struct *handle,
1136 const struct smb_filename *smb_fname,
1137 mode_t mode);
1138 int smb_vfs_call_fchmod(struct vfs_handle_struct *handle,
1139 struct files_struct *fsp, mode_t mode);
1140 int smb_vfs_call_chown(struct vfs_handle_struct *handle,
1141 const struct smb_filename *smb_fname,
1142 uid_t uid,
1143 gid_t gid);
1144 int smb_vfs_call_fchown(struct vfs_handle_struct *handle,
1145 struct files_struct *fsp, uid_t uid, gid_t gid);
1146 int smb_vfs_call_lchown(struct vfs_handle_struct *handle,
1147 const struct smb_filename *smb_fname,
1148 uid_t uid,
1149 gid_t gid);
1150 int smb_vfs_call_chdir(struct vfs_handle_struct *handle, const char *path);
1151 char *smb_vfs_call_getwd(struct vfs_handle_struct *handle);
1152 int smb_vfs_call_ntimes(struct vfs_handle_struct *handle,
1153 const struct smb_filename *smb_fname,
1154 struct smb_file_time *ft);
1155 int smb_vfs_call_ftruncate(struct vfs_handle_struct *handle,
1156 struct files_struct *fsp, off_t offset);
1157 int smb_vfs_call_fallocate(struct vfs_handle_struct *handle,
1158 struct files_struct *fsp,
1159 uint32_t mode,
1160 off_t offset,
1161 off_t len);
1162 bool smb_vfs_call_lock(struct vfs_handle_struct *handle,
1163 struct files_struct *fsp, int op, off_t offset,
1164 off_t count, int type);
1165 int smb_vfs_call_kernel_flock(struct vfs_handle_struct *handle,
1166 struct files_struct *fsp, uint32_t share_mode,
1167 uint32_t access_mask);
1168 int smb_vfs_call_linux_setlease(struct vfs_handle_struct *handle,
1169 struct files_struct *fsp, int leasetype);
1170 bool smb_vfs_call_getlock(struct vfs_handle_struct *handle,
1171 struct files_struct *fsp, off_t *poffset,
1172 off_t *pcount, int *ptype, pid_t *ppid);
1173 int smb_vfs_call_symlink(struct vfs_handle_struct *handle, const char *oldpath,
1174 const char *newpath);
1175 int smb_vfs_call_readlink(struct vfs_handle_struct *handle,
1176 const char *path, char *buf, size_t bufsiz);
1177 int smb_vfs_call_link(struct vfs_handle_struct *handle, const char *oldpath,
1178 const char *newpath);
1179 int smb_vfs_call_mknod(struct vfs_handle_struct *handle, const char *path,
1180 mode_t mode, SMB_DEV_T dev);
1181 char *smb_vfs_call_realpath(struct vfs_handle_struct *handle, const char *path);
1182 int smb_vfs_call_chflags(struct vfs_handle_struct *handle, const char *path,
1183 unsigned int flags);
1184 struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,
1185 const SMB_STRUCT_STAT *sbuf);
1186 NTSTATUS smb_vfs_call_streaminfo(struct vfs_handle_struct *handle,
1187 struct files_struct *fsp,
1188 const struct smb_filename *smb_fname,
1189 TALLOC_CTX *mem_ctx,
1190 unsigned int *num_streams,
1191 struct stream_struct **streams);
1192 int smb_vfs_call_get_real_filename(struct vfs_handle_struct *handle,
1193 const char *path, const char *name,
1194 TALLOC_CTX *mem_ctx, char **found_name);
1195 const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,
1196 const char *filename);
1197 NTSTATUS smb_vfs_call_brl_lock_windows(struct vfs_handle_struct *handle,
1198 struct byte_range_lock *br_lck,
1199 struct lock_struct *plock,
1200 bool blocking_lock);
1201 bool smb_vfs_call_brl_unlock_windows(struct vfs_handle_struct *handle,
1202 struct messaging_context *msg_ctx,
1203 struct byte_range_lock *br_lck,
1204 const struct lock_struct *plock);
1205 bool smb_vfs_call_brl_cancel_windows(struct vfs_handle_struct *handle,
1206 struct byte_range_lock *br_lck,
1207 struct lock_struct *plock);
1208 bool smb_vfs_call_strict_lock(struct vfs_handle_struct *handle,
1209 struct files_struct *fsp,
1210 struct lock_struct *plock);
1211 void smb_vfs_call_strict_unlock(struct vfs_handle_struct *handle,
1212 struct files_struct *fsp,
1213 struct lock_struct *plock);
1214 NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle,
1215 const char *name,
1216 enum vfs_translate_direction direction,
1217 TALLOC_CTX *mem_ctx,
1218 char **mapped_name);
1219 NTSTATUS smb_vfs_call_fsctl(struct vfs_handle_struct *handle,
1220 struct files_struct *fsp,
1221 TALLOC_CTX *ctx,
1222 uint32_t function,
1223 uint16_t req_flags,
1224 const uint8_t *_in_data,
1225 uint32_t in_len,
1226 uint8_t **_out_data,
1227 uint32_t max_out_len,
1228 uint32_t *out_len);
1229 NTSTATUS smb_vfs_call_get_dos_attributes(struct vfs_handle_struct *handle,
1230 struct smb_filename *smb_fname,
1231 uint32_t *dosmode);
1232 NTSTATUS smb_vfs_call_fget_dos_attributes(struct vfs_handle_struct *handle,
1233 struct files_struct *fsp,
1234 uint32_t *dosmode);
1235 NTSTATUS smb_vfs_call_set_dos_attributes(struct vfs_handle_struct *handle,
1236 const struct smb_filename *smb_fname,
1237 uint32_t dosmode);
1238 NTSTATUS smb_vfs_call_fset_dos_attributes(struct vfs_handle_struct *handle,
1239 struct files_struct *fsp,
1240 uint32_t dosmode);
1241 struct tevent_req *smb_vfs_call_copy_chunk_send(struct vfs_handle_struct *handle,
1242 TALLOC_CTX *mem_ctx,
1243 struct tevent_context *ev,
1244 struct files_struct *src_fsp,
1245 off_t src_off,
1246 struct files_struct *dest_fsp,
1247 off_t dest_off,
1248 off_t num);
1249 NTSTATUS smb_vfs_call_copy_chunk_recv(struct vfs_handle_struct *handle,
1250 struct tevent_req *req,
1251 off_t *copied);
1252 NTSTATUS smb_vfs_call_get_compression(struct vfs_handle_struct *handle,
1253 TALLOC_CTX *mem_ctx,
1254 struct files_struct *fsp,
1255 struct smb_filename *smb_fname,
1256 uint16_t *_compression_fmt);
1257 NTSTATUS smb_vfs_call_set_compression(struct vfs_handle_struct *handle,
1258 TALLOC_CTX *mem_ctx,
1259 struct files_struct *fsp,
1260 uint16_t compression_fmt);
1261 NTSTATUS smb_vfs_call_snap_check_path(vfs_handle_struct *handle,
1262 TALLOC_CTX *mem_ctx,
1263 const char *service_path,
1264 char **base_volume);
1265 NTSTATUS smb_vfs_call_snap_create(struct vfs_handle_struct *handle,
1266 TALLOC_CTX *mem_ctx,
1267 const char *base_volume,
1268 time_t *tstamp,
1269 bool rw,
1270 char **base_path,
1271 char **snap_path);
1272 NTSTATUS smb_vfs_call_snap_delete(struct vfs_handle_struct *handle,
1273 TALLOC_CTX *mem_ctx,
1274 char *base_path,
1275 char *snap_path);
1276 NTSTATUS smb_vfs_call_fget_nt_acl(struct vfs_handle_struct *handle,
1277 struct files_struct *fsp,
1278 uint32_t security_info,
1279 TALLOC_CTX *mem_ctx,
1280 struct security_descriptor **ppdesc);
1281 NTSTATUS smb_vfs_call_get_nt_acl(struct vfs_handle_struct *handle,
1282 const struct smb_filename *smb_fname,
1283 uint32_t security_info,
1284 TALLOC_CTX *mem_ctx,
1285 struct security_descriptor **ppdesc);
1286 NTSTATUS smb_vfs_call_fset_nt_acl(struct vfs_handle_struct *handle,
1287 struct files_struct *fsp,
1288 uint32_t security_info_sent,
1289 const struct security_descriptor *psd);
1290 NTSTATUS smb_vfs_call_audit_file(struct vfs_handle_struct *handle,
1291 struct smb_filename *file,
1292 struct security_acl *sacl,
1293 uint32_t access_requested,
1294 uint32_t access_denied);
1295 int smb_vfs_call_chmod_acl(struct vfs_handle_struct *handle,
1296 const struct smb_filename *file,
1297 mode_t mode);
1298 int smb_vfs_call_fchmod_acl(struct vfs_handle_struct *handle,
1299 struct files_struct *fsp, mode_t mode);
1300 SMB_ACL_T smb_vfs_call_sys_acl_get_file(struct vfs_handle_struct *handle,
1301 const char *path_p,
1302 SMB_ACL_TYPE_T type,
1303 TALLOC_CTX *mem_ctx);
1304 SMB_ACL_T smb_vfs_call_sys_acl_get_fd(struct vfs_handle_struct *handle,
1305 struct files_struct *fsp,
1306 TALLOC_CTX *mem_ctx);
1307 int smb_vfs_call_sys_acl_blob_get_file(struct vfs_handle_struct *handle,
1308 const char *path_p,
1309 TALLOC_CTX *mem_ctx,
1310 char **blob_description,
1311 DATA_BLOB *blob);
1312 int smb_vfs_call_sys_acl_blob_get_fd(struct vfs_handle_struct *handle,
1313 struct files_struct *fsp,
1314 TALLOC_CTX *mem_ctx,
1315 char **blob_description,
1316 DATA_BLOB *blob);
1317 int smb_vfs_call_sys_acl_set_file(struct vfs_handle_struct *handle,
1318 const char *name, SMB_ACL_TYPE_T acltype,
1319 SMB_ACL_T theacl);
1320 int smb_vfs_call_sys_acl_set_fd(struct vfs_handle_struct *handle,
1321 struct files_struct *fsp, SMB_ACL_T theacl);
1322 int smb_vfs_call_sys_acl_delete_def_file(struct vfs_handle_struct *handle,
1323 const char *path);
1324 ssize_t smb_vfs_call_getxattr(struct vfs_handle_struct *handle,
1325 const char *path, const char *name, void *value,
1326 size_t size);
1327 ssize_t smb_vfs_call_fgetxattr(struct vfs_handle_struct *handle,
1328 struct files_struct *fsp, const char *name,
1329 void *value, size_t size);
1330 ssize_t smb_vfs_call_listxattr(struct vfs_handle_struct *handle,
1331 const char *path, char *list, size_t size);
1332 ssize_t smb_vfs_call_llistxattr(struct vfs_handle_struct *handle,
1333 const char *path, char *list, size_t size);
1334 ssize_t smb_vfs_call_flistxattr(struct vfs_handle_struct *handle,
1335 struct files_struct *fsp, char *list,
1336 size_t size);
1337 int smb_vfs_call_removexattr(struct vfs_handle_struct *handle,
1338 const char *path, const char *name);
1339 int smb_vfs_call_fremovexattr(struct vfs_handle_struct *handle,
1340 struct files_struct *fsp, const char *name);
1341 int smb_vfs_call_setxattr(struct vfs_handle_struct *handle, const char *path,
1342 const char *name, const void *value, size_t size,
1343 int flags);
1344 int smb_vfs_call_lsetxattr(struct vfs_handle_struct *handle, const char *path,
1345 const char *name, const void *value, size_t size,
1346 int flags);
1347 int smb_vfs_call_fsetxattr(struct vfs_handle_struct *handle,
1348 struct files_struct *fsp, const char *name,
1349 const void *value, size_t size, int flags);
1350 bool smb_vfs_call_aio_force(struct vfs_handle_struct *handle,
1351 struct files_struct *fsp);
1352 bool smb_vfs_call_is_offline(struct vfs_handle_struct *handle,
1353 const struct smb_filename *fname,
1354 SMB_STRUCT_STAT *sbuf);
1355 int smb_vfs_call_set_offline(struct vfs_handle_struct *handle,
1356 const struct smb_filename *fname);
1357 NTSTATUS smb_vfs_call_durable_cookie(struct vfs_handle_struct *handle,
1358 struct files_struct *fsp,
1359 TALLOC_CTX *mem_ctx,
1360 DATA_BLOB *cookie);
1361 NTSTATUS smb_vfs_call_durable_disconnect(struct vfs_handle_struct *handle,
1362 struct files_struct *fsp,
1363 const DATA_BLOB old_cookie,
1364 TALLOC_CTX *mem_ctx,
1365 DATA_BLOB *new_cookie);
1366 NTSTATUS smb_vfs_call_durable_reconnect(struct vfs_handle_struct *handle,
1367 struct smb_request *smb1req,
1368 struct smbXsrv_open *op,
1369 const DATA_BLOB old_cookie,
1370 TALLOC_CTX *mem_ctx,
1371 struct files_struct **fsp,
1372 DATA_BLOB *new_cookie);
1373 NTSTATUS smb_vfs_call_readdir_attr(struct vfs_handle_struct *handle,
1374 const struct smb_filename *fname,
1375 TALLOC_CTX *mem_ctx,
1376 struct readdir_attr_data **attr_data);
1378 NTSTATUS smb_register_vfs(int version, const char *name,
1379 const struct vfs_fn_pointers *fns);
1380 void *vfs_add_fsp_extension_notype(vfs_handle_struct *handle,
1381 files_struct *fsp, size_t ext_size,
1382 void (*destroy_fn)(void *p_data));
1383 void vfs_remove_fsp_extension(vfs_handle_struct *handle, files_struct *fsp);
1384 void vfs_remove_all_fsp_extensions(struct files_struct *fsp);
1385 void *vfs_memctx_fsp_extension(vfs_handle_struct *handle, files_struct *fsp);
1386 void *vfs_fetch_fsp_extension(vfs_handle_struct *handle, files_struct *fsp);
1388 void smb_vfs_assert_all_fns(const struct vfs_fn_pointers* fns,
1389 const char *module);
1391 #endif /* _VFS_H */