From: Volker Lendecke Date: Wed, 14 Aug 2019 19:27:53 +0000 (+0200) Subject: smbd: Simplify has_other_nonposix_opens() X-Git-Tag: tdb-1.4.2~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d6f89c9883abaf7e9152887b7fa13449579c09c;p=thirdparty%2Fsamba.git smbd: Simplify has_other_nonposix_opens() 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 Reviewed-by: Ralph Böhme --- diff --git a/source3/smbd/close.c b/source3/smbd/close.c index b3fda4d9521..12d7f8c9a95 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -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; inum_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) { diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index ce49deafed3..607bd54dd79 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -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 */ diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index d268558cfb8..d054b111a90 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -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);