]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: move calling fsp_set_gen_id() to fsp_bind_smb()
authorRalph Boehme <slow@samba.org>
Thu, 9 Oct 2025 13:17:38 +0000 (15:17 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 10 Oct 2025 10:40:30 +0000 (10:40 +0000)
No change in behaviour. fsp_set_gen_id() sets the primary key for the
share_mode_entry of the corresponding open file handle. None of the pathref fsp
needs that before being passed to SMB_VFS_CREATE_FILE().

As file_new() calls fsp_bind_smb(), all fsps will get an id when
create_file_unixpath() either calls file_new when creating files or it calls
fsp_bind_smb() when "converting" an pathref fsp that was passed into
SMB_VFS_CREATE_FILE() to an FSA fsp.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/smbd/files.c

index 334810e45f91279a600944cccfbb026d6933e8d1..779d1f3c611327dc8cf65f4077f2a5d51df3cf24 100644 (file)
@@ -112,6 +112,8 @@ NTSTATUS fsp_bind_smb(struct files_struct *fsp, struct smb_request *req)
        NTTIME now;
        NTSTATUS status;
 
+       fsp_set_gen_id(fsp);
+
        if (req == NULL) {
                DBG_DEBUG("INTERNAL_OPEN_ONLY, skipping smbXsrv_open\n");
                return NT_STATUS_OK;
@@ -160,8 +162,6 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
                return status;
        }
 
-       fsp_set_gen_id(fsp);
-
        /*
         * Create an smb_filename with "" for the base_name.  There are very
         * few NULL checks, so make sure it's initialized with something. to
@@ -422,7 +422,6 @@ static NTSTATUS openat_pathref_fullname(
        }
 
        GetTimeOfDay(&fsp->open_time);
-       fsp_set_gen_id(fsp);
        ZERO_STRUCT(conn->sconn->fsp_fi_cache);
 
        fsp->fsp_flags.is_pathref = true;
@@ -599,7 +598,6 @@ NTSTATUS open_rootdir_pathref_fsp(connection_struct *conn,
                goto fail;
        }
        GetTimeOfDay(&fsp->open_time);
-       fsp_set_gen_id(fsp);
        ZERO_STRUCT(conn->sconn->fsp_fi_cache);
        fsp->fsp_flags.is_pathref = true;
 
@@ -679,7 +677,6 @@ NTSTATUS open_stream_pathref_fsp(
        }
 
        GetTimeOfDay(&fsp->open_time);
-       fsp_set_gen_id(fsp);
        ZERO_STRUCT(conn->sconn->fsp_fi_cache);
 
        fsp->fsp_flags.is_pathref = true;
@@ -1079,7 +1076,6 @@ NTSTATUS openat_pathref_fsp_nosymlink(
        }
 
        GetTimeOfDay(&fsp->open_time);
-       fsp_set_gen_id(fsp);
        ZERO_STRUCT(conn->sconn->fsp_fi_cache);
 
        fsp->fsp_name = &full_fname;
@@ -1552,7 +1548,6 @@ NTSTATUS openat_pathref_fsp_lcomp(struct files_struct *dirfsp,
        }
 
        GetTimeOfDay(&fsp->open_time);
-       fsp_set_gen_id(fsp);
        ZERO_STRUCT(conn->sconn->fsp_fi_cache);
 
        fsp->fsp_flags.is_pathref = true;
@@ -1699,7 +1694,6 @@ NTSTATUS openat_pathref_fsp_dot(TALLOC_CTX *mem_ctx,
        }
 
        GetTimeOfDay(&fsp->open_time);
-       fsp_set_gen_id(fsp);
        ZERO_STRUCT(conn->sconn->fsp_fi_cache);
 
        fsp->fsp_flags.is_pathref = true;