1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

smbd: Simplify copy_file()

The only two callers did not use "count" and "target_is_directory".

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2022-05-19 20:43:40 +02:00 committed by Jeremy Allison
parent 9bacf7529d
commit e7a60eb7c9
4 changed files with 12 additions and 47 deletions

View File

@ -4781,8 +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,
0, false);
OPENX_FILE_CREATE_IF_NOT_EXIST);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("%s: copy %s to %s failed: %s\n", __func__,
smb_fname_str_dbg(src_fname_tmp),

View File

@ -1461,8 +1461,7 @@ static WERROR move_driver_file_to_download_area(TALLOC_CTX *mem_ctx,
status = copy_file(mem_ctx, conn, smb_fname_old, smb_fname_new,
OPENX_FILE_EXISTS_TRUNCATE |
OPENX_FILE_CREATE_IF_NOT_EXIST,
0, false);
OPENX_FILE_CREATE_IF_NOT_EXIST);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("move_driver_file_to_download_area: Unable "

View File

@ -988,9 +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,
int count,
bool target_is_directory);
int ofun);
uint64_t get_lock_offset(const uint8_t *data, int data_offset,
bool large_file_format);

View File

@ -1836,9 +1836,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
connection_struct *conn,
struct smb_filename *smb_fname_src,
struct smb_filename *smb_fname_dst,
int ofun,
int count,
bool target_is_directory)
int ofun)
{
struct smb_filename *smb_fname_dst_tmp = NULL;
off_t ret=-1;
@ -1853,31 +1851,6 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
return NT_STATUS_NO_MEMORY;
}
/*
* If the target is a directory, extract the last component from the
* src filename and append it to the dst filename
*/
if (target_is_directory) {
const char *p;
/* dest/target can't be a stream if it's a directory. */
SMB_ASSERT(smb_fname_dst->stream_name == NULL);
p = strrchr_m(smb_fname_src->base_name,'/');
if (p) {
p++;
} else {
p = smb_fname_src->base_name;
}
smb_fname_dst_tmp->base_name =
talloc_asprintf_append(smb_fname_dst_tmp->base_name, "/%s",
p);
if (!smb_fname_dst_tmp->base_name) {
status = NT_STATUS_NO_MEMORY;
goto out;
}
}
status = vfs_file_exist(conn, smb_fname_src);
if (!NT_STATUS_IS_OK(status)) {
goto out;
@ -1888,18 +1861,14 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
goto out;
}
if (!target_is_directory && count) {
new_create_disposition = FILE_OPEN;
} else {
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;
}
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. */