From: Volker Lendecke Date: Fri, 24 Jan 2025 11:58:22 +0000 (+0100) Subject: smbd: Remove vfs_file_exist() X-Git-Tag: tdb-1.4.13~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97d483f175cbd9da413c4d3bbae2a3a48aec8566;p=thirdparty%2Fsamba.git smbd: Remove vfs_file_exist() Both callers followed this with SMB_VFS_CREATE_FILE which can be given FILE_NON_DIRECTORY_FILE as an option to achieve the same. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 14a1e496c04..5b322c38baf 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -1090,13 +1090,6 @@ static uint32_t get_correct_cversion(const struct auth_session_info *session_inf goto error_exit; } - nt_status = vfs_file_exist(conn, smb_fname); - if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("get_correct_cversion: vfs_file_exist failed\n")); - *perr = WERR_FILE_NOT_FOUND; - goto error_exit; - } - nt_status = SMB_VFS_CREATE_FILE( conn, /* conn */ NULL, /* req */ @@ -1105,7 +1098,7 @@ static uint32_t get_correct_cversion(const struct auth_session_info *session_inf FILE_GENERIC_READ, /* access_mask */ FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */ FILE_OPEN, /* create_disposition*/ - 0, /* create_options */ + FILE_NON_DIRECTORY_FILE, /* create_options */ FILE_ATTRIBUTE_NORMAL, /* file_attributes */ INTERNAL_OPEN_ONLY, /* oplock_request */ NULL, /* lease */ diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 33bfd5b7ae4..f53b6a7bbfb 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1165,7 +1165,6 @@ void sys_utmp_yield(const char *username, const char *hostname, bool vfs_init_custom(connection_struct *conn, const char *vfs_object); bool smbd_vfs_init(connection_struct *conn); -NTSTATUS vfs_file_exist(connection_struct *conn, struct smb_filename *smb_fname); bool vfs_valid_pread_range(off_t offset, size_t length); bool vfs_valid_pwrite_range(const struct files_struct *fsp, off_t offset, diff --git a/source3/smbd/smb2_reply.c b/source3/smbd/smb2_reply.c index 693fad9bce6..794b5ddf66b 100644 --- a/source3/smbd/smb2_reply.c +++ b/source3/smbd/smb2_reply.c @@ -2004,11 +2004,6 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, return NT_STATUS_NO_MEMORY; } - status = vfs_file_exist(conn, smb_fname_src); - if (!NT_STATUS_IS_OK(status)) { - goto out; - } - status = openat_pathref_fsp(conn->cwd_fsp, smb_fname_src); if (!NT_STATUS_IS_OK(status)) { goto out; @@ -2023,7 +2018,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, FILE_GENERIC_READ, /* access_mask */ FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */ FILE_OPEN, /* create_disposition*/ - 0, /* create_options */ + FILE_NON_DIRECTORY_FILE, /* create_options */ FILE_ATTRIBUTE_NORMAL, /* file_attributes */ INTERNAL_OPEN_ONLY, /* oplock_request */ NULL, /* lease */ diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index a1d4e7707db..76895f52e03 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -403,21 +403,6 @@ bool smbd_vfs_init(connection_struct *conn) return True; } -/******************************************************************* - Check if a file exists in the vfs. -********************************************************************/ - -NTSTATUS vfs_file_exist(connection_struct *conn, struct smb_filename *smb_fname) -{ - /* Only return OK if stat was successful and S_ISREG */ - if ((SMB_VFS_STAT(conn, smb_fname) != -1) && - S_ISREG(smb_fname->st.st_ex_mode)) { - return NT_STATUS_OK; - } - - return NT_STATUS_OBJECT_NAME_NOT_FOUND; -} - bool vfs_valid_pread_range(off_t offset, size_t length) { return sys_valid_io_range(offset, length);