Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/smbd/vfs.c

    r919 r988  
    2828#include "smbd/smbd.h"
    2929#include "smbd/globals.h"
    30 #include "memcache.h"
     30#include "../lib/util/memcache.h"
    3131#include "transfer_file.h"
    3232#include "ntioctl.h"
     33#include "lib/util/tevent_unix.h"
    3334
    3435#undef DBGC_CLASS
     
    3637
    3738static_decl_vfs;
     39
     40struct vfs_fsp_data {
     41    struct vfs_fsp_data *next;
     42    struct vfs_handle_struct *owner;
     43    void (*destroy)(void *p_data);
     44    void *_dummy_;
     45    /* NOTE: This structure contains four pointers so that we can guarantee
     46     * that the end of the structure is always both 4-byte and 8-byte aligned.
     47     */
     48};
    3849
    3950struct vfs_init_function_entry {
     
    168179                          vfs_object));
    169180
    170                 status = smb_probe_module("vfs", module_path);
     181                status = smb_load_module("vfs", module_path);
    171182                if (!NT_STATUS_IS_OK(status)) {
    172183                        DEBUG(0, ("error probing vfs module '%s': %s\n",
     
    184195        DEBUGADD(5,("Successfully loaded vfs module [%s] with the new modules system\n", vfs_object));
    185196
    186         handle = TALLOC_ZERO_P(conn, vfs_handle_struct);
     197        handle = talloc_zero(conn, vfs_handle_struct);
    187198        if (!handle) {
    188199                DEBUG(0,("TALLOC_ZERO() failed!\n"));
     
    212223******************************************************************/
    213224
    214 #define EXT_DATA_AREA(e) ((uint8 *)(e) + sizeof(struct vfs_fsp_data))
     225#define EXT_DATA_AREA(e) ((uint8_t *)(e) + sizeof(struct vfs_fsp_data))
    215226
    216227void *vfs_add_fsp_extension_notype(vfs_handle_struct *handle,
     
    262273}
    263274
     275void vfs_remove_all_fsp_extensions(files_struct *fsp)
     276{
     277        struct vfs_fsp_data *curr;
     278        struct vfs_fsp_data *next;
     279
     280        for (curr = fsp->vfs_extension; curr; curr = next) {
     281
     282                next = curr->next;
     283                fsp->vfs_extension = next;
     284
     285                if (curr->destroy) {
     286                        curr->destroy(EXT_DATA_AREA(curr));
     287                }
     288                TALLOC_FREE(curr);
     289        }
     290}
     291
    264292void *vfs_memctx_fsp_extension(vfs_handle_struct *handle, files_struct *fsp)
    265293{
     
    301329        /* Normal share - initialise with disk access functions */
    302330        vfs_init_default(conn);
     331
     332        /* No need to load vfs modules for printer connections */
     333        if (conn->printer) {
     334                return True;
     335        }
     336
    303337        vfs_objects = lp_vfs_objects(SNUM(conn));
    304338
     
    360394}
    361395
    362 ssize_t vfs_pread_data(files_struct *fsp, char *buf,
    363                 size_t byte_count, SMB_OFF_T offset)
    364 {
    365         size_t total=0;
    366 
    367         while (total < byte_count)
    368         {
    369                 ssize_t ret = SMB_VFS_PREAD(fsp, buf + total,
    370                                         byte_count - total, offset + total);
    371 
    372                 if (ret == 0) return total;
    373                 if (ret == -1) {
    374                         if (errno == EINTR)
    375                                 continue;
    376                         else
    377                                 return -1;
    378                 }
    379                 total += ret;
    380         }
    381         return (ssize_t)total;
    382 }
    383 
    384396/****************************************************************************
    385397 Write data to a fd on the vfs.
     
    395407
    396408        if (req && req->unread_bytes) {
     409                int sockfd = req->xconn->transport.sock;
     410                int old_flags;
    397411                SMB_ASSERT(req->unread_bytes == N);
    398412                /* VFS_RECVFILE must drain the socket
    399413                 * before returning. */
    400414                req->unread_bytes = 0;
    401                 return SMB_VFS_RECVFILE(req->sconn->sock,
     415                /* Ensure the socket is blocking. */
     416                old_flags = fcntl(sockfd, F_GETFL, 0);
     417                if (set_blocking(sockfd, true) == -1) {
     418                        return (ssize_t)-1;
     419                }
     420                ret = SMB_VFS_RECVFILE(sockfd,
    402421                                        fsp,
    403                                         (SMB_OFF_T)-1,
     422                                        (off_t)-1,
    404423                                        N);
     424                if (fcntl(sockfd, F_SETFL, old_flags) == -1) {
     425                        return (ssize_t)-1;
     426                }
     427                return ret;
    405428        }
    406429
     
    422445                        const char *buffer,
    423446                        size_t N,
    424                         SMB_OFF_T offset)
     447                        off_t offset)
    425448{
    426449        size_t total=0;
     
    428451
    429452        if (req && req->unread_bytes) {
     453                int sockfd = req->xconn->transport.sock;
    430454                SMB_ASSERT(req->unread_bytes == N);
    431455                /* VFS_RECVFILE must drain the socket
    432456                 * before returning. */
    433457                req->unread_bytes = 0;
    434                 return SMB_VFS_RECVFILE(req->sconn->sock,
    435                                         fsp,
    436                                         offset,
    437                                         N);
     458                /*
     459                 * Leave the socket non-blocking and
     460                 * use SMB_VFS_RECVFILE. If it returns
     461                 * EAGAIN || EWOULDBLOCK temporarily set
     462                 * the socket blocking and retry
     463                 * the RECVFILE.
     464                 */
     465                while (total < N) {
     466                        ret = SMB_VFS_RECVFILE(sockfd,
     467                                                fsp,
     468                                                offset + total,
     469                                                N - total);
     470                        if (ret == 0 || (ret == -1 &&
     471                                         (errno == EAGAIN ||
     472                                          errno == EWOULDBLOCK))) {
     473                                int old_flags;
     474                                /* Ensure the socket is blocking. */
     475                                old_flags = fcntl(sockfd, F_GETFL, 0);
     476                                if (set_blocking(sockfd, true) == -1) {
     477                                        return (ssize_t)-1;
     478                                }
     479                                ret = SMB_VFS_RECVFILE(sockfd,
     480                                                        fsp,
     481                                                        offset + total,
     482                                                        N - total);
     483                                if (fcntl(sockfd, F_SETFL, old_flags) == -1) {
     484                                        return (ssize_t)-1;
     485                                }
     486                                if (ret == -1) {
     487                                        return (ssize_t)-1;
     488                                }
     489                                total += ret;
     490                                return (ssize_t)total;
     491                        }
     492                        /* Any other error case. */
     493                        if (ret == -1) {
     494                                return ret;
     495                        }
     496                        total += ret;
     497                }
     498                return (ssize_t)total;
    438499        }
    439500
     
    472533                  fsp_str_dbg(fsp), (double)len));
    473534
    474         if (((SMB_OFF_T)len) < 0) {
     535        if (((off_t)len) < 0) {
    475536                DEBUG(0,("vfs_allocate_file_space: %s negative len "
    476537                         "requested.\n", fsp_str_dbg(fsp)));
     
    496557                contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_SHRINK);
    497558
    498                 flush_write_cache(fsp, SIZECHANGE_FLUSH);
    499                 if ((ret = SMB_VFS_FTRUNCATE(fsp, (SMB_OFF_T)len)) != -1) {
     559                flush_write_cache(fsp, SAMBA_SIZECHANGE_FLUSH);
     560                if ((ret = SMB_VFS_FTRUNCATE(fsp, (off_t)len)) != -1) {
    500561                        set_filelen_write_cache(fsp, len);
    501562                }
     
    506567        }
    507568
    508         if (!lp_strict_allocate(SNUM(fsp->conn)))
    509                 return 0;
    510 
    511569        /* Grow - we need to test if we have enough space. */
    512570
    513571        contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_GROW);
    514572
    515         /* See if we have a syscall that will allocate beyond end-of-file
    516            without changing EOF. */
    517         ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_KEEP_SIZE, 0, len);
     573        if (lp_strict_allocate(SNUM(fsp->conn))) {
     574                /* See if we have a syscall that will allocate beyond
     575                   end-of-file without changing EOF. */
     576                ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_FL_KEEP_SIZE,
     577                                        0, len);
     578        } else {
     579                ret = 0;
     580        }
    518581
    519582        contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_ALLOC_GROW);
     
    525588        }
    526589
     590        if (ret == -1 && errno == ENOSPC) {
     591                return -1;
     592        }
     593
    527594        len -= fsp->fsp_name->st.st_ex_size;
    528595        len /= 1024; /* Len is now number of 1k blocks needed. */
    529         space_avail = get_dfree_info(conn, fsp->fsp_name->base_name, false,
     596        space_avail = get_dfree_info(conn, fsp->fsp_name->base_name,
    530597                                     &bsize, &dfree, &dsize);
    531598        if (space_avail == (uint64_t)-1) {
     
    552619****************************************************************************/
    553620
    554 int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len)
     621int vfs_set_filelen(files_struct *fsp, off_t len)
    555622{
    556623        int ret;
     
    560627        DEBUG(10,("vfs_set_filelen: ftruncate %s to len %.0f\n",
    561628                  fsp_str_dbg(fsp), (double)len));
    562         flush_write_cache(fsp, SIZECHANGE_FLUSH);
     629        flush_write_cache(fsp, SAMBA_SIZECHANGE_FLUSH);
    563630        if ((ret = SMB_VFS_FTRUNCATE(fsp, len)) != -1) {
    564631                set_filelen_write_cache(fsp, len);
     
    579646 as this is also called from the default SMB_VFS_FTRUNCATE code.
    580647 Always extends the file size.
    581  Returns 0 on success, errno on failure.
     648 Returns 0 on success, -1 on failure.
    582649****************************************************************************/
    583650
    584651#define SPARSE_BUF_WRITE_SIZE (32*1024)
    585652
    586 int vfs_slow_fallocate(files_struct *fsp, SMB_OFF_T offset, SMB_OFF_T len)
     653int vfs_slow_fallocate(files_struct *fsp, off_t offset, off_t len)
    587654{
    588655        ssize_t pwrite_ret;
     
    593660                if (!sparse_buf) {
    594661                        errno = ENOMEM;
    595                         return ENOMEM;
     662                        return -1;
    596663                }
    597664        }
     
    602669                pwrite_ret = SMB_VFS_PWRITE(fsp, sparse_buf, curr_write_size, offset + total);
    603670                if (pwrite_ret == -1) {
     671                        int saved_errno = errno;
    604672                        DEBUG(10,("vfs_slow_fallocate: SMB_VFS_PWRITE for file "
    605673                                  "%s failed with error %s\n",
    606                                   fsp_str_dbg(fsp), strerror(errno)));
    607                         return errno;
     674                                  fsp_str_dbg(fsp), strerror(saved_errno)));
     675                        errno = saved_errno;
     676                        return -1;
    608677                }
    609678                total += pwrite_ret;
     
    620689****************************************************************************/
    621690
    622 int vfs_fill_sparse(files_struct *fsp, SMB_OFF_T len)
     691int vfs_fill_sparse(files_struct *fsp, off_t len)
    623692{
    624693        int ret;
    625694        NTSTATUS status;
    626         SMB_OFF_T offset;
     695        off_t offset;
    627696        size_t num_to_write;
    628697
     
    649718        contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_FILL_SPARSE);
    650719
    651         flush_write_cache(fsp, SIZECHANGE_FLUSH);
     720        flush_write_cache(fsp, SAMBA_SIZECHANGE_FLUSH);
    652721
    653722        offset = fsp->fsp_name->st.st_ex_size;
     
    661730                 * case we do our own emulation. fallocate implementations can
    662731                 * return ENOTSUP or EINVAL in cases like that. */
    663                 ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE,
    664                                 offset, num_to_write);
    665                 if (ret == ENOSPC) {
    666                         errno = ENOSPC;
    667                         ret = -1;
     732                ret = SMB_VFS_FALLOCATE(fsp, 0, offset, num_to_write);
     733                if (ret == -1 && errno == ENOSPC) {
    668734                        goto out;
    669735                }
     
    676742
    677743        ret = vfs_slow_fallocate(fsp, offset, num_to_write);
    678         if (ret != 0) {
    679                 errno = ret;
    680                 ret = -1;
    681         }
    682744
    683745 out:
     
    695757****************************************************************************/
    696758
    697 static ssize_t vfs_read_fn(void *file, void *buf, size_t len)
     759static ssize_t vfs_pread_fn(void *file, void *buf, size_t len, off_t offset)
    698760{
    699761        struct files_struct *fsp = (struct files_struct *)file;
    700762
    701         return SMB_VFS_READ(fsp, buf, len);
    702 }
    703 
    704 static ssize_t vfs_write_fn(void *file, const void *buf, size_t len)
     763        return SMB_VFS_PREAD(fsp, buf, len, offset);
     764}
     765
     766static ssize_t vfs_pwrite_fn(void *file, const void *buf, size_t len, off_t offset)
    705767{
    706768        struct files_struct *fsp = (struct files_struct *)file;
    707769
    708         return SMB_VFS_WRITE(fsp, buf, len);
    709 }
    710 
    711 SMB_OFF_T vfs_transfer_file(files_struct *in, files_struct *out, SMB_OFF_T n)
     770        return SMB_VFS_PWRITE(fsp, buf, len, offset);
     771}
     772
     773off_t vfs_transfer_file(files_struct *in, files_struct *out, off_t n)
    712774{
    713775        return transfer_file_internal((void *)in, (void *)out, n,
    714                                       vfs_read_fn, vfs_write_fn);
     776                                      vfs_pread_fn, vfs_pwrite_fn);
    715777}
    716778
     
    722784                            SMB_STRUCT_STAT *sbuf, char **talloced)
    723785{
    724         SMB_STRUCT_DIRENT *ptr= NULL;
     786        struct dirent *ptr= NULL;
    725787        const char *dname;
    726788        char *translated;
     
    766828int vfs_ChDir(connection_struct *conn, const char *path)
    767829{
    768         int res;
     830        int ret;
    769831
    770832        if (!LastDir) {
     
    772834        }
    773835
    774         if (strcsequal(path,"."))
    775                 return(0);
    776 
    777         if (*path == '/' && strcsequal(LastDir,path))
    778                 return(0);
     836        if (ISDOT(path)) {
     837                return 0;
     838        }
     839
     840        if (*path == '/' && strcsequal(LastDir,path)) {
     841                return 0;
     842        }
    779843
    780844        DEBUG(4,("vfs_ChDir to %s\n",path));
    781845
    782         res = SMB_VFS_CHDIR(conn,path);
    783         if (!res) {
     846        ret = SMB_VFS_CHDIR(conn,path);
     847        if (ret == 0) {
     848                /* Global cache. */
    784849                SAFE_FREE(LastDir);
    785850                LastDir = SMB_STRDUP(path);
    786         }
    787         return(res);
     851
     852                /* conn cache. */
     853                TALLOC_FREE(conn->cwd);
     854                conn->cwd = vfs_GetWd(conn, conn);
     855                DEBUG(4,("vfs_ChDir got %s\n",conn->cwd));
     856        }
     857        return ret;
    788858}
    789859
     
    796866char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
    797867{
    798         char s[PATH_MAX+1];
     868        char *current_dir = NULL;
    799869        char *result = NULL;
    800870        DATA_BLOB cache_value;
     
    802872        struct smb_filename *smb_fname_dot = NULL;
    803873        struct smb_filename *smb_fname_full = NULL;
    804         NTSTATUS status;
    805 
    806         *s = 0;
    807874
    808875        if (!lp_getwd_cache()) {
     
    810877        }
    811878
    812         status = create_synthetic_smb_fname(ctx, ".", NULL, NULL,
    813                                             &smb_fname_dot);
    814         if (!NT_STATUS_IS_OK(status)) {
    815                 errno = map_errno_from_nt_status(status);
     879        smb_fname_dot = synthetic_smb_fname(ctx, ".", NULL, NULL);
     880        if (smb_fname_dot == NULL) {
     881                errno = ENOMEM;
    816882                goto out;
    817883        }
     
    838904                   && (cache_value.data[cache_value.length-1] == '\0'));
    839905
    840         status = create_synthetic_smb_fname(ctx, (char *)cache_value.data,
    841                                             NULL, NULL, &smb_fname_full);
    842         if (!NT_STATUS_IS_OK(status)) {
    843                 errno = map_errno_from_nt_status(status);
     906        smb_fname_full = synthetic_smb_fname(ctx, (char *)cache_value.data,
     907                                             NULL, NULL);
     908        if (smb_fname_full == NULL) {
     909                errno = ENOMEM;
    844910                goto out;
    845911        }
     
    867933         */
    868934
    869         if (!SMB_VFS_GETWD(conn,s)) {
     935        current_dir = SMB_VFS_GETWD(conn);
     936        if (current_dir == NULL) {
    870937                DEBUG(0, ("vfs_GetWd: SMB_VFS_GETWD call failed: %s\n",
    871938                          strerror(errno)));
     
    878945                memcache_add(smbd_memcache(), GETWD_CACHE,
    879946                             data_blob_const(&key, sizeof(key)),
    880                              data_blob_const(s, strlen(s)+1));
    881         }
    882 
    883         result = talloc_strdup(ctx, s);
     947                             data_blob_const(current_dir,
     948                                                strlen(current_dir)+1));
     949        }
     950
     951        result = talloc_strdup(ctx, current_dir);
    884952        if (result == NULL) {
    885953                errno = ENOMEM;
     
    889957        TALLOC_FREE(smb_fname_dot);
    890958        TALLOC_FREE(smb_fname_full);
     959        SAFE_FREE(current_dir);
    891960        return result;
     961}
     962
     963/*******************************************************************
     964 Reduce a file name, removing .. elements and checking that
     965 it is below dir in the heirachy. This uses realpath.
     966 This function must run as root, and will return names
     967 and valid stat structs that can be checked on open.
     968********************************************************************/
     969
     970NTSTATUS check_reduced_name_with_privilege(connection_struct *conn,
     971                        const char *fname,
     972                        struct smb_request *smbreq)
     973{
     974        NTSTATUS status;
     975        TALLOC_CTX *ctx = talloc_tos();
     976        const char *conn_rootdir;
     977        size_t rootdir_len;
     978        char *dir_name = NULL;
     979        const char *last_component = NULL;
     980        char *resolved_name = NULL;
     981        char *saved_dir = NULL;
     982        struct smb_filename *smb_fname_cwd = NULL;
     983        struct privilege_paths *priv_paths = NULL;
     984        int ret;
     985
     986        DEBUG(3,("check_reduced_name_with_privilege [%s] [%s]\n",
     987                        fname,
     988                        conn->connectpath));
     989
     990
     991        priv_paths = talloc_zero(smbreq, struct privilege_paths);
     992        if (!priv_paths) {
     993                status = NT_STATUS_NO_MEMORY;
     994                goto err;
     995        }
     996
     997        if (!parent_dirname(ctx, fname, &dir_name, &last_component)) {
     998                status = NT_STATUS_NO_MEMORY;
     999                goto err;
     1000        }
     1001
     1002        priv_paths->parent_name.base_name = talloc_strdup(priv_paths, dir_name);
     1003        priv_paths->file_name.base_name = talloc_strdup(priv_paths, last_component);
     1004
     1005        if (priv_paths->parent_name.base_name == NULL ||
     1006                        priv_paths->file_name.base_name == NULL) {
     1007                status = NT_STATUS_NO_MEMORY;
     1008                goto err;
     1009        }
     1010
     1011        if (SMB_VFS_STAT(conn, &priv_paths->parent_name) != 0) {
     1012                status = map_nt_error_from_unix(errno);
     1013                goto err;
     1014        }
     1015        /* Remember where we were. */
     1016        saved_dir = vfs_GetWd(ctx, conn);
     1017        if (!saved_dir) {
     1018                status = map_nt_error_from_unix(errno);
     1019                goto err;
     1020        }
     1021
     1022        /* Go to the parent directory to lock in memory. */
     1023        if (vfs_ChDir(conn, priv_paths->parent_name.base_name) == -1) {
     1024                status = map_nt_error_from_unix(errno);
     1025                goto err;
     1026        }
     1027
     1028        /* Get the absolute path of the parent directory. */
     1029        resolved_name = SMB_VFS_REALPATH(conn,".");
     1030        if (!resolved_name) {
     1031                status = map_nt_error_from_unix(errno);
     1032                goto err;
     1033        }
     1034
     1035        if (*resolved_name != '/') {
     1036                DEBUG(0,("check_reduced_name_with_privilege: realpath "
     1037                        "doesn't return absolute paths !\n"));
     1038                status = NT_STATUS_OBJECT_NAME_INVALID;
     1039                goto err;
     1040        }
     1041
     1042        DEBUG(10,("check_reduced_name_with_privilege: realpath [%s] -> [%s]\n",
     1043                priv_paths->parent_name.base_name,
     1044                resolved_name));
     1045
     1046        /* Now check the stat value is the same. */
     1047        smb_fname_cwd = synthetic_smb_fname(talloc_tos(), ".", NULL, NULL);
     1048        if (smb_fname_cwd == NULL) {
     1049                status = NT_STATUS_NO_MEMORY;
     1050                goto err;
     1051        }
     1052
     1053        if (SMB_VFS_LSTAT(conn, smb_fname_cwd) != 0) {
     1054                status = map_nt_error_from_unix(errno);
     1055                goto err;
     1056        }
     1057
     1058        /* Ensure we're pointing at the same place. */
     1059        if (!check_same_stat(&smb_fname_cwd->st, &priv_paths->parent_name.st)) {
     1060                DEBUG(0,("check_reduced_name_with_privilege: "
     1061                        "device/inode/uid/gid on directory %s changed. "
     1062                        "Denying access !\n",
     1063                        priv_paths->parent_name.base_name));
     1064                status = NT_STATUS_ACCESS_DENIED;
     1065                goto err;
     1066        }
     1067
     1068        /* Ensure we're below the connect path. */
     1069
     1070        conn_rootdir = SMB_VFS_CONNECTPATH(conn, fname);
     1071        if (conn_rootdir == NULL) {
     1072                DEBUG(2, ("check_reduced_name_with_privilege: Could not get "
     1073                        "conn_rootdir\n"));
     1074                status = NT_STATUS_ACCESS_DENIED;
     1075                goto err;
     1076        }
     1077
     1078        rootdir_len = strlen(conn_rootdir);
     1079
     1080        /*
     1081         * In the case of rootdir_len == 1, we know that conn_rootdir is
     1082         * "/", and we also know that resolved_name starts with a slash.
     1083         * So, in this corner case, resolved_name is automatically a
     1084         * sub-directory of the conn_rootdir. Thus we can skip the string
     1085         * comparison and the next character checks (which are even
     1086         * wrong in this case).
     1087         */
     1088        if (rootdir_len != 1) {
     1089                bool matched;
     1090
     1091                matched = (strncmp(conn_rootdir, resolved_name,
     1092                                rootdir_len) == 0);
     1093
     1094                if (!matched || (resolved_name[rootdir_len] != '/' &&
     1095                                 resolved_name[rootdir_len] != '\0')) {
     1096                        DEBUG(2, ("check_reduced_name_with_privilege: Bad "
     1097                                "access attempt: %s is a symlink outside the "
     1098                                "share path\n",
     1099                                dir_name));
     1100                        DEBUGADD(2, ("conn_rootdir =%s\n", conn_rootdir));
     1101                        DEBUGADD(2, ("resolved_name=%s\n", resolved_name));
     1102                        status = NT_STATUS_ACCESS_DENIED;
     1103                        goto err;
     1104                }
     1105        }
     1106
     1107        /* Now ensure that the last component either doesn't
     1108           exist, or is *NOT* a symlink. */
     1109
     1110        ret = SMB_VFS_LSTAT(conn, &priv_paths->file_name);
     1111        if (ret == -1) {
     1112                /* Errno must be ENOENT for this be ok. */
     1113                if (errno != ENOENT) {
     1114                        status = map_nt_error_from_unix(errno);
     1115                        DEBUG(2, ("check_reduced_name_with_privilege: "
     1116                                "LSTAT on %s failed with %s\n",
     1117                                priv_paths->file_name.base_name,
     1118                                nt_errstr(status)));
     1119                        goto err;
     1120                }
     1121        }
     1122
     1123        if (VALID_STAT(priv_paths->file_name.st) &&
     1124                        S_ISLNK(priv_paths->file_name.st.st_ex_mode)) {
     1125                DEBUG(2, ("check_reduced_name_with_privilege: "
     1126                        "Last component %s is a symlink. Denying"
     1127                        "access.\n",
     1128                        priv_paths->file_name.base_name));
     1129                status = NT_STATUS_ACCESS_DENIED;
     1130                goto err;
     1131        }
     1132
     1133        smbreq->priv_paths = priv_paths;
     1134        status = NT_STATUS_OK;
     1135
     1136  err:
     1137
     1138        if (saved_dir) {
     1139                vfs_ChDir(conn, saved_dir);
     1140        }
     1141        SAFE_FREE(resolved_name);
     1142        if (!NT_STATUS_IS_OK(status)) {
     1143                TALLOC_FREE(priv_paths);
     1144        }
     1145        TALLOC_FREE(dir_name);
     1146        return status;
    8921147}
    8931148
     
    9031158        bool allow_widelinks = false;
    9041159
    905         DEBUG(3,("check_reduced_name [%s] [%s]\n", fname, conn->connectpath));
     1160        DBG_DEBUG("check_reduced_name [%s] [%s]\n", fname, conn->connectpath);
    9061161
    9071162        resolved_name = SMB_VFS_REALPATH(conn,fname);
     
    9201175                                const char *last_component = NULL;
    9211176                                char *new_name = NULL;
     1177                                int ret;
    9221178
    9231179                                /* Last component didn't exist.
     
    9451201                                        return status;
    9461202                                }
    947                                 new_name = talloc_asprintf(ctx,
    948                                                 "%s/%s",
    949                                                 resolved_name,
    950                                                 last_component);
    951                                 if (!new_name) {
     1203                                ret = asprintf(&new_name, "%s/%s",
     1204                                               resolved_name, last_component);
     1205                                SAFE_FREE(resolved_name);
     1206                                if (ret == -1) {
    9521207                                        return NT_STATUS_NO_MEMORY;
    9531208                                }
    954                                 SAFE_FREE(resolved_name);
    955                                 resolved_name = SMB_STRDUP(new_name);
    956                                 if (!resolved_name) {
    957                                         return NT_STATUS_NO_MEMORY;
    958                                 }
     1209                                resolved_name = new_name;
    9591210                                break;
    9601211                        }
     
    9771228
    9781229        allow_widelinks = lp_widelinks(SNUM(conn));
    979         allow_symlinks = lp_symlinks(SNUM(conn));
     1230        allow_symlinks = lp_follow_symlinks(SNUM(conn));
    9801231
    9811232        /* Common widelinks and symlinks checks. */
     
    9831234                const char *conn_rootdir;
    9841235                size_t rootdir_len;
    985                 bool matched;
    9861236
    9871237                conn_rootdir = SMB_VFS_CONNECTPATH(conn, fname);
     
    9941244
    9951245                rootdir_len = strlen(conn_rootdir);
    996                 matched = (strncmp(conn_rootdir, resolved_name,
    997                                 rootdir_len) == 0);
    998                 if (!matched || (resolved_name[rootdir_len] != '/' &&
    999                                  resolved_name[rootdir_len] != '\0')) {
    1000                         DEBUG(2, ("check_reduced_name: Bad access "
    1001                                 "attempt: %s is a symlink outside the "
    1002                                 "share path\n", fname));
    1003                         DEBUGADD(2, ("conn_rootdir =%s\n", conn_rootdir));
    1004                         DEBUGADD(2, ("resolved_name=%s\n", resolved_name));
    1005                         SAFE_FREE(resolved_name);
    1006                         return NT_STATUS_ACCESS_DENIED;
     1246
     1247                /*
     1248                 * In the case of rootdir_len == 1, we know that
     1249                 * conn_rootdir is "/", and we also know that
     1250                 * resolved_name starts with a slash.  So, in this
     1251                 * corner case, resolved_name is automatically a
     1252                 * sub-directory of the conn_rootdir. Thus we can skip
     1253                 * the string comparison and the next character checks
     1254                 * (which are even wrong in this case).
     1255                 */
     1256                if (rootdir_len != 1) {
     1257                        bool matched;
     1258
     1259                        matched = (strncmp(conn_rootdir, resolved_name,
     1260                                        rootdir_len) == 0);
     1261                        if (!matched || (resolved_name[rootdir_len] != '/' &&
     1262                                         resolved_name[rootdir_len] != '\0')) {
     1263                                DEBUG(2, ("check_reduced_name: Bad access "
     1264                                        "attempt: %s is a symlink outside the "
     1265                                        "share path\n", fname));
     1266                                DEBUGADD(2, ("conn_rootdir =%s\n",
     1267                                             conn_rootdir));
     1268                                DEBUGADD(2, ("resolved_name=%s\n",
     1269                                             resolved_name));
     1270                                SAFE_FREE(resolved_name);
     1271                                return NT_STATUS_ACCESS_DENIED;
     1272                        }
    10071273                }
    10081274
     
    10291295                        if (strcmp(fname, p)!=0) {
    10301296                                DEBUG(2, ("check_reduced_name: Bad access "
    1031                                         "attempt: %s is a symlink\n",
    1032                                         fname));
     1297                                        "attempt: %s is a symlink to %s\n",
     1298                                          fname, p));
    10331299                                SAFE_FREE(resolved_name);
    10341300                                return NT_STATUS_ACCESS_DENIED;
     
    10391305  out:
    10401306
    1041         DEBUG(3,("check_reduced_name: %s reduced to %s\n", fname,
    1042                  resolved_name));
     1307        DBG_INFO("%s reduced to %s\n", fname, resolved_name);
    10431308        SAFE_FREE(resolved_name);
    10441309        return NT_STATUS_OK;
     
    10481313 * XXX: This is temporary and there should be no callers of this once
    10491314 * smb_filename is plumbed through all path based operations.
     1315 *
     1316 * Called when we know stream name parsing has already been done.
    10501317 */
    1051 int vfs_stat_smb_fname(struct connection_struct *conn, const char *fname,
     1318int vfs_stat_smb_basename(struct connection_struct *conn, const char *fname,
    10521319                       SMB_STRUCT_STAT *psbuf)
    10531320{
    1054         struct smb_filename *smb_fname = NULL;
    1055         NTSTATUS status;
     1321        struct smb_filename smb_fname = {
     1322                        .base_name = discard_const_p(char, fname)
     1323        };
    10561324        int ret;
    10571325
    1058         status = create_synthetic_smb_fname_split(talloc_tos(), fname, NULL,
    1059                                                   &smb_fname);
    1060         if (!NT_STATUS_IS_OK(status)) {
    1061                 errno = map_errno_from_nt_status(status);
    1062                 return -1;
    1063         }
    1064 
    10651326        if (lp_posix_pathnames()) {
    1066                 ret = SMB_VFS_LSTAT(conn, smb_fname);
     1327                ret = SMB_VFS_LSTAT(conn, &smb_fname);
    10671328        } else {
    1068                 ret = SMB_VFS_STAT(conn, smb_fname);
     1329                ret = SMB_VFS_STAT(conn, &smb_fname);
    10691330        }
    10701331
    10711332        if (ret != -1) {
    1072                 *psbuf = smb_fname->st;
    1073         }
    1074 
    1075         TALLOC_FREE(smb_fname);
    1076         return ret;
    1077 }
    1078 
    1079 /**
    1080  * XXX: This is temporary and there should be no callers of this once
    1081  * smb_filename is plumbed through all path based operations.
    1082  */
    1083 int vfs_lstat_smb_fname(struct connection_struct *conn, const char *fname,
    1084                         SMB_STRUCT_STAT *psbuf)
    1085 {
    1086         struct smb_filename *smb_fname = NULL;
    1087         NTSTATUS status;
    1088         int ret;
    1089 
    1090         status = create_synthetic_smb_fname_split(talloc_tos(), fname, NULL,
    1091                                                   &smb_fname);
    1092         if (!NT_STATUS_IS_OK(status)) {
    1093                 errno = map_errno_from_nt_status(status);
    1094                 return -1;
    1095         }
    1096 
    1097         ret = SMB_VFS_LSTAT(conn, smb_fname);
    1098         if (ret != -1) {
    1099                 *psbuf = smb_fname->st;
    1100         }
    1101 
    1102         TALLOC_FREE(smb_fname);
     1333                *psbuf = smb_fname.st;
     1334        }
    11031335        return ret;
    11041336}
     
    11131345
    11141346        if(fsp->fh->fd == -1) {
    1115                 if (fsp->posix_open) {
     1347                if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) {
    11161348                        ret = SMB_VFS_LSTAT(fsp->conn, fsp->fsp_name);
    11171349                } else {
     
    11551387                         const char *service, const char *user)
    11561388{
    1157         VFS_FIND(connect_fn);
     1389        VFS_FIND(connect);
    11581390        return handle->fns->connect_fn(handle, service, user);
    11591391}
     
    11621394{
    11631395        VFS_FIND(disconnect);
    1164         handle->fns->disconnect(handle);
     1396        handle->fns->disconnect_fn(handle);
    11651397}
    11661398
    11671399uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
    1168                                 const char *path, bool small_query,
    1169                                 uint64_t *bsize, uint64_t *dfree,
    1170                                 uint64_t *dsize)
     1400                                const char *path, uint64_t *bsize,
     1401                                uint64_t *dfree, uint64_t *dsize)
    11711402{
    11721403        VFS_FIND(disk_free);
    1173         return handle->fns->disk_free(handle, path, small_query, bsize, dfree,
    1174                                       dsize);
    1175 }
    1176 
    1177 int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
     1404        return handle->fns->disk_free_fn(handle, path, bsize, dfree, dsize);
     1405}
     1406
     1407int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, const char *path,
    11781408                           enum SMB_QUOTA_TYPE qtype, unid_t id,
    11791409                           SMB_DISK_QUOTA *qt)
    11801410{
    11811411        VFS_FIND(get_quota);
    1182         return handle->fns->get_quota(handle, qtype, id, qt);
     1412        return handle->fns->get_quota_fn(handle, path, qtype, id, qt);
    11831413}
    11841414
     
    11881418{
    11891419        VFS_FIND(set_quota);
    1190         return handle->fns->set_quota(handle, qtype, id, qt);
     1420        return handle->fns->set_quota_fn(handle, qtype, id, qt);
    11911421}
    11921422
     
    11971427{
    11981428        VFS_FIND(get_shadow_copy_data);
    1199         return handle->fns->get_shadow_copy_data(handle, fsp, shadow_copy_data,
    1200                                                  labels);
     1429        return handle->fns->get_shadow_copy_data_fn(handle, fsp,
     1430                                                    shadow_copy_data,
     1431                                                    labels);
    12011432}
    12021433int smb_vfs_call_statvfs(struct vfs_handle_struct *handle, const char *path,
     
    12041435{
    12051436        VFS_FIND(statvfs);
    1206         return handle->fns->statvfs(handle, path, statbuf);
     1437        return handle->fns->statvfs_fn(handle, path, statbuf);
    12071438}
    12081439
     
    12111442{
    12121443        VFS_FIND(fs_capabilities);
    1213         return handle->fns->fs_capabilities(handle, p_ts_res);
    1214 }
    1215 
    1216 SMB_STRUCT_DIR *smb_vfs_call_opendir(struct vfs_handle_struct *handle,
     1444        return handle->fns->fs_capabilities_fn(handle, p_ts_res);
     1445}
     1446
     1447NTSTATUS smb_vfs_call_get_dfs_referrals(struct vfs_handle_struct *handle,
     1448                                        struct dfs_GetDFSReferral *r)
     1449{
     1450        VFS_FIND(get_dfs_referrals);
     1451        return handle->fns->get_dfs_referrals_fn(handle, r);
     1452}
     1453
     1454DIR *smb_vfs_call_opendir(struct vfs_handle_struct *handle,
    12171455                                     const char *fname, const char *mask,
    1218                                      uint32 attributes)
     1456                                     uint32_t attributes)
    12191457{
    12201458        VFS_FIND(opendir);
    1221         return handle->fns->opendir(handle, fname, mask, attributes);
    1222 }
    1223 
    1224 SMB_STRUCT_DIR *smb_vfs_call_fdopendir(struct vfs_handle_struct *handle,
     1459        return handle->fns->opendir_fn(handle, fname, mask, attributes);
     1460}
     1461
     1462DIR *smb_vfs_call_fdopendir(struct vfs_handle_struct *handle,
    12251463                                        struct files_struct *fsp,
    12261464                                        const char *mask,
    1227                                         uint32 attributes)
     1465                                        uint32_t attributes)
    12281466{
    12291467        VFS_FIND(fdopendir);
    1230         return handle->fns->fdopendir(handle, fsp, mask, attributes);
    1231 }
    1232 
    1233 SMB_STRUCT_DIRENT *smb_vfs_call_readdir(struct vfs_handle_struct *handle,
    1234                                               SMB_STRUCT_DIR *dirp,
     1468        return handle->fns->fdopendir_fn(handle, fsp, mask, attributes);
     1469}
     1470
     1471struct dirent *smb_vfs_call_readdir(struct vfs_handle_struct *handle,
     1472                                              DIR *dirp,
    12351473                                              SMB_STRUCT_STAT *sbuf)
    12361474{
    12371475        VFS_FIND(readdir);
    1238         return handle->fns->readdir(handle, dirp, sbuf);
     1476        return handle->fns->readdir_fn(handle, dirp, sbuf);
    12391477}
    12401478
    12411479void smb_vfs_call_seekdir(struct vfs_handle_struct *handle,
    1242                           SMB_STRUCT_DIR *dirp, long offset)
     1480                          DIR *dirp, long offset)
    12431481{
    12441482        VFS_FIND(seekdir);
    1245         handle->fns->seekdir(handle, dirp, offset);
     1483        handle->fns->seekdir_fn(handle, dirp, offset);
    12461484}
    12471485
    12481486long smb_vfs_call_telldir(struct vfs_handle_struct *handle,
    1249                           SMB_STRUCT_DIR *dirp)
     1487                          DIR *dirp)
    12501488{
    12511489        VFS_FIND(telldir);
    1252         return handle->fns->telldir(handle, dirp);
     1490        return handle->fns->telldir_fn(handle, dirp);
    12531491}
    12541492
    12551493void smb_vfs_call_rewind_dir(struct vfs_handle_struct *handle,
    1256                              SMB_STRUCT_DIR *dirp)
     1494                             DIR *dirp)
    12571495{
    12581496        VFS_FIND(rewind_dir);
    1259         handle->fns->rewind_dir(handle, dirp);
     1497        handle->fns->rewind_dir_fn(handle, dirp);
    12601498}
    12611499
     
    12641502{
    12651503        VFS_FIND(mkdir);
    1266         return handle->fns->mkdir(handle, path, mode);
     1504        return handle->fns->mkdir_fn(handle, path, mode);
    12671505}
    12681506
     
    12701508{
    12711509        VFS_FIND(rmdir);
    1272         return handle->fns->rmdir(handle, path);
     1510        return handle->fns->rmdir_fn(handle, path);
    12731511}
    12741512
    12751513int smb_vfs_call_closedir(struct vfs_handle_struct *handle,
    1276                           SMB_STRUCT_DIR *dir)
     1514                          DIR *dir)
    12771515{
    12781516        VFS_FIND(closedir);
    1279         return handle->fns->closedir(handle, dir);
     1517        return handle->fns->closedir_fn(handle, dir);
    12801518}
    12811519
    12821520void smb_vfs_call_init_search_op(struct vfs_handle_struct *handle,
    1283                                  SMB_STRUCT_DIR *dirp)
     1521                                 DIR *dirp)
    12841522{
    12851523        VFS_FIND(init_search_op);
    1286         handle->fns->init_search_op(handle, dirp);
     1524        handle->fns->init_search_op_fn(handle, dirp);
    12871525}
    12881526
     
    12911529                      int flags, mode_t mode)
    12921530{
    1293         VFS_FIND(open_fn);
     1531        VFS_FIND(open);
    12941532        return handle->fns->open_fn(handle, smb_fname, fsp, flags, mode);
    12951533}
     
    13051543                                  uint32_t file_attributes,
    13061544                                  uint32_t oplock_request,
     1545                                  struct smb2_lease *lease,
    13071546                                  uint64_t allocation_size,
    13081547                                  uint32_t private_flags,
     
    13101549                                  struct ea_list *ea_list,
    13111550                                  files_struct **result,
    1312                                   int *pinfo)
     1551                                  int *pinfo,
     1552                                  const struct smb2_create_blobs *in_context_blobs,
     1553                                  struct smb2_create_blobs *out_context_blobs)
    13131554{
    13141555        VFS_FIND(create_file);
    1315         return handle->fns->create_file(
     1556        return handle->fns->create_file_fn(
    13161557                handle, req, root_dir_fid, smb_fname, access_mask,
    13171558                share_access, create_disposition, create_options,
    1318                 file_attributes, oplock_request, allocation_size,
     1559                file_attributes, oplock_request, lease, allocation_size,
    13191560                private_flags, sd, ea_list,
    1320                 result, pinfo);
    1321 }
    1322 
    1323 int smb_vfs_call_close_fn(struct vfs_handle_struct *handle,
    1324                           struct files_struct *fsp)
    1325 {
    1326         VFS_FIND(close_fn);
     1561                result, pinfo, in_context_blobs, out_context_blobs);
     1562}
     1563
     1564int smb_vfs_call_close(struct vfs_handle_struct *handle,
     1565                       struct files_struct *fsp)
     1566{
     1567        VFS_FIND(close);
    13271568        return handle->fns->close_fn(handle, fsp);
    13281569}
    13291570
    1330 ssize_t smb_vfs_call_vfs_read(struct vfs_handle_struct *handle,
    1331                               struct files_struct *fsp, void *data, size_t n)
    1332 {
    1333         VFS_FIND(vfs_read);
    1334         return handle->fns->vfs_read(handle, fsp, data, n);
     1571ssize_t smb_vfs_call_read(struct vfs_handle_struct *handle,
     1572                          struct files_struct *fsp, void *data, size_t n)
     1573{
     1574        VFS_FIND(read);
     1575        return handle->fns->read_fn(handle, fsp, data, n);
    13351576}
    13361577
    13371578ssize_t smb_vfs_call_pread(struct vfs_handle_struct *handle,
    13381579                           struct files_struct *fsp, void *data, size_t n,
    1339                            SMB_OFF_T offset)
     1580                           off_t offset)
    13401581{
    13411582        VFS_FIND(pread);
    1342         return handle->fns->pread(handle, fsp, data, n, offset);
     1583        return handle->fns->pread_fn(handle, fsp, data, n, offset);
     1584}
     1585
     1586struct smb_vfs_call_pread_state {
     1587        ssize_t (*recv_fn)(struct tevent_req *req, int *err);
     1588        ssize_t retval;
     1589};
     1590
     1591static void smb_vfs_call_pread_done(struct tevent_req *subreq);
     1592
     1593struct tevent_req *smb_vfs_call_pread_send(struct vfs_handle_struct *handle,
     1594                                           TALLOC_CTX *mem_ctx,
     1595                                           struct tevent_context *ev,
     1596                                           struct files_struct *fsp,
     1597                                           void *data,
     1598                                           size_t n, off_t offset)
     1599{
     1600        struct tevent_req *req, *subreq;
     1601        struct smb_vfs_call_pread_state *state;
     1602
     1603        req = tevent_req_create(mem_ctx, &state,
     1604                                struct smb_vfs_call_pread_state);
     1605        if (req == NULL) {
     1606                return NULL;
     1607        }
     1608        VFS_FIND(pread_send);
     1609        state->recv_fn = handle->fns->pread_recv_fn;
     1610
     1611        subreq = handle->fns->pread_send_fn(handle, state, ev, fsp, data, n,
     1612                                            offset);
     1613        if (tevent_req_nomem(subreq, req)) {
     1614                return tevent_req_post(req, ev);
     1615        }
     1616        tevent_req_set_callback(subreq, smb_vfs_call_pread_done, req);
     1617        return req;
     1618}
     1619
     1620static void smb_vfs_call_pread_done(struct tevent_req *subreq)
     1621{
     1622        struct tevent_req *req = tevent_req_callback_data(
     1623                subreq, struct tevent_req);
     1624        struct smb_vfs_call_pread_state *state = tevent_req_data(
     1625                req, struct smb_vfs_call_pread_state);
     1626        int err;
     1627
     1628        state->retval = state->recv_fn(subreq, &err);
     1629        TALLOC_FREE(subreq);
     1630        if (state->retval == -1) {
     1631                tevent_req_error(req, err);
     1632                return;
     1633        }
     1634        tevent_req_done(req);
     1635}
     1636
     1637ssize_t SMB_VFS_PREAD_RECV(struct tevent_req *req, int *perrno)
     1638{
     1639        struct smb_vfs_call_pread_state *state = tevent_req_data(
     1640                req, struct smb_vfs_call_pread_state);
     1641        int err;
     1642
     1643        if (tevent_req_is_unix_error(req, &err)) {
     1644                *perrno = err;
     1645                return -1;
     1646        }
     1647        return state->retval;
    13431648}
    13441649
     
    13481653{
    13491654        VFS_FIND(write);
    1350         return handle->fns->write(handle, fsp, data, n);
     1655        return handle->fns->write_fn(handle, fsp, data, n);
    13511656}
    13521657
    13531658ssize_t smb_vfs_call_pwrite(struct vfs_handle_struct *handle,
    13541659                            struct files_struct *fsp, const void *data,
    1355                             size_t n, SMB_OFF_T offset)
     1660                            size_t n, off_t offset)
    13561661{
    13571662        VFS_FIND(pwrite);
    1358         return handle->fns->pwrite(handle, fsp, data, n, offset);
    1359 }
    1360 
    1361 SMB_OFF_T smb_vfs_call_lseek(struct vfs_handle_struct *handle,
    1362                              struct files_struct *fsp, SMB_OFF_T offset,
     1663        return handle->fns->pwrite_fn(handle, fsp, data, n, offset);
     1664}
     1665
     1666struct smb_vfs_call_pwrite_state {
     1667        ssize_t (*recv_fn)(struct tevent_req *req, int *err);
     1668        ssize_t retval;
     1669};
     1670
     1671static void smb_vfs_call_pwrite_done(struct tevent_req *subreq);
     1672
     1673struct tevent_req *smb_vfs_call_pwrite_send(struct vfs_handle_struct *handle,
     1674                                            TALLOC_CTX *mem_ctx,
     1675                                            struct tevent_context *ev,
     1676                                            struct files_struct *fsp,
     1677                                            const void *data,
     1678                                            size_t n, off_t offset)
     1679{
     1680        struct tevent_req *req, *subreq;
     1681        struct smb_vfs_call_pwrite_state *state;
     1682
     1683        req = tevent_req_create(mem_ctx, &state,
     1684                                struct smb_vfs_call_pwrite_state);
     1685        if (req == NULL) {
     1686                return NULL;
     1687        }
     1688        VFS_FIND(pwrite_send);
     1689        state->recv_fn = handle->fns->pwrite_recv_fn;
     1690
     1691        subreq = handle->fns->pwrite_send_fn(handle, state, ev, fsp, data, n,
     1692                                             offset);
     1693        if (tevent_req_nomem(subreq, req)) {
     1694                return tevent_req_post(req, ev);
     1695        }
     1696        tevent_req_set_callback(subreq, smb_vfs_call_pwrite_done, req);
     1697        return req;
     1698}
     1699
     1700static void smb_vfs_call_pwrite_done(struct tevent_req *subreq)
     1701{
     1702        struct tevent_req *req = tevent_req_callback_data(
     1703                subreq, struct tevent_req);
     1704        struct smb_vfs_call_pwrite_state *state = tevent_req_data(
     1705                req, struct smb_vfs_call_pwrite_state);
     1706        int err;
     1707
     1708        state->retval = state->recv_fn(subreq, &err);
     1709        TALLOC_FREE(subreq);
     1710        if (state->retval == -1) {
     1711                tevent_req_error(req, err);
     1712                return;
     1713        }
     1714        tevent_req_done(req);
     1715}
     1716
     1717ssize_t SMB_VFS_PWRITE_RECV(struct tevent_req *req, int *perrno)
     1718{
     1719        struct smb_vfs_call_pwrite_state *state = tevent_req_data(
     1720                req, struct smb_vfs_call_pwrite_state);
     1721        int err;
     1722
     1723        if (tevent_req_is_unix_error(req, &err)) {
     1724                *perrno = err;
     1725                return -1;
     1726        }
     1727        return state->retval;
     1728}
     1729
     1730off_t smb_vfs_call_lseek(struct vfs_handle_struct *handle,
     1731                             struct files_struct *fsp, off_t offset,
    13631732                             int whence)
    13641733{
    13651734        VFS_FIND(lseek);
    1366         return handle->fns->lseek(handle, fsp, offset, whence);
     1735        return handle->fns->lseek_fn(handle, fsp, offset, whence);
    13671736}
    13681737
    13691738ssize_t smb_vfs_call_sendfile(struct vfs_handle_struct *handle, int tofd,
    13701739                              files_struct *fromfsp, const DATA_BLOB *header,
    1371                               SMB_OFF_T offset, size_t count)
     1740                              off_t offset, size_t count)
    13721741{
    13731742        VFS_FIND(sendfile);
    1374         return handle->fns->sendfile(handle, tofd, fromfsp, header, offset,
    1375                                      count);
     1743        return handle->fns->sendfile_fn(handle, tofd, fromfsp, header, offset,
     1744                                        count);
    13761745}
    13771746
    13781747ssize_t smb_vfs_call_recvfile(struct vfs_handle_struct *handle, int fromfd,
    1379                               files_struct *tofsp, SMB_OFF_T offset,
     1748                              files_struct *tofsp, off_t offset,
    13801749                              size_t count)
    13811750{
    13821751        VFS_FIND(recvfile);
    1383         return handle->fns->recvfile(handle, fromfd, tofsp, offset, count);
     1752        return handle->fns->recvfile_fn(handle, fromfd, tofsp, offset, count);
    13841753}
    13851754
     
    13891758{
    13901759        VFS_FIND(rename);
    1391         return handle->fns->rename(handle, smb_fname_src, smb_fname_dst);
     1760        return handle->fns->rename_fn(handle, smb_fname_src, smb_fname_dst);
    13921761}
    13931762
     
    13961765{
    13971766        VFS_FIND(fsync);
    1398         return handle->fns->fsync(handle, fsp);
    1399 }
     1767        return handle->fns->fsync_fn(handle, fsp);
     1768}
     1769
     1770struct smb_vfs_call_fsync_state {
     1771        int (*recv_fn)(struct tevent_req *req, int *err);
     1772        int retval;
     1773};
     1774
     1775static void smb_vfs_call_fsync_done(struct tevent_req *subreq);
     1776
     1777struct tevent_req *smb_vfs_call_fsync_send(struct vfs_handle_struct *handle,
     1778                                           TALLOC_CTX *mem_ctx,
     1779                                           struct tevent_context *ev,
     1780                                           struct files_struct *fsp)
     1781{
     1782        struct tevent_req *req, *subreq;
     1783        struct smb_vfs_call_fsync_state *state;
     1784
     1785        req = tevent_req_create(mem_ctx, &state,
     1786                                struct smb_vfs_call_fsync_state);
     1787        if (req == NULL) {
     1788                return NULL;
     1789        }
     1790        VFS_FIND(fsync_send);
     1791        state->recv_fn = handle->fns->fsync_recv_fn;
     1792
     1793        subreq = handle->fns->fsync_send_fn(handle, state, ev, fsp);
     1794        if (tevent_req_nomem(subreq, req)) {
     1795                return tevent_req_post(req, ev);
     1796        }
     1797        tevent_req_set_callback(subreq, smb_vfs_call_fsync_done, req);
     1798        return req;
     1799}
     1800
     1801static void smb_vfs_call_fsync_done(struct tevent_req *subreq)
     1802{
     1803        struct tevent_req *req = tevent_req_callback_data(
     1804                subreq, struct tevent_req);
     1805        struct smb_vfs_call_fsync_state *state = tevent_req_data(
     1806                req, struct smb_vfs_call_fsync_state);
     1807        int err;
     1808
     1809        state->retval = state->recv_fn(subreq, &err);
     1810        TALLOC_FREE(subreq);
     1811        if (state->retval == -1) {
     1812                tevent_req_error(req, err);
     1813                return;
     1814        }
     1815        tevent_req_done(req);
     1816}
     1817
     1818int SMB_VFS_FSYNC_RECV(struct tevent_req *req, int *perrno)
     1819{
     1820        struct smb_vfs_call_fsync_state *state = tevent_req_data(
     1821                req, struct smb_vfs_call_fsync_state);
     1822        int err;
     1823
     1824        if (tevent_req_is_unix_error(req, &err)) {
     1825                *perrno = err;
     1826                return -1;
     1827        }
     1828        return state->retval;
     1829}
     1830
    14001831
    14011832int smb_vfs_call_stat(struct vfs_handle_struct *handle,
     
    14031834{
    14041835        VFS_FIND(stat);
    1405         return handle->fns->stat(handle, smb_fname);
     1836        return handle->fns->stat_fn(handle, smb_fname);
    14061837}
    14071838
     
    14101841{
    14111842        VFS_FIND(fstat);
    1412         return handle->fns->fstat(handle, fsp, sbuf);
     1843        return handle->fns->fstat_fn(handle, fsp, sbuf);
    14131844}
    14141845
     
    14171848{
    14181849        VFS_FIND(lstat);
    1419         return handle->fns->lstat(handle, smb_filename);
     1850        return handle->fns->lstat_fn(handle, smb_filename);
    14201851}
    14211852
     
    14251856{
    14261857        VFS_FIND(get_alloc_size);
    1427         return handle->fns->get_alloc_size(handle, fsp, sbuf);
     1858        return handle->fns->get_alloc_size_fn(handle, fsp, sbuf);
    14281859}
    14291860
     
    14321863{
    14331864        VFS_FIND(unlink);
    1434         return handle->fns->unlink(handle, smb_fname);
     1865        return handle->fns->unlink_fn(handle, smb_fname);
    14351866}
    14361867
     
    14391870{
    14401871        VFS_FIND(chmod);
    1441         return handle->fns->chmod(handle, path, mode);
     1872        return handle->fns->chmod_fn(handle, path, mode);
    14421873}
    14431874
     
    14461877{
    14471878        VFS_FIND(fchmod);
    1448         return handle->fns->fchmod(handle, fsp, mode);
     1879        return handle->fns->fchmod_fn(handle, fsp, mode);
    14491880}
    14501881
     
    14531884{
    14541885        VFS_FIND(chown);
    1455         return handle->fns->chown(handle, path, uid, gid);
     1886        return handle->fns->chown_fn(handle, path, uid, gid);
    14561887}
    14571888
     
    14601891{
    14611892        VFS_FIND(fchown);
    1462         return handle->fns->fchown(handle, fsp, uid, gid);
     1893        return handle->fns->fchown_fn(handle, fsp, uid, gid);
    14631894}
    14641895
     
    14671898{
    14681899        VFS_FIND(lchown);
    1469         return handle->fns->lchown(handle, path, uid, gid);
     1900        return handle->fns->lchown_fn(handle, path, uid, gid);
    14701901}
    14711902
     
    15251956
    15261957                ZERO_STRUCT(local_fname);
    1527                 local_fname.base_name = CONST_DISCARD(char *,final_component);
     1958                local_fname.base_name = discard_const_p(char, final_component);
    15281959
    15291960                /* Must use lstat here. */
     
    15441975        }
    15451976
    1546         if (fsp->posix_open || as_root) {
     1977        if ((fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) || as_root) {
    15471978                ret = SMB_VFS_LCHOWN(fsp->conn,
    15481979                        path,
     
    15732004{
    15742005        VFS_FIND(chdir);
    1575         return handle->fns->chdir(handle, path);
    1576 }
    1577 
    1578 char *smb_vfs_call_getwd(struct vfs_handle_struct *handle, char *buf)
     2006        return handle->fns->chdir_fn(handle, path);
     2007}
     2008
     2009char *smb_vfs_call_getwd(struct vfs_handle_struct *handle)
    15792010{
    15802011        VFS_FIND(getwd);
    1581         return handle->fns->getwd(handle, buf);
     2012        return handle->fns->getwd_fn(handle);
    15822013}
    15832014
     
    15872018{
    15882019        VFS_FIND(ntimes);
    1589         return handle->fns->ntimes(handle, smb_fname, ft);
     2020        return handle->fns->ntimes_fn(handle, smb_fname, ft);
    15902021}
    15912022
    15922023int smb_vfs_call_ftruncate(struct vfs_handle_struct *handle,
    1593                            struct files_struct *fsp, SMB_OFF_T offset)
     2024                           struct files_struct *fsp, off_t offset)
    15942025{
    15952026        VFS_FIND(ftruncate);
    1596         return handle->fns->ftruncate(handle, fsp, offset);
     2027        return handle->fns->ftruncate_fn(handle, fsp, offset);
    15972028}
    15982029
    15992030int smb_vfs_call_fallocate(struct vfs_handle_struct *handle,
    1600                                 struct files_struct *fsp,
    1601                                 enum vfs_fallocate_mode mode,
    1602                                 SMB_OFF_T offset,
    1603                                 SMB_OFF_T len)
     2031                           struct files_struct *fsp,
     2032                           uint32_t mode,
     2033                           off_t offset,
     2034                           off_t len)
    16042035{
    16052036        VFS_FIND(fallocate);
    1606         return handle->fns->fallocate(handle, fsp, mode, offset, len);
     2037        return handle->fns->fallocate_fn(handle, fsp, mode, offset, len);
    16072038}
    16082039
    16092040int smb_vfs_call_kernel_flock(struct vfs_handle_struct *handle,
    1610                               struct files_struct *fsp, uint32 share_mode,
     2041                              struct files_struct *fsp, uint32_t share_mode,
    16112042                              uint32_t access_mask)
    16122043{
    16132044        VFS_FIND(kernel_flock);
    1614         return handle->fns->kernel_flock(handle, fsp, share_mode,
     2045        return handle->fns->kernel_flock_fn(handle, fsp, share_mode,
    16152046                                         access_mask);
    16162047}
     
    16202051{
    16212052        VFS_FIND(linux_setlease);
    1622         return handle->fns->linux_setlease(handle, fsp, leasetype);
     2053        return handle->fns->linux_setlease_fn(handle, fsp, leasetype);
    16232054}
    16242055
     
    16272058{
    16282059        VFS_FIND(symlink);
    1629         return handle->fns->symlink(handle, oldpath, newpath);
    1630 }
    1631 
    1632 int smb_vfs_call_vfs_readlink(struct vfs_handle_struct *handle,
     2060        return handle->fns->symlink_fn(handle, oldpath, newpath);
     2061}
     2062
     2063int smb_vfs_call_readlink(struct vfs_handle_struct *handle,
    16332064                              const char *path, char *buf, size_t bufsiz)
    16342065{
    1635         VFS_FIND(vfs_readlink);
    1636         return handle->fns->vfs_readlink(handle, path, buf, bufsiz);
     2066        VFS_FIND(readlink);
     2067        return handle->fns->readlink_fn(handle, path, buf, bufsiz);
    16372068}
    16382069
     
    16412072{
    16422073        VFS_FIND(link);
    1643         return handle->fns->link(handle, oldpath, newpath);
     2074        return handle->fns->link_fn(handle, oldpath, newpath);
    16442075}
    16452076
     
    16482079{
    16492080        VFS_FIND(mknod);
    1650         return handle->fns->mknod(handle, path, mode, dev);
     2081        return handle->fns->mknod_fn(handle, path, mode, dev);
    16512082}
    16522083
     
    16542085{
    16552086        VFS_FIND(realpath);
    1656         return handle->fns->realpath(handle, path);
    1657 }
    1658 
    1659 NTSTATUS smb_vfs_call_notify_watch(struct vfs_handle_struct *handle,
    1660                                    struct sys_notify_context *ctx,
    1661                                    struct notify_entry *e,
    1662                                    void (*callback)(struct sys_notify_context *ctx,
    1663                                                     void *private_data,
    1664                                                     struct notify_event *ev),
    1665                                    void *private_data, void *handle_p)
    1666 {
    1667         VFS_FIND(notify_watch);
    1668         return handle->fns->notify_watch(handle, ctx, e, callback,
    1669                                          private_data, handle_p);
     2087        return handle->fns->realpath_fn(handle, path);
    16702088}
    16712089
     
    16742092{
    16752093        VFS_FIND(chflags);
    1676         return handle->fns->chflags(handle, path, flags);
     2094        return handle->fns->chflags_fn(handle, path, flags);
    16772095}
    16782096
     
    16812099{
    16822100        VFS_FIND(file_id_create);
    1683         return handle->fns->file_id_create(handle, sbuf);
     2101        return handle->fns->file_id_create_fn(handle, sbuf);
    16842102}
    16852103
     
    16922110{
    16932111        VFS_FIND(streaminfo);
    1694         return handle->fns->streaminfo(handle, fsp, fname, mem_ctx,
    1695                                        num_streams, streams);
     2112        return handle->fns->streaminfo_fn(handle, fsp, fname, mem_ctx,
     2113                                          num_streams, streams);
    16962114}
    16972115
     
    17012119{
    17022120        VFS_FIND(get_real_filename);
    1703         return handle->fns->get_real_filename(handle, path, name, mem_ctx,
    1704                                               found_name);
     2121        return handle->fns->get_real_filename_fn(handle, path, name, mem_ctx,
     2122                                                found_name);
    17052123}
    17062124
     
    17092127{
    17102128        VFS_FIND(connectpath);
    1711         return handle->fns->connectpath(handle, filename);
     2129        return handle->fns->connectpath_fn(handle, filename);
    17122130}
    17132131
     
    17172135{
    17182136        VFS_FIND(strict_lock);
    1719         return handle->fns->strict_lock(handle, fsp, plock);
     2137        return handle->fns->strict_lock_fn(handle, fsp, plock);
    17202138}
    17212139
     
    17252143{
    17262144        VFS_FIND(strict_unlock);
    1727         handle->fns->strict_unlock(handle, fsp, plock);
     2145        handle->fns->strict_unlock_fn(handle, fsp, plock);
    17282146}
    17292147
     
    17352153{
    17362154        VFS_FIND(translate_name);
    1737         return handle->fns->translate_name(handle, name, direction, mem_ctx,
    1738                                            mapped_name);
     2155        return handle->fns->translate_name_fn(handle, name, direction, mem_ctx,
     2156                                              mapped_name);
     2157}
     2158
     2159NTSTATUS smb_vfs_call_fsctl(struct vfs_handle_struct *handle,
     2160                            struct files_struct *fsp,
     2161                            TALLOC_CTX *ctx,
     2162                            uint32_t function,
     2163                            uint16_t req_flags,
     2164                            const uint8_t *in_data,
     2165                            uint32_t in_len,
     2166                            uint8_t **out_data,
     2167                            uint32_t max_out_len,
     2168                            uint32_t *out_len)
     2169{
     2170        VFS_FIND(fsctl);
     2171        return handle->fns->fsctl_fn(handle, fsp, ctx, function, req_flags,
     2172                                     in_data, in_len, out_data, max_out_len,
     2173                                     out_len);
     2174}
     2175
     2176struct tevent_req *smb_vfs_call_copy_chunk_send(struct vfs_handle_struct *handle,
     2177                                                TALLOC_CTX *mem_ctx,
     2178                                                struct tevent_context *ev,
     2179                                                struct files_struct *src_fsp,
     2180                                                off_t src_off,
     2181                                                struct files_struct *dest_fsp,
     2182                                                off_t dest_off,
     2183                                                off_t num)
     2184{
     2185        VFS_FIND(copy_chunk_send);
     2186        return handle->fns->copy_chunk_send_fn(handle, mem_ctx, ev, src_fsp,
     2187                                               src_off, dest_fsp, dest_off, num);
     2188}
     2189
     2190NTSTATUS smb_vfs_call_copy_chunk_recv(struct vfs_handle_struct *handle,
     2191                                      struct tevent_req *req,
     2192                                      off_t *copied)
     2193{
     2194        VFS_FIND(copy_chunk_recv);
     2195        return handle->fns->copy_chunk_recv_fn(handle, req, copied);
     2196}
     2197
     2198NTSTATUS smb_vfs_call_get_compression(vfs_handle_struct *handle,
     2199                                      TALLOC_CTX *mem_ctx,
     2200                                      struct files_struct *fsp,
     2201                                      struct smb_filename *smb_fname,
     2202                                      uint16_t *_compression_fmt)
     2203{
     2204        VFS_FIND(get_compression);
     2205        return handle->fns->get_compression_fn(handle, mem_ctx, fsp, smb_fname,
     2206                                               _compression_fmt);
     2207}
     2208
     2209NTSTATUS smb_vfs_call_set_compression(vfs_handle_struct *handle,
     2210                                      TALLOC_CTX *mem_ctx,
     2211                                      struct files_struct *fsp,
     2212                                      uint16_t compression_fmt)
     2213{
     2214        VFS_FIND(set_compression);
     2215        return handle->fns->set_compression_fn(handle, mem_ctx, fsp,
     2216                                               compression_fmt);
     2217}
     2218
     2219NTSTATUS smb_vfs_call_snap_check_path(vfs_handle_struct *handle,
     2220                                      TALLOC_CTX *mem_ctx,
     2221                                      const char *service_path,
     2222                                      char **base_volume)
     2223{
     2224        VFS_FIND(snap_check_path);
     2225        return handle->fns->snap_check_path_fn(handle, mem_ctx, service_path,
     2226                                               base_volume);
     2227}
     2228
     2229NTSTATUS smb_vfs_call_snap_create(struct vfs_handle_struct *handle,
     2230                                  TALLOC_CTX *mem_ctx,
     2231                                  const char *base_volume,
     2232                                  time_t *tstamp,
     2233                                  bool rw,
     2234                                  char **base_path,
     2235                                  char **snap_path)
     2236{
     2237        VFS_FIND(snap_create);
     2238        return handle->fns->snap_create_fn(handle, mem_ctx, base_volume, tstamp,
     2239                                           rw, base_path, snap_path);
     2240}
     2241
     2242NTSTATUS smb_vfs_call_snap_delete(struct vfs_handle_struct *handle,
     2243                                  TALLOC_CTX *mem_ctx,
     2244                                  char *base_path,
     2245                                  char *snap_path)
     2246{
     2247        VFS_FIND(snap_delete);
     2248        return handle->fns->snap_delete_fn(handle, mem_ctx, base_path,
     2249                                           snap_path);
    17392250}
    17402251
    17412252NTSTATUS smb_vfs_call_fget_nt_acl(struct vfs_handle_struct *handle,
    17422253                                  struct files_struct *fsp,
    1743                                   uint32 security_info,
     2254                                  uint32_t security_info,
     2255                                  TALLOC_CTX *mem_ctx,
    17442256                                  struct security_descriptor **ppdesc)
    17452257{
    17462258        VFS_FIND(fget_nt_acl);
    1747         return handle->fns->fget_nt_acl(handle, fsp, security_info,
    1748                                         ppdesc);
     2259        return handle->fns->fget_nt_acl_fn(handle, fsp, security_info,
     2260                                           mem_ctx, ppdesc);
    17492261}
    17502262
    17512263NTSTATUS smb_vfs_call_get_nt_acl(struct vfs_handle_struct *handle,
    17522264                                 const char *name,
    1753                                  uint32 security_info,
     2265                                 uint32_t security_info,
     2266                                 TALLOC_CTX *mem_ctx,
    17542267                                 struct security_descriptor **ppdesc)
    17552268{
    17562269        VFS_FIND(get_nt_acl);
    1757         return handle->fns->get_nt_acl(handle, name, security_info, ppdesc);
     2270        return handle->fns->get_nt_acl_fn(handle, name, security_info, mem_ctx, ppdesc);
    17582271}
    17592272
    17602273NTSTATUS smb_vfs_call_fset_nt_acl(struct vfs_handle_struct *handle,
    17612274                                  struct files_struct *fsp,
    1762                                   uint32 security_info_sent,
     2275                                  uint32_t security_info_sent,
    17632276                                  const struct security_descriptor *psd)
    17642277{
    17652278        VFS_FIND(fset_nt_acl);
    1766         return handle->fns->fset_nt_acl(handle, fsp, security_info_sent, psd);
     2279        return handle->fns->fset_nt_acl_fn(handle, fsp, security_info_sent,
     2280                                           psd);
     2281}
     2282
     2283NTSTATUS smb_vfs_call_audit_file(struct vfs_handle_struct *handle,
     2284                                 struct smb_filename *file,
     2285                                 struct security_acl *sacl,
     2286                                 uint32_t access_requested,
     2287                                 uint32_t access_denied)
     2288{
     2289        VFS_FIND(audit_file);
     2290        return handle->fns->audit_file_fn(handle,
     2291                                          file,
     2292                                          sacl,
     2293                                          access_requested,
     2294                                          access_denied);
    17672295}
    17682296
     
    17712299{
    17722300        VFS_FIND(chmod_acl);
    1773         return handle->fns->chmod_acl(handle, name, mode);
     2301        return handle->fns->chmod_acl_fn(handle, name, mode);
    17742302}
    17752303
     
    17782306{
    17792307        VFS_FIND(fchmod_acl);
    1780         return handle->fns->fchmod_acl(handle, fsp, mode);
    1781 }
    1782 
    1783 int smb_vfs_call_sys_acl_get_entry(struct vfs_handle_struct *handle,
    1784                                    SMB_ACL_T theacl, int entry_id,
    1785                                    SMB_ACL_ENTRY_T *entry_p)
    1786 {
    1787         VFS_FIND(sys_acl_get_entry);
    1788         return handle->fns->sys_acl_get_entry(handle, theacl, entry_id,
    1789                                               entry_p);
    1790 }
    1791 
    1792 int smb_vfs_call_sys_acl_get_tag_type(struct vfs_handle_struct *handle,
    1793                                       SMB_ACL_ENTRY_T entry_d,
    1794                                       SMB_ACL_TAG_T *tag_type_p)
    1795 {
    1796         VFS_FIND(sys_acl_get_tag_type);
    1797         return handle->fns->sys_acl_get_tag_type(handle, entry_d, tag_type_p);
    1798 }
    1799 
    1800 int smb_vfs_call_sys_acl_get_permset(struct vfs_handle_struct *handle,
    1801                                      SMB_ACL_ENTRY_T entry_d,
    1802                                      SMB_ACL_PERMSET_T *permset_p)
    1803 {
    1804         VFS_FIND(sys_acl_get_permset);
    1805         return handle->fns->sys_acl_get_permset(handle, entry_d, permset_p);
    1806 }
    1807 
    1808 void * smb_vfs_call_sys_acl_get_qualifier(struct vfs_handle_struct *handle,
    1809                                           SMB_ACL_ENTRY_T entry_d)
    1810 {
    1811         VFS_FIND(sys_acl_get_qualifier);
    1812         return handle->fns->sys_acl_get_qualifier(handle, entry_d);
     2308        return handle->fns->fchmod_acl_fn(handle, fsp, mode);
    18132309}
    18142310
    18152311SMB_ACL_T smb_vfs_call_sys_acl_get_file(struct vfs_handle_struct *handle,
    18162312                                        const char *path_p,
    1817                                         SMB_ACL_TYPE_T type)
     2313                                        SMB_ACL_TYPE_T type,
     2314                                        TALLOC_CTX *mem_ctx)
    18182315{
    18192316        VFS_FIND(sys_acl_get_file);
    1820         return handle->fns->sys_acl_get_file(handle, path_p, type);
     2317        return handle->fns->sys_acl_get_file_fn(handle, path_p, type, mem_ctx);
    18212318}
    18222319
    18232320SMB_ACL_T smb_vfs_call_sys_acl_get_fd(struct vfs_handle_struct *handle,
    1824                                       struct files_struct *fsp)
     2321                                      struct files_struct *fsp,
     2322                                      TALLOC_CTX *mem_ctx)
    18252323{
    18262324        VFS_FIND(sys_acl_get_fd);
    1827         return handle->fns->sys_acl_get_fd(handle, fsp);
    1828 }
    1829 
    1830 int smb_vfs_call_sys_acl_clear_perms(struct vfs_handle_struct *handle,
    1831                                      SMB_ACL_PERMSET_T permset)
    1832 {
    1833         VFS_FIND(sys_acl_clear_perms);
    1834         return handle->fns->sys_acl_clear_perms(handle, permset);
    1835 }
    1836 
    1837 int smb_vfs_call_sys_acl_add_perm(struct vfs_handle_struct *handle,
    1838                                   SMB_ACL_PERMSET_T permset,
    1839                                   SMB_ACL_PERM_T perm)
    1840 {
    1841         VFS_FIND(sys_acl_add_perm);
    1842         return handle->fns->sys_acl_add_perm(handle, permset, perm);
    1843 }
    1844 
    1845 char * smb_vfs_call_sys_acl_to_text(struct vfs_handle_struct *handle,
    1846                                     SMB_ACL_T theacl, ssize_t *plen)
    1847 {
    1848         VFS_FIND(sys_acl_to_text);
    1849         return handle->fns->sys_acl_to_text(handle, theacl, plen);
    1850 }
    1851 
    1852 SMB_ACL_T smb_vfs_call_sys_acl_init(struct vfs_handle_struct *handle,
    1853                                     int count)
    1854 {
    1855         VFS_FIND(sys_acl_init);
    1856         return handle->fns->sys_acl_init(handle, count);
    1857 }
    1858 
    1859 int smb_vfs_call_sys_acl_create_entry(struct vfs_handle_struct *handle,
    1860                                       SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry)
    1861 {
    1862         VFS_FIND(sys_acl_create_entry);
    1863         return handle->fns->sys_acl_create_entry(handle, pacl, pentry);
    1864 }
    1865 
    1866 int smb_vfs_call_sys_acl_set_tag_type(struct vfs_handle_struct *handle,
    1867                                       SMB_ACL_ENTRY_T entry,
    1868                                       SMB_ACL_TAG_T tagtype)
    1869 {
    1870         VFS_FIND(sys_acl_set_tag_type);
    1871         return handle->fns->sys_acl_set_tag_type(handle, entry, tagtype);
    1872 }
    1873 
    1874 int smb_vfs_call_sys_acl_set_qualifier(struct vfs_handle_struct *handle,
    1875                                        SMB_ACL_ENTRY_T entry, void *qual)
    1876 {
    1877         VFS_FIND(sys_acl_set_qualifier);
    1878         return handle->fns->sys_acl_set_qualifier(handle, entry, qual);
    1879 }
    1880 
    1881 int smb_vfs_call_sys_acl_set_permset(struct vfs_handle_struct *handle,
    1882                                      SMB_ACL_ENTRY_T entry,
    1883                                      SMB_ACL_PERMSET_T permset)
    1884 {
    1885         VFS_FIND(sys_acl_set_permset);
    1886         return handle->fns->sys_acl_set_permset(handle, entry, permset);
    1887 }
    1888 
    1889 int smb_vfs_call_sys_acl_valid(struct vfs_handle_struct *handle,
    1890                                SMB_ACL_T theacl)
    1891 {
    1892         VFS_FIND(sys_acl_valid);
    1893         return handle->fns->sys_acl_valid(handle, theacl);
     2325        return handle->fns->sys_acl_get_fd_fn(handle, fsp, mem_ctx);
     2326}
     2327
     2328int smb_vfs_call_sys_acl_blob_get_file(struct vfs_handle_struct *handle,
     2329                                       const char *path_p,
     2330                                       TALLOC_CTX *mem_ctx,
     2331                                       char **blob_description,
     2332                                       DATA_BLOB *blob)
     2333{
     2334        VFS_FIND(sys_acl_blob_get_file);
     2335        return handle->fns->sys_acl_blob_get_file_fn(handle, path_p, mem_ctx, blob_description, blob);
     2336}
     2337
     2338int smb_vfs_call_sys_acl_blob_get_fd(struct vfs_handle_struct *handle,
     2339                                     struct files_struct *fsp,
     2340                                     TALLOC_CTX *mem_ctx,
     2341                                     char **blob_description,
     2342                                     DATA_BLOB *blob)
     2343{
     2344        VFS_FIND(sys_acl_blob_get_fd);
     2345        return handle->fns->sys_acl_blob_get_fd_fn(handle, fsp, mem_ctx, blob_description, blob);
    18942346}
    18952347
     
    18992351{
    19002352        VFS_FIND(sys_acl_set_file);
    1901         return handle->fns->sys_acl_set_file(handle, name, acltype, theacl);
     2353        return handle->fns->sys_acl_set_file_fn(handle, name, acltype, theacl);
    19022354}
    19032355
     
    19062358{
    19072359        VFS_FIND(sys_acl_set_fd);
    1908         return handle->fns->sys_acl_set_fd(handle, fsp, theacl);
     2360        return handle->fns->sys_acl_set_fd_fn(handle, fsp, theacl);
    19092361}
    19102362
     
    19132365{
    19142366        VFS_FIND(sys_acl_delete_def_file);
    1915         return handle->fns->sys_acl_delete_def_file(handle, path);
    1916 }
    1917 
    1918 int smb_vfs_call_sys_acl_get_perm(struct vfs_handle_struct *handle,
    1919                                   SMB_ACL_PERMSET_T permset,
    1920                                   SMB_ACL_PERM_T perm)
    1921 {
    1922         VFS_FIND(sys_acl_get_perm);
    1923         return handle->fns->sys_acl_get_perm(handle, permset, perm);
    1924 }
    1925 
    1926 int smb_vfs_call_sys_acl_free_text(struct vfs_handle_struct *handle,
    1927                                    char *text)
    1928 {
    1929         VFS_FIND(sys_acl_free_text);
    1930         return handle->fns->sys_acl_free_text(handle, text);
    1931 }
    1932 
    1933 int smb_vfs_call_sys_acl_free_acl(struct vfs_handle_struct *handle,
    1934                                   SMB_ACL_T posix_acl)
    1935 {
    1936         VFS_FIND(sys_acl_free_acl);
    1937         return handle->fns->sys_acl_free_acl(handle, posix_acl);
    1938 }
    1939 
    1940 int smb_vfs_call_sys_acl_free_qualifier(struct vfs_handle_struct *handle,
    1941                                         void *qualifier, SMB_ACL_TAG_T tagtype)
    1942 {
    1943         VFS_FIND(sys_acl_free_qualifier);
    1944         return handle->fns->sys_acl_free_qualifier(handle, qualifier, tagtype);
     2367        return handle->fns->sys_acl_delete_def_file_fn(handle, path);
    19452368}
    19462369
     
    19502373{
    19512374        VFS_FIND(getxattr);
    1952         return handle->fns->getxattr(handle, path, name, value, size);
    1953 }
    1954 
    1955 ssize_t smb_vfs_call_lgetxattr(struct vfs_handle_struct *handle,
    1956                                const char *path, const char *name, void *value,
    1957                                size_t size)
    1958 {
    1959         VFS_FIND(lgetxattr);
    1960         return handle->fns->lgetxattr(handle, path, name, value, size);
     2375        return handle->fns->getxattr_fn(handle, path, name, value, size);
    19612376}
    19622377
     
    19662381{
    19672382        VFS_FIND(fgetxattr);
    1968         return handle->fns->fgetxattr(handle, fsp, name, value, size);
     2383        return handle->fns->fgetxattr_fn(handle, fsp, name, value, size);
    19692384}
    19702385
     
    19732388{
    19742389        VFS_FIND(listxattr);
    1975         return handle->fns->listxattr(handle, path, list, size);
    1976 }
    1977 
    1978 ssize_t smb_vfs_call_llistxattr(struct vfs_handle_struct *handle,
    1979                                 const char *path, char *list, size_t size)
    1980 {
    1981         VFS_FIND(llistxattr);
    1982         return handle->fns->llistxattr(handle, path, list, size);
     2390        return handle->fns->listxattr_fn(handle, path, list, size);
    19832391}
    19842392
     
    19882396{
    19892397        VFS_FIND(flistxattr);
    1990         return handle->fns->flistxattr(handle, fsp, list, size);
     2398        return handle->fns->flistxattr_fn(handle, fsp, list, size);
    19912399}
    19922400
     
    19952403{
    19962404        VFS_FIND(removexattr);
    1997         return handle->fns->removexattr(handle, path, name);
    1998 }
    1999 
    2000 int smb_vfs_call_lremovexattr(struct vfs_handle_struct *handle,
    2001                               const char *path, const char *name)
    2002 {
    2003         VFS_FIND(lremovexattr);
    2004         return handle->fns->lremovexattr(handle, path, name);
     2405        return handle->fns->removexattr_fn(handle, path, name);
    20052406}
    20062407
     
    20092410{
    20102411        VFS_FIND(fremovexattr);
    2011         return handle->fns->fremovexattr(handle, fsp, name);
     2412        return handle->fns->fremovexattr_fn(handle, fsp, name);
    20122413}
    20132414
     
    20172418{
    20182419        VFS_FIND(setxattr);
    2019         return handle->fns->setxattr(handle, path, name, value, size, flags);
    2020 }
    2021 
    2022 int smb_vfs_call_lsetxattr(struct vfs_handle_struct *handle, const char *path,
    2023                            const char *name, const void *value, size_t size,
    2024                            int flags)
    2025 {
    2026         VFS_FIND(lsetxattr);
    2027         return handle->fns->lsetxattr(handle, path, name, value, size, flags);
     2420        return handle->fns->setxattr_fn(handle, path, name, value, size, flags);
    20282421}
    20292422
     
    20332426{
    20342427        VFS_FIND(fsetxattr);
    2035         return handle->fns->fsetxattr(handle, fsp, name, value, size, flags);
    2036 }
    2037 
    2038 int smb_vfs_call_aio_read(struct vfs_handle_struct *handle,
    2039                           struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
    2040 {
    2041         VFS_FIND(aio_read);
    2042         return handle->fns->aio_read(handle, fsp, aiocb);
    2043 }
    2044 
    2045 int smb_vfs_call_aio_write(struct vfs_handle_struct *handle,
    2046                            struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
    2047 {
    2048         VFS_FIND(aio_write);
    2049         return handle->fns->aio_write(handle, fsp, aiocb);
    2050 }
    2051 
    2052 ssize_t smb_vfs_call_aio_return_fn(struct vfs_handle_struct *handle,
    2053                                    struct files_struct *fsp,
    2054                                    SMB_STRUCT_AIOCB *aiocb)
    2055 {
    2056         VFS_FIND(aio_return_fn);
    2057         return handle->fns->aio_return_fn(handle, fsp, aiocb);
    2058 }
    2059 
    2060 int smb_vfs_call_aio_cancel(struct vfs_handle_struct *handle,
    2061                             struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
    2062 {
    2063         VFS_FIND(aio_cancel);
    2064         return handle->fns->aio_cancel(handle, fsp, aiocb);
    2065 }
    2066 
    2067 int smb_vfs_call_aio_error_fn(struct vfs_handle_struct *handle,
    2068                               struct files_struct *fsp,
    2069                               SMB_STRUCT_AIOCB *aiocb)
    2070 {
    2071         VFS_FIND(aio_error_fn);
    2072         return handle->fns->aio_error_fn(handle, fsp, aiocb);
    2073 }
    2074 
    2075 int smb_vfs_call_aio_fsync(struct vfs_handle_struct *handle,
    2076                            struct files_struct *fsp, int op,
    2077                            SMB_STRUCT_AIOCB *aiocb)
    2078 {
    2079         VFS_FIND(aio_fsync);
    2080         return handle->fns->aio_fsync(handle, fsp, op, aiocb);
    2081 }
    2082 
    2083 int smb_vfs_call_aio_suspend(struct vfs_handle_struct *handle,
    2084                              struct files_struct *fsp,
    2085                              const SMB_STRUCT_AIOCB * const aiocb[], int n,
    2086                              const struct timespec *timeout)
    2087 {
    2088         VFS_FIND(aio_suspend);
    2089         return handle->fns->aio_suspend(handle, fsp, aiocb, n, timeout);
     2428        return handle->fns->fsetxattr_fn(handle, fsp, name, value, size, flags);
    20902429}
    20912430
     
    20942433{
    20952434        VFS_FIND(aio_force);
    2096         return handle->fns->aio_force(handle, fsp);
     2435        return handle->fns->aio_force_fn(handle, fsp);
    20972436}
    20982437
     
    21022441{
    21032442        VFS_FIND(is_offline);
    2104         return handle->fns->is_offline(handle, fname, sbuf);
     2443        return handle->fns->is_offline_fn(handle, fname, sbuf);
    21052444}
    21062445
     
    21092448{
    21102449        VFS_FIND(set_offline);
    2111         return handle->fns->set_offline(handle, fname);
    2112 }
     2450        return handle->fns->set_offline_fn(handle, fname);
     2451}
     2452
     2453NTSTATUS smb_vfs_call_durable_cookie(struct vfs_handle_struct *handle,
     2454                                     struct files_struct *fsp,
     2455                                     TALLOC_CTX *mem_ctx,
     2456                                     DATA_BLOB *cookie)
     2457{
     2458        VFS_FIND(durable_cookie);
     2459        return handle->fns->durable_cookie_fn(handle, fsp, mem_ctx, cookie);
     2460}
     2461
     2462NTSTATUS smb_vfs_call_durable_disconnect(struct vfs_handle_struct *handle,
     2463                                         struct files_struct *fsp,
     2464                                         const DATA_BLOB old_cookie,
     2465                                         TALLOC_CTX *mem_ctx,
     2466                                         DATA_BLOB *new_cookie)
     2467{
     2468        VFS_FIND(durable_disconnect);
     2469        return handle->fns->durable_disconnect_fn(handle, fsp, old_cookie,
     2470                                                  mem_ctx, new_cookie);
     2471}
     2472
     2473NTSTATUS smb_vfs_call_durable_reconnect(struct vfs_handle_struct *handle,
     2474                                        struct smb_request *smb1req,
     2475                                        struct smbXsrv_open *op,
     2476                                        const DATA_BLOB old_cookie,
     2477                                        TALLOC_CTX *mem_ctx,
     2478                                        struct files_struct **fsp,
     2479                                        DATA_BLOB *new_cookie)
     2480{
     2481        VFS_FIND(durable_reconnect);
     2482        return handle->fns->durable_reconnect_fn(handle, smb1req, op,
     2483                                                 old_cookie, mem_ctx, fsp,
     2484                                                 new_cookie);
     2485}
     2486
     2487NTSTATUS smb_vfs_call_readdir_attr(struct vfs_handle_struct *handle,
     2488                                   const struct smb_filename *fname,
     2489                                   TALLOC_CTX *mem_ctx,
     2490                                   struct readdir_attr_data **attr_data)
     2491{
     2492        VFS_FIND(readdir_attr);
     2493        return handle->fns->readdir_attr_fn(handle, fname, mem_ctx, attr_data);
     2494}
Note: See TracChangeset for help on using the changeset viewer.