s3: Change set_ea() and its callers to use smb_filename
[samba.git] / source3 / smbd / trans2.c
index dc2544c4e3554c9049da768b53dd19ff7b1bd489..8bd37633d05a1132db5b7e1849024a69943e6a56 100644 (file)
@@ -404,12 +404,22 @@ static void canonicalize_ea_name(connection_struct *conn, files_struct *fsp, con
  Set or delete an extended attribute.
 ****************************************************************************/
 
-NTSTATUS set_ea(connection_struct *conn, files_struct *fsp, const char *fname, struct ea_list *ea_list)
+NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
+               const struct smb_filename *smb_fname, struct ea_list *ea_list)
 {
+       char *fname = NULL;
+       NTSTATUS status;
+
        if (!lp_ea_support(SNUM(conn))) {
                return NT_STATUS_EAS_NOT_SUPPORTED;
        }
 
+       status = get_full_smb_filename(talloc_tos(), smb_fname,
+                                      &fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
        for (;ea_list; ea_list = ea_list->next) {
                int ret;
                fstring unix_ea_name;
@@ -941,6 +951,23 @@ static void call_trans2open(connection_struct *conn,
                fname, (unsigned int)deny_mode, (unsigned int)open_attr,
                (unsigned int)open_ofun, open_size));
 
+       status = filename_convert(ctx,
+                               conn,
+                               req->flags2 & FLAGS2_DFS_PATHNAMES,
+                               fname,
+                               &smb_fname,
+                               &fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
+                       reply_botherror(req,
+                               NT_STATUS_PATH_NOT_COVERED,
+                               ERRSRV, ERRbadpath);
+                       goto out;
+               }
+               reply_nterror(req, status);
+               goto out;
+       }
+
        if (open_ofun == 0) {
                reply_nterror(req, NT_STATUS_OBJECT_NAME_COLLISION);
                goto out;
@@ -985,24 +1012,11 @@ static void call_trans2open(connection_struct *conn,
                goto out;
        }
 
-       status = unix_convert(ctx, conn, fname, &smb_fname, 0);
-       if (!NT_STATUS_IS_OK(status)) {
-               reply_nterror(req, status);
-               goto out;
-       }
-
-       status = get_full_smb_filename(ctx, smb_fname, &fname);
-       if (!NT_STATUS_IS_OK(status)) {
-               reply_nterror(req, status);
-               goto out;
-       }
-
        status = SMB_VFS_CREATE_FILE(
                conn,                                   /* conn */
                req,                                    /* req */
                0,                                      /* root_dir_fid */
-               fname,                                  /* fname */
-               0,                                      /* create_file_flags */
+               smb_fname,                              /* fname */
                access_mask,                            /* access_mask */
                share_mode,                             /* share_access */
                create_disposition,                     /* create_disposition*/
@@ -1013,8 +1027,7 @@ static void call_trans2open(connection_struct *conn,
                NULL,                                   /* sd */
                ea_list,                                /* ea_list */
                &fsp,                                   /* result */
-               &smb_action,                            /* pinfo */
-               &smb_fname->st);                        /* psbuf */
+               &smb_action);                           /* psbuf */
 
        if (!NT_STATUS_IS_OK(status)) {
                if (open_was_deferred(req->mid)) {
@@ -1392,14 +1405,17 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
                        }
 
                        if (INFO_LEVEL_IS_UNIX(info_level)) {
-                               if (SMB_VFS_LSTAT(conn,pathreal,&sbuf) != 0) {
+                               if (vfs_lstat_smb_fname(conn, pathreal,
+                                                       &sbuf) != 0) {
                                        DEBUG(5,("get_lanman2_dir_entry:Couldn't lstat [%s] (%s)\n",
                                                pathreal,strerror(errno)));
                                        TALLOC_FREE(pathreal);
                                        TALLOC_FREE(fname);
                                        continue;
                                }
-                       } else if (!VALID_STAT(sbuf) && SMB_VFS_STAT(conn,pathreal,&sbuf) != 0) {
+                       } else if (!VALID_STAT(sbuf) &&
+                                  vfs_stat_smb_fname(conn, pathreal,
+                                                     &sbuf) != 0) {
                                /* Needed to show the msdfs symlinks as
                                 * directories */
 
@@ -2623,7 +2639,7 @@ static void call_trans2qfsinfo(connection_struct *conn,
 
        DEBUG(3,("call_trans2qfsinfo: level = %d\n", info_level));
 
-       if(SMB_VFS_STAT(conn,".",&st)!=0) {
+       if(vfs_stat_smb_fname(conn,".",&st)!=0) {
                DEBUG(2,("call_trans2qfsinfo: stat of . failed (%s)\n", strerror(errno)));
                reply_doserror(req, ERRSRV, ERRinvdevice);
                return;
@@ -3868,13 +3884,13 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
        char *lock_data = NULL;
        bool ms_dfs_link = false;
        TALLOC_CTX *ctx = talloc_tos();
+       NTSTATUS status = NT_STATUS_OK;
 
        if (!params) {
                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
                return;
        }
 
-       ZERO_STRUCT(sbuf);
        ZERO_STRUCT(write_time_ts);
 
        if (tran_call == TRANSACT2_QFILEINFO) {
@@ -3912,6 +3928,13 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
                        return;
                }
 
+               status = create_synthetic_smb_fname_split(talloc_tos(), fname,
+                                                         NULL, &smb_fname);
+               if (!NT_STATUS_IS_OK(status)) {
+                       reply_nterror(req, status);
+                       return;
+               }
+
                if(fsp->fake_file_handle) {
                        /*
                         * This is actually for the QUOTA_FAKE_FILE --metze
@@ -3928,18 +3951,25 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
 
                        if (INFO_LEVEL_IS_UNIX(info_level)) {
                                /* Always do lstat for UNIX calls. */
-                               if (SMB_VFS_LSTAT(conn,fname,&sbuf)) {
-                                       DEBUG(3,("call_trans2qfilepathinfo: SMB_VFS_LSTAT of %s failed (%s)\n",fname,strerror(errno)));
+                               if (SMB_VFS_LSTAT(conn, smb_fname)) {
+                                       DEBUG(3,("call_trans2qfilepathinfo: "
+                                                "SMB_VFS_LSTAT of %s failed "
+                                                "(%s)\n",
+                                                smb_fname_str_dbg(smb_fname),
+                                                strerror(errno)));
                                        reply_unixerror(req,ERRDOS,ERRbadpath);
                                        return;
                                }
-                       } else if (SMB_VFS_STAT(conn,fname,&sbuf)) {
-                               DEBUG(3,("call_trans2qfilepathinfo: SMB_VFS_STAT of %s failed (%s)\n",fname,strerror(errno)));
+                       } else if (SMB_VFS_STAT(conn, smb_fname)) {
+                               DEBUG(3,("call_trans2qfilepathinfo: "
+                                        "SMB_VFS_STAT of %s failed (%s)\n",
+                                        smb_fname_str_dbg(smb_fname),
+                                        strerror(errno)));
                                reply_unixerror(req, ERRDOS, ERRbadpath);
                                return;
                        }
 
-                       fileid = vfs_file_id_from_sbuf(conn, &sbuf);
+                       fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st);
                        get_file_infos(fileid, &delete_pending, &write_time_ts);
                } else {
                        /*
@@ -3949,19 +3979,18 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
                                return;
                        }
 
-                       if (SMB_VFS_FSTAT(fsp, &sbuf) != 0) {
-                               DEBUG(3,("fstat of fnum %d failed (%s)\n", fsp->fnum, strerror(errno)));
+                       if (SMB_VFS_FSTAT(fsp, &smb_fname->st) != 0) {
+                               DEBUG(3, ("fstat of fnum %d failed (%s)\n",
+                                         fsp->fnum, strerror(errno)));
                                reply_unixerror(req, ERRDOS, ERRbadfid);
                                return;
                        }
                        pos = fsp->fh->position_information;
-                       fileid = vfs_file_id_from_sbuf(conn, &sbuf);
+                       fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st);
                        get_file_infos(fileid, &delete_pending, &write_time_ts);
                }
 
        } else {
-               NTSTATUS status = NT_STATUS_OK;
-
                /* qpathinfo */
                if (total_params < 7) {
                        reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
@@ -3985,75 +4014,67 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
                        return;
                }
 
-               status = resolve_dfspath(ctx,
+               status = filename_convert(ctx,
                                        conn,
                                        req->flags2 & FLAGS2_DFS_PATHNAMES,
                                        fname,
+                                       &smb_fname,
                                        &fname);
                if (!NT_STATUS_IS_OK(status)) {
                        if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
                                reply_botherror(req,
                                                NT_STATUS_PATH_NOT_COVERED,
                                                ERRSRV, ERRbadpath);
+                               return;
                        }
                        reply_nterror(req, status);
                        return;
                }
 
-               status = unix_convert(ctx, conn, fname, &smb_fname, 0);
-               if (!NT_STATUS_IS_OK(status)) {
-                       reply_nterror(req, status);
-                       return;
-               }
-               sbuf = smb_fname->st;
-
-               status = get_full_smb_filename(ctx, smb_fname, &fname);
-               TALLOC_FREE(smb_fname);
-               if (!NT_STATUS_IS_OK(status)) {
-                       reply_nterror(req, status);
-                       return;
-               }
-
-               status = check_name(conn, fname);
-               if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(3,("call_trans2qfilepathinfo: fileinfo of %s failed (%s)\n",fname,nt_errstr(status)));
-                       reply_nterror(req, status);
-                       return;
-               }
-
+               /* If this is a stream, check if there is a delete_pending. */
                if ((conn->fs_capabilities & FILE_NAMED_STREAMS)
-                   && is_ntfs_stream_name(fname)) {
-                       char *base;
-                       SMB_STRUCT_STAT bsbuf;
-
-                       status = split_ntfs_stream_name(talloc_tos(), fname,
-                                                       &base, NULL);
+                   && is_ntfs_stream_smb_fname(smb_fname)) {
+                       struct smb_filename *smb_fname_base = NULL;
+
+                       /* Create an smb_filename with stream_name == NULL. */
+                       status =
+                           create_synthetic_smb_fname(talloc_tos(),
+                                                      smb_fname->base_name,
+                                                      NULL, NULL,
+                                                      &smb_fname_base);
                        if (!NT_STATUS_IS_OK(status)) {
-                               DEBUG(10, ("create_file_unixpath: "
-                                       "split_ntfs_stream_name failed: %s\n",
-                                       nt_errstr(status)));
                                reply_nterror(req, status);
                                return;
                        }
 
-                       SMB_ASSERT(!is_ntfs_stream_name(base)); /* paranoia.. */
-
                        if (INFO_LEVEL_IS_UNIX(info_level)) {
                                /* Always do lstat for UNIX calls. */
-                               if (SMB_VFS_LSTAT(conn,base,&bsbuf)) {
-                                       DEBUG(3,("call_trans2qfilepathinfo: SMB_VFS_LSTAT of %s failed (%s)\n",base,strerror(errno)));
+                               if (SMB_VFS_LSTAT(conn, smb_fname_base) != 0) {
+                                       DEBUG(3,("call_trans2qfilepathinfo: "
+                                                "SMB_VFS_LSTAT of %s failed "
+                                                "(%s)\n",
+                                                smb_fname_str_dbg(smb_fname_base),
+                                                strerror(errno)));
+                                       TALLOC_FREE(smb_fname_base);
                                        reply_unixerror(req,ERRDOS,ERRbadpath);
                                        return;
                                }
                        } else {
-                               if (SMB_VFS_STAT(conn,base,&bsbuf) != 0) {
-                                       DEBUG(3,("call_trans2qfilepathinfo: fileinfo of %s failed (%s)\n",base,strerror(errno)));
+                               if (SMB_VFS_STAT(conn, smb_fname_base) != 0) {
+                                       DEBUG(3,("call_trans2qfilepathinfo: "
+                                                "fileinfo of %s failed "
+                                                "(%s)\n",
+                                                smb_fname_str_dbg(smb_fname_base),
+                                                strerror(errno)));
+                                       TALLOC_FREE(smb_fname_base);
                                        reply_unixerror(req,ERRDOS,ERRbadpath);
                                        return;
                                }
                        }
 
-                       fileid = vfs_file_id_from_sbuf(conn, &bsbuf);
+                       fileid = vfs_file_id_from_sbuf(conn,
+                                                      &smb_fname_base->st);
+                       TALLOC_FREE(smb_fname_base);
                        get_file_infos(fileid, &delete_pending, NULL);
                        if (delete_pending) {
                                reply_nterror(req, NT_STATUS_DELETE_PENDING);
@@ -4063,23 +4084,32 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
 
                if (INFO_LEVEL_IS_UNIX(info_level)) {
                        /* Always do lstat for UNIX calls. */
-                       if (SMB_VFS_LSTAT(conn,fname,&sbuf)) {
-                               DEBUG(3,("call_trans2qfilepathinfo: SMB_VFS_LSTAT of %s failed (%s)\n",fname,strerror(errno)));
+                       if (SMB_VFS_LSTAT(conn, smb_fname)) {
+                               DEBUG(3,("call_trans2qfilepathinfo: "
+                                        "SMB_VFS_LSTAT of %s failed (%s)\n",
+                                        smb_fname_str_dbg(smb_fname),
+                                        strerror(errno)));
                                reply_unixerror(req, ERRDOS, ERRbadpath);
                                return;
                        }
 
-               } else if (!VALID_STAT(sbuf) && SMB_VFS_STAT(conn,fname,&sbuf) && (info_level != SMB_INFO_IS_NAME_VALID)) {
-                       ms_dfs_link = check_msdfs_link(conn,fname,&sbuf);
+               } else if (!VALID_STAT(smb_fname->st) &&
+                          SMB_VFS_STAT(conn, smb_fname) &&
+                          (info_level != SMB_INFO_IS_NAME_VALID)) {
+                       ms_dfs_link = check_msdfs_link(conn, fname,
+                                                      &smb_fname->st);
 
                        if (!ms_dfs_link) {
-                               DEBUG(3,("call_trans2qfilepathinfo: SMB_VFS_STAT of %s failed (%s)\n",fname,strerror(errno)));
+                               DEBUG(3,("call_trans2qfilepathinfo: "
+                                        "SMB_VFS_STAT of %s failed (%s)\n",
+                                        smb_fname_str_dbg(smb_fname),
+                                        strerror(errno)));
                                reply_unixerror(req, ERRDOS, ERRbadpath);
                                return;
                        }
                }
 
-               fileid = vfs_file_id_from_sbuf(conn, &sbuf);
+               fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st);
                get_file_infos(fileid, &delete_pending, &write_time_ts);
                if (delete_pending) {
                        reply_nterror(req, NT_STATUS_DELETE_PENDING);
@@ -4087,6 +4117,9 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
                }
        }
 
+       /* Set sbuf for use below. */
+       sbuf = smb_fname->st;
+
        if (INFO_LEVEL_IS_UNIX(info_level) && !lp_unix_extensions()) {
                reply_nterror(req, NT_STATUS_INVALID_LEVEL);
                return;
@@ -4525,7 +4558,6 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                case SMB_FILE_STREAM_INFORMATION: {
                        unsigned int num_streams;
                        struct stream_struct *streams;
-                       NTSTATUS status;
 
                        DEBUG(10,("call_trans2qfilepathinfo: "
                                  "SMB_FILE_STREAM_INFORMATION\n"));
@@ -4752,7 +4784,6 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
 
                case SMB_QUERY_POSIX_LOCK:
                {
-                       NTSTATUS status = NT_STATUS_INVALID_LEVEL;
                        uint64_t count;
                        uint64_t offset;
                        uint32 lock_pid;
@@ -4846,65 +4877,33 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
 
 NTSTATUS hardlink_internals(TALLOC_CTX *ctx,
                connection_struct *conn,
-               const char *oldname_in,
-               const char *newname_in)
+               const struct smb_filename *smb_fname_old,
+               const struct smb_filename *smb_fname_new)
 {
-       struct smb_filename *smb_fname = NULL;
-       struct smb_filename *smb_fname_new = NULL;
        char *oldname = NULL;
        char *newname = NULL;
        NTSTATUS status = NT_STATUS_OK;
 
-       status = unix_convert(ctx, conn, oldname_in, &smb_fname, 0);
-       if (!NT_STATUS_IS_OK(status)) {
-               goto out;
-       }
-
-       status = get_full_smb_filename(ctx, smb_fname, &oldname);
-       if (!NT_STATUS_IS_OK(status)) {
-               goto out;
-       }
-
-       status = check_name(conn, oldname);
-       if (!NT_STATUS_IS_OK(status)) {
-               goto out;
-       }
-
        /* source must already exist. */
-       if (!VALID_STAT(smb_fname->st)) {
-               status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
-               goto out;
-       }
-
-       status = unix_convert(ctx, conn, newname_in, &smb_fname_new, 0);
-       if (!NT_STATUS_IS_OK(status)) {
-               goto out;
-       }
-
-       status = get_full_smb_filename(ctx, smb_fname_new, &newname);
-       if (!NT_STATUS_IS_OK(status)) {
-               goto out;
-       }
-
-       status = check_name(conn, newname);
-       if (!NT_STATUS_IS_OK(status)) {
-               goto out;
+       if (!VALID_STAT(smb_fname_old->st)) {
+               return NT_STATUS_OBJECT_NAME_NOT_FOUND;
        }
 
        /* Disallow if newname already exists. */
        if (VALID_STAT(smb_fname_new->st)) {
-               status = NT_STATUS_OBJECT_NAME_COLLISION;
-               goto out;
+               return NT_STATUS_OBJECT_NAME_COLLISION;
        }
 
        /* No links from a directory. */
-       if (S_ISDIR(smb_fname->st.st_ex_mode)) {
-               status = NT_STATUS_FILE_IS_A_DIRECTORY;
-               goto out;
+       if (S_ISDIR(smb_fname_old->st.st_ex_mode)) {
+               return NT_STATUS_FILE_IS_A_DIRECTORY;
        }
 
-       /* Ensure this is within the share. */
-       status = check_reduced_name(conn, oldname);
+       status = get_full_smb_filename(ctx, smb_fname_new, &newname);
+       if (!NT_STATUS_IS_OK(status)) {
+               goto out;
+       }
+       status = get_full_smb_filename(ctx, smb_fname_old, &oldname);
        if (!NT_STATUS_IS_OK(status)) {
                goto out;
        }
@@ -4917,8 +4916,8 @@ NTSTATUS hardlink_internals(TALLOC_CTX *ctx,
                                 nt_errstr(status), newname, oldname));
        }
  out:
-       TALLOC_FREE(smb_fname);
-       TALLOC_FREE(smb_fname_new);
+       TALLOC_FREE(newname);
+       TALLOC_FREE(oldname);
        return status;
 }
 
@@ -5080,6 +5079,7 @@ static NTSTATUS smb_set_file_size(connection_struct *conn,
                                SMB_STRUCT_STAT *psbuf,
                                SMB_OFF_T size)
 {
+       struct smb_filename *smb_fname = NULL;
        NTSTATUS status = NT_STATUS_OK;
        files_struct *new_fsp = NULL;
 
@@ -5105,12 +5105,17 @@ static NTSTATUS smb_set_file_size(connection_struct *conn,
                return NT_STATUS_OK;
        }
 
+       status = create_synthetic_smb_fname_split(talloc_tos(), fname, psbuf,
+                                                 &smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
         status = SMB_VFS_CREATE_FILE(
                conn,                                   /* conn */
                req,                                    /* req */
                0,                                      /* root_dir_fid */
-               fname,                                  /* fname */
-               0,                                      /* create_file_flags */
+               smb_fname,                              /* fname */
                FILE_WRITE_ATTRIBUTES,                  /* access_mask */
                (FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
                    FILE_SHARE_DELETE),
@@ -5122,8 +5127,10 @@ static NTSTATUS smb_set_file_size(connection_struct *conn,
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &new_fsp,                               /* result */
-               NULL,                                   /* pinfo */
-               psbuf);                                 /* psbuf */
+               NULL);                                  /* pinfo */
+
+       *psbuf = smb_fname->st;
+       TALLOC_FREE(smb_fname);
 
        if (!NT_STATUS_IS_OK(status)) {
                /* NB. We check for open_was_deferred in the caller. */
@@ -5149,7 +5156,7 @@ static NTSTATUS smb_info_set_ea(connection_struct *conn,
                                const char *pdata,
                                int total_data,
                                files_struct *fsp,
-                               const char *fname)
+                               const struct smb_filename *smb_fname)
 {
        struct ea_list *ea_list = NULL;
        TALLOC_CTX *ctx = NULL;
@@ -5179,7 +5186,7 @@ static NTSTATUS smb_info_set_ea(connection_struct *conn,
        if (!ea_list) {
                return NT_STATUS_INVALID_PARAMETER;
        }
-       status = set_ea(conn, fsp, fname, ea_list);
+       status = set_ea(conn, fsp, smb_fname, ea_list);
 
        return status;
 }
@@ -5372,9 +5379,10 @@ static NTSTATUS smb_set_file_unix_link(connection_struct *conn,
 static NTSTATUS smb_set_file_unix_hlink(connection_struct *conn,
                                        struct smb_request *req,
                                        const char *pdata, int total_data,
-                                       const char *fname)
+                                       const struct smb_filename *smb_fname_new)
 {
        char *oldname = NULL;
+       struct smb_filename *smb_fname_old = NULL;
        TALLOC_CTX *ctx = talloc_tos();
        NTSTATUS status = NT_STATUS_OK;
 
@@ -5389,18 +5397,20 @@ static NTSTATUS smb_set_file_unix_hlink(connection_struct *conn,
                return status;
        }
 
-       status = resolve_dfspath(ctx, conn,
+       DEBUG(10,("smb_set_file_unix_hlink: SMB_SET_FILE_UNIX_LINK doing hard link %s -> %s\n",
+               smb_fname_str_dbg(smb_fname_new), oldname));
+
+       status = filename_convert(ctx,
+                               conn,
                                req->flags2 & FLAGS2_DFS_PATHNAMES,
                                oldname,
+                               &smb_fname_old,
                                &oldname);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
 
-       DEBUG(10,("smb_set_file_unix_hlink: SMB_SET_FILE_UNIX_LINK doing hard link %s -> %s\n",
-               fname, oldname));
-
-       return hardlink_internals(ctx, conn, oldname, fname);
+       return hardlink_internals(ctx, conn, smb_fname_old, smb_fname_new);
 }
 
 /****************************************************************************
@@ -5839,6 +5849,7 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn,
                                        const char *fname,
                                        SMB_STRUCT_STAT *psbuf)
 {
+       struct smb_filename *smb_fname = NULL;
        uint64_t allocation_size = 0;
        NTSTATUS status = NT_STATUS_OK;
        files_struct *new_fsp = NULL;
@@ -5890,12 +5901,17 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn,
 
        /* Pathname or stat or directory file. */
 
-       status = SMB_VFS_CREATE_FILE(
+       status = create_synthetic_smb_fname_split(talloc_tos(), fname, psbuf,
+                                                 &smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+        status = SMB_VFS_CREATE_FILE(
                conn,                                   /* conn */
                req,                                    /* req */
                0,                                      /* root_dir_fid */
-               fname,                                  /* fname */
-               0,                                      /* create_file_flags */
+               smb_fname,                              /* fname */
                FILE_WRITE_DATA,                        /* access_mask */
                (FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
                    FILE_SHARE_DELETE),
@@ -5907,8 +5923,10 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn,
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &new_fsp,                               /* result */
-               NULL,                                   /* pinfo */
-               psbuf);                                 /* psbuf */
+               NULL);                                  /* pinfo */
+
+       *psbuf = smb_fname->st;
+       TALLOC_FREE(smb_fname);
 
        if (!NT_STATUS_IS_OK(status)) {
                /* NB. We check for open_was_deferred in the caller. */
@@ -6051,7 +6069,7 @@ static NTSTATUS smb_unix_mknod(connection_struct *conn,
                TALLOC_FREE(parent);
        }
 
-       if (SMB_VFS_STAT(conn, fname, psbuf) != 0) {
+       if (vfs_stat_smb_fname(conn, fname, psbuf) != 0) {
                status = map_nt_error_from_unix(errno);
                SMB_VFS_UNLINK(conn,fname);
                return status;
@@ -6311,6 +6329,7 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn,
                                SMB_STRUCT_STAT *psbuf,
                                int *pdata_return_size)
 {
+       struct smb_filename *smb_fname;
        NTSTATUS status = NT_STATUS_OK;
        uint32 raw_unixmode = 0;
        uint32 mod_unixmode = 0;
@@ -6337,12 +6356,17 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn,
        DEBUG(10,("smb_posix_mkdir: file %s, mode 0%o\n",
                fname, (unsigned int)unixmode ));
 
-       status = SMB_VFS_CREATE_FILE(
+       status = create_synthetic_smb_fname_split(talloc_tos(), fname, psbuf,
+                                                 &smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+        status = SMB_VFS_CREATE_FILE(
                conn,                                   /* conn */
                req,                                    /* req */
                0,                                      /* root_dir_fid */
-               fname,                                  /* fname */
-               0,                                      /* create_file_flags */
+               smb_fname,                              /* fname */
                FILE_READ_ATTRIBUTES,                   /* access_mask */
                FILE_SHARE_NONE,                        /* share_access */
                FILE_CREATE,                            /* create_disposition*/
@@ -6353,8 +6377,10 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn,
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
-               &info,                                  /* pinfo */
-               psbuf);                                 /* psbuf */
+               &info);                                 /* pinfo */
+
+       *psbuf = smb_fname->st;
+       TALLOC_FREE(smb_fname);
 
         if (NT_STATUS_IS_OK(status)) {
                 close_file(req, fsp, NORMAL_CLOSE);
@@ -6414,6 +6440,7 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
                                SMB_STRUCT_STAT *psbuf,
                                int *pdata_return_size)
 {
+       struct smb_filename *smb_fname = NULL;
        bool extended_oplock_granted = False;
        char *pdata = *ppdata;
        uint32 flags = 0;
@@ -6513,12 +6540,17 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
                (unsigned int)wire_open_mode,
                (unsigned int)unixmode ));
 
+       status = create_synthetic_smb_fname_split(talloc_tos(), fname, psbuf,
+                                                 &smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
         status = SMB_VFS_CREATE_FILE(
                conn,                                   /* conn */
                req,                                    /* req */
                0,                                      /* root_dir_fid */
-               fname,                                  /* fname */
-               0,                                      /* create_file_flags */
+               smb_fname,                              /* fname */
                access_mask,                            /* access_mask */
                (FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
                    FILE_SHARE_DELETE),
@@ -6530,8 +6562,10 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
-               &info,                                  /* pinfo */
-               psbuf);                                 /* psbuf */
+               &info);                                 /* pinfo */
+
+       *psbuf = smb_fname->st;
+       TALLOC_FREE(smb_fname);
 
        if (!NT_STATUS_IS_OK(status)) {
                return status;
@@ -6611,6 +6645,7 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
                                const char *fname,
                                SMB_STRUCT_STAT *psbuf)
 {
+       struct smb_filename *smb_fname = NULL;
        NTSTATUS status = NT_STATUS_OK;
        files_struct *fsp = NULL;
        uint16 flags = 0;
@@ -6643,12 +6678,17 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
                create_options |= FILE_DIRECTORY_FILE;
        }
 
+       status = create_synthetic_smb_fname_split(talloc_tos(), fname, psbuf,
+                                                 &smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
         status = SMB_VFS_CREATE_FILE(
                conn,                                   /* conn */
                req,                                    /* req */
                0,                                      /* root_dir_fid */
-               fname,                                  /* fname */
-               0,                                      /* create_file_flags */
+               smb_fname,                              /* fname */
                DELETE_ACCESS,                          /* access_mask */
                (FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
                    FILE_SHARE_DELETE),
@@ -6660,8 +6700,10 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
-               &info,                                  /* pinfo */
-               psbuf);                                 /* psbuf */
+               &info);                                 /* pinfo */
+
+       *psbuf = smb_fname->st;
+       TALLOC_FREE(smb_fname);
 
        if (!NT_STATUS_IS_OK(status)) {
                return status;
@@ -6745,8 +6787,6 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                return;
        }
 
-       ZERO_STRUCT(sbuf);
-
        if (tran_call == TRANSACT2_SETFILEINFO) {
                if (total_params < 4) {
                        reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
@@ -6766,6 +6806,13 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                        return;
                }
 
+               status = create_synthetic_smb_fname_split(talloc_tos(), fname,
+                                                         NULL, &smb_fname);
+               if (!NT_STATUS_IS_OK(status)) {
+                       reply_nterror(req, status);
+                       return;
+               }
+
                if(fsp->is_directory || fsp->fh->fd == -1) {
                        /*
                         * This is actually a SETFILEINFO on a directory
@@ -6774,14 +6821,21 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                         */
                        if (INFO_LEVEL_IS_UNIX(info_level)) {
                                /* Always do lstat for UNIX calls. */
-                               if (SMB_VFS_LSTAT(conn,fname,&sbuf)) {
-                                       DEBUG(3,("call_trans2setfilepathinfo: SMB_VFS_LSTAT of %s failed (%s)\n",fname,strerror(errno)));
+                               if (SMB_VFS_LSTAT(conn, smb_fname)) {
+                                       DEBUG(3,("call_trans2setfilepathinfo: "
+                                                "SMB_VFS_LSTAT of %s failed "
+                                                "(%s)\n",
+                                                smb_fname_str_dbg(smb_fname),
+                                                strerror(errno)));
                                        reply_unixerror(req,ERRDOS,ERRbadpath);
                                        return;
                                }
                        } else {
-                               if (SMB_VFS_STAT(conn,fname,&sbuf) != 0) {
-                                       DEBUG(3,("call_trans2setfilepathinfo: fileinfo of %s failed (%s)\n",fname,strerror(errno)));
+                               if (SMB_VFS_STAT(conn, smb_fname) != 0) {
+                                       DEBUG(3,("call_trans2setfilepathinfo: "
+                                                "fileinfo of %s failed (%s)\n",
+                                                smb_fname_str_dbg(smb_fname),
+                                                strerror(errno)));
                                        reply_unixerror(req,ERRDOS,ERRbadpath);
                                        return;
                                }
@@ -6812,8 +6866,10 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                                return;
                        }
 
-                       if (SMB_VFS_FSTAT(fsp, &sbuf) != 0) {
-                               DEBUG(3,("call_trans2setfilepathinfo: fstat of fnum %d failed (%s)\n",fsp->fnum, strerror(errno)));
+                       if (SMB_VFS_FSTAT(fsp, &smb_fname->st) != 0) {
+                               DEBUG(3,("call_trans2setfilepathinfo: fstat "
+                                        "of fnum %d failed (%s)\n", fsp->fnum,
+                                        strerror(errno)));
                                reply_unixerror(req, ERRDOS, ERRbadfid);
                                return;
                        }
@@ -6834,9 +6890,10 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                        return;
                }
 
-               status = resolve_dfspath(ctx, conn,
+               status = filename_convert(ctx, conn,
                                         req->flags2 & FLAGS2_DFS_PATHNAMES,
                                         fname,
+                                        &smb_fname,
                                         &fname);
                if (!NT_STATUS_IS_OK(status)) {
                        if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
@@ -6849,41 +6906,28 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                        return;
                }
 
-               status = unix_convert(ctx, conn, fname, &smb_fname, 0);
-               if (!NT_STATUS_IS_OK(status)) {
-                       reply_nterror(req, status);
-                       return;
-               }
-               sbuf = smb_fname->st;
-
-               status = get_full_smb_filename(ctx, smb_fname, &fname);
-               TALLOC_FREE(smb_fname);
-               if (!NT_STATUS_IS_OK(status)) {
-                       reply_nterror(req, status);
-                       return;
-               }
-
-               status = check_name(conn, fname);
-               if (!NT_STATUS_IS_OK(status)) {
-                       reply_nterror(req, status);
-                       return;
-               }
-
                if (INFO_LEVEL_IS_UNIX(info_level)) {
                        /*
                         * For CIFS UNIX extensions the target name may not exist.
                         */
 
                        /* Always do lstat for UNIX calls. */
-                       SMB_VFS_LSTAT(conn,fname,&sbuf);
-
-               } else if (!VALID_STAT(sbuf) && SMB_VFS_STAT(conn,fname,&sbuf)) {
-                       DEBUG(3,("call_trans2setfilepathinfo: SMB_VFS_STAT of %s failed (%s)\n",fname,strerror(errno)));
+                       SMB_VFS_LSTAT(conn, smb_fname);
+
+               } else if (!VALID_STAT(smb_fname->st) &&
+                          SMB_VFS_STAT(conn, smb_fname)) {
+                       DEBUG(3,("call_trans2setfilepathinfo: SMB_VFS_STAT of "
+                                "%s failed (%s)\n",
+                                smb_fname_str_dbg(smb_fname),
+                                strerror(errno)));
                        reply_unixerror(req, ERRDOS, ERRbadpath);
                        return;
                }
        }
 
+       /* Set sbuf for use below. */
+       sbuf = smb_fname->st;
+
        if (INFO_LEVEL_IS_UNIX(info_level) && !lp_unix_extensions()) {
                reply_nterror(req, NT_STATUS_INVALID_LEVEL);
                return;
@@ -6930,7 +6974,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                                                pdata,
                                                total_data,
                                                fsp,
-                                               fname);
+                                               smb_fname);
                        break;
                }
 
@@ -7054,14 +7098,14 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
 
                case SMB_SET_FILE_UNIX_HLINK:
                {
-                       if (tran_call != TRANSACT2_SETPATHINFO) {
+                       if (tran_call != TRANSACT2_SETPATHINFO || smb_fname == NULL) {
                                /* We must have a pathname for this. */
                                reply_nterror(req, NT_STATUS_INVALID_LEVEL);
                                return;
                        }
                        status = smb_set_file_unix_hlink(conn, req,
                                                         pdata, total_data,
-                                                        fname);
+                                                        smb_fname);
                        break;
                }
 
@@ -7202,18 +7246,23 @@ static void call_trans2mkdir(connection_struct *conn, struct smb_request *req,
 
        DEBUG(3,("call_trans2mkdir : name = %s\n", directory));
 
-       status = unix_convert(ctx, conn, directory, &smb_dname, 0);
-       if (!NT_STATUS_IS_OK(status)) {
-               reply_nterror(req, status);
-               return;
-       }
+       status = filename_convert(ctx,
+                               conn,
+                               req->flags2 & FLAGS2_DFS_PATHNAMES,
+                               directory,
+                               &smb_dname,
+                               &directory);
 
-       status = check_name(conn, smb_dname->base_name);
        if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(5,("call_trans2mkdir error (%s)\n", nt_errstr(status)));
+               if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
+                       reply_botherror(req,
+                               NT_STATUS_PATH_NOT_COVERED,
+                               ERRSRV, ERRbadpath);
+                       return;
+               }
                reply_nterror(req, status);
-               goto out;
-       }
+               return;
+        }
 
        /* Any data in this call is an EA list. */
        if (total_data && (total_data != 4) && !lp_ea_support(SNUM(conn))) {
@@ -7261,7 +7310,7 @@ static void call_trans2mkdir(connection_struct *conn, struct smb_request *req,
 
        /* Try and set any given EA. */
        if (ea_list) {
-               status = set_ea(conn, NULL, smb_dname->base_name, ea_list);
+               status = set_ea(conn, NULL, smb_dname, ea_list);
                if (!NT_STATUS_IS_OK(status)) {
                        reply_nterror(req, status);
                        goto out;