From 851cadba51b00b326c5f040f23f95932aec53105 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 1 Apr 2008 11:40:23 +0200 Subject: 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 used to be commit 4130b873291d39e363184fe4e38dc1f24ebe5056) --- source3/smbd/dir.c | 2 +- source3/smbd/filename.c | 18 +++++++++++++----- source3/smbd/trans2.c | 13 +++++-------- 3 files changed, 19 insertions(+), 14 deletions(-) (limited to 'source3/smbd') diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 8531d6250d..5fc2e3719e 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -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); } diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 10e9583049..4323e843d2 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -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 diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 06bb31622f..9e56434d5c 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -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()) { -- cgit