mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
locking: combine get_delete_on_close_flag() and get_write_time() into get_file_infos()
This means we need to fetch the record only once. metze
This commit is contained in:
parent
5df3463431
commit
4130b87329
@ -940,37 +940,40 @@ bool rename_share_filename(struct messaging_context *msg_ctx,
|
||||
return True;
|
||||
}
|
||||
|
||||
struct timespec get_write_time(struct file_id id)
|
||||
void get_file_infos(struct file_id id,
|
||||
bool *delete_on_close,
|
||||
struct timespec *write_time)
|
||||
{
|
||||
struct timespec result;
|
||||
struct share_mode_lock *lck;
|
||||
|
||||
ZERO_STRUCT(result);
|
||||
if (delete_on_close) {
|
||||
*delete_on_close = false;
|
||||
}
|
||||
|
||||
if (write_time) {
|
||||
ZERO_STRUCTP(write_time);
|
||||
}
|
||||
|
||||
if (!(lck = fetch_share_mode_unlocked(talloc_tos(), id, NULL, NULL))) {
|
||||
return result;
|
||||
return;
|
||||
}
|
||||
result = lck->changed_write_time;
|
||||
|
||||
if (null_timespec(result)) {
|
||||
result = lck->old_write_time;
|
||||
if (delete_on_close) {
|
||||
*delete_on_close = lck->delete_on_close;
|
||||
}
|
||||
|
||||
if (write_time) {
|
||||
struct timespec wt;
|
||||
|
||||
wt = lck->changed_write_time;
|
||||
if (null_timespec(wt)) {
|
||||
wt = lck->old_write_time;
|
||||
}
|
||||
|
||||
*write_time = wt;
|
||||
}
|
||||
|
||||
TALLOC_FREE(lck);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool get_delete_on_close_flag(struct file_id id)
|
||||
{
|
||||
bool result;
|
||||
struct share_mode_lock *lck;
|
||||
|
||||
if (!(lck = fetch_share_mode_unlocked(talloc_tos(), id, NULL, NULL))) {
|
||||
return False;
|
||||
}
|
||||
result = lck->delete_on_close;
|
||||
TALLOC_FREE(lck);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool is_valid_share_mode_entry(const struct share_mode_entry *e)
|
||||
|
@ -886,7 +886,7 @@ bool get_dir_entry(TALLOC_CTX *ctx,
|
||||
*date = sbuf.st_mtime;
|
||||
|
||||
fileid = vfs_file_id_from_sbuf(conn, &sbuf);
|
||||
write_time_ts = get_write_time(fileid);
|
||||
get_file_infos(fileid, NULL, &write_time_ts);
|
||||
if (!null_timespec(write_time_ts)) {
|
||||
*date = convert_timespec_to_time_t(write_time_ts);
|
||||
}
|
||||
|
@ -611,11 +611,19 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
|
||||
} /* end else */
|
||||
|
||||
#ifdef DEVELOPER
|
||||
if (VALID_STAT(st) &&
|
||||
get_delete_on_close_flag(vfs_file_id_from_sbuf(conn,
|
||||
&st))) {
|
||||
result = NT_STATUS_DELETE_PENDING;
|
||||
goto fail;
|
||||
/*
|
||||
* This sucks!
|
||||
* We should never provide different behaviors
|
||||
* depending on DEVELOPER!!!
|
||||
*/
|
||||
if (VALID_STAT(st)) {
|
||||
bool delete_pending;
|
||||
get_file_infos(vfs_file_id_from_sbuf(conn, &st),
|
||||
&delete_pending, NULL);
|
||||
if (delete_pending) {
|
||||
result = NT_STATUS_DELETE_PENDING;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1398,8 +1398,8 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
|
||||
adate_ts = get_atimespec(&sbuf);
|
||||
create_date_ts = get_create_timespec(&sbuf,lp_fake_dir_create_times(SNUM(conn)));
|
||||
|
||||
write_time_ts = get_write_time(
|
||||
vfs_file_id_from_sbuf(conn, &sbuf));
|
||||
get_file_infos(vfs_file_id_from_sbuf(conn, &sbuf),
|
||||
NULL, &write_time_ts);
|
||||
if (!null_timespec(write_time_ts)) {
|
||||
mdate_ts = write_time_ts;
|
||||
}
|
||||
@ -3870,8 +3870,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
|
||||
}
|
||||
|
||||
fileid = vfs_file_id_from_sbuf(conn, &sbuf);
|
||||
delete_pending = get_delete_on_close_flag(fileid);
|
||||
write_time_ts = get_write_time(fileid);
|
||||
get_file_infos(fileid, &delete_pending, &write_time_ts);
|
||||
} else {
|
||||
/*
|
||||
* Original code - this is an open file.
|
||||
@ -3887,8 +3886,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
|
||||
}
|
||||
pos = fsp->fh->position_information;
|
||||
fileid = vfs_file_id_from_sbuf(conn, &sbuf);
|
||||
delete_pending = get_delete_on_close_flag(fileid);
|
||||
write_time_ts = get_write_time(fileid);
|
||||
get_file_infos(fileid, &delete_pending, &write_time_ts);
|
||||
access_mask = fsp->access_mask;
|
||||
}
|
||||
|
||||
@ -3959,12 +3957,11 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
|
||||
}
|
||||
|
||||
fileid = vfs_file_id_from_sbuf(conn, &sbuf);
|
||||
delete_pending = get_delete_on_close_flag(fileid);
|
||||
get_file_infos(fileid, &delete_pending, &write_time_ts);
|
||||
if (delete_pending) {
|
||||
reply_nterror(req, NT_STATUS_DELETE_PENDING);
|
||||
return;
|
||||
}
|
||||
write_time_ts = get_write_time(fileid);
|
||||
}
|
||||
|
||||
if (INFO_LEVEL_IS_UNIX(info_level) && !lp_unix_extensions()) {
|
||||
|
Loading…
Reference in New Issue
Block a user