From 1c444f9c37c01f986cbe880f0a6d4abdd8c34a0b Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 2 Oct 2020 16:51:16 +0200 Subject: [PATCH] smbd: remove fsp->dirfsp This was supposed to be a shortcut to avoid passing dirfsp around as an explicit function argument throughout the whole codebase when the new VFS design idea was based on using *AT functions throughout the VFS. Now that we've opted for basing the VFS on handles and *AT functions will only be used in a much more limitted extent, it makes sense to remove this internal dirfsp reference, otherwise the combination of internal fsp->dirfsp and smb_fname->fsp is going to be a tough to wrap your head around. Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- source3/include/vfs.h | 5 +++-- source3/lib/filename_util.c | 20 -------------------- source3/smbd/close.c | 12 ------------ source3/smbd/durable.c | 3 --- source3/smbd/open.c | 4 ---- 5 files changed, 3 insertions(+), 41 deletions(-) diff --git a/source3/include/vfs.h b/source3/include/vfs.h index d527f850628..81e9a9f8716 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -327,9 +327,11 @@ * Version 43 - SMB_VFS_READ_DFS_PATHAT() should take a non-const name. There's no easy way to return stat info for a DFS link otherwise. + * Change to Version 44 - will ship with 4.14. + * Version 44 - Remove dirfsp arg from struct files_struct */ -#define SMB_VFS_INTERFACE_VERSION 43 +#define SMB_VFS_INTERFACE_VERSION 44 /* All intercepted VFS operations must be declared as static functions inside module source @@ -384,7 +386,6 @@ typedef struct files_struct { struct smbXsrv_open *op; struct connection_struct *conn; struct fd_handle *fh; - struct files_struct *dirfsp; unsigned int num_smb_operations; struct file_id file_id; uint64_t initial_allocation_size; /* Faked up initial allocation on disk. */ diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c index 84a248eb766..fb79dab09bd 100644 --- a/source3/lib/filename_util.c +++ b/source3/lib/filename_util.c @@ -187,26 +187,6 @@ const char *fsp_str_dbg(const struct files_struct *fsp) return ""; } - if (fsp->dirfsp == NULL || fsp->dirfsp == fsp->conn->cwd_fsp) { - return name; - } - - if (ISDOT(fsp->dirfsp->fsp_name->base_name)) { - return name; - } - - name = smb_fname_str_dbg(fsp->fsp_name); - if (name == NULL) { - return ""; - } - - name = talloc_asprintf(talloc_tos(), - "%s/%s", - fsp->dirfsp->fsp_name->base_name, - name); - if (name == NULL) { - return ""; - } return name; } diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 9974877edc2..12735fc69da 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -1300,18 +1300,6 @@ NTSTATUS close_file(struct smb_request *req, files_struct *fsp, return NT_STATUS_OK; } - if (fsp->dirfsp != NULL && - fsp->dirfsp != fsp->conn->cwd_fsp) - { - status = fd_close(fsp->dirfsp); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - file_free(NULL, fsp->dirfsp); - fsp->dirfsp = NULL; - } - if (fsp->fsp_flags.is_directory) { status = close_directory(req, fsp, close_type); } else if (fsp->fake_file_handle != NULL) { diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index 8f3ad80389c..e3334e15ae5 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -761,9 +761,6 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, fsp->close_write_time = nt_time_to_full_timespec( cookie.close_write_time); - /* TODO: real dirfsp... */ - fsp->dirfsp = fsp->conn->cwd_fsp; - status = fsp_set_smb_fname(fsp, smb_fname); if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(lck); diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 35fda540b65..0686081b993 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -3380,8 +3380,6 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, bool setup_poll = false; bool ok; - SMB_ASSERT(fsp->dirfsp == conn->cwd_fsp); - if (conn->printer) { /* * Printers are handled completely differently. @@ -5647,8 +5645,6 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, goto fail; } - fsp->dirfsp = fsp->conn->cwd_fsp; - if (base_fsp) { /* * We're opening the stream element of a -- 2.34.1