This slightly simplifies the code path for all callers which assume
that a share mode exists already. Only the callers in open_file_ntcreate
and open_directory will ever create new share modes.
Signed-off-by: Jeremy Allison <jra@samba.org>
{
struct share_mode_lock *lck;
{
struct share_mode_lock *lck;
+ if ((servicepath == NULL) || (smb_fname == NULL) ||
+ (old_write_time == NULL)) {
+ return NULL;
+ }
+
lck = talloc_zero(mem_ctx, struct share_mode_lock);
if (lck == NULL) {
goto fail;
lck = talloc_zero(mem_ctx, struct share_mode_lock);
if (lck == NULL) {
goto fail;
-struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
- const struct file_id id,
- const char *servicepath,
- const struct smb_filename *smb_fname,
- const struct timespec *old_write_time)
+struct share_mode_lock *get_share_mode_lock_fresh(TALLOC_CTX *mem_ctx,
+ const struct file_id id,
+ const char *servicepath,
+ const struct smb_filename *smb_fname,
+ const struct timespec *old_write_time)
{
struct share_mode_lock *lck;
struct file_id tmp;
{
struct share_mode_lock *lck;
struct file_id tmp;
TALLOC_FREE(rec);
return NULL;
}
TALLOC_FREE(rec);
return NULL;
}
lck->id = id;
lck->record = talloc_move(lck, &rec);
talloc_set_destructor(lck, share_mode_lock_destructor);
lck->id = id;
lck->record = talloc_move(lck, &rec);
talloc_set_destructor(lck, share_mode_lock_destructor);
+struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
+ const struct file_id id)
+{
+ return get_share_mode_lock_fresh(mem_ctx, id, NULL, NULL, NULL);
+}
+
struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
const struct file_id id)
{
struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
const struct file_id id)
{
delete_on_close ? "Adding" : "Removing", fsp->fnum,
fsp_str_dbg(fsp)));
delete_on_close ? "Adding" : "Removing", fsp->fnum,
fsp_str_dbg(fsp)));
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
- NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id);
if (lck == NULL) {
return False;
}
if (lck == NULL) {
return False;
}
convert_timespec_to_time_t(write_time)),
file_id_string_tos(&fileid)));
convert_timespec_to_time_t(write_time)),
file_id_string_tos(&fileid)));
- lck = get_share_mode_lock(talloc_tos(), fileid, NULL, NULL, NULL);
+ lck = get_share_mode_lock(talloc_tos(), fileid);
if (lck == NULL) {
return False;
}
if (lck == NULL) {
return False;
}
convert_timespec_to_time_t(write_time)),
file_id_string_tos(&fileid)));
convert_timespec_to_time_t(write_time)),
file_id_string_tos(&fileid)));
- lck = get_share_mode_lock(talloc_tos(), fileid, NULL, NULL, NULL);
+ lck = get_share_mode_lock(talloc_tos(), fileid);
if (lck == NULL) {
return False;
}
if (lck == NULL) {
return False;
}
bool locking_end(void);
char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e);
struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
bool locking_end(void);
char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e);
struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
- const struct file_id id,
- const char *servicepath,
- const struct smb_filename *smb_fname,
- const struct timespec *old_write_time);
+ const struct file_id id);
+struct share_mode_lock *get_share_mode_lock_fresh(
+ TALLOC_CTX *mem_ctx,
+ const struct file_id id,
+ const char *servicepath,
+ const struct smb_filename *smb_fname,
+ const struct timespec *old_write_time);
struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
const struct file_id id);
bool rename_share_filename(struct messaging_context *msg_ctx,
struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
const struct file_id id);
bool rename_share_filename(struct messaging_context *msg_ctx,
* This prevents race conditions with the file being created. JRA.
*/
* This prevents race conditions with the file being created. JRA.
*/
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
- NULL);
-
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id);
if (lck == NULL) {
DEBUG(0, ("close_remove_share_mode: Could not get share mode "
"lock for file %s\n", fsp_str_dbg(fsp)));
if (lck == NULL) {
DEBUG(0, ("close_remove_share_mode: Could not get share mode "
"lock for file %s\n", fsp_str_dbg(fsp)));
* must update it in the open file db too. */
(void)set_write_time(fsp->file_id, fsp->close_write_time);
* must update it in the open file db too. */
(void)set_write_time(fsp->file_id, fsp->close_write_time);
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL, NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id);
if (lck) {
/* Close write times overwrite sticky write times
so we must replace any sticky write time here. */
if (lck) {
/* Close write times overwrite sticky write times
so we must replace any sticky write time here. */
* reference to a directory also.
*/
* reference to a directory also.
*/
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
- NULL);
-
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id);
if (lck == NULL) {
DEBUG(0, ("close_directory: Could not get share mode lock for "
"%s\n", fsp_str_dbg(fsp)));
if (lck == NULL) {
DEBUG(0, ("close_directory: Could not get share mode lock for "
"%s\n", fsp_str_dbg(fsp)));
void remove_deferred_open_entry(struct file_id id, uint64_t mid,
struct server_id pid)
{
void remove_deferred_open_entry(struct file_id id, uint64_t mid,
struct server_id pid)
{
- struct share_mode_lock *lck = get_share_mode_lock(talloc_tos(), id,
- NULL, NULL, NULL);
+ struct share_mode_lock *lck = get_share_mode_lock(talloc_tos(), id);
if (lck == NULL) {
DEBUG(0, ("could not get share mode lock\n"));
return;
if (lck == NULL) {
DEBUG(0, ("could not get share mode lock\n"));
return;
lock on the brlock database. */
}
lock on the brlock database. */
}
- *p_lck = get_share_mode_lock(mem_ctx,
- id,
- connectpath,
- smb_fname,
- p_old_write_time);
+ *p_lck = get_share_mode_lock_fresh(
+ mem_ctx, id, connectpath, smb_fname, p_old_write_time);
if (*p_lck == NULL) {
DEBUG(0, ("Could not get share mode lock\n"));
if (*p_lck == NULL) {
DEBUG(0, ("Could not get share mode lock\n"));
return NT_STATUS_ACCESS_DENIED;
}
return NT_STATUS_ACCESS_DENIED;
}
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id,
- conn->connectpath, smb_dname, &mtimespec);
+ lck = get_share_mode_lock_fresh(talloc_tos(), fsp->file_id,
+ conn->connectpath, smb_dname,
+ &mtimespec);
if (lck == NULL) {
DEBUG(0, ("open_directory: Could not get share mode lock for "
if (lck == NULL) {
DEBUG(0, ("open_directory: Could not get share mode lock for "
struct share_mode_lock *lck;
/* Remove the oplock flag from the sharemode. */
struct share_mode_lock *lck;
/* Remove the oplock flag from the sharemode. */
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
- NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id);
if (lck == NULL) {
DEBUG(0,("remove_oplock: failed to lock share entry for "
"file %s\n", fsp_str_dbg(fsp)));
if (lck == NULL) {
DEBUG(0,("remove_oplock: failed to lock share entry for "
"file %s\n", fsp_str_dbg(fsp)));
bool ret;
struct share_mode_lock *lck;
bool ret;
struct share_mode_lock *lck;
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
- NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id);
if (lck == NULL) {
DEBUG(0,("downgrade_oplock: failed to lock share entry for "
"file %s\n", fsp_str_dbg(fsp)));
if (lck == NULL) {
DEBUG(0,("downgrade_oplock: failed to lock share entry for "
"file %s\n", fsp_str_dbg(fsp)));
if (!LEVEL_II_OPLOCK_TYPE(fsp->oplock_type))
return;
if (!LEVEL_II_OPLOCK_TYPE(fsp->oplock_type))
return;
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
- NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id);
if (lck == NULL) {
DEBUG(0,("release_level_2_oplocks_on_change: failed to lock "
"share mode entry for file %s.\n", fsp_str_dbg(fsp)));
if (lck == NULL) {
DEBUG(0,("release_level_2_oplocks_on_change: failed to lock "
"share mode entry for file %s.\n", fsp_str_dbg(fsp)));
status = NT_STATUS_ACCESS_DENIED;
}
status = NT_STATUS_ACCESS_DENIED;
}
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
- NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id);
/*
* We have the file open ourselves, so not being able to get the
/*
* We have the file open ourselves, so not being able to get the
* non-POSIX opens return SHARING_VIOLATION.
*/
* non-POSIX opens return SHARING_VIOLATION.
*/
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
- NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id);
if (lck == NULL) {
DEBUG(0, ("smb_posix_unlink: Could not get share mode "
"lock for file %s\n", fsp_str_dbg(fsp)));
if (lck == NULL) {
DEBUG(0, ("smb_posix_unlink: Could not get share mode "
"lock for file %s\n", fsp_str_dbg(fsp)));