s3:smbd/durable: update the low level write_time before disconnecting the file.
authorStefan Metzmacher <metze@samba.org>
Fri, 19 Oct 2012 08:58:47 +0000 (10:58 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 19 Oct 2012 13:21:10 +0000 (15:21 +0200)
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 <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source3/smbd/durable.c

index feec0dad6e381ee93e071f51726aa50ac2e4d68f..f8e82c2a14aaa5267d147ac5a35906d0f14df9f8 100644 (file)
@@ -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);