smbd: remove fsp->dirfsp
authorRalph Boehme <slow@samba.org>
Fri, 2 Oct 2020 14:51:16 +0000 (16:51 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 2 Oct 2020 19:39:44 +0000 (19:39 +0000)
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 <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/include/vfs.h
source3/lib/filename_util.c
source3/smbd/close.c
source3/smbd/durable.c
source3/smbd/open.c

index d527f8506283b59f221aa98ec7d81be502703eca..81e9a9f871627defb77bd7e229bb56a0bb8cdf97 100644 (file)
  * 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. */
index 84a248eb766a443ec593a2526debacc41a195c8e..fb79dab09bd7f9bc4eaabfc2363bcda22d369178 100644 (file)
@@ -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;
 }
 
index 9974877edc254463681d5771f725c006ef03e1cc..12735fc69dae83dd5a2d655a2c70c565c7e0ad4c 100644 (file)
@@ -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) {
index 8f3ad80389c2b34a625639511149c62aa94ea04a..e3334e15ae59992cc8fedbe4c0b204ca8668e615 100644 (file)
@@ -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);
index 35fda540b65a456f965f60409af954fcbde060fc..0686081b99303f1fbd38bfa81edae91822c838a1 100644 (file)
@@ -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