LCOV - code coverage report
Current view: top level - source3/smbd - vfs.c (source / functions) Hit Total Coverage
Test: coverage report for recycleplus df22b230 Lines: 517 967 53.5 %
Date: 2024-02-14 10:14:15 Functions: 97 145 66.9 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/Netbios implementation.
       3             :    Version 1.9.
       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
       9             : 
      10             :    This program is free software; you can redistribute it and/or modify
      11             :    it under the terms of the GNU General Public License as published by
      12             :    the Free Software Foundation; either version 3 of the License, or
      13             :    (at your option) any later version.
      14             : 
      15             :    This program is distributed in the hope that it will be useful,
      16             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      17             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      18             :    GNU General Public License for more details.
      19             : 
      20             :    You should have received a copy of the GNU General Public License
      21             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      22             : 
      23             :    This work was sponsored by Optifacio Software Services, Inc.
      24             : */
      25             : 
      26             : #include "includes.h"
      27             : #include "system/filesys.h"
      28             : #include "smbd/smbd.h"
      29             : #include "smbd/globals.h"
      30             : #include "../lib/util/memcache.h"
      31             : #include "transfer_file.h"
      32             : #include "ntioctl.h"
      33             : #include "lib/util/tevent_unix.h"
      34             : #include "lib/util/tevent_ntstatus.h"
      35             : #include "lib/util/sys_rw.h"
      36             : 
      37             : #undef DBGC_CLASS
      38             : #define DBGC_CLASS DBGC_VFS
      39             : 
      40             : static_decl_vfs;
      41             : 
      42             : struct vfs_fsp_data {
      43             :     struct vfs_fsp_data *next;
      44             :     struct vfs_handle_struct *owner;
      45             :     void (*destroy)(void *p_data);
      46             :     void *_dummy_;
      47             :     /* NOTE: This structure contains four pointers so that we can guarantee
      48             :      * that the end of the structure is always both 4-byte and 8-byte aligned.
      49             :      */
      50             : };
      51             : 
      52             : struct vfs_init_function_entry {
      53             :         char *name;
      54             :         struct vfs_init_function_entry *prev, *next;
      55             :         const struct vfs_fn_pointers *fns;
      56             : };
      57             : 
      58             : /****************************************************************************
      59             :     maintain the list of available backends
      60             : ****************************************************************************/
      61             : 
      62      114300 : static struct vfs_init_function_entry *vfs_find_backend_entry(const char *name)
      63             : {
      64      114300 :         struct vfs_init_function_entry *entry = backends;
      65             : 
      66      114300 :         DEBUG(10, ("vfs_find_backend_entry called for %s\n", name));
      67             : 
      68      533797 :         while(entry) {
      69      469862 :                 if (strcmp(entry->name, name)==0) return entry;
      70      419497 :                 entry = entry->next;
      71             :         }
      72             : 
      73       63935 :         return NULL;
      74             : }
      75             : 
      76       42385 : NTSTATUS smb_register_vfs(int version, const char *name,
      77             :                           const struct vfs_fn_pointers *fns)
      78             : {
      79       42385 :         struct vfs_init_function_entry *entry = backends;
      80             : 
      81       42385 :         if ((version != SMB_VFS_INTERFACE_VERSION)) {
      82           0 :                 DEBUG(0, ("Failed to register vfs module.\n"
      83             :                           "The module was compiled against SMB_VFS_INTERFACE_VERSION %d,\n"
      84             :                           "current SMB_VFS_INTERFACE_VERSION is %d.\n"
      85             :                           "Please recompile against the current Samba Version!\n",  
      86             :                           version, SMB_VFS_INTERFACE_VERSION));
      87           0 :                 return NT_STATUS_OBJECT_TYPE_MISMATCH;
      88             :         }
      89             : 
      90       42385 :         if (!name || !name[0]) {
      91           0 :                 DEBUG(0,("smb_register_vfs() called with NULL pointer or empty name!\n"));
      92           0 :                 return NT_STATUS_INVALID_PARAMETER;
      93             :         }
      94             : 
      95       42385 :         if (vfs_find_backend_entry(name)) {
      96           0 :                 DEBUG(0,("VFS module %s already loaded!\n", name));
      97           0 :                 return NT_STATUS_OBJECT_NAME_COLLISION;
      98             :         }
      99             : 
     100       42385 :         entry = SMB_XMALLOC_P(struct vfs_init_function_entry);
     101       42385 :         entry->name = smb_xstrdup(name);
     102       42385 :         entry->fns = fns;
     103             : 
     104       42385 :         DLIST_ADD(backends, entry);
     105       42385 :         DEBUG(5, ("Successfully added vfs backend '%s'\n", name));
     106       42385 :         return NT_STATUS_OK;
     107             : }
     108             : 
     109             : /****************************************************************************
     110             :   initialise default vfs hooks
     111             : ****************************************************************************/
     112             : 
     113        7970 : static void vfs_init_default(connection_struct *conn)
     114             : {
     115        7970 :         DEBUG(3, ("Initialising default vfs hooks\n"));
     116        7970 :         vfs_init_custom(conn, DEFAULT_VFS_MODULE_NAME);
     117        7970 : }
     118             : 
     119             : /****************************************************************************
     120             :   initialise custom vfs hooks
     121             :  ****************************************************************************/
     122             : 
     123       50365 : bool vfs_init_custom(connection_struct *conn, const char *vfs_object)
     124             : {
     125       50365 :         char *module_path = NULL;
     126       50365 :         char *module_name = NULL;
     127       50365 :         char *module_param = NULL, *p;
     128             :         vfs_handle_struct *handle;
     129             :         const struct vfs_init_function_entry *entry;
     130             : 
     131       50365 :         if (!conn||!vfs_object||!vfs_object[0]) {
     132           0 :                 DEBUG(0, ("vfs_init_custom() called with NULL pointer or "
     133             :                           "empty vfs_object!\n"));
     134           0 :                 return False;
     135             :         }
     136             : 
     137       50365 :         if(!backends) {
     138        4869 :                 static_init_vfs(NULL);
     139             :         }
     140             : 
     141       50365 :         DEBUG(3, ("Initialising custom vfs hooks from [%s]\n", vfs_object));
     142             : 
     143       50365 :         module_path = smb_xstrdup(vfs_object);
     144             : 
     145       50365 :         p = strchr_m(module_path, ':');
     146             : 
     147       50365 :         if (p) {
     148           0 :                 *p = 0;
     149           0 :                 module_param = p+1;
     150           0 :                 trim_char(module_param, ' ', ' ');
     151             :         }
     152             : 
     153       50365 :         trim_char(module_path, ' ', ' ');
     154             : 
     155       50365 :         module_name = smb_xstrdup(module_path);
     156             : 
     157       50365 :         if ((module_name[0] == '/') &&
     158        7970 :             (strcmp(module_path, DEFAULT_VFS_MODULE_NAME) != 0)) {
     159             : 
     160             :                 /*
     161             :                  * Extract the module name from the path. Just use the base
     162             :                  * name of the last path component.
     163             :                  */
     164             : 
     165           0 :                 SAFE_FREE(module_name);
     166           0 :                 module_name = smb_xstrdup(strrchr_m(module_path, '/')+1);
     167             : 
     168           0 :                 p = strchr_m(module_name, '.');
     169             : 
     170           0 :                 if (p != NULL) {
     171           0 :                         *p = '\0';
     172             :                 }
     173             :         }
     174             : 
     175             :         /* First, try to load the module with the new module system */
     176       50365 :         entry = vfs_find_backend_entry(module_name);
     177       50365 :         if (!entry) {
     178             :                 NTSTATUS status;
     179             : 
     180       21550 :                 DEBUG(5, ("vfs module [%s] not loaded - trying to load...\n",
     181             :                           vfs_object));
     182             : 
     183       21550 :                 status = smb_load_module("vfs", module_path);
     184       21550 :                 if (!NT_STATUS_IS_OK(status)) {
     185           0 :                         DEBUG(0, ("error probing vfs module '%s': %s\n",
     186             :                                   module_path, nt_errstr(status)));
     187           0 :                         goto fail;
     188             :                 }
     189             : 
     190       21550 :                 entry = vfs_find_backend_entry(module_name);
     191       21550 :                 if (!entry) {
     192           0 :                         DEBUG(0,("Can't find a vfs module [%s]\n",vfs_object));
     193           0 :                         goto fail;
     194             :                 }
     195             :         }
     196             : 
     197       50365 :         DEBUGADD(5,("Successfully loaded vfs module [%s] with the new modules system\n", vfs_object));
     198             : 
     199       50365 :         handle = talloc_zero(conn, vfs_handle_struct);
     200       50365 :         if (!handle) {
     201           0 :                 DEBUG(0,("TALLOC_ZERO() failed!\n"));
     202           0 :                 goto fail;
     203             :         }
     204       50365 :         handle->conn = conn;
     205       50365 :         handle->fns = entry->fns;
     206       50365 :         if (module_param) {
     207           0 :                 handle->param = talloc_strdup(conn, module_param);
     208             :         }
     209       50365 :         DLIST_ADD(conn->vfs_handles, handle);
     210             : 
     211       50365 :         SAFE_FREE(module_path);
     212       50365 :         SAFE_FREE(module_name);
     213       50365 :         return True;
     214             : 
     215           0 :  fail:
     216           0 :         SAFE_FREE(module_path);
     217           0 :         SAFE_FREE(module_name);
     218           0 :         return False;
     219             : }
     220             : 
     221             : /*****************************************************************
     222             :  Allow VFS modules to extend files_struct with VFS-specific state.
     223             :  This will be ok for small numbers of extensions, but might need to
     224             :  be refactored if it becomes more widely used.
     225             : ******************************************************************/
     226             : 
     227             : #define EXT_DATA_AREA(e) ((uint8_t *)(e) + sizeof(struct vfs_fsp_data))
     228             : 
     229        2406 : void *vfs_add_fsp_extension_notype(vfs_handle_struct *handle,
     230             :                                    files_struct *fsp, size_t ext_size,
     231             :                                    void (*destroy_fn)(void *p_data))
     232             : {
     233             :         struct vfs_fsp_data *ext;
     234             :         void * ext_data;
     235             : 
     236             :         /* Prevent VFS modules adding multiple extensions. */
     237        2406 :         if ((ext_data = vfs_fetch_fsp_extension(handle, fsp))) {
     238           0 :                 return ext_data;
     239             :         }
     240             : 
     241        2406 :         ext = talloc_zero_size(
     242             :                 handle->conn, sizeof(struct vfs_fsp_data) + ext_size);
     243        2406 :         if (ext == NULL) {
     244           0 :                 return NULL;
     245             :         }
     246             : 
     247        2406 :         ext->owner = handle;
     248        2406 :         ext->next = fsp->vfs_extension;
     249        2406 :         ext->destroy = destroy_fn;
     250        2406 :         fsp->vfs_extension = ext;
     251        2406 :         return EXT_DATA_AREA(ext);
     252             : }
     253             : 
     254        2382 : void vfs_remove_fsp_extension(vfs_handle_struct *handle, files_struct *fsp)
     255             : {
     256             :         struct vfs_fsp_data *curr;
     257             :         struct vfs_fsp_data *prev;
     258             : 
     259        2382 :         for (curr = fsp->vfs_extension, prev = NULL;
     260        2382 :              curr;
     261           0 :              prev = curr, curr = curr->next) {
     262        2382 :                 if (curr->owner == handle) {
     263        2382 :                     if (prev) {
     264           0 :                             prev->next = curr->next;
     265             :                     } else {
     266        2382 :                             fsp->vfs_extension = curr->next;
     267             :                     }
     268        2382 :                     if (curr->destroy) {
     269           0 :                             curr->destroy(EXT_DATA_AREA(curr));
     270             :                     }
     271        2382 :                     TALLOC_FREE(curr);
     272        2382 :                     return;
     273             :                 }
     274             :         }
     275             : }
     276             : 
     277      146984 : void vfs_remove_all_fsp_extensions(files_struct *fsp)
     278             : {
     279             :         struct vfs_fsp_data *curr;
     280             :         struct vfs_fsp_data *next;
     281             : 
     282      147008 :         for (curr = fsp->vfs_extension; curr; curr = next) {
     283             : 
     284          24 :                 next = curr->next;
     285          24 :                 fsp->vfs_extension = next;
     286             : 
     287          24 :                 if (curr->destroy) {
     288           0 :                         curr->destroy(EXT_DATA_AREA(curr));
     289             :                 }
     290          24 :                 TALLOC_FREE(curr);
     291             :         }
     292      146984 : }
     293             : 
     294        4820 : void *vfs_memctx_fsp_extension(vfs_handle_struct *handle,
     295             :                                const struct files_struct *fsp)
     296             : {
     297             :         struct vfs_fsp_data *head;
     298             : 
     299        4820 :         for (head = fsp->vfs_extension; head; head = head->next) {
     300        1781 :                 if (head->owner == handle) {
     301        1781 :                         return head;
     302             :                 }
     303             :         }
     304             : 
     305        3039 :         return NULL;
     306             : }
     307             : 
     308        4772 : void *vfs_fetch_fsp_extension(vfs_handle_struct *handle,
     309             :                               const struct files_struct *fsp)
     310             : {
     311             :         struct vfs_fsp_data *head;
     312             : 
     313        4772 :         head = (struct vfs_fsp_data *)vfs_memctx_fsp_extension(handle, fsp);
     314        4772 :         if (head != NULL) {
     315        1733 :                 return EXT_DATA_AREA(head);
     316             :         }
     317             : 
     318        3039 :         return NULL;
     319             : }
     320             : 
     321             : #undef EXT_DATA_AREA
     322             : 
     323             : /*
     324             :  * Ensure this module catches all VFS functions.
     325             :  */
     326             : #ifdef DEVELOPER
     327       12036 : void smb_vfs_assert_all_fns(const struct vfs_fn_pointers* fns,
     328             :                             const char *module)
     329             : {
     330       12036 :         bool missing_fn = false;
     331             :         unsigned int idx;
     332       12036 :         const uintptr_t *end = (const uintptr_t *)(fns + 1);
     333             : 
     334     1215636 :         for (idx = 0; ((const uintptr_t *)fns + idx) < end; idx++) {
     335     1203600 :                 if (*((const uintptr_t *)fns + idx) == 0) {
     336           0 :                         DBG_ERR("VFS function at index %d not implemented "
     337             :                                 "in module %s\n", idx, module);
     338           0 :                         missing_fn = true;
     339             :                 }
     340             :         }
     341             : 
     342       12036 :         if (missing_fn) {
     343           0 :                 smb_panic("Required VFS function not implemented in module.\n");
     344             :         }
     345       12036 : }
     346             : #else
     347             : void smb_vfs_assert_all_fns(const struct vfs_fn_pointers* fns,
     348             :                             const char *module)
     349             : {
     350             : }
     351             : #endif
     352             : 
     353             : /*****************************************************************
     354             :  Generic VFS init.
     355             : ******************************************************************/
     356             : 
     357        7970 : bool smbd_vfs_init(connection_struct *conn)
     358             : {
     359             :         const char **vfs_objects;
     360        7970 :         unsigned int i = 0;
     361        7970 :         int j = 0;
     362             : 
     363             :         /* Normal share - initialise with disk access functions */
     364        7970 :         vfs_init_default(conn);
     365             : 
     366             :         /* No need to load vfs modules for printer connections */
     367        7970 :         if (conn->printer) {
     368           0 :                 return True;
     369             :         }
     370             : 
     371        7970 :         if (lp_widelinks(SNUM(conn))) {
     372             :                 /*
     373             :                  * As the widelinks logic is now moving into a
     374             :                  * vfs_widelinks module, we need to custom load
     375             :                  * it after the default module is initialized.
     376             :                  * That way no changes to smb.conf files are
     377             :                  * needed.
     378             :                  */
     379           8 :                 bool ok = vfs_init_custom(conn, "widelinks");
     380           8 :                 if (!ok) {
     381           0 :                         DBG_ERR("widelinks enabled and vfs_init_custom "
     382             :                                 "failed for vfs_widelinks module\n");
     383           0 :                         return false;
     384             :                 }
     385             :         }
     386             : 
     387        7970 :         vfs_objects = lp_vfs_objects(SNUM(conn));
     388             : 
     389             :         /* Override VFS functions if 'vfs object' was not specified*/
     390        7970 :         if (!vfs_objects || !vfs_objects[0])
     391           0 :                 return True;
     392             : 
     393       50357 :         for (i=0; vfs_objects[i] ;) {
     394       42387 :                 i++;
     395             :         }
     396             : 
     397       50357 :         for (j=i-1; j >= 0; j--) {
     398       42387 :                 if (!vfs_init_custom(conn, vfs_objects[j])) {
     399           0 :                         DEBUG(0, ("smbd_vfs_init: vfs_init_custom failed for %s\n", vfs_objects[j]));
     400           0 :                         return False;
     401             :                 }
     402             :         }
     403        7970 :         return True;
     404             : }
     405             : 
     406             : /*******************************************************************
     407             :  Check if a file exists in the vfs.
     408             : ********************************************************************/
     409             : 
     410           0 : NTSTATUS vfs_file_exist(connection_struct *conn, struct smb_filename *smb_fname)
     411             : {
     412             :         /* Only return OK if stat was successful and S_ISREG */
     413           0 :         if ((SMB_VFS_STAT(conn, smb_fname) != -1) &&
     414           0 :             S_ISREG(smb_fname->st.st_ex_mode)) {
     415           0 :                 return NT_STATUS_OK;
     416             :         }
     417             : 
     418           0 :         return NT_STATUS_OBJECT_NAME_NOT_FOUND;
     419             : }
     420             : 
     421         376 : bool vfs_valid_pread_range(off_t offset, size_t length)
     422             : {
     423         376 :         return sys_valid_io_range(offset, length);
     424             : }
     425             : 
     426         492 : bool vfs_valid_pwrite_range(off_t offset, size_t length)
     427             : {
     428             :         /*
     429             :          * See MAXFILESIZE in [MS-FSA] 2.1.5.3 Server Requests a Write
     430             :          */
     431             :         static const uint64_t maxfilesize = 0xfffffff0000;
     432             :         uint64_t last_byte_ofs;
     433             :         bool ok;
     434             : 
     435         492 :         ok = sys_valid_io_range(offset, length);
     436         492 :         if (!ok) {
     437           0 :                 return false;
     438             :         }
     439             : 
     440         492 :         if (length == 0) {
     441          18 :                 return true;
     442             :         }
     443             : 
     444         474 :         last_byte_ofs = offset + length;
     445         474 :         if (last_byte_ofs > maxfilesize) {
     446           0 :                 return false;
     447             :         }
     448             : 
     449         474 :         return true;
     450             : }
     451             : 
     452          24 : ssize_t vfs_pwrite_data(struct smb_request *req,
     453             :                         files_struct *fsp,
     454             :                         const char *buffer,
     455             :                         size_t N,
     456             :                         off_t offset)
     457             : {
     458          24 :         size_t total=0;
     459             :         ssize_t ret;
     460             :         bool ok;
     461             : 
     462          24 :         ok = vfs_valid_pwrite_range(offset, N);
     463          24 :         if (!ok) {
     464           0 :                 errno = EINVAL;
     465           0 :                 return -1;
     466             :         }
     467             : 
     468          24 :         if (req && req->unread_bytes) {
     469           0 :                 int sockfd = req->xconn->transport.sock;
     470           0 :                 SMB_ASSERT(req->unread_bytes == N);
     471             :                 /* VFS_RECVFILE must drain the socket
     472             :                  * before returning. */
     473           0 :                 req->unread_bytes = 0;
     474             :                 /*
     475             :                  * Leave the socket non-blocking and
     476             :                  * use SMB_VFS_RECVFILE. If it returns
     477             :                  * EAGAIN || EWOULDBLOCK temporarily set
     478             :                  * the socket blocking and retry
     479             :                  * the RECVFILE.
     480             :                  */
     481           0 :                 while (total < N) {
     482           0 :                         ret = SMB_VFS_RECVFILE(sockfd,
     483             :                                                 fsp,
     484             :                                                 offset + total,
     485             :                                                 N - total);
     486           0 :                         if (ret == 0 || (ret == -1 &&
     487           0 :                                          (errno == EAGAIN ||
     488           0 :                                           errno == EWOULDBLOCK))) {
     489             :                                 int old_flags;
     490             :                                 /* Ensure the socket is blocking. */
     491           0 :                                 old_flags = fcntl(sockfd, F_GETFL, 0);
     492           0 :                                 if (set_blocking(sockfd, true) == -1) {
     493           0 :                                         return (ssize_t)-1;
     494             :                                 }
     495           0 :                                 ret = SMB_VFS_RECVFILE(sockfd,
     496             :                                                         fsp,
     497             :                                                         offset + total,
     498             :                                                         N - total);
     499           0 :                                 if (fcntl(sockfd, F_SETFL, old_flags) == -1) {
     500           0 :                                         return (ssize_t)-1;
     501             :                                 }
     502           0 :                                 if (ret == -1) {
     503           0 :                                         return (ssize_t)-1;
     504             :                                 }
     505           0 :                                 total += ret;
     506           0 :                                 return (ssize_t)total;
     507             :                         }
     508             :                         /* Any other error case. */
     509           0 :                         if (ret == -1) {
     510           0 :                                 return ret;
     511             :                         }
     512           0 :                         total += ret;
     513             :                 }
     514           0 :                 return (ssize_t)total;
     515             :         }
     516             : 
     517          48 :         while (total < N) {
     518          24 :                 ret = SMB_VFS_PWRITE(fsp, buffer + total, N - total,
     519             :                                      offset + total);
     520             : 
     521          24 :                 if (ret == -1)
     522           0 :                         return -1;
     523          24 :                 if (ret == 0)
     524           0 :                         return total;
     525             : 
     526          24 :                 total += ret;
     527             :         }
     528          24 :         return (ssize_t)total;
     529             : }
     530             : /****************************************************************************
     531             :  An allocate file space call using the vfs interface.
     532             :  Allocates space for a file from a filedescriptor.
     533             :  Returns 0 on success, -1 on failure.
     534             : ****************************************************************************/
     535             : 
     536          18 : int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
     537             : {
     538             :         int ret;
     539          18 :         connection_struct *conn = fsp->conn;
     540             :         uint64_t space_avail;
     541             :         uint64_t bsize,dfree,dsize;
     542             :         NTSTATUS status;
     543             :         bool ok;
     544             : 
     545             :         /*
     546             :          * Actually try and commit the space on disk....
     547             :          */
     548             : 
     549          18 :         DEBUG(10,("vfs_allocate_file_space: file %s, len %.0f\n",
     550             :                   fsp_str_dbg(fsp), (double)len));
     551             : 
     552          18 :         ok = vfs_valid_pwrite_range((off_t)len, 0);
     553          18 :         if (!ok) {
     554           0 :                 DEBUG(0,("vfs_allocate_file_space: %s negative/invalid len "
     555             :                          "requested.\n", fsp_str_dbg(fsp)));
     556           0 :                 errno = EINVAL;
     557           0 :                 return -1;
     558             :         }
     559             : 
     560          18 :         status = vfs_stat_fsp(fsp);
     561          18 :         if (!NT_STATUS_IS_OK(status)) {
     562           0 :                 return -1;
     563             :         }
     564             : 
     565          18 :         if (len == (uint64_t)fsp->fsp_name->st.st_ex_size)
     566           0 :                 return 0;
     567             : 
     568          18 :         if (len < (uint64_t)fsp->fsp_name->st.st_ex_size) {
     569             :                 /* Shrink - use ftruncate. */
     570             : 
     571           0 :                 DEBUG(10,("vfs_allocate_file_space: file %s, shrink. Current "
     572             :                           "size %.0f\n", fsp_str_dbg(fsp),
     573             :                           (double)fsp->fsp_name->st.st_ex_size));
     574             : 
     575           0 :                 contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_SHRINK);
     576             : 
     577           0 :                 ret = SMB_VFS_FTRUNCATE(fsp, (off_t)len);
     578             : 
     579           0 :                 contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_ALLOC_SHRINK);
     580             : 
     581           0 :                 return ret;
     582             :         }
     583             : 
     584             :         /* Grow - we need to test if we have enough space. */
     585             : 
     586          18 :         contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_GROW);
     587             : 
     588          18 :         if (lp_strict_allocate(SNUM(fsp->conn))) {
     589             :                 /* See if we have a syscall that will allocate beyond
     590             :                    end-of-file without changing EOF. */
     591           0 :                 ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_FL_KEEP_SIZE,
     592             :                                         0, len);
     593             :         } else {
     594          18 :                 ret = 0;
     595             :         }
     596             : 
     597          18 :         contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_ALLOC_GROW);
     598             : 
     599          18 :         if (ret == 0) {
     600             :                 /* We changed the allocation size on disk, but not
     601             :                    EOF - exactly as required. We're done ! */
     602          18 :                 return 0;
     603             :         }
     604             : 
     605           0 :         if (ret == -1 && errno == ENOSPC) {
     606           0 :                 return -1;
     607             :         }
     608             : 
     609           0 :         len -= fsp->fsp_name->st.st_ex_size;
     610           0 :         len /= 1024; /* Len is now number of 1k blocks needed. */
     611             :         space_avail =
     612           0 :             get_dfree_info(conn, fsp->fsp_name, &bsize, &dfree, &dsize);
     613           0 :         if (space_avail == (uint64_t)-1) {
     614           0 :                 return -1;
     615             :         }
     616             : 
     617           0 :         DEBUG(10,("vfs_allocate_file_space: file %s, grow. Current size %.0f, "
     618             :                   "needed blocks = %.0f, space avail = %.0f\n",
     619             :                   fsp_str_dbg(fsp), (double)fsp->fsp_name->st.st_ex_size, (double)len,
     620             :                   (double)space_avail));
     621             : 
     622           0 :         if (len > space_avail) {
     623           0 :                 errno = ENOSPC;
     624           0 :                 return -1;
     625             :         }
     626             : 
     627           0 :         return 0;
     628             : }
     629             : 
     630             : /****************************************************************************
     631             :  A vfs set_filelen call.
     632             :  set the length of a file from a filedescriptor.
     633             :  Returns 0 on success, -1 on failure.
     634             : ****************************************************************************/
     635             : 
     636           0 : int vfs_set_filelen(files_struct *fsp, off_t len)
     637             : {
     638             :         int ret;
     639             :         bool ok;
     640             : 
     641           0 :         ok = vfs_valid_pwrite_range(len, 0);
     642           0 :         if (!ok) {
     643           0 :                 errno = EINVAL;
     644           0 :                 return -1;
     645             :         }
     646             : 
     647           0 :         contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_SET_FILE_LEN);
     648             : 
     649           0 :         DEBUG(10,("vfs_set_filelen: ftruncate %s to len %.0f\n",
     650             :                   fsp_str_dbg(fsp), (double)len));
     651           0 :         if ((ret = SMB_VFS_FTRUNCATE(fsp, len)) != -1) {
     652           0 :                 notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
     653             :                              FILE_NOTIFY_CHANGE_SIZE
     654             :                              | FILE_NOTIFY_CHANGE_ATTRIBUTES,
     655           0 :                              fsp->fsp_name->base_name);
     656             :         }
     657             : 
     658           0 :         contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_SET_FILE_LEN);
     659             : 
     660           0 :         return ret;
     661             : }
     662             : 
     663             : /****************************************************************************
     664             :  A slow version of fallocate. Fallback code if SMB_VFS_FALLOCATE
     665             :  fails. Needs to be outside of the default version of SMB_VFS_FALLOCATE
     666             :  as this is also called from the default SMB_VFS_FTRUNCATE code.
     667             :  Always extends the file size.
     668             :  Returns 0 on success, -1 on failure.
     669             : ****************************************************************************/
     670             : 
     671             : #define SPARSE_BUF_WRITE_SIZE (32*1024)
     672             : 
     673           0 : int vfs_slow_fallocate(files_struct *fsp, off_t offset, off_t len)
     674             : {
     675             :         ssize_t pwrite_ret;
     676           0 :         size_t total = 0;
     677             :         bool ok;
     678             : 
     679           0 :         ok = vfs_valid_pwrite_range(offset, len);
     680           0 :         if (!ok) {
     681           0 :                 errno = EINVAL;
     682           0 :                 return -1;
     683             :         }
     684             : 
     685           0 :         if (!sparse_buf) {
     686           0 :                 sparse_buf = SMB_CALLOC_ARRAY(char, SPARSE_BUF_WRITE_SIZE);
     687           0 :                 if (!sparse_buf) {
     688           0 :                         errno = ENOMEM;
     689           0 :                         return -1;
     690             :                 }
     691             :         }
     692             : 
     693           0 :         while (total < len) {
     694           0 :                 size_t curr_write_size = MIN(SPARSE_BUF_WRITE_SIZE, (len - total));
     695             : 
     696           0 :                 pwrite_ret = SMB_VFS_PWRITE(fsp, sparse_buf, curr_write_size, offset + total);
     697           0 :                 if (pwrite_ret == -1) {
     698           0 :                         int saved_errno = errno;
     699           0 :                         DEBUG(10,("vfs_slow_fallocate: SMB_VFS_PWRITE for file "
     700             :                                   "%s failed with error %s\n",
     701             :                                   fsp_str_dbg(fsp), strerror(saved_errno)));
     702           0 :                         errno = saved_errno;
     703           0 :                         return -1;
     704             :                 }
     705           0 :                 total += pwrite_ret;
     706             :         }
     707             : 
     708           0 :         return 0;
     709             : }
     710             : 
     711             : /****************************************************************************
     712             :  A vfs fill sparse call.
     713             :  Writes zeros from the end of file to len, if len is greater than EOF.
     714             :  Used only by strict_sync.
     715             :  Returns 0 on success, -1 on failure.
     716             : ****************************************************************************/
     717             : 
     718           0 : int vfs_fill_sparse(files_struct *fsp, off_t len)
     719             : {
     720             :         int ret;
     721             :         NTSTATUS status;
     722             :         off_t offset;
     723             :         size_t num_to_write;
     724             :         bool ok;
     725             : 
     726           0 :         ok = vfs_valid_pwrite_range(len, 0);
     727           0 :         if (!ok) {
     728           0 :                 errno = EINVAL;
     729           0 :                 return -1;
     730             :         }
     731             : 
     732           0 :         status = vfs_stat_fsp(fsp);
     733           0 :         if (!NT_STATUS_IS_OK(status)) {
     734           0 :                 return -1;
     735             :         }
     736             : 
     737           0 :         if (len <= fsp->fsp_name->st.st_ex_size) {
     738           0 :                 return 0;
     739             :         }
     740             : 
     741             : #ifdef S_ISFIFO
     742           0 :         if (S_ISFIFO(fsp->fsp_name->st.st_ex_mode)) {
     743           0 :                 return 0;
     744             :         }
     745             : #endif
     746             : 
     747           0 :         DEBUG(10,("vfs_fill_sparse: write zeros in file %s from len %.0f to "
     748             :                   "len %.0f (%.0f bytes)\n", fsp_str_dbg(fsp),
     749             :                   (double)fsp->fsp_name->st.st_ex_size, (double)len,
     750             :                   (double)(len - fsp->fsp_name->st.st_ex_size)));
     751             : 
     752           0 :         contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_FILL_SPARSE);
     753             : 
     754           0 :         offset = fsp->fsp_name->st.st_ex_size;
     755           0 :         num_to_write = len - fsp->fsp_name->st.st_ex_size;
     756             : 
     757             :         /* Only do this on non-stream file handles. */
     758           0 :         if (!fsp_is_alternate_stream(fsp)) {
     759             :                 /* for allocation try fallocate first. This can fail on some
     760             :                  * platforms e.g. when the filesystem doesn't support it and no
     761             :                  * emulation is being done by the libc (like on AIX with JFS1). In that
     762             :                  * case we do our own emulation. fallocate implementations can
     763             :                  * return ENOTSUP or EINVAL in cases like that. */
     764           0 :                 ret = SMB_VFS_FALLOCATE(fsp, 0, offset, num_to_write);
     765           0 :                 if (ret == -1 && errno == ENOSPC) {
     766           0 :                         goto out;
     767             :                 }
     768           0 :                 if (ret == 0) {
     769           0 :                         goto out;
     770             :                 }
     771           0 :                 DEBUG(10,("vfs_fill_sparse: SMB_VFS_FALLOCATE failed with "
     772             :                         "error %d. Falling back to slow manual allocation\n", ret));
     773             :         }
     774             : 
     775           0 :         ret = vfs_slow_fallocate(fsp, offset, num_to_write);
     776             : 
     777           0 :  out:
     778             : 
     779           0 :         contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_FILL_SPARSE);
     780           0 :         return ret;
     781             : }
     782             : 
     783             : /*******************************************************************************
     784             :  Set a fd into blocking/nonblocking mode through VFS
     785             : *******************************************************************************/
     786             : 
     787        1196 : int vfs_set_blocking(files_struct *fsp, bool set)
     788             : {
     789             :         int val;
     790             : #ifdef O_NONBLOCK
     791             : #define FLAG_TO_SET O_NONBLOCK
     792             : #else
     793             : #ifdef SYSV
     794             : #define FLAG_TO_SET O_NDELAY
     795             : #else /* BSD */
     796             : #define FLAG_TO_SET FNDELAY
     797             : #endif
     798             : #endif
     799             : 
     800        1196 :         if (fsp->fsp_flags.is_pathref) {
     801           0 :                 return 0;
     802             :         }
     803             : 
     804        1196 :         val = SMB_VFS_FCNTL(fsp, F_GETFL, 0);
     805        1196 :         if (val == -1) {
     806           0 :                 return -1;
     807             :         }
     808             : 
     809        1196 :         if (set) {
     810        1196 :                 val &= ~FLAG_TO_SET;
     811             :         } else {
     812           0 :                 val |= FLAG_TO_SET;
     813             :         }
     814             : 
     815        1196 :         return SMB_VFS_FCNTL(fsp, F_SETFL, val);
     816             : #undef FLAG_TO_SET
     817             : }
     818             : 
     819             : /****************************************************************************
     820             :  Transfer some data (n bytes) between two file_struct's.
     821             : ****************************************************************************/
     822             : 
     823           0 : static ssize_t vfs_pread_fn(void *file, void *buf, size_t len, off_t offset)
     824             : {
     825           0 :         struct files_struct *fsp = (struct files_struct *)file;
     826             : 
     827           0 :         return SMB_VFS_PREAD(fsp, buf, len, offset);
     828             : }
     829             : 
     830           0 : static ssize_t vfs_pwrite_fn(void *file, const void *buf, size_t len, off_t offset)
     831             : {
     832           0 :         struct files_struct *fsp = (struct files_struct *)file;
     833             : 
     834           0 :         return SMB_VFS_PWRITE(fsp, buf, len, offset);
     835             : }
     836             : 
     837           0 : off_t vfs_transfer_file(files_struct *in, files_struct *out, off_t n)
     838             : {
     839           0 :         return transfer_file_internal((void *)in, (void *)out, n,
     840             :                                       vfs_pread_fn, vfs_pwrite_fn);
     841             : }
     842             : 
     843             : /*******************************************************************
     844             :  A vfs_readdir wrapper which just returns the file name.
     845             : ********************************************************************/
     846             : 
     847       33866 : const char *vfs_readdirname(connection_struct *conn,
     848             :                             struct files_struct *dirfsp,
     849             :                             void *p,
     850             :                             SMB_STRUCT_STAT *sbuf,
     851             :                             char **talloced)
     852             : {
     853       33866 :         struct dirent *ptr= NULL;
     854             :         const char *dname;
     855             :         char *translated;
     856             :         NTSTATUS status;
     857             : 
     858       33866 :         if (!p)
     859           0 :                 return(NULL);
     860             : 
     861       33866 :         ptr = SMB_VFS_READDIR(conn, dirfsp, (DIR *)p, sbuf);
     862       33866 :         if (!ptr)
     863        4775 :                 return(NULL);
     864             : 
     865       29091 :         dname = ptr->d_name;
     866             : 
     867       29091 :         status = SMB_VFS_TRANSLATE_NAME(conn, dname, vfs_translate_to_windows,
     868             :                                         talloc_tos(), &translated);
     869       29091 :         if (NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) {
     870       29091 :                 *talloced = NULL;
     871       29091 :                 return dname;
     872             :         }
     873           0 :         *talloced = translated;
     874           0 :         if (!NT_STATUS_IS_OK(status)) {
     875           0 :                 return NULL;
     876             :         }
     877           0 :         return translated;
     878             : }
     879             : 
     880             : /*******************************************************************
     881             :  A wrapper for vfs_chdir().
     882             : ********************************************************************/
     883             : 
     884      178244 : int vfs_ChDir(connection_struct *conn, const struct smb_filename *smb_fname)
     885             : {
     886             :         int ret;
     887      178244 :         struct smb_filename *cwd = NULL;
     888             : 
     889      178244 :         if (!LastDir) {
     890       26091 :                 LastDir = SMB_STRDUP("");
     891             :         }
     892             : 
     893      178244 :         if (ISDOT(smb_fname->base_name)) {
     894             :                 /*
     895             :                  * passing a '.' is a noop,
     896             :                  * and we only expect this after
     897             :                  * everything is initialized.
     898             :                  *
     899             :                  * So the first vfs_ChDir() on a given
     900             :                  * connection_struct must not be '.'.
     901             :                  *
     902             :                  * Note: conn_new() sets
     903             :                  * conn->cwd_fsp->fh->fd = -1
     904             :                  * and vfs_ChDir() leaves with
     905             :                  * conn->cwd_fsp->fh->fd = AT_FDCWD
     906             :                  * on success!
     907             :                  */
     908           0 :                 if (fsp_get_pathref_fd(conn->cwd_fsp) != AT_FDCWD) {
     909             :                         /*
     910             :                          * This should never happen and
     911             :                          * we might change this to
     912             :                          * SMB_ASSERT() in future.
     913             :                          */
     914           0 :                         DBG_ERR("Called with '.' as first operation!\n");
     915           0 :                         log_stack_trace();
     916           0 :                         errno = EINVAL;
     917           0 :                         return -1;
     918             :                 }
     919           0 :                 return 0;
     920             :         }
     921             : 
     922      349090 :         if (smb_fname->base_name[0] == '/' &&
     923      170846 :             strcsequal(LastDir,smb_fname->base_name))
     924             :         {
     925             :                 /*
     926             :                  * conn->cwd_fsp->fsp_name and the kernel
     927             :                  * are already correct, but conn->cwd_fsp->fh->fd
     928             :                  * might still be -1 as initialized in conn_new().
     929             :                  *
     930             :                  * This can happen when a client made a 2nd
     931             :                  * tree connect to a share with the same underlying
     932             :                  * path (may or may not the same share).
     933             :                  */
     934      125930 :                 fsp_set_fd(conn->cwd_fsp, AT_FDCWD);
     935      125930 :                 return 0;
     936             :         }
     937             : 
     938       52314 :         DEBUG(4,("vfs_ChDir to %s\n", smb_fname->base_name));
     939             : 
     940       52314 :         ret = SMB_VFS_CHDIR(conn, smb_fname);
     941       52314 :         if (ret != 0) {
     942         849 :                 return -1;
     943             :         }
     944             : 
     945             :         /*
     946             :          * Always replace conn->cwd_fsp. We
     947             :          * don't know if it's been modified by
     948             :          * VFS modules in the stack.
     949             :          */
     950       51465 :         fsp_set_fd(conn->cwd_fsp, AT_FDCWD);
     951             : 
     952             :         /* conn cache. */
     953       51465 :         cwd = vfs_GetWd(conn, conn);
     954       51465 :         if (cwd == NULL) {
     955             :                 /*
     956             :                  * vfs_GetWd() failed.
     957             :                  * We must be able to read cwd.
     958             :                  * Return to original directory
     959             :                  * and return -1.
     960             :                  */
     961           0 :                 int saved_errno = errno;
     962             : 
     963           0 :                 if (conn->cwd_fsp->fsp_name == NULL) {
     964             :                         /*
     965             :                          * Failed on the very first chdir()+getwd()
     966             :                          * for this connection. We can't
     967             :                          * continue.
     968             :                          */
     969           0 :                         smb_panic("conn->cwd getwd failed\n");
     970             :                         /* NOTREACHED */
     971             :                         return -1;
     972             :                 }
     973             : 
     974             :                 /* Return to the previous $cwd. */
     975           0 :                 ret = SMB_VFS_CHDIR(conn, conn->cwd_fsp->fsp_name);
     976           0 :                 if (ret != 0) {
     977           0 :                         smb_panic("conn->cwd getwd failed\n");
     978             :                         /* NOTREACHED */
     979             :                         return -1;
     980             :                 }
     981           0 :                 errno = saved_errno;
     982             :                 /* And fail the chdir(). */
     983           0 :                 return -1;
     984             :         }
     985             : 
     986             :         /* vfs_GetWd() succeeded. */
     987             :         /* Replace global cache. */
     988       51465 :         SAFE_FREE(LastDir);
     989       51465 :         LastDir = SMB_STRDUP(smb_fname->base_name);
     990             : 
     991             :         /*
     992             :          * (Indirect) Callers of vfs_ChDir() may still hold references to the
     993             :          * old conn->cwd_fsp->fsp_name. Move it to talloc_tos(), that way
     994             :          * callers can use it for the lifetime of the SMB request.
     995             :          */
     996       51465 :         talloc_move(talloc_tos(), &conn->cwd_fsp->fsp_name);
     997             : 
     998       51465 :         conn->cwd_fsp->fsp_name = talloc_move(conn->cwd_fsp, &cwd);
     999             : 
    1000       51465 :         DBG_INFO("vfs_ChDir got %s\n", fsp_str_dbg(conn->cwd_fsp));
    1001             : 
    1002       51465 :         return ret;
    1003             : }
    1004             : 
    1005             : /*******************************************************************
    1006             :  Return the absolute current directory path - given a UNIX pathname.
    1007             :  Note that this path is returned in DOS format, not UNIX
    1008             :  format. Note this can be called with conn == NULL.
    1009             : ********************************************************************/
    1010             : 
    1011       65208 : struct smb_filename *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
    1012             : {
    1013       65208 :         struct smb_filename *current_dir_fname = NULL;
    1014             :         struct file_id key;
    1015       65208 :         struct smb_filename *smb_fname_dot = NULL;
    1016       65208 :         struct smb_filename *smb_fname_full = NULL;
    1017       65208 :         struct smb_filename *result = NULL;
    1018             : 
    1019       65208 :         if (!lp_getwd_cache()) {
    1020           0 :                 goto nocache;
    1021             :         }
    1022             : 
    1023       65208 :         smb_fname_dot = synthetic_smb_fname(ctx,
    1024             :                                             ".",
    1025             :                                             NULL,
    1026             :                                             NULL,
    1027             :                                             0,
    1028             :                                             0);
    1029       65208 :         if (smb_fname_dot == NULL) {
    1030           0 :                 errno = ENOMEM;
    1031           0 :                 goto out;
    1032             :         }
    1033             : 
    1034       65208 :         if (SMB_VFS_STAT(conn, smb_fname_dot) == -1) {
    1035             :                 /*
    1036             :                  * Known to fail for root: the directory may be NFS-mounted
    1037             :                  * and exported with root_squash (so has no root access).
    1038             :                  */
    1039           0 :                 DEBUG(1,("vfs_GetWd: couldn't stat \".\" error %s "
    1040             :                          "(NFS problem ?)\n", strerror(errno) ));
    1041           0 :                 goto nocache;
    1042             :         }
    1043             : 
    1044       65208 :         key = vfs_file_id_from_sbuf(conn, &smb_fname_dot->st);
    1045             : 
    1046       65208 :         smb_fname_full = (struct smb_filename *)memcache_lookup_talloc(
    1047             :                                         smbd_memcache(),
    1048             :                                         GETWD_CACHE,
    1049             :                                         data_blob_const(&key, sizeof(key)));
    1050             : 
    1051       65208 :         if (smb_fname_full == NULL) {
    1052       12572 :                 goto nocache;
    1053             :         }
    1054             : 
    1055       52636 :         if ((SMB_VFS_STAT(conn, smb_fname_full) == 0) &&
    1056       52636 :             (smb_fname_dot->st.st_ex_dev == smb_fname_full->st.st_ex_dev) &&
    1057       52636 :             (smb_fname_dot->st.st_ex_ino == smb_fname_full->st.st_ex_ino) &&
    1058       52636 :             (S_ISDIR(smb_fname_dot->st.st_ex_mode))) {
    1059             :                 /*
    1060             :                  * Ok, we're done
    1061             :                  * Note: smb_fname_full is owned by smbd_memcache()
    1062             :                  * so we must make a copy to return.
    1063             :                  */
    1064       52636 :                 result = cp_smb_filename(ctx, smb_fname_full);
    1065       52636 :                 if (result == NULL) {
    1066           0 :                         errno = ENOMEM;
    1067             :                 }
    1068       52636 :                 goto out;
    1069             :         }
    1070             : 
    1071           0 :  nocache:
    1072             : 
    1073             :         /*
    1074             :          * We don't have the information to hand so rely on traditional
    1075             :          * methods. The very slow getcwd, which spawns a process on some
    1076             :          * systems, or the not quite so bad getwd.
    1077             :          */
    1078             : 
    1079       12572 :         current_dir_fname = SMB_VFS_GETWD(conn, ctx);
    1080       12572 :         if (current_dir_fname == NULL) {
    1081           0 :                 DEBUG(0, ("vfs_GetWd: SMB_VFS_GETWD call failed: %s\n",
    1082             :                           strerror(errno)));
    1083           0 :                 goto out;
    1084             :         }
    1085             : 
    1086       12572 :         if (lp_getwd_cache() && VALID_STAT(smb_fname_dot->st)) {
    1087       12572 :                 key = vfs_file_id_from_sbuf(conn, &smb_fname_dot->st);
    1088             : 
    1089             :                 /*
    1090             :                  * smbd_memcache() will own current_dir_fname after the
    1091             :                  * memcache_add_talloc call, so we must make
    1092             :                  * a copy on ctx to return.
    1093             :                  */
    1094       12572 :                 result = cp_smb_filename(ctx, current_dir_fname);
    1095       12572 :                 if (result == NULL) {
    1096           0 :                         errno = ENOMEM;
    1097             :                 }
    1098             : 
    1099             :                 /*
    1100             :                  * Ensure the memory going into the cache
    1101             :                  * doesn't have a destructor so it can be
    1102             :                  * cleanly freed.
    1103             :                  */
    1104       12572 :                 talloc_set_destructor(current_dir_fname, NULL);
    1105             : 
    1106       12572 :                 memcache_add_talloc(smbd_memcache(),
    1107             :                                 GETWD_CACHE,
    1108             :                                 data_blob_const(&key, sizeof(key)),
    1109             :                                 &current_dir_fname);
    1110             :                 /* current_dir_fname is now == NULL here. */
    1111             :         } else {
    1112             :                 /* current_dir_fname is already allocated on ctx. */
    1113           0 :                 result = current_dir_fname;
    1114             :         }
    1115             : 
    1116       65208 :  out:
    1117       65208 :         TALLOC_FREE(smb_fname_dot);
    1118             :         /*
    1119             :          * Don't free current_dir_fname here. It's either been moved
    1120             :          * to the memcache or is being returned in result.
    1121             :          */
    1122       65208 :         return result;
    1123             : }
    1124             : 
    1125             : /*
    1126             :  * Ensure LSTAT is called for POSIX paths.
    1127             :  */
    1128        4712 : int vfs_stat(struct connection_struct *conn,
    1129             :              struct smb_filename *smb_fname)
    1130             : {
    1131        4712 :         if (smb_fname->flags & SMB_FILENAME_POSIX_PATH) {
    1132           0 :                 return SMB_VFS_LSTAT(conn, smb_fname);
    1133             :         }
    1134        4712 :         return SMB_VFS_STAT(conn, smb_fname);
    1135             : }
    1136             : 
    1137             : /**
    1138             :  * XXX: This is temporary and there should be no callers of this once
    1139             :  * smb_filename is plumbed through all path based operations.
    1140             :  *
    1141             :  * Called when we know stream name parsing has already been done.
    1142             :  */
    1143           0 : int vfs_stat_smb_basename(struct connection_struct *conn,
    1144             :                         const struct smb_filename *smb_fname_in,
    1145             :                         SMB_STRUCT_STAT *psbuf)
    1146             : {
    1147           0 :         struct smb_filename smb_fname = {
    1148           0 :                 .base_name = discard_const_p(char, smb_fname_in->base_name),
    1149           0 :                 .flags = smb_fname_in->flags,
    1150           0 :                 .twrp = smb_fname_in->twrp,
    1151             :         };
    1152             :         int ret;
    1153             : 
    1154           0 :         ret = vfs_stat(conn, &smb_fname);
    1155           0 :         if (ret != -1) {
    1156           0 :                 *psbuf = smb_fname.st;
    1157             :         }
    1158           0 :         return ret;
    1159             : }
    1160             : 
    1161             : /**
    1162             :  * Ensure LSTAT is called for POSIX paths.
    1163             :  */
    1164             : 
    1165       33903 : NTSTATUS vfs_stat_fsp(files_struct *fsp)
    1166             : {
    1167             :         int ret;
    1168       33903 :         struct stat_ex saved_stat = fsp->fsp_name->st;
    1169             : 
    1170       33903 :         if (fsp_get_pathref_fd(fsp) == -1) {
    1171           0 :                 if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) {
    1172           0 :                         ret = SMB_VFS_LSTAT(fsp->conn, fsp->fsp_name);
    1173             :                 } else {
    1174           0 :                         ret = SMB_VFS_STAT(fsp->conn, fsp->fsp_name);
    1175             :                 }
    1176             :         } else {
    1177       33903 :                 ret = SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st);
    1178             :         }
    1179       33903 :         if (ret == -1) {
    1180           0 :                 return map_nt_error_from_unix(errno);
    1181             :         }
    1182       33903 :         update_stat_ex_from_saved_stat(&fsp->fsp_name->st, &saved_stat);
    1183       33903 :         fsp->fsp_flags.is_directory = S_ISDIR(fsp->fsp_name->st.st_ex_mode);
    1184       33903 :         return NT_STATUS_OK;
    1185             : }
    1186             : 
    1187        2382 : void init_smb_file_time(struct smb_file_time *ft)
    1188             : {
    1189        2382 :         *ft = (struct smb_file_time) {
    1190        2382 :                 .atime = make_omit_timespec(),
    1191        2382 :                 .ctime = make_omit_timespec(),
    1192        2382 :                 .mtime = make_omit_timespec(),
    1193        2382 :                 .create_time = make_omit_timespec()
    1194             :         };
    1195        2382 : }
    1196             : 
    1197             : /**
    1198             :  * Initialize num_streams and streams, then call VFS op streaminfo
    1199             :  */
    1200             : 
    1201        2815 : NTSTATUS vfs_fstreaminfo(struct files_struct *fsp,
    1202             :                         TALLOC_CTX *mem_ctx,
    1203             :                         unsigned int *num_streams,
    1204             :                         struct stream_struct **streams)
    1205             : {
    1206        2815 :         *num_streams = 0;
    1207        2815 :         *streams = NULL;
    1208             : 
    1209        2815 :         if (fsp == NULL) {
    1210             :                 /*
    1211             :                  * Callers may pass fsp == NULL when passing smb_fname->fsp of a
    1212             :                  * symlink. This is ok, handle it here, by just return no
    1213             :                  * streams on a symlink.
    1214             :                  */
    1215           0 :                 return NT_STATUS_OK;
    1216             :         }
    1217             : 
    1218        2815 :         if (fsp_get_pathref_fd(fsp) == -1) {
    1219             :                 /*
    1220             :                  * No streams on non-real files/directories.
    1221             :                  */
    1222           0 :                 return NT_STATUS_OK;
    1223             :         }
    1224             : 
    1225        2815 :         return SMB_VFS_FSTREAMINFO(fsp,
    1226             :                         mem_ctx,
    1227             :                         num_streams,
    1228             :                         streams);
    1229             : }
    1230             : 
    1231          24 : int vfs_fake_fd(void)
    1232             : {
    1233             :         int pipe_fds[2];
    1234             :         int ret;
    1235             : 
    1236             :         /*
    1237             :          * Return a valid fd, but ensure any attempt to use
    1238             :          * it returns an error (EPIPE).
    1239             :          */
    1240          24 :         ret = pipe(pipe_fds);
    1241          24 :         if (ret != 0) {
    1242           0 :                 return -1;
    1243             :         }
    1244             : 
    1245          24 :         close(pipe_fds[1]);
    1246          24 :         return pipe_fds[0];
    1247             : }
    1248             : 
    1249             : /*
    1250             :  * This is just a helper to make
    1251             :  * users of vfs_fake_fd() more symmetric
    1252             :  */
    1253          24 : int vfs_fake_fd_close(int fd)
    1254             : {
    1255          24 :         return close(fd);
    1256             : }
    1257             : 
    1258             : /*
    1259             :   generate a file_id from a stat structure
    1260             :  */
    1261      196879 : struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_STAT *sbuf)
    1262             : {
    1263      196879 :         return SMB_VFS_FILE_ID_CREATE(conn, sbuf);
    1264             : }
    1265             : 
    1266        1844 : NTSTATUS vfs_at_fspcwd(TALLOC_CTX *mem_ctx,
    1267             :                        struct connection_struct *conn,
    1268             :                        struct files_struct **_fsp)
    1269             : {
    1270        1844 :         struct files_struct *fsp = NULL;
    1271             : 
    1272        1844 :         fsp = talloc_zero(mem_ctx, struct files_struct);
    1273        1844 :         if (fsp == NULL) {
    1274           0 :                 return NT_STATUS_NO_MEMORY;
    1275             :         }
    1276             : 
    1277        1844 :         fsp->fsp_name = synthetic_smb_fname(fsp, ".", NULL, NULL, 0, 0);
    1278        1844 :         if (fsp->fsp_name == NULL) {
    1279           0 :                 TALLOC_FREE(fsp);
    1280           0 :                 return NT_STATUS_NO_MEMORY;
    1281             :         }
    1282             : 
    1283        1844 :         fsp->fh = fd_handle_create(fsp);
    1284        1844 :         if (fsp->fh == NULL) {
    1285           0 :                 TALLOC_FREE(fsp);
    1286           0 :                 return NT_STATUS_NO_MEMORY;
    1287             :         }
    1288             : 
    1289        1844 :         fsp_set_fd(fsp, AT_FDCWD);
    1290        1844 :         fsp->fnum = FNUM_FIELD_INVALID;
    1291        1844 :         fsp->conn = conn;
    1292             : 
    1293        1844 :         *_fsp = fsp;
    1294        1844 :         return NT_STATUS_OK;
    1295             : }
    1296             : 
    1297       31883 : NTSTATUS vfs_fget_dos_attributes(struct files_struct *fsp,
    1298             :                                  uint32_t *dosmode)
    1299             : {
    1300             :         NTSTATUS status;
    1301             : 
    1302             :         /*
    1303             :          * First make sure to pass the base_fsp to the VFS
    1304             :          */
    1305       31883 :         status = SMB_VFS_FGET_DOS_ATTRIBUTES(
    1306             :                 fsp->conn, metadata_fsp(fsp), dosmode);
    1307       31883 :         if (!NT_STATUS_IS_OK(status)) {
    1308       20148 :                 return status;
    1309             :         }
    1310             : 
    1311             :         /*
    1312             :          * If this isn't a stream fsp we're done, ...
    1313             :          */
    1314       11735 :         if (!fsp_is_alternate_stream(fsp)) {
    1315       11595 :                 return NT_STATUS_OK;
    1316             :         }
    1317             : 
    1318             :         /*
    1319             :          * ...otherwise the VFS might have updated the btime, propagate the
    1320             :          * btime from the base_fsp to the stream fsp.
    1321             :          */
    1322             : 
    1323         140 :         if (fsp->base_fsp->fsp_name->st.st_ex_iflags & ST_EX_IFLAG_CALCULATED_BTIME) {
    1324             :                 /*
    1325             :                  * Not a value from backend storage, ignore it
    1326             :                  */
    1327           0 :                 return NT_STATUS_OK;
    1328             :         }
    1329             : 
    1330         140 :         update_stat_ex_create_time(&fsp->fsp_name->st,
    1331         140 :                                    fsp->base_fsp->fsp_name->st.st_ex_btime);
    1332             : 
    1333         140 :         return NT_STATUS_OK;
    1334             : }
    1335             : 
    1336             : static struct smb_vfs_deny_state *smb_vfs_deny_global;
    1337             : 
    1338         261 : void smb_vfs_assert_allowed(void)
    1339             : {
    1340         261 :         if (unlikely(smb_vfs_deny_global != NULL)) {
    1341           0 :                 DBG_ERR("Called with VFS denied by %s\n",
    1342             :                         smb_vfs_deny_global->location);
    1343           0 :                 smb_panic("Called with VFS denied!");
    1344             :         }
    1345         261 : }
    1346             : 
    1347       29405 : void _smb_vfs_deny_push(struct smb_vfs_deny_state *state, const char *location)
    1348             : {
    1349       29405 :         SMB_ASSERT(smb_vfs_deny_global != state);
    1350             : 
    1351       29405 :         *state = (struct smb_vfs_deny_state) {
    1352             :                 .parent = smb_vfs_deny_global,
    1353             :                 .location = location,
    1354             :         };
    1355             : 
    1356       29405 :         smb_vfs_deny_global = state;
    1357       29405 : }
    1358             : 
    1359       29405 : void _smb_vfs_deny_pop(struct smb_vfs_deny_state *state, const char *location)
    1360             : {
    1361       29405 :         SMB_ASSERT(smb_vfs_deny_global == state);
    1362             : 
    1363       29405 :         smb_vfs_deny_global = state->parent;
    1364             : 
    1365       29405 :         *state = (struct smb_vfs_deny_state) { .parent = NULL, };
    1366       29405 : }
    1367             : 
    1368             : #define VFS_FIND(__fn__) do { \
    1369             :         if (unlikely(smb_vfs_deny_global != NULL)) { \
    1370             :                 DBG_ERR("Called with VFS denied by %s\n", \
    1371             :                         smb_vfs_deny_global->location); \
    1372             :                 smb_panic("Called with VFS denied!"); \
    1373             :         } \
    1374             :         while (handle->fns->__fn__##_fn==NULL) { \
    1375             :                 handle = handle->next; \
    1376             :         } \
    1377             : } while(0)
    1378             : 
    1379       42399 : int smb_vfs_call_connect(struct vfs_handle_struct *handle,
    1380             :                          const char *service, const char *user)
    1381             : {
    1382       50365 :         VFS_FIND(connect);
    1383       42399 :         return handle->fns->connect_fn(handle, service, user);
    1384             : }
    1385             : 
    1386       18505 : void smb_vfs_call_disconnect(struct vfs_handle_struct *handle)
    1387             : {
    1388       50365 :         VFS_FIND(disconnect);
    1389       18505 :         handle->fns->disconnect_fn(handle);
    1390       18505 : }
    1391             : 
    1392         741 : uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
    1393             :                                 const struct smb_filename *smb_fname,
    1394             :                                 uint64_t *bsize,
    1395             :                                 uint64_t *dfree,
    1396             :                                 uint64_t *dsize)
    1397             : {
    1398        2433 :         VFS_FIND(disk_free);
    1399         741 :         return handle->fns->disk_free_fn(handle, smb_fname,
    1400             :                         bsize, dfree, dsize);
    1401             : }
    1402             : 
    1403        1482 : int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
    1404             :                                 const struct smb_filename *smb_fname,
    1405             :                                 enum SMB_QUOTA_TYPE qtype,
    1406             :                                 unid_t id,
    1407             :                                 SMB_DISK_QUOTA *qt)
    1408             : {
    1409        4866 :         VFS_FIND(get_quota);
    1410        1482 :         return handle->fns->get_quota_fn(handle, smb_fname, qtype, id, qt);
    1411             : }
    1412             : 
    1413           0 : int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,
    1414             :                            enum SMB_QUOTA_TYPE qtype, unid_t id,
    1415             :                            SMB_DISK_QUOTA *qt)
    1416             : {
    1417           0 :         VFS_FIND(set_quota);
    1418           0 :         return handle->fns->set_quota_fn(handle, qtype, id, qt);
    1419             : }
    1420             : 
    1421         132 : int smb_vfs_call_get_shadow_copy_data(struct vfs_handle_struct *handle,
    1422             :                                       struct files_struct *fsp,
    1423             :                                       struct shadow_copy_data *shadow_copy_data,
    1424             :                                       bool labels)
    1425             : {
    1426         308 :         VFS_FIND(get_shadow_copy_data);
    1427         132 :         return handle->fns->get_shadow_copy_data_fn(handle, fsp, 
    1428             :                                                     shadow_copy_data,
    1429             :                                                     labels);
    1430             : }
    1431        7401 : int smb_vfs_call_statvfs(struct vfs_handle_struct *handle,
    1432             :                         const struct smb_filename *smb_fname,
    1433             :                         struct vfs_statvfs_struct *statbuf)
    1434             : {
    1435       25207 :         VFS_FIND(statvfs);
    1436        7401 :         return handle->fns->statvfs_fn(handle, smb_fname, statbuf);
    1437             : }
    1438             : 
    1439       11312 : uint32_t smb_vfs_call_fs_capabilities(struct vfs_handle_struct *handle,
    1440             :                         enum timestamp_set_resolution *p_ts_res)
    1441             : {
    1442       25207 :         VFS_FIND(fs_capabilities);
    1443       11312 :         return handle->fns->fs_capabilities_fn(handle, p_ts_res);
    1444             : }
    1445             : 
    1446        4785 : NTSTATUS smb_vfs_call_get_dfs_referrals(struct vfs_handle_struct *handle,
    1447             :                                         struct dfs_GetDFSReferral *r)
    1448             : {
    1449       11429 :         VFS_FIND(get_dfs_referrals);
    1450        4785 :         return handle->fns->get_dfs_referrals_fn(handle, r);
    1451             : }
    1452             : 
    1453           0 : NTSTATUS smb_vfs_call_create_dfs_pathat(struct vfs_handle_struct *handle,
    1454             :                                 struct files_struct *dirfsp,
    1455             :                                 const struct smb_filename *smb_fname,
    1456             :                                 const struct referral *reflist,
    1457             :                                 size_t referral_count)
    1458             : {
    1459           0 :         VFS_FIND(create_dfs_pathat);
    1460           0 :         return handle->fns->create_dfs_pathat_fn(handle,
    1461             :                                                 dirfsp,
    1462             :                                                 smb_fname,
    1463             :                                                 reflist,
    1464             :                                                 referral_count);
    1465             : }
    1466             : 
    1467       33702 : NTSTATUS smb_vfs_call_read_dfs_pathat(struct vfs_handle_struct *handle,
    1468             :                                 TALLOC_CTX *mem_ctx,
    1469             :                                 struct files_struct *dirfsp,
    1470             :                                 struct smb_filename *smb_fname,
    1471             :                                 struct referral **ppreflist,
    1472             :                                 size_t *preferral_count)
    1473             : {
    1474       78638 :         VFS_FIND(read_dfs_pathat);
    1475       33702 :         return handle->fns->read_dfs_pathat_fn(handle,
    1476             :                                                 mem_ctx,
    1477             :                                                 dirfsp,
    1478             :                                                 smb_fname,
    1479             :                                                 ppreflist,
    1480             :                                                 preferral_count);
    1481             : }
    1482             : 
    1483       11001 : DIR *smb_vfs_call_fdopendir(struct vfs_handle_struct *handle,
    1484             :                                         struct files_struct *fsp,
    1485             :                                         const char *mask,
    1486             :                                         uint32_t attributes)
    1487             : {
    1488       40612 :         VFS_FIND(fdopendir);
    1489       11001 :         return handle->fns->fdopendir_fn(handle, fsp, mask, attributes);
    1490             : }
    1491             : 
    1492       72106 : struct dirent *smb_vfs_call_readdir(struct vfs_handle_struct *handle,
    1493             :                                     struct files_struct *dirfsp,
    1494             :                                     DIR *dirp,
    1495             :                                     SMB_STRUCT_STAT *sbuf)
    1496             : {
    1497      221584 :         VFS_FIND(readdir);
    1498       72106 :         return handle->fns->readdir_fn(handle, dirfsp, dirp, sbuf);
    1499             : }
    1500             : 
    1501           0 : void smb_vfs_call_seekdir(struct vfs_handle_struct *handle,
    1502             :                           DIR *dirp, long offset)
    1503             : {
    1504           0 :         VFS_FIND(seekdir);
    1505           0 :         handle->fns->seekdir_fn(handle, dirp, offset);
    1506           0 : }
    1507             : 
    1508       49639 : long smb_vfs_call_telldir(struct vfs_handle_struct *handle,
    1509             :                           DIR *dirp)
    1510             : {
    1511      131575 :         VFS_FIND(telldir);
    1512       49639 :         return handle->fns->telldir_fn(handle, dirp);
    1513             : }
    1514             : 
    1515           0 : void smb_vfs_call_rewind_dir(struct vfs_handle_struct *handle,
    1516             :                              DIR *dirp)
    1517             : {
    1518           0 :         VFS_FIND(rewind_dir);
    1519           0 :         handle->fns->rewind_dir_fn(handle, dirp);
    1520           0 : }
    1521             : 
    1522        2588 : int smb_vfs_call_mkdirat(struct vfs_handle_struct *handle,
    1523             :                         struct files_struct *dirfsp,
    1524             :                         const struct smb_filename *smb_fname,
    1525             :                         mode_t mode)
    1526             : {
    1527        6816 :         VFS_FIND(mkdirat);
    1528        2588 :         return handle->fns->mkdirat_fn(handle,
    1529             :                         dirfsp,
    1530             :                         smb_fname,
    1531             :                         mode);
    1532             : }
    1533             : 
    1534       11001 : int smb_vfs_call_closedir(struct vfs_handle_struct *handle,
    1535             :                           DIR *dir)
    1536             : {
    1537       40612 :         VFS_FIND(closedir);
    1538       11001 :         return handle->fns->closedir_fn(handle, dir);
    1539             : }
    1540             : 
    1541      590897 : int smb_vfs_call_openat(struct vfs_handle_struct *handle,
    1542             :                         const struct files_struct *dirfsp,
    1543             :                         const struct smb_filename *smb_fname,
    1544             :                         struct files_struct *fsp,
    1545             :                         const struct vfs_open_how *how)
    1546             : {
    1547      961797 :         VFS_FIND(openat);
    1548      590897 :         return handle->fns->openat_fn(handle,
    1549             :                                       dirfsp,
    1550             :                                       smb_fname,
    1551             :                                       fsp,
    1552             :                                       how);
    1553             : }
    1554             : 
    1555       28959 : NTSTATUS smb_vfs_call_create_file(struct vfs_handle_struct *handle,
    1556             :                                   struct smb_request *req,
    1557             :                                   struct files_struct *dirfsp,
    1558             :                                   struct smb_filename *smb_fname,
    1559             :                                   uint32_t access_mask,
    1560             :                                   uint32_t share_access,
    1561             :                                   uint32_t create_disposition,
    1562             :                                   uint32_t create_options,
    1563             :                                   uint32_t file_attributes,
    1564             :                                   uint32_t oplock_request,
    1565             :                                   const struct smb2_lease *lease,
    1566             :                                   uint64_t allocation_size,
    1567             :                                   uint32_t private_flags,
    1568             :                                   struct security_descriptor *sd,
    1569             :                                   struct ea_list *ea_list,
    1570             :                                   files_struct **result,
    1571             :                                   int *pinfo,
    1572             :                                   const struct smb2_create_blobs *in_context_blobs,
    1573             :                                   struct smb2_create_blobs *out_context_blobs)
    1574             : {
    1575       92207 :         VFS_FIND(create_file);
    1576       28959 :         return handle->fns->create_file_fn(
    1577             :                 handle, req, dirfsp, smb_fname,
    1578             :                 access_mask, share_access, create_disposition, create_options,
    1579             :                 file_attributes, oplock_request, lease, allocation_size,
    1580             :                 private_flags, sd, ea_list,
    1581             :                 result, pinfo, in_context_blobs, out_context_blobs);
    1582             : }
    1583             : 
    1584      165732 : int smb_vfs_call_close(struct vfs_handle_struct *handle,
    1585             :                        struct files_struct *fsp)
    1586             : {
    1587      577103 :         VFS_FIND(close);
    1588      165732 :         return handle->fns->close_fn(handle, fsp);
    1589             : }
    1590             : 
    1591           0 : ssize_t smb_vfs_call_pread(struct vfs_handle_struct *handle,
    1592             :                            struct files_struct *fsp, void *data, size_t n,
    1593             :                            off_t offset)
    1594             : {
    1595           0 :         VFS_FIND(pread);
    1596           0 :         return handle->fns->pread_fn(handle, fsp, data, n, offset);
    1597             : }
    1598             : 
    1599             : struct smb_vfs_call_pread_state {
    1600             :         ssize_t (*recv_fn)(struct tevent_req *req, struct vfs_aio_state *vfs_aio_state);
    1601             :         ssize_t retval;
    1602             :         struct vfs_aio_state vfs_aio_state;
    1603             : };
    1604             : 
    1605             : static void smb_vfs_call_pread_done(struct tevent_req *subreq);
    1606             : 
    1607         414 : struct tevent_req *smb_vfs_call_pread_send(struct vfs_handle_struct *handle,
    1608             :                                            TALLOC_CTX *mem_ctx,
    1609             :                                            struct tevent_context *ev,
    1610             :                                            struct files_struct *fsp,
    1611             :                                            void *data,
    1612             :                                            size_t n, off_t offset)
    1613             : {
    1614             :         struct tevent_req *req, *subreq;
    1615             :         struct smb_vfs_call_pread_state *state;
    1616             : 
    1617         414 :         req = tevent_req_create(mem_ctx, &state,
    1618             :                                 struct smb_vfs_call_pread_state);
    1619         414 :         if (req == NULL) {
    1620           0 :                 return NULL;
    1621             :         }
    1622        2275 :         VFS_FIND(pread_send);
    1623         414 :         state->recv_fn = handle->fns->pread_recv_fn;
    1624             : 
    1625         414 :         subreq = handle->fns->pread_send_fn(handle, state, ev, fsp, data, n,
    1626             :                                             offset);
    1627         414 :         if (tevent_req_nomem(subreq, req)) {
    1628           0 :                 return tevent_req_post(req, ev);
    1629             :         }
    1630         414 :         tevent_req_set_callback(subreq, smb_vfs_call_pread_done, req);
    1631         414 :         return req;
    1632             : }
    1633             : 
    1634         414 : static void smb_vfs_call_pread_done(struct tevent_req *subreq)
    1635             : {
    1636         414 :         struct tevent_req *req = tevent_req_callback_data(
    1637             :                 subreq, struct tevent_req);
    1638         414 :         struct smb_vfs_call_pread_state *state = tevent_req_data(
    1639             :                 req, struct smb_vfs_call_pread_state);
    1640             : 
    1641         414 :         state->retval = state->recv_fn(subreq, &state->vfs_aio_state);
    1642         414 :         TALLOC_FREE(subreq);
    1643         414 :         if (state->retval == -1) {
    1644           0 :                 tevent_req_error(req, state->vfs_aio_state.error);
    1645           0 :                 return;
    1646             :         }
    1647         414 :         tevent_req_done(req);
    1648             : }
    1649             : 
    1650         414 : ssize_t SMB_VFS_PREAD_RECV(struct tevent_req *req,
    1651             :                            struct vfs_aio_state *vfs_aio_state)
    1652             : {
    1653         414 :         struct smb_vfs_call_pread_state *state = tevent_req_data(
    1654             :                 req, struct smb_vfs_call_pread_state);
    1655             :         ssize_t retval;
    1656             : 
    1657         414 :         if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
    1658           0 :                 tevent_req_received(req);
    1659           0 :                 return -1;
    1660             :         }
    1661         414 :         *vfs_aio_state = state->vfs_aio_state;
    1662         414 :         retval = state->retval;
    1663         414 :         tevent_req_received(req);
    1664         414 :         return retval;
    1665             : }
    1666             : 
    1667          64 : ssize_t smb_vfs_call_pwrite(struct vfs_handle_struct *handle,
    1668             :                             struct files_struct *fsp, const void *data,
    1669             :                             size_t n, off_t offset)
    1670             : {
    1671         144 :         VFS_FIND(pwrite);
    1672          64 :         return handle->fns->pwrite_fn(handle, fsp, data, n, offset);
    1673             : }
    1674             : 
    1675             : struct smb_vfs_call_pwrite_state {
    1676             :         ssize_t (*recv_fn)(struct tevent_req *req, struct vfs_aio_state *vfs_aio_state);
    1677             :         ssize_t retval;
    1678             :         struct vfs_aio_state vfs_aio_state;
    1679             : };
    1680             : 
    1681             : static void smb_vfs_call_pwrite_done(struct tevent_req *subreq);
    1682             : 
    1683         524 : struct tevent_req *smb_vfs_call_pwrite_send(struct vfs_handle_struct *handle,
    1684             :                                             TALLOC_CTX *mem_ctx,
    1685             :                                             struct tevent_context *ev,
    1686             :                                             struct files_struct *fsp,
    1687             :                                             const void *data,
    1688             :                                             size_t n, off_t offset)
    1689             : {
    1690             :         struct tevent_req *req, *subreq;
    1691             :         struct smb_vfs_call_pwrite_state *state;
    1692             : 
    1693         524 :         req = tevent_req_create(mem_ctx, &state,
    1694             :                                 struct smb_vfs_call_pwrite_state);
    1695         524 :         if (req == NULL) {
    1696           0 :                 return NULL;
    1697             :         }
    1698        2605 :         VFS_FIND(pwrite_send);
    1699         524 :         state->recv_fn = handle->fns->pwrite_recv_fn;
    1700             : 
    1701         524 :         subreq = handle->fns->pwrite_send_fn(handle, state, ev, fsp, data, n,
    1702             :                                              offset);
    1703         524 :         if (tevent_req_nomem(subreq, req)) {
    1704           0 :                 return tevent_req_post(req, ev);
    1705             :         }
    1706         524 :         tevent_req_set_callback(subreq, smb_vfs_call_pwrite_done, req);
    1707         524 :         return req;
    1708             : }
    1709             : 
    1710         524 : static void smb_vfs_call_pwrite_done(struct tevent_req *subreq)
    1711             : {
    1712         524 :         struct tevent_req *req = tevent_req_callback_data(
    1713             :                 subreq, struct tevent_req);
    1714         524 :         struct smb_vfs_call_pwrite_state *state = tevent_req_data(
    1715             :                 req, struct smb_vfs_call_pwrite_state);
    1716             : 
    1717         524 :         state->retval = state->recv_fn(subreq, &state->vfs_aio_state);
    1718         524 :         TALLOC_FREE(subreq);
    1719         524 :         if (state->retval == -1) {
    1720           0 :                 tevent_req_error(req, state->vfs_aio_state.error);
    1721           0 :                 return;
    1722             :         }
    1723         524 :         tevent_req_done(req);
    1724             : }
    1725             : 
    1726         524 : ssize_t SMB_VFS_PWRITE_RECV(struct tevent_req *req,
    1727             :                             struct vfs_aio_state *vfs_aio_state)
    1728             : {
    1729         524 :         struct smb_vfs_call_pwrite_state *state = tevent_req_data(
    1730             :                 req, struct smb_vfs_call_pwrite_state);
    1731             :         ssize_t retval;
    1732             : 
    1733         524 :         if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
    1734           0 :                 tevent_req_received(req);
    1735           0 :                 return -1;
    1736             :         }
    1737         524 :         *vfs_aio_state = state->vfs_aio_state;
    1738         524 :         retval = state->retval;
    1739         524 :         tevent_req_received(req);
    1740         524 :         return retval;
    1741             : }
    1742             : 
    1743           0 : off_t smb_vfs_call_lseek(struct vfs_handle_struct *handle,
    1744             :                              struct files_struct *fsp, off_t offset,
    1745             :                              int whence)
    1746             : {
    1747           0 :         VFS_FIND(lseek);
    1748           0 :         return handle->fns->lseek_fn(handle, fsp, offset, whence);
    1749             : }
    1750             : 
    1751           0 : ssize_t smb_vfs_call_sendfile(struct vfs_handle_struct *handle, int tofd,
    1752             :                               files_struct *fromfsp, const DATA_BLOB *header,
    1753             :                               off_t offset, size_t count)
    1754             : {
    1755           0 :         VFS_FIND(sendfile);
    1756           0 :         return handle->fns->sendfile_fn(handle, tofd, fromfsp, header, offset,
    1757             :                                         count);
    1758             : }
    1759             : 
    1760           0 : ssize_t smb_vfs_call_recvfile(struct vfs_handle_struct *handle, int fromfd,
    1761             :                               files_struct *tofsp, off_t offset,
    1762             :                               size_t count)
    1763             : {
    1764           0 :         VFS_FIND(recvfile);
    1765           0 :         return handle->fns->recvfile_fn(handle, fromfd, tofsp, offset, count);
    1766             : }
    1767             : 
    1768          80 : int smb_vfs_call_renameat(struct vfs_handle_struct *handle,
    1769             :                         files_struct *srcfsp,
    1770             :                         const struct smb_filename *smb_fname_src,
    1771             :                         files_struct *dstfsp,
    1772             :                         const struct smb_filename *smb_fname_dst)
    1773             : {
    1774         140 :         VFS_FIND(renameat);
    1775          80 :         return handle->fns->renameat_fn(handle,
    1776             :                                 srcfsp,
    1777             :                                 smb_fname_src,
    1778             :                                 dstfsp,
    1779             :                                 smb_fname_dst);
    1780             : }
    1781             : 
    1782             : struct smb_vfs_call_fsync_state {
    1783             :         int (*recv_fn)(struct tevent_req *req, struct vfs_aio_state *vfs_aio_state);
    1784             :         int retval;
    1785             :         struct vfs_aio_state vfs_aio_state;
    1786             : };
    1787             : 
    1788             : static void smb_vfs_call_fsync_done(struct tevent_req *subreq);
    1789             : 
    1790           0 : struct tevent_req *smb_vfs_call_fsync_send(struct vfs_handle_struct *handle,
    1791             :                                            TALLOC_CTX *mem_ctx,
    1792             :                                            struct tevent_context *ev,
    1793             :                                            struct files_struct *fsp)
    1794             : {
    1795             :         struct tevent_req *req, *subreq;
    1796             :         struct smb_vfs_call_fsync_state *state;
    1797             : 
    1798           0 :         req = tevent_req_create(mem_ctx, &state,
    1799             :                                 struct smb_vfs_call_fsync_state);
    1800           0 :         if (req == NULL) {
    1801           0 :                 return NULL;
    1802             :         }
    1803           0 :         VFS_FIND(fsync_send);
    1804           0 :         state->recv_fn = handle->fns->fsync_recv_fn;
    1805             : 
    1806           0 :         subreq = handle->fns->fsync_send_fn(handle, state, ev, fsp);
    1807           0 :         if (tevent_req_nomem(subreq, req)) {
    1808           0 :                 return tevent_req_post(req, ev);
    1809             :         }
    1810           0 :         tevent_req_set_callback(subreq, smb_vfs_call_fsync_done, req);
    1811           0 :         return req;
    1812             : }
    1813             : 
    1814           0 : static void smb_vfs_call_fsync_done(struct tevent_req *subreq)
    1815             : {
    1816           0 :         struct tevent_req *req = tevent_req_callback_data(
    1817             :                 subreq, struct tevent_req);
    1818           0 :         struct smb_vfs_call_fsync_state *state = tevent_req_data(
    1819             :                 req, struct smb_vfs_call_fsync_state);
    1820             : 
    1821           0 :         state->retval = state->recv_fn(subreq, &state->vfs_aio_state);
    1822           0 :         TALLOC_FREE(subreq);
    1823           0 :         if (state->retval == -1) {
    1824           0 :                 tevent_req_error(req, state->vfs_aio_state.error);
    1825           0 :                 return;
    1826             :         }
    1827           0 :         tevent_req_done(req);
    1828             : }
    1829             : 
    1830           0 : int SMB_VFS_FSYNC_RECV(struct tevent_req *req, struct vfs_aio_state *vfs_aio_state)
    1831             : {
    1832           0 :         struct smb_vfs_call_fsync_state *state = tevent_req_data(
    1833             :                 req, struct smb_vfs_call_fsync_state);
    1834             :         ssize_t retval;
    1835             : 
    1836           0 :         if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
    1837           0 :                 tevent_req_received(req);
    1838           0 :                 return -1;
    1839             :         }
    1840           0 :         *vfs_aio_state = state->vfs_aio_state;
    1841           0 :         retval = state->retval;
    1842           0 :         tevent_req_received(req);
    1843           0 :         return retval;
    1844             : }
    1845             : 
    1846             : /*
    1847             :  * Synchronous version of fsync, built from backend
    1848             :  * async VFS primitives. Uses a temporary sub-event
    1849             :  * context (NOT NESTED).
    1850             :  */
    1851             : 
    1852           0 : int smb_vfs_fsync_sync(files_struct *fsp)
    1853             : {
    1854           0 :         TALLOC_CTX *frame = talloc_stackframe();
    1855           0 :         struct tevent_req *req = NULL;
    1856           0 :         struct vfs_aio_state aio_state = { 0 };
    1857           0 :         int ret = -1;
    1858             :         bool ok;
    1859           0 :         struct tevent_context *ev = samba_tevent_context_init(frame);
    1860             : 
    1861           0 :         if (ev == NULL) {
    1862           0 :                 goto out;
    1863             :         }
    1864             : 
    1865           0 :         req = SMB_VFS_FSYNC_SEND(talloc_tos(), ev, fsp);
    1866           0 :         if (req == NULL) {
    1867           0 :                 goto out;
    1868             :         }
    1869             : 
    1870           0 :         ok = tevent_req_poll(req, ev);
    1871           0 :         if (!ok) {
    1872           0 :                 goto out;
    1873             :         }
    1874             : 
    1875           0 :         ret = SMB_VFS_FSYNC_RECV(req, &aio_state);
    1876             : 
    1877           0 :   out:
    1878             : 
    1879           0 :         TALLOC_FREE(frame);
    1880           0 :         if (aio_state.error != 0) {
    1881           0 :                 errno = aio_state.error;
    1882             :         }
    1883           0 :         return ret;
    1884             : }
    1885             : 
    1886      503260 : int smb_vfs_call_stat(struct vfs_handle_struct *handle,
    1887             :                       struct smb_filename *smb_fname)
    1888             : {
    1889      853719 :         VFS_FIND(stat);
    1890      503260 :         return handle->fns->stat_fn(handle, smb_fname);
    1891             : }
    1892             : 
    1893     1088168 : int smb_vfs_call_fstat(struct vfs_handle_struct *handle,
    1894             :                        struct files_struct *fsp, SMB_STRUCT_STAT *sbuf)
    1895             : {
    1896     1951859 :         VFS_FIND(fstat);
    1897     1088168 :         return handle->fns->fstat_fn(handle, fsp, sbuf);
    1898             : }
    1899             : 
    1900        2647 : int smb_vfs_call_lstat(struct vfs_handle_struct *handle,
    1901             :                        struct smb_filename *smb_filename)
    1902             : {
    1903        4981 :         VFS_FIND(lstat);
    1904        2647 :         return handle->fns->lstat_fn(handle, smb_filename);
    1905             : }
    1906             : 
    1907        1330 : int smb_vfs_call_fstatat(
    1908             :         struct vfs_handle_struct *handle,
    1909             :         const struct files_struct *dirfsp,
    1910             :         const struct smb_filename *smb_fname,
    1911             :         SMB_STRUCT_STAT *sbuf,
    1912             :         int flags)
    1913             : {
    1914        2419 :         VFS_FIND(fstatat);
    1915        1330 :         return handle->fns->fstatat_fn(handle, dirfsp, smb_fname, sbuf, flags);
    1916             : }
    1917             : 
    1918       56370 : uint64_t smb_vfs_call_get_alloc_size(struct vfs_handle_struct *handle,
    1919             :                                      struct files_struct *fsp,
    1920             :                                      const SMB_STRUCT_STAT *sbuf)
    1921             : {
    1922      189557 :         VFS_FIND(get_alloc_size);
    1923       56370 :         return handle->fns->get_alloc_size_fn(handle, fsp, sbuf);
    1924             : }
    1925             : 
    1926        6202 : int smb_vfs_call_unlinkat(struct vfs_handle_struct *handle,
    1927             :                         struct files_struct *dirfsp,
    1928             :                         const struct smb_filename *smb_fname,
    1929             :                         int flags)
    1930             : {
    1931        8635 :         VFS_FIND(unlinkat);
    1932        6202 :         return handle->fns->unlinkat_fn(handle,
    1933             :                         dirfsp,
    1934             :                         smb_fname,
    1935             :                         flags);
    1936             : }
    1937             : 
    1938           0 : int smb_vfs_call_fchmod(struct vfs_handle_struct *handle,
    1939             :                         struct files_struct *fsp, mode_t mode)
    1940             : {
    1941           0 :         VFS_FIND(fchmod);
    1942           0 :         return handle->fns->fchmod_fn(handle, fsp, mode);
    1943             : }
    1944             : 
    1945        2729 : int smb_vfs_call_fchown(struct vfs_handle_struct *handle,
    1946             :                         struct files_struct *fsp, uid_t uid, gid_t gid)
    1947             : {
    1948        7842 :         VFS_FIND(fchown);
    1949        2729 :         return handle->fns->fchown_fn(handle, fsp, uid, gid);
    1950             : }
    1951             : 
    1952           0 : int smb_vfs_call_lchown(struct vfs_handle_struct *handle,
    1953             :                         const struct smb_filename *smb_fname,
    1954             :                         uid_t uid,
    1955             :                         gid_t gid)
    1956             : {
    1957           0 :         VFS_FIND(lchown);
    1958           0 :         return handle->fns->lchown_fn(handle, smb_fname, uid, gid);
    1959             : }
    1960             : 
    1961       87446 : int smb_vfs_call_chdir(struct vfs_handle_struct *handle,
    1962             :                         const struct smb_filename *smb_fname)
    1963             : {
    1964      331313 :         VFS_FIND(chdir);
    1965       87446 :         return handle->fns->chdir_fn(handle, smb_fname);
    1966             : }
    1967             : 
    1968       19106 : struct smb_filename *smb_vfs_call_getwd(struct vfs_handle_struct *handle,
    1969             :                                 TALLOC_CTX *ctx)
    1970             : {
    1971       78627 :         VFS_FIND(getwd);
    1972       19106 :         return handle->fns->getwd_fn(handle, ctx);
    1973             : }
    1974             : 
    1975         728 : int smb_vfs_call_fntimes(struct vfs_handle_struct *handle,
    1976             :                          struct files_struct *fsp,
    1977             :                          struct smb_file_time *ft)
    1978             : {
    1979        3089 :         VFS_FIND(fntimes);
    1980         728 :         return handle->fns->fntimes_fn(handle, fsp, ft);
    1981             : }
    1982             : 
    1983         100 : int smb_vfs_call_ftruncate(struct vfs_handle_struct *handle,
    1984             :                            struct files_struct *fsp, off_t offset)
    1985             : {
    1986         446 :         VFS_FIND(ftruncate);
    1987         100 :         return handle->fns->ftruncate_fn(handle, fsp, offset);
    1988             : }
    1989             : 
    1990           0 : int smb_vfs_call_fallocate(struct vfs_handle_struct *handle,
    1991             :                            struct files_struct *fsp,
    1992             :                            uint32_t mode,
    1993             :                            off_t offset,
    1994             :                            off_t len)
    1995             : {
    1996           0 :         VFS_FIND(fallocate);
    1997           0 :         return handle->fns->fallocate_fn(handle, fsp, mode, offset, len);
    1998             : }
    1999             : 
    2000           0 : int smb_vfs_call_filesystem_sharemode(struct vfs_handle_struct *handle,
    2001             :                                       struct files_struct *fsp,
    2002             :                                       uint32_t share_mode,
    2003             :                                       uint32_t access_mask)
    2004             : {
    2005           0 :         VFS_FIND(filesystem_sharemode);
    2006           0 :         return handle->fns->filesystem_sharemode_fn(handle,
    2007             :                                                     fsp,
    2008             :                                                     share_mode,
    2009             :                                                     access_mask);
    2010             : }
    2011             : 
    2012        3640 : int smb_vfs_call_fcntl(struct vfs_handle_struct *handle,
    2013             :                        struct files_struct *fsp, int cmd, ...)
    2014             : {
    2015             :         int result;
    2016             :         va_list cmd_arg;
    2017             : 
    2018       14948 :         VFS_FIND(fcntl);
    2019             : 
    2020        3640 :         va_start(cmd_arg, cmd);
    2021        3640 :         result = handle->fns->fcntl_fn(handle, fsp, cmd, cmd_arg);
    2022        3640 :         va_end(cmd_arg);
    2023             : 
    2024        3640 :         return result;
    2025             : }
    2026             : 
    2027           0 : int smb_vfs_call_linux_setlease(struct vfs_handle_struct *handle,
    2028             :                                 struct files_struct *fsp, int leasetype)
    2029             : {
    2030           0 :         VFS_FIND(linux_setlease);
    2031           0 :         return handle->fns->linux_setlease_fn(handle, fsp, leasetype);
    2032             : }
    2033             : 
    2034           0 : int smb_vfs_call_symlinkat(struct vfs_handle_struct *handle,
    2035             :                         const struct smb_filename *link_target,
    2036             :                         struct files_struct *dirfsp,
    2037             :                         const struct smb_filename *new_smb_fname)
    2038             : {
    2039           0 :         VFS_FIND(symlinkat);
    2040           0 :         return handle->fns->symlinkat_fn(handle,
    2041             :                                 link_target,
    2042             :                                 dirfsp,
    2043             :                                 new_smb_fname);
    2044             : }
    2045             : 
    2046       44358 : int smb_vfs_call_readlinkat(struct vfs_handle_struct *handle,
    2047             :                         const struct files_struct *dirfsp,
    2048             :                         const struct smb_filename *smb_fname,
    2049             :                         char *buf,
    2050             :                         size_t bufsiz)
    2051             : {
    2052      103502 :         VFS_FIND(readlinkat);
    2053       44358 :         return handle->fns->readlinkat_fn(handle,
    2054             :                                 dirfsp,
    2055             :                                 smb_fname,
    2056             :                                 buf,
    2057             :                                 bufsiz);
    2058             : }
    2059             : 
    2060          12 : int smb_vfs_call_linkat(struct vfs_handle_struct *handle,
    2061             :                         struct files_struct *srcfsp,
    2062             :                         const struct smb_filename *old_smb_fname,
    2063             :                         struct files_struct *dstfsp,
    2064             :                         const struct smb_filename *new_smb_fname,
    2065             :                         int flags)
    2066             : {
    2067          28 :         VFS_FIND(linkat);
    2068          12 :         return handle->fns->linkat_fn(handle,
    2069             :                                 srcfsp,
    2070             :                                 old_smb_fname,
    2071             :                                 dstfsp,
    2072             :                                 new_smb_fname,
    2073             :                                 flags);
    2074             : }
    2075             : 
    2076           0 : int smb_vfs_call_mknodat(struct vfs_handle_struct *handle,
    2077             :                         struct files_struct *dirfsp,
    2078             :                         const struct smb_filename *smb_fname,
    2079             :                         mode_t mode,
    2080             :                         SMB_DEV_T dev)
    2081             : {
    2082           0 :         VFS_FIND(mknodat);
    2083           0 :         return handle->fns->mknodat_fn(handle,
    2084             :                                 dirfsp,
    2085             :                                 smb_fname,
    2086             :                                 mode,
    2087             :                                 dev);
    2088             : }
    2089             : 
    2090      180940 : struct smb_filename *smb_vfs_call_realpath(struct vfs_handle_struct *handle,
    2091             :                         TALLOC_CTX *ctx,
    2092             :                         const struct smb_filename *smb_fname)
    2093             : {
    2094      655205 :         VFS_FIND(realpath);
    2095      180940 :         return handle->fns->realpath_fn(handle, ctx, smb_fname);
    2096             : }
    2097             : 
    2098           0 : int smb_vfs_call_fchflags(struct vfs_handle_struct *handle,
    2099             :                         struct files_struct *fsp,
    2100             :                         unsigned int flags)
    2101             : {
    2102           0 :         VFS_FIND(fchflags);
    2103           0 :         return handle->fns->fchflags_fn(handle, fsp, flags);
    2104             : }
    2105             : 
    2106     1092198 : struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,
    2107             :                                            const SMB_STRUCT_STAT *sbuf)
    2108             : {
    2109     2443847 :         VFS_FIND(file_id_create);
    2110     1092198 :         return handle->fns->file_id_create_fn(handle, sbuf);
    2111             : }
    2112             : 
    2113       23108 : uint64_t smb_vfs_call_fs_file_id(struct vfs_handle_struct *handle,
    2114             :                                  const SMB_STRUCT_STAT *sbuf)
    2115             : {
    2116       75015 :         VFS_FIND(fs_file_id);
    2117       23108 :         return handle->fns->fs_file_id_fn(handle, sbuf);
    2118             : }
    2119             : 
    2120        6900 : NTSTATUS smb_vfs_call_fstreaminfo(struct vfs_handle_struct *handle,
    2121             :                                  struct files_struct *fsp,
    2122             :                                  TALLOC_CTX *mem_ctx,
    2123             :                                  unsigned int *num_streams,
    2124             :                                  struct stream_struct **streams)
    2125             : {
    2126       17489 :         VFS_FIND(fstreaminfo);
    2127        6900 :         return handle->fns->fstreaminfo_fn(handle, fsp, mem_ctx,
    2128             :                                           num_streams, streams);
    2129             : }
    2130             : 
    2131        6277 : NTSTATUS smb_vfs_call_get_real_filename_at(struct vfs_handle_struct *handle,
    2132             :                                            struct files_struct *dirfsp,
    2133             :                                            const char *name,
    2134             :                                            TALLOC_CTX *mem_ctx,
    2135             :                                            char **found_name)
    2136             : {
    2137       21820 :         VFS_FIND(get_real_filename_at);
    2138        6277 :         return handle->fns->get_real_filename_at_fn(
    2139             :                 handle, dirfsp, name, mem_ctx, found_name);
    2140             : }
    2141             : 
    2142      218876 : const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,
    2143             :                                  const struct files_struct *dirfsp,
    2144             :                                  const struct smb_filename *smb_fname)
    2145             : {
    2146      765927 :         VFS_FIND(connectpath);
    2147      218876 :         return handle->fns->connectpath_fn(handle, dirfsp, smb_fname);
    2148             : }
    2149             : 
    2150        1002 : bool smb_vfs_call_strict_lock_check(struct vfs_handle_struct *handle,
    2151             :                                     struct files_struct *fsp,
    2152             :                                     struct lock_struct *plock)
    2153             : {
    2154        5024 :         VFS_FIND(strict_lock_check);
    2155        1002 :         return handle->fns->strict_lock_check_fn(handle, fsp, plock);
    2156             : }
    2157             : 
    2158       64641 : NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle,
    2159             :                                      const char *name,
    2160             :                                      enum vfs_translate_direction direction,
    2161             :                                      TALLOC_CTX *mem_ctx,
    2162             :                                      char **mapped_name)
    2163             : {
    2164      191637 :         VFS_FIND(translate_name);
    2165       64641 :         return handle->fns->translate_name_fn(handle, name, direction, mem_ctx,
    2166             :                                               mapped_name);
    2167             : }
    2168             : 
    2169      192411 : NTSTATUS smb_vfs_call_parent_pathname(struct vfs_handle_struct *handle,
    2170             :                                       TALLOC_CTX *mem_ctx,
    2171             :                                       const struct smb_filename *smb_fname_in,
    2172             :                                       struct smb_filename **parent_dir_out,
    2173             :                                       struct smb_filename **atname_out)
    2174             : {
    2175      678625 :         VFS_FIND(parent_pathname);
    2176      192411 :         return handle->fns->parent_pathname_fn(handle,
    2177             :                                                mem_ctx,
    2178             :                                                smb_fname_in,
    2179             :                                                parent_dir_out,
    2180             :                                                atname_out);
    2181             : }
    2182             : 
    2183         144 : NTSTATUS smb_vfs_call_fsctl(struct vfs_handle_struct *handle,
    2184             :                             struct files_struct *fsp,
    2185             :                             TALLOC_CTX *ctx,
    2186             :                             uint32_t function,
    2187             :                             uint16_t req_flags,
    2188             :                             const uint8_t *in_data,
    2189             :                             uint32_t in_len,
    2190             :                             uint8_t **out_data,
    2191             :                             uint32_t max_out_len,
    2192             :                             uint32_t *out_len)
    2193             : {
    2194         336 :         VFS_FIND(fsctl);
    2195         144 :         return handle->fns->fsctl_fn(handle, fsp, ctx, function, req_flags,
    2196             :                                      in_data, in_len, out_data, max_out_len,
    2197             :                                      out_len);
    2198             : }
    2199             : 
    2200       68829 : NTSTATUS smb_vfs_call_fget_dos_attributes(struct vfs_handle_struct *handle,
    2201             :                                           struct files_struct *fsp,
    2202             :                                           uint32_t *dosmode)
    2203             : {
    2204      209291 :         VFS_FIND(fget_dos_attributes);
    2205       68829 :         return handle->fns->fget_dos_attributes_fn(handle, fsp, dosmode);
    2206             : }
    2207             : 
    2208        2311 : NTSTATUS smb_vfs_call_fset_dos_attributes(struct vfs_handle_struct *handle,
    2209             :                                           struct files_struct *fsp,
    2210             :                                           uint32_t dosmode)
    2211             : {
    2212        9243 :         VFS_FIND(fset_dos_attributes);
    2213        2311 :         return handle->fns->fset_dos_attributes_fn(handle, fsp, dosmode);
    2214             : }
    2215             : 
    2216           0 : struct tevent_req *smb_vfs_call_offload_read_send(TALLOC_CTX *mem_ctx,
    2217             :                                                   struct tevent_context *ev,
    2218             :                                                   struct vfs_handle_struct *handle,
    2219             :                                                   struct files_struct *fsp,
    2220             :                                                   uint32_t fsctl,
    2221             :                                                   uint32_t ttl,
    2222             :                                                   off_t offset,
    2223             :                                                   size_t to_copy)
    2224             : {
    2225           0 :         VFS_FIND(offload_read_send);
    2226           0 :         return handle->fns->offload_read_send_fn(mem_ctx, ev, handle,
    2227             :                                                  fsp, fsctl,
    2228             :                                                  ttl, offset, to_copy);
    2229             : }
    2230             : 
    2231           0 : NTSTATUS smb_vfs_call_offload_read_recv(struct tevent_req *req,
    2232             :                                         struct vfs_handle_struct *handle,
    2233             :                                         TALLOC_CTX *mem_ctx,
    2234             :                                         uint32_t *flags,
    2235             :                                         uint64_t *xferlen,
    2236             :                                         DATA_BLOB *token_blob)
    2237             : {
    2238           0 :         VFS_FIND(offload_read_recv);
    2239           0 :         return handle->fns->offload_read_recv_fn(req, handle, mem_ctx, flags, xferlen, token_blob);
    2240             : }
    2241             : 
    2242           0 : struct tevent_req *smb_vfs_call_offload_write_send(struct vfs_handle_struct *handle,
    2243             :                                                    TALLOC_CTX *mem_ctx,
    2244             :                                                    struct tevent_context *ev,
    2245             :                                                    uint32_t fsctl,
    2246             :                                                    DATA_BLOB *token,
    2247             :                                                    off_t transfer_offset,
    2248             :                                                    struct files_struct *dest_fsp,
    2249             :                                                    off_t dest_off,
    2250             :                                                    off_t num)
    2251             : {
    2252           0 :         VFS_FIND(offload_write_send);
    2253           0 :         return handle->fns->offload_write_send_fn(handle, mem_ctx, ev, fsctl,
    2254             :                                                token, transfer_offset,
    2255             :                                                dest_fsp, dest_off, num);
    2256             : }
    2257             : 
    2258           0 : NTSTATUS smb_vfs_call_offload_write_recv(struct vfs_handle_struct *handle,
    2259             :                                          struct tevent_req *req,
    2260             :                                          off_t *copied)
    2261             : {
    2262           0 :         VFS_FIND(offload_write_recv);
    2263           0 :         return handle->fns->offload_write_recv_fn(handle, req, copied);
    2264             : }
    2265             : 
    2266             : struct smb_vfs_call_get_dos_attributes_state {
    2267             :         files_struct *dir_fsp;
    2268             :         NTSTATUS (*recv_fn)(struct tevent_req *req,
    2269             :                             struct vfs_aio_state *aio_state,
    2270             :                             uint32_t *dosmode);
    2271             :         struct vfs_aio_state aio_state;
    2272             :         uint32_t dos_attributes;
    2273             : };
    2274             : 
    2275             : static void smb_vfs_call_get_dos_attributes_done(struct tevent_req *subreq);
    2276             : 
    2277           0 : struct tevent_req *smb_vfs_call_get_dos_attributes_send(
    2278             :                         TALLOC_CTX *mem_ctx,
    2279             :                         struct tevent_context *ev,
    2280             :                         struct vfs_handle_struct *handle,
    2281             :                         files_struct *dir_fsp,
    2282             :                         struct smb_filename *smb_fname)
    2283             : {
    2284           0 :         struct tevent_req *req = NULL;
    2285           0 :         struct smb_vfs_call_get_dos_attributes_state *state = NULL;
    2286           0 :         struct tevent_req *subreq = NULL;
    2287             : 
    2288           0 :         req = tevent_req_create(mem_ctx, &state,
    2289             :                                 struct smb_vfs_call_get_dos_attributes_state);
    2290           0 :         if (req == NULL) {
    2291           0 :                 return NULL;
    2292             :         }
    2293             : 
    2294           0 :         VFS_FIND(get_dos_attributes_send);
    2295             : 
    2296           0 :         *state = (struct smb_vfs_call_get_dos_attributes_state) {
    2297             :                 .dir_fsp = dir_fsp,
    2298           0 :                 .recv_fn = handle->fns->get_dos_attributes_recv_fn,
    2299             :         };
    2300             : 
    2301           0 :         subreq = handle->fns->get_dos_attributes_send_fn(mem_ctx,
    2302             :                                                          ev,
    2303             :                                                          handle,
    2304             :                                                          dir_fsp,
    2305             :                                                          smb_fname);
    2306           0 :         if (tevent_req_nomem(subreq, req)) {
    2307           0 :                 return tevent_req_post(req, ev);
    2308             :         }
    2309           0 :         tevent_req_defer_callback(req, ev);
    2310             : 
    2311           0 :         tevent_req_set_callback(subreq,
    2312             :                                 smb_vfs_call_get_dos_attributes_done,
    2313             :                                 req);
    2314             : 
    2315           0 :         return req;
    2316             : }
    2317             : 
    2318           0 : static void smb_vfs_call_get_dos_attributes_done(struct tevent_req *subreq)
    2319             : {
    2320             :         struct tevent_req *req =
    2321           0 :                 tevent_req_callback_data(subreq,
    2322             :                 struct tevent_req);
    2323             :         struct smb_vfs_call_get_dos_attributes_state *state =
    2324           0 :                 tevent_req_data(req,
    2325             :                 struct smb_vfs_call_get_dos_attributes_state);
    2326             :         NTSTATUS status;
    2327             :         bool ok;
    2328             : 
    2329             :         /*
    2330             :          * Make sure we run as the user again
    2331             :          */
    2332           0 :         ok = change_to_user_and_service_by_fsp(state->dir_fsp);
    2333           0 :         SMB_ASSERT(ok);
    2334             : 
    2335           0 :         status = state->recv_fn(subreq,
    2336             :                                 &state->aio_state,
    2337             :                                 &state->dos_attributes);
    2338           0 :         TALLOC_FREE(subreq);
    2339           0 :         if (tevent_req_nterror(req, status)) {
    2340           0 :                 return;
    2341             :         }
    2342             : 
    2343           0 :         tevent_req_done(req);
    2344             : }
    2345             : 
    2346           0 : NTSTATUS smb_vfs_call_get_dos_attributes_recv(
    2347             :                 struct tevent_req *req,
    2348             :                 struct vfs_aio_state *aio_state,
    2349             :                 uint32_t *dos_attributes)
    2350             : {
    2351             :         struct smb_vfs_call_get_dos_attributes_state *state =
    2352           0 :                 tevent_req_data(req,
    2353             :                 struct smb_vfs_call_get_dos_attributes_state);
    2354             :         NTSTATUS status;
    2355             : 
    2356           0 :         if (tevent_req_is_nterror(req, &status)) {
    2357           0 :                 tevent_req_received(req);
    2358           0 :                 return status;
    2359             :         }
    2360             : 
    2361           0 :         *aio_state = state->aio_state;
    2362           0 :         *dos_attributes = state->dos_attributes;
    2363           0 :         tevent_req_received(req);
    2364           0 :         return NT_STATUS_OK;
    2365             : }
    2366             : 
    2367           0 : NTSTATUS smb_vfs_call_fget_compression(vfs_handle_struct *handle,
    2368             :                                       TALLOC_CTX *mem_ctx,
    2369             :                                       struct files_struct *fsp,
    2370             :                                       uint16_t *_compression_fmt)
    2371             : {
    2372           0 :         VFS_FIND(fget_compression);
    2373           0 :         return handle->fns->fget_compression_fn(handle, mem_ctx, fsp,
    2374             :                                                _compression_fmt);
    2375             : }
    2376             : 
    2377           0 : NTSTATUS smb_vfs_call_set_compression(vfs_handle_struct *handle,
    2378             :                                       TALLOC_CTX *mem_ctx,
    2379             :                                       struct files_struct *fsp,
    2380             :                                       uint16_t compression_fmt)
    2381             : {
    2382           0 :         VFS_FIND(set_compression);
    2383           0 :         return handle->fns->set_compression_fn(handle, mem_ctx, fsp,
    2384             :                                                compression_fmt);
    2385             : }
    2386             : 
    2387           0 : NTSTATUS smb_vfs_call_snap_check_path(vfs_handle_struct *handle,
    2388             :                                       TALLOC_CTX *mem_ctx,
    2389             :                                       const char *service_path,
    2390             :                                       char **base_volume)
    2391             : {
    2392           0 :         VFS_FIND(snap_check_path);
    2393           0 :         return handle->fns->snap_check_path_fn(handle, mem_ctx, service_path,
    2394             :                                                base_volume);
    2395             : }
    2396             : 
    2397           0 : NTSTATUS smb_vfs_call_snap_create(struct vfs_handle_struct *handle,
    2398             :                                   TALLOC_CTX *mem_ctx,
    2399             :                                   const char *base_volume,
    2400             :                                   time_t *tstamp,
    2401             :                                   bool rw,
    2402             :                                   char **base_path,
    2403             :                                   char **snap_path)
    2404             : {
    2405           0 :         VFS_FIND(snap_create);
    2406           0 :         return handle->fns->snap_create_fn(handle, mem_ctx, base_volume, tstamp,
    2407             :                                            rw, base_path, snap_path);
    2408             : }
    2409             : 
    2410           0 : NTSTATUS smb_vfs_call_snap_delete(struct vfs_handle_struct *handle,
    2411             :                                   TALLOC_CTX *mem_ctx,
    2412             :                                   char *base_path,
    2413             :                                   char *snap_path)
    2414             : {
    2415           0 :         VFS_FIND(snap_delete);
    2416           0 :         return handle->fns->snap_delete_fn(handle, mem_ctx, base_path,
    2417             :                                            snap_path);
    2418             : }
    2419             : 
    2420       17483 : NTSTATUS smb_vfs_call_fget_nt_acl(struct vfs_handle_struct *handle,
    2421             :                                   struct files_struct *fsp,
    2422             :                                   uint32_t security_info,
    2423             :                                   TALLOC_CTX *mem_ctx,
    2424             :                                   struct security_descriptor **ppdesc)
    2425             : {
    2426       40508 :         VFS_FIND(fget_nt_acl);
    2427       17483 :         return handle->fns->fget_nt_acl_fn(handle, fsp, security_info,
    2428             :                                            mem_ctx, ppdesc);
    2429             : }
    2430             : 
    2431        5464 : NTSTATUS smb_vfs_call_fset_nt_acl(struct vfs_handle_struct *handle,
    2432             :                                   struct files_struct *fsp,
    2433             :                                   uint32_t security_info_sent,
    2434             :                                   const struct security_descriptor *psd)
    2435             : {
    2436       14642 :         VFS_FIND(fset_nt_acl);
    2437        5464 :         return handle->fns->fset_nt_acl_fn(handle, fsp, security_info_sent, 
    2438             :                                            psd);
    2439             : }
    2440             : 
    2441           0 : NTSTATUS smb_vfs_call_audit_file(struct vfs_handle_struct *handle,
    2442             :                                  struct smb_filename *file,
    2443             :                                  struct security_acl *sacl,
    2444             :                                  uint32_t access_requested,
    2445             :                                  uint32_t access_denied)
    2446             : {
    2447           0 :         VFS_FIND(audit_file);
    2448           0 :         return handle->fns->audit_file_fn(handle, 
    2449             :                                           file, 
    2450             :                                           sacl, 
    2451             :                                           access_requested, 
    2452             :                                           access_denied);
    2453             : }
    2454             : 
    2455       26364 : SMB_ACL_T smb_vfs_call_sys_acl_get_fd(struct vfs_handle_struct *handle,
    2456             :                                       struct files_struct *fsp,
    2457             :                                       SMB_ACL_TYPE_T type,
    2458             :                                       TALLOC_CTX *mem_ctx)
    2459             : {
    2460       46823 :         VFS_FIND(sys_acl_get_fd);
    2461       26364 :         return handle->fns->sys_acl_get_fd_fn(handle, fsp, type, mem_ctx);
    2462             : }
    2463             : 
    2464        7875 : int smb_vfs_call_sys_acl_blob_get_fd(struct vfs_handle_struct *handle,
    2465             :                                      struct files_struct *fsp,
    2466             :                                      TALLOC_CTX *mem_ctx, 
    2467             :                                      char **blob_description,
    2468             :                                      DATA_BLOB *blob)
    2469             : {
    2470        7875 :         VFS_FIND(sys_acl_blob_get_fd);
    2471        7875 :         return handle->fns->sys_acl_blob_get_fd_fn(handle, fsp, mem_ctx, blob_description, blob);
    2472             : }
    2473             : 
    2474        3436 : int smb_vfs_call_sys_acl_set_fd(struct vfs_handle_struct *handle,
    2475             :                                 struct files_struct *fsp,
    2476             :                                 SMB_ACL_TYPE_T type,
    2477             :                                 SMB_ACL_T theacl)
    2478             : {
    2479        4691 :         VFS_FIND(sys_acl_set_fd);
    2480        3436 :         return handle->fns->sys_acl_set_fd_fn(handle, fsp, type, theacl);
    2481             : }
    2482             : 
    2483           5 : int smb_vfs_call_sys_acl_delete_def_fd(struct vfs_handle_struct *handle,
    2484             :                                 struct files_struct *fsp)
    2485             : {
    2486          10 :         VFS_FIND(sys_acl_delete_def_fd);
    2487           5 :         return handle->fns->sys_acl_delete_def_fd_fn(handle, fsp);
    2488             : }
    2489             : 
    2490             : struct smb_vfs_call_getxattrat_state {
    2491             :         files_struct *dir_fsp;
    2492             :         ssize_t (*recv_fn)(struct tevent_req *req,
    2493             :                            struct vfs_aio_state *aio_state,
    2494             :                            TALLOC_CTX *mem_ctx,
    2495             :                            uint8_t **xattr_value);
    2496             :         ssize_t retval;
    2497             :         uint8_t *xattr_value;
    2498             :         struct vfs_aio_state aio_state;
    2499             : };
    2500             : 
    2501             : static void smb_vfs_call_getxattrat_done(struct tevent_req *subreq);
    2502             : 
    2503           0 : struct tevent_req *smb_vfs_call_getxattrat_send(
    2504             :                         TALLOC_CTX *mem_ctx,
    2505             :                         struct tevent_context *ev,
    2506             :                         struct vfs_handle_struct *handle,
    2507             :                         files_struct *dir_fsp,
    2508             :                         const struct smb_filename *smb_fname,
    2509             :                         const char *xattr_name,
    2510             :                         size_t alloc_hint)
    2511             : {
    2512           0 :         struct tevent_req *req = NULL;
    2513           0 :         struct smb_vfs_call_getxattrat_state *state = NULL;
    2514           0 :         struct tevent_req *subreq = NULL;
    2515             : 
    2516           0 :         req = tevent_req_create(mem_ctx, &state,
    2517             :                                 struct smb_vfs_call_getxattrat_state);
    2518           0 :         if (req == NULL) {
    2519           0 :                 return NULL;
    2520             :         }
    2521             : 
    2522           0 :         VFS_FIND(getxattrat_send);
    2523             : 
    2524           0 :         *state = (struct smb_vfs_call_getxattrat_state) {
    2525             :                 .dir_fsp = dir_fsp,
    2526           0 :                 .recv_fn = handle->fns->getxattrat_recv_fn,
    2527             :         };
    2528             : 
    2529           0 :         subreq = handle->fns->getxattrat_send_fn(mem_ctx,
    2530             :                                                  ev,
    2531             :                                                  handle,
    2532             :                                                  dir_fsp,
    2533             :                                                  smb_fname,
    2534             :                                                  xattr_name,
    2535             :                                                  alloc_hint);
    2536           0 :         if (tevent_req_nomem(subreq, req)) {
    2537           0 :                 return tevent_req_post(req, ev);
    2538             :         }
    2539           0 :         tevent_req_defer_callback(req, ev);
    2540             : 
    2541           0 :         tevent_req_set_callback(subreq, smb_vfs_call_getxattrat_done, req);
    2542           0 :         return req;
    2543             : }
    2544             : 
    2545           0 : static void smb_vfs_call_getxattrat_done(struct tevent_req *subreq)
    2546             : {
    2547           0 :         struct tevent_req *req = tevent_req_callback_data(
    2548             :                 subreq, struct tevent_req);
    2549           0 :         struct smb_vfs_call_getxattrat_state *state = tevent_req_data(
    2550             :                 req, struct smb_vfs_call_getxattrat_state);
    2551             :         bool ok;
    2552             : 
    2553             :         /*
    2554             :          * Make sure we run as the user again
    2555             :          */
    2556           0 :         ok = change_to_user_and_service_by_fsp(state->dir_fsp);
    2557           0 :         SMB_ASSERT(ok);
    2558             : 
    2559           0 :         state->retval = state->recv_fn(subreq,
    2560             :                                        &state->aio_state,
    2561             :                                        state,
    2562             :                                        &state->xattr_value);
    2563           0 :         TALLOC_FREE(subreq);
    2564           0 :         if (state->retval == -1) {
    2565           0 :                 tevent_req_error(req, state->aio_state.error);
    2566           0 :                 return;
    2567             :         }
    2568             : 
    2569           0 :         tevent_req_done(req);
    2570             : }
    2571             : 
    2572           0 : ssize_t smb_vfs_call_getxattrat_recv(struct tevent_req *req,
    2573             :                                      struct vfs_aio_state *aio_state,
    2574             :                                      TALLOC_CTX *mem_ctx,
    2575             :                                      uint8_t **xattr_value)
    2576             : {
    2577           0 :         struct smb_vfs_call_getxattrat_state *state = tevent_req_data(
    2578             :                 req, struct smb_vfs_call_getxattrat_state);
    2579             :         size_t xattr_size;
    2580             : 
    2581           0 :         if (tevent_req_is_unix_error(req, &aio_state->error)) {
    2582           0 :                 tevent_req_received(req);
    2583           0 :                 return -1;
    2584             :         }
    2585             : 
    2586           0 :         *aio_state = state->aio_state;
    2587           0 :         xattr_size = state->retval;
    2588           0 :         if (xattr_value != NULL) {
    2589           0 :                 *xattr_value = talloc_move(mem_ctx, &state->xattr_value);
    2590             :         }
    2591             : 
    2592           0 :         tevent_req_received(req);
    2593           0 :         return xattr_size;
    2594             : }
    2595             : 
    2596      437914 : ssize_t smb_vfs_call_fgetxattr(struct vfs_handle_struct *handle,
    2597             :                                struct files_struct *fsp, const char *name,
    2598             :                                void *value, size_t size)
    2599             : {
    2600      498742 :         VFS_FIND(fgetxattr);
    2601      437914 :         return handle->fns->fgetxattr_fn(handle, fsp, name, value, size);
    2602             : }
    2603             : 
    2604       21330 : ssize_t smb_vfs_call_flistxattr(struct vfs_handle_struct *handle,
    2605             :                                 struct files_struct *fsp, char *list,
    2606             :                                 size_t size)
    2607             : {
    2608       37458 :         VFS_FIND(flistxattr);
    2609       21330 :         return handle->fns->flistxattr_fn(handle, fsp, list, size);
    2610             : }
    2611             : 
    2612          71 : int smb_vfs_call_fremovexattr(struct vfs_handle_struct *handle,
    2613             :                               struct files_struct *fsp, const char *name)
    2614             : {
    2615         129 :         VFS_FIND(fremovexattr);
    2616          71 :         return handle->fns->fremovexattr_fn(handle, fsp, name);
    2617             : }
    2618             : 
    2619       14234 : int smb_vfs_call_fsetxattr(struct vfs_handle_struct *handle,
    2620             :                            struct files_struct *fsp, const char *name,
    2621             :                            const void *value, size_t size, int flags)
    2622             : {
    2623       21177 :         VFS_FIND(fsetxattr);
    2624       14234 :         return handle->fns->fsetxattr_fn(handle, fsp, name, value, size, flags);
    2625             : }
    2626             : 
    2627           0 : bool smb_vfs_call_aio_force(struct vfs_handle_struct *handle,
    2628             :                             struct files_struct *fsp)
    2629             : {
    2630           0 :         VFS_FIND(aio_force);
    2631           0 :         return handle->fns->aio_force_fn(handle, fsp);
    2632             : }
    2633             : 
    2634           0 : NTSTATUS smb_vfs_call_durable_cookie(struct vfs_handle_struct *handle,
    2635             :                                      struct files_struct *fsp,
    2636             :                                      TALLOC_CTX *mem_ctx,
    2637             :                                      DATA_BLOB *cookie)
    2638             : {
    2639           0 :         VFS_FIND(durable_cookie);
    2640           0 :         return handle->fns->durable_cookie_fn(handle, fsp, mem_ctx, cookie);
    2641             : }
    2642             : 
    2643           0 : NTSTATUS smb_vfs_call_durable_disconnect(struct vfs_handle_struct *handle,
    2644             :                                          struct files_struct *fsp,
    2645             :                                          const DATA_BLOB old_cookie,
    2646             :                                          TALLOC_CTX *mem_ctx,
    2647             :                                          DATA_BLOB *new_cookie)
    2648             : {
    2649           0 :         VFS_FIND(durable_disconnect);
    2650           0 :         return handle->fns->durable_disconnect_fn(handle, fsp, old_cookie,
    2651             :                                                   mem_ctx, new_cookie);
    2652             : }
    2653             : 
    2654           0 : NTSTATUS smb_vfs_call_durable_reconnect(struct vfs_handle_struct *handle,
    2655             :                                         struct smb_request *smb1req,
    2656             :                                         struct smbXsrv_open *op,
    2657             :                                         const DATA_BLOB old_cookie,
    2658             :                                         TALLOC_CTX *mem_ctx,
    2659             :                                         struct files_struct **fsp,
    2660             :                                         DATA_BLOB *new_cookie)
    2661             : {
    2662           0 :         VFS_FIND(durable_reconnect);
    2663           0 :         return handle->fns->durable_reconnect_fn(handle, smb1req, op,
    2664             :                                                  old_cookie, mem_ctx, fsp,
    2665             :                                                  new_cookie);
    2666             : }
    2667             : 
    2668       20177 : NTSTATUS smb_vfs_call_freaddir_attr(struct vfs_handle_struct *handle,
    2669             :                                     struct files_struct *fsp,
    2670             :                                     TALLOC_CTX *mem_ctx,
    2671             :                                     struct readdir_attr_data **attr_data)
    2672             : {
    2673       65827 :         VFS_FIND(freaddir_attr);
    2674       20177 :         return handle->fns->freaddir_attr_fn(handle,
    2675             :                                              fsp,
    2676             :                                              mem_ctx,
    2677             :                                              attr_data);
    2678             : }
    2679             : 
    2680          30 : bool smb_vfs_call_lock(struct vfs_handle_struct *handle,
    2681             :                        struct files_struct *fsp, int op, off_t offset,
    2682             :                        off_t count, int type)
    2683             : {
    2684          70 :         VFS_FIND(lock);
    2685          30 :         return handle->fns->lock_fn(handle, fsp, op, offset, count, type);
    2686             : }
    2687             : 
    2688         998 : bool smb_vfs_call_getlock(struct vfs_handle_struct *handle,
    2689             :                           struct files_struct *fsp, off_t *poffset,
    2690             :                           off_t *pcount, int *ptype, pid_t *ppid)
    2691             : {
    2692        5020 :         VFS_FIND(getlock);
    2693         998 :         return handle->fns->getlock_fn(handle, fsp, poffset, pcount, ptype,
    2694             :                                        ppid);
    2695             : }
    2696             : 
    2697          15 : NTSTATUS smb_vfs_call_brl_lock_windows(struct vfs_handle_struct *handle,
    2698             :                                        struct byte_range_lock *br_lck,
    2699             :                                        struct lock_struct *plock)
    2700             : {
    2701          35 :         VFS_FIND(brl_lock_windows);
    2702          15 :         return handle->fns->brl_lock_windows_fn(handle, br_lck, plock);
    2703             : }
    2704             : 
    2705          27 : bool smb_vfs_call_brl_unlock_windows(struct vfs_handle_struct *handle,
    2706             :                                      struct byte_range_lock *br_lck,
    2707             :                                      const struct lock_struct *plock)
    2708             : {
    2709          63 :         VFS_FIND(brl_unlock_windows);
    2710          27 :         return handle->fns->brl_unlock_windows_fn(handle, br_lck, plock);
    2711             : }

Generated by: LCOV version 1.14