]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Simplify copy_file()
authorVolker Lendecke <vl@samba.org>
Fri, 20 May 2022 06:06:28 +0000 (08:06 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 20 May 2022 19:02:37 +0000 (19:02 +0000)
Pass in new_create_disposition directly. We can also remove the
if-case (ofun & OPENX_FILE_EXISTS_OPEN) in copy_file, the two callers
don't use it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_fruit.c
source3/printing/nt_printing.c
source3/smbd/proto.h
source3/smbd/smb2_reply.c

index dba09cc462c697f87852fe413101927cfea5aec0..05ab8fcea69edb1078448e2d3c24b490cda76053 100644 (file)
@@ -4781,7 +4781,7 @@ static void fruit_offload_write_done(struct tevent_req *subreq)
                                   state->handle->conn,
                                   src_fname_tmp,
                                   dst_fname_tmp,
-                                  OPENX_FILE_CREATE_IF_NOT_EXIST);
+                                  FILE_CREATE);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(1, ("%s: copy %s to %s failed: %s\n", __func__,
                                  smb_fname_str_dbg(src_fname_tmp),
index 85517406852ee55c4602160636600cad52075bdf..0929e53243602509800c865efc78cb7939ec6d4e 100644 (file)
@@ -1460,8 +1460,7 @@ static WERROR move_driver_file_to_download_area(TALLOC_CTX *mem_ctx,
                          smb_fname_new->base_name));
 
                status = copy_file(mem_ctx, conn, smb_fname_old, smb_fname_new,
-                                  OPENX_FILE_EXISTS_TRUNCATE |
-                                  OPENX_FILE_CREATE_IF_NOT_EXIST);
+                                  FILE_OVERWRITE_IF);
 
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0,("move_driver_file_to_download_area: Unable "
index 28591a17e389dc8230e0b7bb9bd2d59a64ea6c31..9917562d1def05f21420ee1a4e2d57e648b64cb8 100644 (file)
@@ -988,7 +988,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
                        connection_struct *conn,
                        struct smb_filename *smb_fname_src,
                        struct smb_filename *smb_fname_dst,
-                       int ofun);
+                       uint32_t new_create_disposition);
 uint64_t get_lock_offset(const uint8_t *data, int data_offset,
                         bool large_file_format);
 
index 6c2876fa80f879ed2e0685aa88770c27b39e26f8..673c1e2216b70566a7321e0e0dfe73eb660866d1 100644 (file)
@@ -1836,13 +1836,12 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
                        connection_struct *conn,
                        struct smb_filename *smb_fname_src,
                        struct smb_filename *smb_fname_dst,
-                       int ofun)
+                       uint32_t new_create_disposition)
 {
        struct smb_filename *smb_fname_dst_tmp = NULL;
        off_t ret=-1;
        files_struct *fsp1,*fsp2;
        uint32_t dosattrs;
-       uint32_t new_create_disposition;
        NTSTATUS status;
 
 
@@ -1861,16 +1860,6 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
                goto out;
        }
 
-       if (!map_open_params_to_ntcreate(smb_fname_dst_tmp->base_name,
-                                        0, ofun,
-                                        NULL, NULL,
-                                        &new_create_disposition,
-                                        NULL,
-                                        NULL)) {
-               status = NT_STATUS_INVALID_PARAMETER;
-               goto out;
-       }
-
        /* Open the src file for reading. */
        status = SMB_VFS_CREATE_FILE(
                conn,                                   /* conn */
@@ -1935,18 +1924,6 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
                goto out;
        }
 
-       if (ofun & OPENX_FILE_EXISTS_OPEN) {
-               ret = SMB_VFS_LSEEK(fsp2, 0, SEEK_END);
-               if (ret == -1) {
-                       DEBUG(0, ("error - vfs lseek returned error %s\n",
-                               strerror(errno)));
-                       status = map_nt_error_from_unix(errno);
-                       close_file_free(NULL, &fsp1, ERROR_CLOSE);
-                       close_file_free(NULL, &fsp2, ERROR_CLOSE);
-                       goto out;
-               }
-       }
-
        /* Do the actual copy. */
        if (smb_fname_src->st.st_ex_size) {
                ret = vfs_transfer_file(fsp1, fsp2, smb_fname_src->st.st_ex_size);