diff options
author | Stefan Metzmacher <metze@samba.org> | 2008-03-12 15:39:38 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2008-04-07 12:29:26 +0200 |
commit | d03453864ab1bc5fd3b4a3abaf96176a006c102b (patch) | |
tree | 13389e06bd05336a1937b98d3e821ad995eef019 /source3/smbd/dosmode.c | |
parent | 2ccf50256e31bd7b9da0f7a7c223bebca5bca062 (diff) | |
download | samba-d03453864ab1bc5fd3b4a3abaf96176a006c102b.tar.gz samba-d03453864ab1bc5fd3b4a3abaf96176a006c102b.tar.bz2 samba-d03453864ab1bc5fd3b4a3abaf96176a006c102b.zip |
smbd: implement the strange write time update logic
We now never call file_ntimes() directly, every update
is done via smb_set_file_time().
This let samba3 pass the BASE-DELAYWRITE test.
The write time is only updated 2 seconds after the
first write() on any open handle to the current time
(not the time of the first write).
Each handle which had write requests updates the write
time to the current time on close().
If the write time is set explicit via setfileinfo or setpathinfo
the write time is visible directly and a following close
on the same handle doesn't update the write time.
metze
(This used to be commit 2eab212ea2e1bfd8fa716c2c89b2c042f7ba12ea)
Diffstat (limited to 'source3/smbd/dosmode.c')
-rw-r--r-- | source3/smbd/dosmode.c | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index a2e617c117..0ac3873275 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -571,6 +571,11 @@ int file_ntimes(connection_struct *conn, const char *fname, const struct timespe errno = 0; ZERO_STRUCT(sbuf); + DEBUG(6, ("file_ntime: actime: %s", + time_to_asc(convert_timespec_to_time_t(ts[0])))); + DEBUG(6, ("file_ntime: modtime: %s", + time_to_asc(convert_timespec_to_time_t(ts[1])))); + /* Don't update the time on read-only shares */ /* We need this as set_filetime (which can be called on close and other paths) can end up calling this function @@ -615,26 +620,35 @@ int file_ntimes(connection_struct *conn, const char *fname, const struct timespe Change a filetime - possibly allowing DOS semantics. *******************************************************************/ -bool set_filetime(connection_struct *conn, const char *fname, - const struct timespec mtime) +bool set_write_time_path(connection_struct *conn, const char *fname, + struct file_id fileid, const struct timespec mtime, + bool overwrite) { - struct timespec ts[2]; - if (null_timespec(mtime)) { - return(True); + return true; } - ts[1] = mtime; /* mtime. */ - ts[0] = ts[1]; /* atime. */ - - if (file_ntimes(conn, fname, ts)) { - DEBUG(4,("set_filetime(%s) failed: %s\n", - fname,strerror(errno))); - return False; + if (!set_write_time(fileid, mtime, overwrite)) { + return false; } - notify_fname(conn, NOTIFY_ACTION_MODIFIED, - FILE_NOTIFY_CHANGE_LAST_WRITE, fname); + /* in the overwrite case the caller should trigger the notify */ + if (!overwrite) { + notify_fname(conn, NOTIFY_ACTION_MODIFIED, + FILE_NOTIFY_CHANGE_LAST_WRITE, fname); + } return true; } + +bool set_write_time_fsp(struct files_struct *fsp, const struct timespec mtime, + bool overwrite) +{ + if (overwrite) { + fsp->write_time_forced = true; + TALLOC_FREE(fsp->update_write_time_event); + } + + return set_write_time_path(fsp->conn, fsp->fsp_name, fsp->file_id, + mtime, overwrite); +} |