2 Unix SMB/Netbios implementation.
4 VFS initialisation and support functions
5 Copyright (C) Tim Potter 1999
6 Copyright (C) Alexander Bokovoy 2002
7 Copyright (C) James Peach 2006
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.
27 #include "system/filesys.h"
28 #include "smbd/globals.h"
30 #include "transfer_file.h"
33 #define DBGC_CLASS DBGC_VFS
37 struct vfs_init_function_entry {
39 struct vfs_init_function_entry *prev, *next;
40 const struct vfs_fn_pointers *fns;
43 /****************************************************************************
44 maintain the list of available backends
45 ****************************************************************************/
47 static struct vfs_init_function_entry *vfs_find_backend_entry(const char *name)
49 struct vfs_init_function_entry *entry = backends;
51 DEBUG(10, ("vfs_find_backend_entry called for %s\n", name));
54 if (strcmp(entry->name, name)==0) return entry;
61 NTSTATUS smb_register_vfs(int version, const char *name,
62 const struct vfs_fn_pointers *fns)
64 struct vfs_init_function_entry *entry = backends;
66 if ((version != SMB_VFS_INTERFACE_VERSION)) {
67 DEBUG(0, ("Failed to register vfs module.\n"
68 "The module was compiled against SMB_VFS_INTERFACE_VERSION %d,\n"
69 "current SMB_VFS_INTERFACE_VERSION is %d.\n"
70 "Please recompile against the current Samba Version!\n",
71 version, SMB_VFS_INTERFACE_VERSION));
72 return NT_STATUS_OBJECT_TYPE_MISMATCH;
75 if (!name || !name[0]) {
76 DEBUG(0,("smb_register_vfs() called with NULL pointer or empty name!\n"));
77 return NT_STATUS_INVALID_PARAMETER;
80 if (vfs_find_backend_entry(name)) {
81 DEBUG(0,("VFS module %s already loaded!\n", name));
82 return NT_STATUS_OBJECT_NAME_COLLISION;
85 entry = SMB_XMALLOC_P(struct vfs_init_function_entry);
86 entry->name = smb_xstrdup(name);
89 DLIST_ADD(backends, entry);
90 DEBUG(5, ("Successfully added vfs backend '%s'\n", name));
94 /****************************************************************************
95 initialise default vfs hooks
96 ****************************************************************************/
98 static void vfs_init_default(connection_struct *conn)
100 DEBUG(3, ("Initialising default vfs hooks\n"));
101 vfs_init_custom(conn, DEFAULT_VFS_MODULE_NAME);
104 /****************************************************************************
105 initialise custom vfs hooks
106 ****************************************************************************/
108 bool vfs_init_custom(connection_struct *conn, const char *vfs_object)
110 char *module_path = NULL;
111 char *module_name = NULL;
112 char *module_param = NULL, *p;
113 vfs_handle_struct *handle;
114 const struct vfs_init_function_entry *entry;
116 if (!conn||!vfs_object||!vfs_object[0]) {
117 DEBUG(0, ("vfs_init_custom() called with NULL pointer or "
118 "empty vfs_object!\n"));
126 DEBUG(3, ("Initialising custom vfs hooks from [%s]\n", vfs_object));
128 module_path = smb_xstrdup(vfs_object);
130 p = strchr_m(module_path, ':');
135 trim_char(module_param, ' ', ' ');
138 trim_char(module_path, ' ', ' ');
140 module_name = smb_xstrdup(module_path);
142 if ((module_name[0] == '/') &&
143 (strcmp(module_path, DEFAULT_VFS_MODULE_NAME) != 0)) {
146 * Extract the module name from the path. Just use the base
147 * name of the last path component.
150 SAFE_FREE(module_name);
151 module_name = smb_xstrdup(strrchr_m(module_path, '/')+1);
153 p = strchr_m(module_name, '.');
160 /* First, try to load the module with the new module system */
161 entry = vfs_find_backend_entry(module_name);
165 DEBUG(5, ("vfs module [%s] not loaded - trying to load...\n",
168 status = smb_probe_module("vfs", module_path);
169 if (!NT_STATUS_IS_OK(status)) {
170 DEBUG(0, ("error probing vfs module '%s': %s\n",
171 module_path, nt_errstr(status)));
175 entry = vfs_find_backend_entry(module_name);
177 DEBUG(0,("Can't find a vfs module [%s]\n",vfs_object));
182 DEBUGADD(5,("Successfully loaded vfs module [%s] with the new modules system\n", vfs_object));
184 handle = TALLOC_ZERO_P(conn, vfs_handle_struct);
186 DEBUG(0,("TALLOC_ZERO() failed!\n"));
190 handle->fns = entry->fns;
192 handle->param = talloc_strdup(conn, module_param);
194 DLIST_ADD(conn->vfs_handles, handle);
196 SAFE_FREE(module_path);
197 SAFE_FREE(module_name);
201 SAFE_FREE(module_path);
202 SAFE_FREE(module_name);
206 /*****************************************************************
207 Allow VFS modules to extend files_struct with VFS-specific state.
208 This will be ok for small numbers of extensions, but might need to
209 be refactored if it becomes more widely used.
210 ******************************************************************/
212 #define EXT_DATA_AREA(e) ((uint8 *)(e) + sizeof(struct vfs_fsp_data))
214 void *vfs_add_fsp_extension_notype(vfs_handle_struct *handle,
215 files_struct *fsp, size_t ext_size,
216 void (*destroy_fn)(void *p_data))
218 struct vfs_fsp_data *ext;
221 /* Prevent VFS modules adding multiple extensions. */
222 if ((ext_data = vfs_fetch_fsp_extension(handle, fsp))) {
226 ext = (struct vfs_fsp_data *)TALLOC_ZERO(
227 handle->conn, sizeof(struct vfs_fsp_data) + ext_size);
233 ext->next = fsp->vfs_extension;
234 ext->destroy = destroy_fn;
235 fsp->vfs_extension = ext;
236 return EXT_DATA_AREA(ext);
239 void vfs_remove_fsp_extension(vfs_handle_struct *handle, files_struct *fsp)
241 struct vfs_fsp_data *curr;
242 struct vfs_fsp_data *prev;
244 for (curr = fsp->vfs_extension, prev = NULL;
246 prev = curr, curr = curr->next) {
247 if (curr->owner == handle) {
249 prev->next = curr->next;
251 fsp->vfs_extension = curr->next;
254 curr->destroy(EXT_DATA_AREA(curr));
262 void *vfs_memctx_fsp_extension(vfs_handle_struct *handle, files_struct *fsp)
264 struct vfs_fsp_data *head;
266 for (head = fsp->vfs_extension; head; head = head->next) {
267 if (head->owner == handle) {
275 void *vfs_fetch_fsp_extension(vfs_handle_struct *handle, files_struct *fsp)
277 struct vfs_fsp_data *head;
279 head = (struct vfs_fsp_data *)vfs_memctx_fsp_extension(handle, fsp);
281 return EXT_DATA_AREA(head);
289 /*****************************************************************
291 ******************************************************************/
293 bool smbd_vfs_init(connection_struct *conn)
295 const char **vfs_objects;
299 /* Normal share - initialise with disk access functions */
300 vfs_init_default(conn);
301 vfs_objects = lp_vfs_objects(SNUM(conn));
303 /* Override VFS functions if 'vfs object' was not specified*/
304 if (!vfs_objects || !vfs_objects[0])
307 for (i=0; vfs_objects[i] ;) {
311 for (j=i-1; j >= 0; j--) {
312 if (!vfs_init_custom(conn, vfs_objects[j])) {
313 DEBUG(0, ("smbd_vfs_init: vfs_init_custom failed for %s\n", vfs_objects[j]));
320 /*******************************************************************
321 Check if a file exists in the vfs.
322 ********************************************************************/
324 NTSTATUS vfs_file_exist(connection_struct *conn, struct smb_filename *smb_fname)
326 /* Only return OK if stat was successful and S_ISREG */
327 if ((SMB_VFS_STAT(conn, smb_fname) != -1) &&
328 S_ISREG(smb_fname->st.st_ex_mode)) {
332 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
335 /****************************************************************************
336 Read data from fsp on the vfs. (note: EINTR re-read differs from vfs_write_data)
337 ****************************************************************************/
339 ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count)
343 while (total < byte_count)
345 ssize_t ret = SMB_VFS_READ(fsp, buf + total,
348 if (ret == 0) return total;
357 return (ssize_t)total;
360 ssize_t vfs_pread_data(files_struct *fsp, char *buf,
361 size_t byte_count, SMB_OFF_T offset)
365 while (total < byte_count)
367 ssize_t ret = SMB_VFS_PREAD(fsp, buf + total,
368 byte_count - total, offset + total);
370 if (ret == 0) return total;
379 return (ssize_t)total;
382 /****************************************************************************
383 Write data to a fd on the vfs.
384 ****************************************************************************/
386 ssize_t vfs_write_data(struct smb_request *req,
394 if (req && req->unread_bytes) {
395 SMB_ASSERT(req->unread_bytes == N);
396 /* VFS_RECVFILE must drain the socket
397 * before returning. */
398 req->unread_bytes = 0;
399 return SMB_VFS_RECVFILE(req->sconn->sock,
406 ret = SMB_VFS_WRITE(fsp, buffer + total, N - total);
415 return (ssize_t)total;
418 ssize_t vfs_pwrite_data(struct smb_request *req,
427 if (req && req->unread_bytes) {
428 SMB_ASSERT(req->unread_bytes == N);
429 /* VFS_RECVFILE must drain the socket
430 * before returning. */
431 req->unread_bytes = 0;
432 return SMB_VFS_RECVFILE(req->sconn->sock,
439 ret = SMB_VFS_PWRITE(fsp, buffer + total, N - total,
449 return (ssize_t)total;
451 /****************************************************************************
452 An allocate file space call using the vfs interface.
453 Allocates space for a file from a filedescriptor.
454 Returns 0 on success, -1 on failure.
455 ****************************************************************************/
457 int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
460 connection_struct *conn = fsp->conn;
461 uint64_t space_avail;
462 uint64_t bsize,dfree,dsize;
466 * Actually try and commit the space on disk....
469 DEBUG(10,("vfs_allocate_file_space: file %s, len %.0f\n",
470 fsp_str_dbg(fsp), (double)len));
472 if (((SMB_OFF_T)len) < 0) {
473 DEBUG(0,("vfs_allocate_file_space: %s negative len "
474 "requested.\n", fsp_str_dbg(fsp)));
479 status = vfs_stat_fsp(fsp);
480 if (!NT_STATUS_IS_OK(status)) {
484 if (len == (uint64_t)fsp->fsp_name->st.st_ex_size)
487 if (len < (uint64_t)fsp->fsp_name->st.st_ex_size) {
488 /* Shrink - use ftruncate. */
490 DEBUG(10,("vfs_allocate_file_space: file %s, shrink. Current "
491 "size %.0f\n", fsp_str_dbg(fsp),
492 (double)fsp->fsp_name->st.st_ex_size));
494 contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_SHRINK);
496 flush_write_cache(fsp, SIZECHANGE_FLUSH);
497 if ((ret = SMB_VFS_FTRUNCATE(fsp, (SMB_OFF_T)len)) != -1) {
498 set_filelen_write_cache(fsp, len);
501 contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_ALLOC_SHRINK);
506 if (!lp_strict_allocate(SNUM(fsp->conn)))
509 /* Grow - we need to test if we have enough space. */
511 contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_GROW);
513 /* See if we have a syscall that will allocate beyond end-of-file
514 without changing EOF. */
515 ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_KEEP_SIZE, 0, len);
517 contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_ALLOC_GROW);
520 /* We changed the allocation size on disk, but not
521 EOF - exactly as required. We're done ! */
525 len -= fsp->fsp_name->st.st_ex_size;
526 len /= 1024; /* Len is now number of 1k blocks needed. */
527 space_avail = get_dfree_info(conn, fsp->fsp_name->base_name, false,
528 &bsize, &dfree, &dsize);
529 if (space_avail == (uint64_t)-1) {
533 DEBUG(10,("vfs_allocate_file_space: file %s, grow. Current size %.0f, "
534 "needed blocks = %.0f, space avail = %.0f\n",
535 fsp_str_dbg(fsp), (double)fsp->fsp_name->st.st_ex_size, (double)len,
536 (double)space_avail));
538 if (len > space_avail) {
546 /****************************************************************************
547 A vfs set_filelen call.
548 set the length of a file from a filedescriptor.
549 Returns 0 on success, -1 on failure.
550 ****************************************************************************/
552 int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len)
556 contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_SET_FILE_LEN);
558 DEBUG(10,("vfs_set_filelen: ftruncate %s to len %.0f\n",
559 fsp_str_dbg(fsp), (double)len));
560 flush_write_cache(fsp, SIZECHANGE_FLUSH);
561 if ((ret = SMB_VFS_FTRUNCATE(fsp, len)) != -1) {
562 set_filelen_write_cache(fsp, len);
563 notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
564 FILE_NOTIFY_CHANGE_SIZE
565 | FILE_NOTIFY_CHANGE_ATTRIBUTES,
566 fsp->fsp_name->base_name);
569 contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_SET_FILE_LEN);
574 /****************************************************************************
575 A slow version of fallocate. Fallback code if SMB_VFS_FALLOCATE
576 fails. Needs to be outside of the default version of SMB_VFS_FALLOCATE
577 as this is also called from the default SMB_VFS_FTRUNCATE code.
578 Always extends the file size.
579 Returns 0 on success, errno on failure.
580 ****************************************************************************/
582 #define SPARSE_BUF_WRITE_SIZE (32*1024)
584 int vfs_slow_fallocate(files_struct *fsp, SMB_OFF_T offset, SMB_OFF_T len)
590 sparse_buf = SMB_CALLOC_ARRAY(char, SPARSE_BUF_WRITE_SIZE);
597 while (total < len) {
598 size_t curr_write_size = MIN(SPARSE_BUF_WRITE_SIZE, (len - total));
600 pwrite_ret = SMB_VFS_PWRITE(fsp, sparse_buf, curr_write_size, offset + total);
601 if (pwrite_ret == -1) {
602 DEBUG(10,("vfs_slow_fallocate: SMB_VFS_PWRITE for file "
603 "%s failed with error %s\n",
604 fsp_str_dbg(fsp), strerror(errno)));
613 /****************************************************************************
614 A vfs fill sparse call.
615 Writes zeros from the end of file to len, if len is greater than EOF.
616 Used only by strict_sync.
617 Returns 0 on success, -1 on failure.
618 ****************************************************************************/
620 int vfs_fill_sparse(files_struct *fsp, SMB_OFF_T len)
627 status = vfs_stat_fsp(fsp);
628 if (!NT_STATUS_IS_OK(status)) {
632 if (len <= fsp->fsp_name->st.st_ex_size) {
637 if (S_ISFIFO(fsp->fsp_name->st.st_ex_mode)) {
642 DEBUG(10,("vfs_fill_sparse: write zeros in file %s from len %.0f to "
643 "len %.0f (%.0f bytes)\n", fsp_str_dbg(fsp),
644 (double)fsp->fsp_name->st.st_ex_size, (double)len,
645 (double)(len - fsp->fsp_name->st.st_ex_size)));
647 contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_FILL_SPARSE);
649 flush_write_cache(fsp, SIZECHANGE_FLUSH);
651 offset = fsp->fsp_name->st.st_ex_size;
652 num_to_write = len - fsp->fsp_name->st.st_ex_size;
654 /* Only do this on non-stream file handles. */
655 if (fsp->base_fsp == NULL) {
656 /* for allocation try fallocate first. This can fail on some
657 * platforms e.g. when the filesystem doesn't support it and no
658 * emulation is being done by the libc (like on AIX with JFS1). In that
659 * case we do our own emulation. fallocate implementations can
660 * return ENOTSUP or EINVAL in cases like that. */
661 ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE,
662 offset, num_to_write);
671 DEBUG(10,("vfs_fill_sparse: SMB_VFS_FALLOCATE failed with "
672 "error %d. Falling back to slow manual allocation\n", ret));
675 ret = vfs_slow_fallocate(fsp, offset, num_to_write);
684 set_filelen_write_cache(fsp, len);
687 contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_FILL_SPARSE);
691 /****************************************************************************
692 Transfer some data (n bytes) between two file_struct's.
693 ****************************************************************************/
695 static ssize_t vfs_read_fn(void *file, void *buf, size_t len)
697 struct files_struct *fsp = (struct files_struct *)file;
699 return SMB_VFS_READ(fsp, buf, len);
702 static ssize_t vfs_write_fn(void *file, const void *buf, size_t len)
704 struct files_struct *fsp = (struct files_struct *)file;
706 return SMB_VFS_WRITE(fsp, buf, len);
709 SMB_OFF_T vfs_transfer_file(files_struct *in, files_struct *out, SMB_OFF_T n)
711 return transfer_file_internal((void *)in, (void *)out, n,
712 vfs_read_fn, vfs_write_fn);
715 /*******************************************************************
716 A vfs_readdir wrapper which just returns the file name.
717 ********************************************************************/
719 const char *vfs_readdirname(connection_struct *conn, void *p,
720 SMB_STRUCT_STAT *sbuf, char **talloced)
722 SMB_STRUCT_DIRENT *ptr= NULL;
730 ptr = SMB_VFS_READDIR(conn, (DIR *)p, sbuf);
742 #ifdef HAVE_BROKEN_READDIR_NAME
743 /* using /usr/ucb/cc is BAD */
747 status = SMB_VFS_TRANSLATE_NAME(conn, dname, vfs_translate_to_windows,
748 talloc_tos(), &translated);
749 if (NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) {
753 *talloced = translated;
754 if (!NT_STATUS_IS_OK(status)) {
760 /*******************************************************************
761 A wrapper for vfs_chdir().
762 ********************************************************************/
764 int vfs_ChDir(connection_struct *conn, const char *path)
769 LastDir = SMB_STRDUP("");
772 if (strcsequal(path,"."))
775 if (*path == '/' && strcsequal(LastDir,path))
778 DEBUG(4,("vfs_ChDir to %s\n",path));
780 res = SMB_VFS_CHDIR(conn,path);
783 LastDir = SMB_STRDUP(path);
788 /*******************************************************************
789 Return the absolute current directory path - given a UNIX pathname.
790 Note that this path is returned in DOS format, not UNIX
791 format. Note this can be called with conn == NULL.
792 ********************************************************************/
794 char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
798 DATA_BLOB cache_value;
800 struct smb_filename *smb_fname_dot = NULL;
801 struct smb_filename *smb_fname_full = NULL;
806 if (!lp_getwd_cache()) {
810 status = create_synthetic_smb_fname(ctx, ".", NULL, NULL,
812 if (!NT_STATUS_IS_OK(status)) {
813 errno = map_errno_from_nt_status(status);
817 if (SMB_VFS_STAT(conn, smb_fname_dot) == -1) {
819 * Known to fail for root: the directory may be NFS-mounted
820 * and exported with root_squash (so has no root access).
822 DEBUG(1,("vfs_GetWd: couldn't stat \".\" error %s "
823 "(NFS problem ?)\n", strerror(errno) ));
827 key = vfs_file_id_from_sbuf(conn, &smb_fname_dot->st);
829 if (!memcache_lookup(smbd_memcache(), GETWD_CACHE,
830 data_blob_const(&key, sizeof(key)),
835 SMB_ASSERT((cache_value.length > 0)
836 && (cache_value.data[cache_value.length-1] == '\0'));
838 status = create_synthetic_smb_fname(ctx, (char *)cache_value.data,
839 NULL, NULL, &smb_fname_full);
840 if (!NT_STATUS_IS_OK(status)) {
841 errno = map_errno_from_nt_status(status);
845 if ((SMB_VFS_STAT(conn, smb_fname_full) == 0) &&
846 (smb_fname_dot->st.st_ex_dev == smb_fname_full->st.st_ex_dev) &&
847 (smb_fname_dot->st.st_ex_ino == smb_fname_full->st.st_ex_ino) &&
848 (S_ISDIR(smb_fname_dot->st.st_ex_mode))) {
852 result = talloc_strdup(ctx, smb_fname_full->base_name);
853 if (result == NULL) {
862 * We don't have the information to hand so rely on traditional
863 * methods. The very slow getcwd, which spawns a process on some
864 * systems, or the not quite so bad getwd.
867 if (!SMB_VFS_GETWD(conn,s)) {
868 DEBUG(0, ("vfs_GetWd: SMB_VFS_GETWD call failed: %s\n",
873 if (lp_getwd_cache() && VALID_STAT(smb_fname_dot->st)) {
874 key = vfs_file_id_from_sbuf(conn, &smb_fname_dot->st);
876 memcache_add(smbd_memcache(), GETWD_CACHE,
877 data_blob_const(&key, sizeof(key)),
878 data_blob_const(s, strlen(s)+1));
881 result = talloc_strdup(ctx, s);
882 if (result == NULL) {
887 TALLOC_FREE(smb_fname_dot);
888 TALLOC_FREE(smb_fname_full);
892 /*******************************************************************
893 Reduce a file name, removing .. elements and checking that
894 it is below dir in the heirachy. This uses realpath.
895 ********************************************************************/
897 NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
899 char *resolved_name = NULL;
902 DEBUG(3,("check_reduced_name [%s] [%s]\n", fname, conn->connectpath));
904 resolved_name = SMB_VFS_REALPATH(conn,fname);
906 if (!resolved_name) {
909 DEBUG(3,("check_reduced_name: Component not a "
910 "directory in getting realpath for "
912 return NT_STATUS_OBJECT_PATH_NOT_FOUND;
915 TALLOC_CTX *ctx = talloc_tos();
916 char *tmp_fname = NULL;
917 char *last_component = NULL;
918 /* Last component didn't exist. Remove it and try and canonicalise the directory. */
920 tmp_fname = talloc_strdup(ctx, fname);
922 return NT_STATUS_NO_MEMORY;
924 p = strrchr_m(tmp_fname, '/');
929 last_component = tmp_fname;
930 tmp_fname = talloc_strdup(ctx,
933 return NT_STATUS_NO_MEMORY;
937 resolved_name = SMB_VFS_REALPATH(conn,tmp_fname);
938 if (!resolved_name) {
939 NTSTATUS status = map_nt_error_from_unix(errno);
941 if (errno == ENOENT || errno == ENOTDIR) {
942 status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
945 DEBUG(3,("check_reduce_name: "
946 "couldn't get realpath for "
952 tmp_fname = talloc_asprintf(ctx,
957 return NT_STATUS_NO_MEMORY;
959 SAFE_FREE(resolved_name);
960 resolved_name = SMB_STRDUP(tmp_fname);
961 if (!resolved_name) {
962 DEBUG(0, ("check_reduced_name: malloc "
963 "fail for %s\n", tmp_fname));
964 return NT_STATUS_NO_MEMORY;
969 DEBUG(3,("check_reduced_name: couldn't get "
970 "realpath for %s\n", fname));
971 return map_nt_error_from_unix(errno);
975 DEBUG(10,("check_reduced_name realpath [%s] -> [%s]\n", fname,
978 if (*resolved_name != '/') {
979 DEBUG(0,("check_reduced_name: realpath doesn't return "
980 "absolute paths !\n"));
981 SAFE_FREE(resolved_name);
982 return NT_STATUS_OBJECT_NAME_INVALID;
985 /* Check for widelinks allowed. */
986 if (!lp_widelinks(SNUM(conn))) {
987 const char *conn_rootdir;
989 conn_rootdir = SMB_VFS_CONNECTPATH(conn, fname);
990 if (conn_rootdir == NULL) {
991 DEBUG(2, ("check_reduced_name: Could not get "
993 SAFE_FREE(resolved_name);
994 return NT_STATUS_ACCESS_DENIED;
997 if (strncmp(conn_rootdir, resolved_name,
998 strlen(conn_rootdir)) != 0) {
999 DEBUG(2, ("check_reduced_name: Bad access "
1000 "attempt: %s is a symlink outside the "
1001 "share path\n", fname));
1002 DEBUGADD(2, ("conn_rootdir =%s\n", conn_rootdir));
1003 DEBUGADD(2, ("resolved_name=%s\n", resolved_name));
1004 SAFE_FREE(resolved_name);
1005 return NT_STATUS_ACCESS_DENIED;
1009 /* Check if we are allowing users to follow symlinks */
1010 /* Patch from David Clerc <David.Clerc@cui.unige.ch>
1011 University of Geneva */
1014 if (!lp_symlinks(SNUM(conn))) {
1015 struct smb_filename *smb_fname = NULL;
1018 status = create_synthetic_smb_fname(talloc_tos(), fname, NULL,
1020 if (!NT_STATUS_IS_OK(status)) {
1021 SAFE_FREE(resolved_name);
1025 if ( (SMB_VFS_LSTAT(conn, smb_fname) != -1) &&
1026 (S_ISLNK(smb_fname->st.st_ex_mode)) ) {
1027 SAFE_FREE(resolved_name);
1028 DEBUG(3,("check_reduced_name: denied: file path name "
1029 "%s is a symlink\n",resolved_name));
1030 TALLOC_FREE(smb_fname);
1031 return NT_STATUS_ACCESS_DENIED;
1033 TALLOC_FREE(smb_fname);
1037 DEBUG(3,("check_reduced_name: %s reduced to %s\n", fname,
1039 SAFE_FREE(resolved_name);
1040 return NT_STATUS_OK;
1044 * XXX: This is temporary and there should be no callers of this once
1045 * smb_filename is plumbed through all path based operations.
1047 int vfs_stat_smb_fname(struct connection_struct *conn, const char *fname,
1048 SMB_STRUCT_STAT *psbuf)
1050 struct smb_filename *smb_fname = NULL;
1054 status = create_synthetic_smb_fname_split(talloc_tos(), fname, NULL,
1056 if (!NT_STATUS_IS_OK(status)) {
1057 errno = map_errno_from_nt_status(status);
1061 if (lp_posix_pathnames()) {
1062 ret = SMB_VFS_LSTAT(conn, smb_fname);
1064 ret = SMB_VFS_STAT(conn, smb_fname);
1068 *psbuf = smb_fname->st;
1071 TALLOC_FREE(smb_fname);
1076 * XXX: This is temporary and there should be no callers of this once
1077 * smb_filename is plumbed through all path based operations.
1079 int vfs_lstat_smb_fname(struct connection_struct *conn, const char *fname,
1080 SMB_STRUCT_STAT *psbuf)
1082 struct smb_filename *smb_fname = NULL;
1086 status = create_synthetic_smb_fname_split(talloc_tos(), fname, NULL,
1088 if (!NT_STATUS_IS_OK(status)) {
1089 errno = map_errno_from_nt_status(status);
1093 ret = SMB_VFS_LSTAT(conn, smb_fname);
1095 *psbuf = smb_fname->st;
1098 TALLOC_FREE(smb_fname);
1103 * Ensure LSTAT is called for POSIX paths.
1106 NTSTATUS vfs_stat_fsp(files_struct *fsp)
1110 if(fsp->fh->fd == -1) {
1111 if (fsp->posix_open) {
1112 ret = SMB_VFS_LSTAT(fsp->conn, fsp->fsp_name);
1114 ret = SMB_VFS_STAT(fsp->conn, fsp->fsp_name);
1117 return map_nt_error_from_unix(errno);
1120 if(SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st) != 0) {
1121 return map_nt_error_from_unix(errno);
1124 return NT_STATUS_OK;
1128 generate a file_id from a stat structure
1130 struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_STAT *sbuf)
1132 return SMB_VFS_FILE_ID_CREATE(conn, sbuf);
1135 int smb_vfs_call_connect(struct vfs_handle_struct *handle,
1136 const char *service, const char *user)
1138 VFS_FIND(connect_fn);
1139 return handle->fns->connect_fn(handle, service, user);
1142 void smb_vfs_call_disconnect(struct vfs_handle_struct *handle)
1144 VFS_FIND(disconnect);
1145 handle->fns->disconnect(handle);
1148 uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
1149 const char *path, bool small_query,
1150 uint64_t *bsize, uint64_t *dfree,
1153 VFS_FIND(disk_free);
1154 return handle->fns->disk_free(handle, path, small_query, bsize, dfree,
1158 int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
1159 enum SMB_QUOTA_TYPE qtype, unid_t id,
1162 VFS_FIND(get_quota);
1163 return handle->fns->get_quota(handle, qtype, id, qt);
1166 int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,
1167 enum SMB_QUOTA_TYPE qtype, unid_t id,
1170 VFS_FIND(set_quota);
1171 return handle->fns->set_quota(handle, qtype, id, qt);
1174 int smb_vfs_call_get_shadow_copy_data(struct vfs_handle_struct *handle,
1175 struct files_struct *fsp,
1176 SHADOW_COPY_DATA *shadow_copy_data,
1179 VFS_FIND(get_shadow_copy_data);
1180 return handle->fns->get_shadow_copy_data(handle, fsp, shadow_copy_data,
1183 int smb_vfs_call_statvfs(struct vfs_handle_struct *handle, const char *path,
1184 struct vfs_statvfs_struct *statbuf)
1187 return handle->fns->statvfs(handle, path, statbuf);
1190 uint32_t smb_vfs_call_fs_capabilities(struct vfs_handle_struct *handle,
1191 enum timestamp_set_resolution *p_ts_res)
1193 VFS_FIND(fs_capabilities);
1194 return handle->fns->fs_capabilities(handle, p_ts_res);
1197 SMB_STRUCT_DIR *smb_vfs_call_opendir(struct vfs_handle_struct *handle,
1198 const char *fname, const char *mask,
1202 return handle->fns->opendir(handle, fname, mask, attributes);
1205 SMB_STRUCT_DIR *smb_vfs_call_fdopendir(struct vfs_handle_struct *handle,
1206 struct files_struct *fsp,
1210 VFS_FIND(fdopendir);
1211 return handle->fns->fdopendir(handle, fsp, mask, attributes);
1214 SMB_STRUCT_DIRENT *smb_vfs_call_readdir(struct vfs_handle_struct *handle,
1215 SMB_STRUCT_DIR *dirp,
1216 SMB_STRUCT_STAT *sbuf)
1219 return handle->fns->readdir(handle, dirp, sbuf);
1222 void smb_vfs_call_seekdir(struct vfs_handle_struct *handle,
1223 SMB_STRUCT_DIR *dirp, long offset)
1226 handle->fns->seekdir(handle, dirp, offset);
1229 long smb_vfs_call_telldir(struct vfs_handle_struct *handle,
1230 SMB_STRUCT_DIR *dirp)
1233 return handle->fns->telldir(handle, dirp);
1236 void smb_vfs_call_rewind_dir(struct vfs_handle_struct *handle,
1237 SMB_STRUCT_DIR *dirp)
1239 VFS_FIND(rewind_dir);
1240 handle->fns->rewind_dir(handle, dirp);
1243 int smb_vfs_call_mkdir(struct vfs_handle_struct *handle, const char *path,
1247 return handle->fns->mkdir(handle, path, mode);
1250 int smb_vfs_call_rmdir(struct vfs_handle_struct *handle, const char *path)
1253 return handle->fns->rmdir(handle, path);
1256 int smb_vfs_call_closedir(struct vfs_handle_struct *handle,
1257 SMB_STRUCT_DIR *dir)
1260 return handle->fns->closedir(handle, dir);
1263 void smb_vfs_call_init_search_op(struct vfs_handle_struct *handle,
1264 SMB_STRUCT_DIR *dirp)
1266 VFS_FIND(init_search_op);
1267 handle->fns->init_search_op(handle, dirp);
1270 int smb_vfs_call_open(struct vfs_handle_struct *handle,
1271 struct smb_filename *smb_fname, struct files_struct *fsp,
1272 int flags, mode_t mode)
1275 return handle->fns->open(handle, smb_fname, fsp, flags, mode);
1278 NTSTATUS smb_vfs_call_create_file(struct vfs_handle_struct *handle,
1279 struct smb_request *req,
1280 uint16_t root_dir_fid,
1281 struct smb_filename *smb_fname,
1282 uint32_t access_mask,
1283 uint32_t share_access,
1284 uint32_t create_disposition,
1285 uint32_t create_options,
1286 uint32_t file_attributes,
1287 uint32_t oplock_request,
1288 uint64_t allocation_size,
1289 uint32_t private_flags,
1290 struct security_descriptor *sd,
1291 struct ea_list *ea_list,
1292 files_struct **result,
1295 VFS_FIND(create_file);
1296 return handle->fns->create_file(
1297 handle, req, root_dir_fid, smb_fname, access_mask,
1298 share_access, create_disposition, create_options,
1299 file_attributes, oplock_request, allocation_size,
1300 private_flags, sd, ea_list,
1304 int smb_vfs_call_close_fn(struct vfs_handle_struct *handle,
1305 struct files_struct *fsp)
1308 return handle->fns->close_fn(handle, fsp);
1311 ssize_t smb_vfs_call_vfs_read(struct vfs_handle_struct *handle,
1312 struct files_struct *fsp, void *data, size_t n)
1315 return handle->fns->vfs_read(handle, fsp, data, n);
1318 ssize_t smb_vfs_call_pread(struct vfs_handle_struct *handle,
1319 struct files_struct *fsp, void *data, size_t n,
1323 return handle->fns->pread(handle, fsp, data, n, offset);
1326 ssize_t smb_vfs_call_write(struct vfs_handle_struct *handle,
1327 struct files_struct *fsp, const void *data,
1331 return handle->fns->write(handle, fsp, data, n);
1334 ssize_t smb_vfs_call_pwrite(struct vfs_handle_struct *handle,
1335 struct files_struct *fsp, const void *data,
1336 size_t n, SMB_OFF_T offset)
1339 return handle->fns->pwrite(handle, fsp, data, n, offset);
1342 SMB_OFF_T smb_vfs_call_lseek(struct vfs_handle_struct *handle,
1343 struct files_struct *fsp, SMB_OFF_T offset,
1347 return handle->fns->lseek(handle, fsp, offset, whence);
1350 ssize_t smb_vfs_call_sendfile(struct vfs_handle_struct *handle, int tofd,
1351 files_struct *fromfsp, const DATA_BLOB *header,
1352 SMB_OFF_T offset, size_t count)
1355 return handle->fns->sendfile(handle, tofd, fromfsp, header, offset,
1359 ssize_t smb_vfs_call_recvfile(struct vfs_handle_struct *handle, int fromfd,
1360 files_struct *tofsp, SMB_OFF_T offset,
1364 return handle->fns->recvfile(handle, fromfd, tofsp, offset, count);
1367 int smb_vfs_call_rename(struct vfs_handle_struct *handle,
1368 const struct smb_filename *smb_fname_src,
1369 const struct smb_filename *smb_fname_dst)
1372 return handle->fns->rename(handle, smb_fname_src, smb_fname_dst);
1375 int smb_vfs_call_fsync(struct vfs_handle_struct *handle,
1376 struct files_struct *fsp)
1379 return handle->fns->fsync(handle, fsp);
1382 int smb_vfs_call_stat(struct vfs_handle_struct *handle,
1383 struct smb_filename *smb_fname)
1386 return handle->fns->stat(handle, smb_fname);
1389 int smb_vfs_call_fstat(struct vfs_handle_struct *handle,
1390 struct files_struct *fsp, SMB_STRUCT_STAT *sbuf)
1393 return handle->fns->fstat(handle, fsp, sbuf);
1396 int smb_vfs_call_lstat(struct vfs_handle_struct *handle,
1397 struct smb_filename *smb_filename)
1400 return handle->fns->lstat(handle, smb_filename);
1403 uint64_t smb_vfs_call_get_alloc_size(struct vfs_handle_struct *handle,
1404 struct files_struct *fsp,
1405 const SMB_STRUCT_STAT *sbuf)
1407 VFS_FIND(get_alloc_size);
1408 return handle->fns->get_alloc_size(handle, fsp, sbuf);
1411 int smb_vfs_call_unlink(struct vfs_handle_struct *handle,
1412 const struct smb_filename *smb_fname)
1415 return handle->fns->unlink(handle, smb_fname);
1418 int smb_vfs_call_chmod(struct vfs_handle_struct *handle, const char *path,
1422 return handle->fns->chmod(handle, path, mode);
1425 int smb_vfs_call_fchmod(struct vfs_handle_struct *handle,
1426 struct files_struct *fsp, mode_t mode)
1429 return handle->fns->fchmod(handle, fsp, mode);
1432 int smb_vfs_call_chown(struct vfs_handle_struct *handle, const char *path,
1433 uid_t uid, gid_t gid)
1436 return handle->fns->chown(handle, path, uid, gid);
1439 int smb_vfs_call_fchown(struct vfs_handle_struct *handle,
1440 struct files_struct *fsp, uid_t uid, gid_t gid)
1443 return handle->fns->fchown(handle, fsp, uid, gid);
1446 int smb_vfs_call_lchown(struct vfs_handle_struct *handle, const char *path,
1447 uid_t uid, gid_t gid)
1450 return handle->fns->lchown(handle, path, uid, gid);
1453 NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid)
1457 if (fsp->fh->fd != -1) {
1459 ret = SMB_VFS_FCHOWN(fsp, uid, gid);
1461 return NT_STATUS_OK;
1463 if (ret == -1 && errno != ENOSYS) {
1464 return map_nt_error_from_unix(errno);
1468 if (fsp->posix_open) {
1469 ret = SMB_VFS_LCHOWN(fsp->conn,
1470 fsp->fsp_name->base_name,
1473 ret = SMB_VFS_CHOWN(fsp->conn,
1474 fsp->fsp_name->base_name,
1478 return NT_STATUS_OK;
1480 return map_nt_error_from_unix(errno);
1483 int smb_vfs_call_chdir(struct vfs_handle_struct *handle, const char *path)
1486 return handle->fns->chdir(handle, path);
1489 char *smb_vfs_call_getwd(struct vfs_handle_struct *handle, char *buf)
1492 return handle->fns->getwd(handle, buf);
1495 int smb_vfs_call_ntimes(struct vfs_handle_struct *handle,
1496 const struct smb_filename *smb_fname,
1497 struct smb_file_time *ft)
1500 return handle->fns->ntimes(handle, smb_fname, ft);
1503 int smb_vfs_call_ftruncate(struct vfs_handle_struct *handle,
1504 struct files_struct *fsp, SMB_OFF_T offset)
1506 VFS_FIND(ftruncate);
1507 return handle->fns->ftruncate(handle, fsp, offset);
1510 int smb_vfs_call_fallocate(struct vfs_handle_struct *handle,
1511 struct files_struct *fsp,
1512 enum vfs_fallocate_mode mode,
1516 VFS_FIND(fallocate);
1517 return handle->fns->fallocate(handle, fsp, mode, offset, len);
1520 int smb_vfs_call_kernel_flock(struct vfs_handle_struct *handle,
1521 struct files_struct *fsp, uint32 share_mode,
1522 uint32_t access_mask)
1524 VFS_FIND(kernel_flock);
1525 return handle->fns->kernel_flock(handle, fsp, share_mode,
1529 int smb_vfs_call_linux_setlease(struct vfs_handle_struct *handle,
1530 struct files_struct *fsp, int leasetype)
1532 VFS_FIND(linux_setlease);
1533 return handle->fns->linux_setlease(handle, fsp, leasetype);
1536 int smb_vfs_call_symlink(struct vfs_handle_struct *handle, const char *oldpath,
1537 const char *newpath)
1540 return handle->fns->symlink(handle, oldpath, newpath);
1543 int smb_vfs_call_vfs_readlink(struct vfs_handle_struct *handle,
1544 const char *path, char *buf, size_t bufsiz)
1546 VFS_FIND(vfs_readlink);
1547 return handle->fns->vfs_readlink(handle, path, buf, bufsiz);
1550 int smb_vfs_call_link(struct vfs_handle_struct *handle, const char *oldpath,
1551 const char *newpath)
1554 return handle->fns->link(handle, oldpath, newpath);
1557 int smb_vfs_call_mknod(struct vfs_handle_struct *handle, const char *path,
1558 mode_t mode, SMB_DEV_T dev)
1561 return handle->fns->mknod(handle, path, mode, dev);
1564 char *smb_vfs_call_realpath(struct vfs_handle_struct *handle, const char *path)
1567 return handle->fns->realpath(handle, path);
1570 NTSTATUS smb_vfs_call_notify_watch(struct vfs_handle_struct *handle,
1571 struct sys_notify_context *ctx,
1572 struct notify_entry *e,
1573 void (*callback)(struct sys_notify_context *ctx,
1575 struct notify_event *ev),
1576 void *private_data, void *handle_p)
1578 VFS_FIND(notify_watch);
1579 return handle->fns->notify_watch(handle, ctx, e, callback,
1580 private_data, handle_p);
1583 int smb_vfs_call_chflags(struct vfs_handle_struct *handle, const char *path,
1587 return handle->fns->chflags(handle, path, flags);
1590 struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,
1591 const SMB_STRUCT_STAT *sbuf)
1593 VFS_FIND(file_id_create);
1594 return handle->fns->file_id_create(handle, sbuf);
1597 NTSTATUS smb_vfs_call_streaminfo(struct vfs_handle_struct *handle,
1598 struct files_struct *fsp,
1600 TALLOC_CTX *mem_ctx,
1601 unsigned int *num_streams,
1602 struct stream_struct **streams)
1604 VFS_FIND(streaminfo);
1605 return handle->fns->streaminfo(handle, fsp, fname, mem_ctx,
1606 num_streams, streams);
1609 int smb_vfs_call_get_real_filename(struct vfs_handle_struct *handle,
1610 const char *path, const char *name,
1611 TALLOC_CTX *mem_ctx, char **found_name)
1613 VFS_FIND(get_real_filename);
1614 return handle->fns->get_real_filename(handle, path, name, mem_ctx,
1618 const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,
1619 const char *filename)
1621 VFS_FIND(connectpath);
1622 return handle->fns->connectpath(handle, filename);
1625 bool smb_vfs_call_strict_lock(struct vfs_handle_struct *handle,
1626 struct files_struct *fsp,
1627 struct lock_struct *plock)
1629 VFS_FIND(strict_lock);
1630 return handle->fns->strict_lock(handle, fsp, plock);
1633 void smb_vfs_call_strict_unlock(struct vfs_handle_struct *handle,
1634 struct files_struct *fsp,
1635 struct lock_struct *plock)
1637 VFS_FIND(strict_unlock);
1638 handle->fns->strict_unlock(handle, fsp, plock);
1641 NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle,
1643 enum vfs_translate_direction direction,
1644 TALLOC_CTX *mem_ctx,
1647 VFS_FIND(translate_name);
1648 return handle->fns->translate_name(handle, name, direction, mem_ctx,
1652 NTSTATUS smb_vfs_call_fget_nt_acl(struct vfs_handle_struct *handle,
1653 struct files_struct *fsp,
1654 uint32 security_info,
1655 struct security_descriptor **ppdesc)
1657 VFS_FIND(fget_nt_acl);
1658 return handle->fns->fget_nt_acl(handle, fsp, security_info,
1662 NTSTATUS smb_vfs_call_get_nt_acl(struct vfs_handle_struct *handle,
1664 uint32 security_info,
1665 struct security_descriptor **ppdesc)
1667 VFS_FIND(get_nt_acl);
1668 return handle->fns->get_nt_acl(handle, name, security_info, ppdesc);
1671 NTSTATUS smb_vfs_call_fset_nt_acl(struct vfs_handle_struct *handle,
1672 struct files_struct *fsp,
1673 uint32 security_info_sent,
1674 const struct security_descriptor *psd)
1676 VFS_FIND(fset_nt_acl);
1677 return handle->fns->fset_nt_acl(handle, fsp, security_info_sent, psd);
1680 int smb_vfs_call_chmod_acl(struct vfs_handle_struct *handle, const char *name,
1683 VFS_FIND(chmod_acl);
1684 return handle->fns->chmod_acl(handle, name, mode);
1687 int smb_vfs_call_fchmod_acl(struct vfs_handle_struct *handle,
1688 struct files_struct *fsp, mode_t mode)
1690 VFS_FIND(fchmod_acl);
1691 return handle->fns->fchmod_acl(handle, fsp, mode);
1694 int smb_vfs_call_sys_acl_get_entry(struct vfs_handle_struct *handle,
1695 SMB_ACL_T theacl, int entry_id,
1696 SMB_ACL_ENTRY_T *entry_p)
1698 VFS_FIND(sys_acl_get_entry);
1699 return handle->fns->sys_acl_get_entry(handle, theacl, entry_id,
1703 int smb_vfs_call_sys_acl_get_tag_type(struct vfs_handle_struct *handle,
1704 SMB_ACL_ENTRY_T entry_d,
1705 SMB_ACL_TAG_T *tag_type_p)
1707 VFS_FIND(sys_acl_get_tag_type);
1708 return handle->fns->sys_acl_get_tag_type(handle, entry_d, tag_type_p);
1711 int smb_vfs_call_sys_acl_get_permset(struct vfs_handle_struct *handle,
1712 SMB_ACL_ENTRY_T entry_d,
1713 SMB_ACL_PERMSET_T *permset_p)
1715 VFS_FIND(sys_acl_get_permset);
1716 return handle->fns->sys_acl_get_permset(handle, entry_d, permset_p);
1719 void * smb_vfs_call_sys_acl_get_qualifier(struct vfs_handle_struct *handle,
1720 SMB_ACL_ENTRY_T entry_d)
1722 VFS_FIND(sys_acl_get_qualifier);
1723 return handle->fns->sys_acl_get_qualifier(handle, entry_d);
1726 SMB_ACL_T smb_vfs_call_sys_acl_get_file(struct vfs_handle_struct *handle,
1728 SMB_ACL_TYPE_T type)
1730 VFS_FIND(sys_acl_get_file);
1731 return handle->fns->sys_acl_get_file(handle, path_p, type);
1734 SMB_ACL_T smb_vfs_call_sys_acl_get_fd(struct vfs_handle_struct *handle,
1735 struct files_struct *fsp)
1737 VFS_FIND(sys_acl_get_fd);
1738 return handle->fns->sys_acl_get_fd(handle, fsp);
1741 int smb_vfs_call_sys_acl_clear_perms(struct vfs_handle_struct *handle,
1742 SMB_ACL_PERMSET_T permset)
1744 VFS_FIND(sys_acl_clear_perms);
1745 return handle->fns->sys_acl_clear_perms(handle, permset);
1748 int smb_vfs_call_sys_acl_add_perm(struct vfs_handle_struct *handle,
1749 SMB_ACL_PERMSET_T permset,
1750 SMB_ACL_PERM_T perm)
1752 VFS_FIND(sys_acl_add_perm);
1753 return handle->fns->sys_acl_add_perm(handle, permset, perm);
1756 char * smb_vfs_call_sys_acl_to_text(struct vfs_handle_struct *handle,
1757 SMB_ACL_T theacl, ssize_t *plen)
1759 VFS_FIND(sys_acl_to_text);
1760 return handle->fns->sys_acl_to_text(handle, theacl, plen);
1763 SMB_ACL_T smb_vfs_call_sys_acl_init(struct vfs_handle_struct *handle,
1766 VFS_FIND(sys_acl_init);
1767 return handle->fns->sys_acl_init(handle, count);
1770 int smb_vfs_call_sys_acl_create_entry(struct vfs_handle_struct *handle,
1771 SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry)
1773 VFS_FIND(sys_acl_create_entry);
1774 return handle->fns->sys_acl_create_entry(handle, pacl, pentry);
1777 int smb_vfs_call_sys_acl_set_tag_type(struct vfs_handle_struct *handle,
1778 SMB_ACL_ENTRY_T entry,
1779 SMB_ACL_TAG_T tagtype)
1781 VFS_FIND(sys_acl_set_tag_type);
1782 return handle->fns->sys_acl_set_tag_type(handle, entry, tagtype);
1785 int smb_vfs_call_sys_acl_set_qualifier(struct vfs_handle_struct *handle,
1786 SMB_ACL_ENTRY_T entry, void *qual)
1788 VFS_FIND(sys_acl_set_qualifier);
1789 return handle->fns->sys_acl_set_qualifier(handle, entry, qual);
1792 int smb_vfs_call_sys_acl_set_permset(struct vfs_handle_struct *handle,
1793 SMB_ACL_ENTRY_T entry,
1794 SMB_ACL_PERMSET_T permset)
1796 VFS_FIND(sys_acl_set_permset);
1797 return handle->fns->sys_acl_set_permset(handle, entry, permset);
1800 int smb_vfs_call_sys_acl_valid(struct vfs_handle_struct *handle,
1803 VFS_FIND(sys_acl_valid);
1804 return handle->fns->sys_acl_valid(handle, theacl);
1807 int smb_vfs_call_sys_acl_set_file(struct vfs_handle_struct *handle,
1808 const char *name, SMB_ACL_TYPE_T acltype,
1811 VFS_FIND(sys_acl_set_file);
1812 return handle->fns->sys_acl_set_file(handle, name, acltype, theacl);
1815 int smb_vfs_call_sys_acl_set_fd(struct vfs_handle_struct *handle,
1816 struct files_struct *fsp, SMB_ACL_T theacl)
1818 VFS_FIND(sys_acl_set_fd);
1819 return handle->fns->sys_acl_set_fd(handle, fsp, theacl);
1822 int smb_vfs_call_sys_acl_delete_def_file(struct vfs_handle_struct *handle,
1825 VFS_FIND(sys_acl_delete_def_file);
1826 return handle->fns->sys_acl_delete_def_file(handle, path);
1829 int smb_vfs_call_sys_acl_get_perm(struct vfs_handle_struct *handle,
1830 SMB_ACL_PERMSET_T permset,
1831 SMB_ACL_PERM_T perm)
1833 VFS_FIND(sys_acl_get_perm);
1834 return handle->fns->sys_acl_get_perm(handle, permset, perm);
1837 int smb_vfs_call_sys_acl_free_text(struct vfs_handle_struct *handle,
1840 VFS_FIND(sys_acl_free_text);
1841 return handle->fns->sys_acl_free_text(handle, text);
1844 int smb_vfs_call_sys_acl_free_acl(struct vfs_handle_struct *handle,
1845 SMB_ACL_T posix_acl)
1847 VFS_FIND(sys_acl_free_acl);
1848 return handle->fns->sys_acl_free_acl(handle, posix_acl);
1851 int smb_vfs_call_sys_acl_free_qualifier(struct vfs_handle_struct *handle,
1852 void *qualifier, SMB_ACL_TAG_T tagtype)
1854 VFS_FIND(sys_acl_free_qualifier);
1855 return handle->fns->sys_acl_free_qualifier(handle, qualifier, tagtype);
1858 ssize_t smb_vfs_call_getxattr(struct vfs_handle_struct *handle,
1859 const char *path, const char *name, void *value,
1863 return handle->fns->getxattr(handle, path, name, value, size);
1866 ssize_t smb_vfs_call_lgetxattr(struct vfs_handle_struct *handle,
1867 const char *path, const char *name, void *value,
1870 VFS_FIND(lgetxattr);
1871 return handle->fns->lgetxattr(handle, path, name, value, size);
1874 ssize_t smb_vfs_call_fgetxattr(struct vfs_handle_struct *handle,
1875 struct files_struct *fsp, const char *name,
1876 void *value, size_t size)
1878 VFS_FIND(fgetxattr);
1879 return handle->fns->fgetxattr(handle, fsp, name, value, size);
1882 ssize_t smb_vfs_call_listxattr(struct vfs_handle_struct *handle,
1883 const char *path, char *list, size_t size)
1885 VFS_FIND(listxattr);
1886 return handle->fns->listxattr(handle, path, list, size);
1889 ssize_t smb_vfs_call_llistxattr(struct vfs_handle_struct *handle,
1890 const char *path, char *list, size_t size)
1892 VFS_FIND(llistxattr);
1893 return handle->fns->llistxattr(handle, path, list, size);
1896 ssize_t smb_vfs_call_flistxattr(struct vfs_handle_struct *handle,
1897 struct files_struct *fsp, char *list,
1900 VFS_FIND(flistxattr);
1901 return handle->fns->flistxattr(handle, fsp, list, size);
1904 int smb_vfs_call_removexattr(struct vfs_handle_struct *handle,
1905 const char *path, const char *name)
1907 VFS_FIND(removexattr);
1908 return handle->fns->removexattr(handle, path, name);
1911 int smb_vfs_call_lremovexattr(struct vfs_handle_struct *handle,
1912 const char *path, const char *name)
1914 VFS_FIND(lremovexattr);
1915 return handle->fns->lremovexattr(handle, path, name);
1918 int smb_vfs_call_fremovexattr(struct vfs_handle_struct *handle,
1919 struct files_struct *fsp, const char *name)
1921 VFS_FIND(fremovexattr);
1922 return handle->fns->fremovexattr(handle, fsp, name);
1925 int smb_vfs_call_setxattr(struct vfs_handle_struct *handle, const char *path,
1926 const char *name, const void *value, size_t size,
1930 return handle->fns->setxattr(handle, path, name, value, size, flags);
1933 int smb_vfs_call_lsetxattr(struct vfs_handle_struct *handle, const char *path,
1934 const char *name, const void *value, size_t size,
1937 VFS_FIND(lsetxattr);
1938 return handle->fns->lsetxattr(handle, path, name, value, size, flags);
1941 int smb_vfs_call_fsetxattr(struct vfs_handle_struct *handle,
1942 struct files_struct *fsp, const char *name,
1943 const void *value, size_t size, int flags)
1945 VFS_FIND(fsetxattr);
1946 return handle->fns->fsetxattr(handle, fsp, name, value, size, flags);
1949 int smb_vfs_call_aio_read(struct vfs_handle_struct *handle,
1950 struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1953 return handle->fns->aio_read(handle, fsp, aiocb);
1956 int smb_vfs_call_aio_write(struct vfs_handle_struct *handle,
1957 struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1959 VFS_FIND(aio_write);
1960 return handle->fns->aio_write(handle, fsp, aiocb);
1963 ssize_t smb_vfs_call_aio_return_fn(struct vfs_handle_struct *handle,
1964 struct files_struct *fsp,
1965 SMB_STRUCT_AIOCB *aiocb)
1967 VFS_FIND(aio_return_fn);
1968 return handle->fns->aio_return_fn(handle, fsp, aiocb);
1971 int smb_vfs_call_aio_cancel(struct vfs_handle_struct *handle,
1972 struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1974 VFS_FIND(aio_cancel);
1975 return handle->fns->aio_cancel(handle, fsp, aiocb);
1978 int smb_vfs_call_aio_error_fn(struct vfs_handle_struct *handle,
1979 struct files_struct *fsp,
1980 SMB_STRUCT_AIOCB *aiocb)
1982 VFS_FIND(aio_error_fn);
1983 return handle->fns->aio_error_fn(handle, fsp, aiocb);
1986 int smb_vfs_call_aio_fsync(struct vfs_handle_struct *handle,
1987 struct files_struct *fsp, int op,
1988 SMB_STRUCT_AIOCB *aiocb)
1990 VFS_FIND(aio_fsync);
1991 return handle->fns->aio_fsync(handle, fsp, op, aiocb);
1994 int smb_vfs_call_aio_suspend(struct vfs_handle_struct *handle,
1995 struct files_struct *fsp,
1996 const SMB_STRUCT_AIOCB * const aiocb[], int n,
1997 const struct timespec *timeout)
1999 VFS_FIND(aio_suspend);
2000 return handle->fns->aio_suspend(handle, fsp, aiocb, n, timeout);
2003 bool smb_vfs_call_aio_force(struct vfs_handle_struct *handle,
2004 struct files_struct *fsp)
2006 VFS_FIND(aio_force);
2007 return handle->fns->aio_force(handle, fsp);
2010 bool smb_vfs_call_is_offline(struct vfs_handle_struct *handle,
2011 const struct smb_filename *fname,
2012 SMB_STRUCT_STAT *sbuf)
2014 VFS_FIND(is_offline);
2015 return handle->fns->is_offline(handle, fname, sbuf);
2018 int smb_vfs_call_set_offline(struct vfs_handle_struct *handle,
2019 const struct smb_filename *fname)
2021 VFS_FIND(set_offline);
2022 return handle->fns->set_offline(handle, fname);