]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Simplify has_other_nonposix_opens()
authorVolker Lendecke <vl@samba.org>
Wed, 14 Aug 2019 19:27:53 +0000 (21:27 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 19 Aug 2019 23:14:38 +0000 (23:14 +0000)
We pick quite some information from "fsp" already, so from an API design
perspecitve it's only fair to only use its implicit server_id. This is
what all the callers did anyway.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
source3/smbd/close.c
source3/smbd/proto.h
source3/smbd/trans2.c

index b3fda4d9521126c7245a315c0feb41fb41d8f650..12d7f8c9a950851fa4b32be7ba69955d2aef97e8 100644 (file)
@@ -234,10 +234,10 @@ NTSTATUS delete_all_streams(connection_struct *conn,
 }
 
 bool has_other_nonposix_opens(struct share_mode_lock *lck,
-                             struct files_struct *fsp,
-                             struct server_id self)
+                             struct files_struct *fsp)
 {
        struct share_mode_data *data = lck->data;
+       struct server_id self = messaging_server_id(fsp->conn->sconn->msg_ctx);
        uint32_t i;
 
        for (i=0; i<data->num_share_modes; i++) {
@@ -274,7 +274,6 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
                                        enum file_close_type close_type)
 {
        connection_struct *conn = fsp->conn;
-       struct server_id self = messaging_server_id(conn->sconn->msg_ctx);
        bool delete_file = false;
        bool changed_user = false;
        struct share_mode_lock *lck = NULL;
@@ -353,7 +352,7 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
 
        delete_file = is_delete_on_close_set(lck, fsp->name_hash);
 
-       delete_file &= !has_other_nonposix_opens(lck, fsp, self);
+       delete_file &= !has_other_nonposix_opens(lck, fsp);
 
        /*
         * NT can set delete_on_close of the last open
@@ -1081,7 +1080,6 @@ static NTSTATUS rmdir_internals(TALLOC_CTX *ctx, files_struct *fsp)
 static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
                                enum file_close_type close_type)
 {
-       struct server_id self = messaging_server_id(fsp->conn->sconn->msg_ctx);
        struct share_mode_lock *lck = NULL;
        bool delete_dir = False;
        NTSTATUS status = NT_STATUS_OK;
@@ -1160,7 +1158,7 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
        delete_dir = get_delete_on_close_token(lck, fsp->name_hash,
                                        &del_nt_token, &del_token);
 
-       delete_dir &= !has_other_nonposix_opens(lck, fsp, self);
+       delete_dir &= !has_other_nonposix_opens(lck, fsp);
 
        if ((close_type == NORMAL_CLOSE || close_type == SHUTDOWN_CLOSE) &&
                                delete_dir) {
index ce49deafed3ca62c13d3f3ef8ab3e481615ae431..607bd54dd790676ec47db74175034da9191eaee8 100644 (file)
@@ -146,8 +146,7 @@ bool recursive_rmdir(TALLOC_CTX *ctx,
                     connection_struct *conn,
                     struct smb_filename *smb_dname);
 bool has_other_nonposix_opens(struct share_mode_lock *lck,
-                             struct files_struct *fsp,
-                             struct server_id self);
+                             struct files_struct *fsp);
 
 /* The following definitions come from smbd/conn.c  */
 
index d268558cfb8dde2d3a407533f676bc227778b515..d054b111a90a5c5842d91b8cd715dcd053b6adce 100644 (file)
@@ -8737,7 +8737,6 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
                                int total_data,
                                struct smb_filename *smb_fname)
 {
-       struct server_id self = messaging_server_id(conn->sconn->msg_ctx);
        NTSTATUS status = NT_STATUS_OK;
        files_struct *fsp = NULL;
        uint16_t flags = 0;
@@ -8808,7 +8807,7 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       other_nonposix_opens = has_other_nonposix_opens(lck, fsp, self);
+       other_nonposix_opens = has_other_nonposix_opens(lck, fsp);
        if (other_nonposix_opens) {
                /* Fail with sharing violation. */
                TALLOC_FREE(lck);