From 137376391d5642c0a18ff70a5184dac4b402fa42 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 19 Oct 2012 10:58:47 +0200 Subject: [PATCH] s3:smbd/durable: update the low level write_time before disconnecting the file. If we close the low level FD, we should better update the write_time if needed. It's not unlikely that the client doesn't reclaim the durable handle, in that case we may not close the after the durable timeout. In such a case we should make sure that we at least update the write time on disconnect, this makes sure backup applications notice that the file was changed. metze Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam --- source3/smbd/durable.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index feec0dad6e3..f8e82c2a14a 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -187,6 +187,25 @@ NTSTATUS vfs_default_durable_disconnect(struct files_struct *fsp, */ lck = get_existing_share_mode_lock(talloc_tos(), fsp->file_id); if (lck != NULL) { + struct smb_file_time ft; + + ZERO_STRUCT(ft); + + if (fsp->write_time_forced) { + ft.mtime = lck->data->changed_write_time; + } else if (fsp->update_write_time_on_close) { + if (null_timespec(fsp->close_write_time)) { + ft.mtime = timespec_current(); + } else { + ft.mtime = fsp->close_write_time; + } + } + + if (!null_timespec(ft.mtime)) { + round_timespec(conn->ts_res, &ft.mtime); + file_ntimes(conn, fsp->fsp_name, &ft); + } + ok = mark_share_mode_disconnected(lck, fsp); if (!ok) { TALLOC_FREE(lck); -- 2.34.1