diff options
author | Jeremy Allison <jra@samba.org> | 2005-03-10 21:43:58 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:55:58 -0500 |
commit | 95e68fa7f8c109204b3ddaeb530e192c71b40e58 (patch) | |
tree | cc0277ddadbfbb929bec2adc254554ca798cfa14 | |
parent | 82379c7bd1827601630da120f5b5ebb9061ce2b5 (diff) | |
download | samba-95e68fa7f8c109204b3ddaeb530e192c71b40e58.tar.gz samba-95e68fa7f8c109204b3ddaeb530e192c71b40e58.tar.bz2 samba-95e68fa7f8c109204b3ddaeb530e192c71b40e58.zip |
r5731: Get delayed write semantics closer to W2K3. We need to store 2 times.
This may fix bug #2382.
Jeremy.
(This used to be commit a27c351e6beafc6609790a9bb9a3d0a1331e8f35)
-rw-r--r-- | source3/include/smb.h | 2 | ||||
-rw-r--r-- | source3/smbd/close.c | 4 | ||||
-rw-r--r-- | source3/smbd/fileio.c | 6 | ||||
-rw-r--r-- | source3/smbd/files.c | 4 |
4 files changed, 15 insertions, 1 deletions
diff --git a/source3/include/smb.h b/source3/include/smb.h index 85a700fcc7..91ec52df23 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -404,7 +404,9 @@ typedef struct files_struct { struct timeval open_time; int share_mode; uint32 desired_access; + BOOL pending_modtime_owner; time_t pending_modtime; + time_t last_write_time; int oplock_type; int sent_oplock_break; unsigned long file_id; diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 4445f2516b..b3244432ff 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -260,8 +260,10 @@ with error %s\n", fsp->fsp_name, strerror(errno) )); * Ensure pending modtime is set after close. */ - if(fsp->pending_modtime) { + if(fsp->pending_modtime && fsp->pending_modtime_owner) { set_filetime(conn, fsp->fsp_name, fsp->pending_modtime); + } else if (fsp->last_write_time) { + set_filetime(conn, fsp->fsp_name, fsp->last_write_time); } DEBUG(2,("%s closed file %s (numopen=%d) %s\n", diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index a21bd69a36..3048c27fa2 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -142,6 +142,12 @@ static ssize_t real_write_file(files_struct *fsp,char *data,SMB_OFF_T pos, size_ if (fsp->pending_modtime) { set_filetime(fsp->conn, fsp->fsp_name, fsp->pending_modtime); + + /* If we didn't get the "set modtime" call ourselves, we must + store the last write time to restore on close. JRA. */ + if (!fsp->pending_modtime_owner) { + fsp->last_write_time = time(NULL); + } } /* Yes - this is correct - writes don't update this. JRA. */ diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 547206815e..143c119693 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -379,6 +379,7 @@ files_struct *file_find_print(void) /**************************************************************************** Set a pending modtime across all files with a given dev/ino pair. + Record the owner of that modtime. ****************************************************************************/ void fsp_set_pending_modtime(files_struct *tfsp, time_t pmod) @@ -394,8 +395,11 @@ void fsp_set_pending_modtime(files_struct *tfsp, time_t pmod) fsp->dev == tfsp->dev && fsp->inode == tfsp->inode ) { fsp->pending_modtime = pmod; + fsp->pending_modtime_owner = False; } } + + tfsp->pending_modtime_owner = True; } /**************************************************************************** |