diff options
author | Stefan Metzmacher <metze@samba.org> | 2008-06-03 11:54:21 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2008-06-03 14:03:51 +0200 |
commit | 60759b64a7508b161de795e42c46c2bd62e0728a (patch) | |
tree | 69488073f7bd696d9bb94a3232831f5bfc915d8e | |
parent | d1bb49a2ab08f8f4eb27ae44bf04bc381faa85c1 (diff) | |
download | samba-60759b64a7508b161de795e42c46c2bd62e0728a.tar.gz samba-60759b64a7508b161de795e42c46c2bd62e0728a.tar.bz2 samba-60759b64a7508b161de795e42c46c2bd62e0728a.zip |
pvfs: correctly set the write time in the handle destructor
metze
(This used to be commit 58c118ab4d2b76c4ea68d79b711b81900634f767)
-rw-r--r-- | source4/ntvfs/posix/pvfs_open.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c index 94480df6b7..c7f93fb0d8 100644 --- a/source4/ntvfs/posix/pvfs_open.c +++ b/source4/ntvfs/posix/pvfs_open.c @@ -436,6 +436,9 @@ cleanup_delete: */ static int pvfs_handle_destructor(struct pvfs_file_handle *h) { + talloc_free(h->write_time.update_event); + h->write_time.update_event = NULL; + if ((h->create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) && h->name->stream_name) { NTSTATUS status; @@ -454,6 +457,14 @@ static int pvfs_handle_destructor(struct pvfs_file_handle *h) h->fd = -1; } + if (!h->write_time.update_forced && + h->write_time.update_on_close && + h->write_time.close_time == 0) { + struct timeval tv; + tv = timeval_current(); + h->write_time.close_time = timeval_to_nttime(&tv); + } + if (h->have_opendb_entry) { struct odb_lock *lck; NTSTATUS status; @@ -465,6 +476,26 @@ static int pvfs_handle_destructor(struct pvfs_file_handle *h) return 0; } + if (h->write_time.update_forced) { + status = odb_get_file_infos(h->pvfs->odb_context, + &h->odb_locking_key, + NULL, + &h->write_time.close_time); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("Unable get write time for '%s' - %s\n", + h->name->full_name, nt_errstr(status))); + } + + h->write_time.update_forced = false; + h->write_time.update_on_close = true; + } else if (h->write_time.update_on_close) { + status = odb_set_write_time(lck, h->write_time.close_time, true); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("Unable set write time for '%s' - %s\n", + h->name->full_name, nt_errstr(status))); + } + } + status = odb_close_file(lck, h, &delete_path); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("Unable to remove opendb entry for '%s' - %s\n", @@ -487,11 +518,26 @@ static int pvfs_handle_destructor(struct pvfs_file_handle *h) FILE_NOTIFY_CHANGE_FILE_NAME, delete_path); } + h->write_time.update_on_close = false; } talloc_free(lck); } + if (h->write_time.update_on_close) { + struct utimbuf unix_times; + + unix_times.actime = nt_time_to_unix(h->name->dos.access_time); + unix_times.modtime = nt_time_to_unix(h->write_time.close_time); + + if (unix_times.actime != 0 || unix_times.modtime != 0) { + if (utime(h->name->full_name, &unix_times) == -1) { + DEBUG(0,("pvfs_close: utime() failed '%s' - %s\n", + h->name->full_name, strerror(errno))); + } + } + } + return 0; } |