summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-12-16 21:04:19 +0000
committerJeremy Allison <jra@samba.org>2001-12-16 21:04:19 +0000
commit24053858543fa6c22c0c3222570109fbfdabab9e (patch)
treebe87c6c968515216b2c520509c4009a6d37e9ef5
parentad9a5a26e088f3fedce9562f688c518d610dbef2 (diff)
downloadsamba-24053858543fa6c22c0c3222570109fbfdabab9e.tar.gz
samba-24053858543fa6c22c0c3222570109fbfdabab9e.tar.xz
samba-24053858543fa6c22c0c3222570109fbfdabab9e.zip
Ensured filetimes set (by name) after close. Ignore errors. This is the
correct way to ensure times set in 'pending modtime' and 'time close' are always set correctly. Inspired by patch from Juergen Hasch. Jeremy.
-rw-r--r--source/smbd/close.c13
-rw-r--r--source/smbd/reply.c27
2 files changed, 24 insertions, 16 deletions
diff --git a/source/smbd/close.c b/source/smbd/close.c
index fae43fca5d3..879c91a81a4 100644
--- a/source/smbd/close.c
+++ b/source/smbd/close.c
@@ -119,6 +119,7 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
size_t share_entry_count = 0;
BOOL delete_on_close = False;
connection_struct *conn = fsp->conn;
+ time_t pending_modtime = fsp->pending_modtime;
int err = 0;
int err1 = 0;
@@ -196,14 +197,22 @@ with error %s\n", fsp->fsp_name, strerror(errno) ));
check_magic(fsp,conn);
}
+ /*
+ * Ensure pending modtime is set after close.
+ */
+
+ if(fsp->pending_modtime) {
+ int saved_errno = errno;
+ set_filetime(conn, fsp->fsp_name, fsp->pending_modtime);
+ errno = saved_errno;
+ }
DEBUG(2,("%s closed file %s (numopen=%d) %s\n",
conn->user,fsp->fsp_name,
conn->num_files_open, err ? strerror(err) : ""));
- if (fsp->fsp_name) {
+ if (fsp->fsp_name)
string_free(&fsp->fsp_name);
- }
file_free(fsp);
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index 675c06f75f2..00e0cb8b863 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -2242,21 +2242,10 @@ int reply_close(connection_struct *conn, char *inbuf,char *outbuf, int size,
* Close ordinary file.
*/
int close_err;
+ pstring file_name;
- /*
- * If there was a modify time outstanding,
- * try and set it here.
- */
- if(fsp->pending_modtime)
- set_filetime(conn, fsp->fsp_name, fsp->pending_modtime);
-
- /*
- * Now take care of any time sent in the close.
- */
- mtime = make_unix_date3(inbuf+smb_vwv1);
-
- /* try and set the date */
- set_filetime(conn, fsp->fsp_name,mtime);
+ /* Save the name for time set in close. */
+ pstrcpy( file_name, fsp->fsp_name);
DEBUG(3,("close fd=%d fnum=%d (numopen=%d)\n",
fsp->fd, fsp->fnum,
@@ -2273,6 +2262,16 @@ int reply_close(connection_struct *conn, char *inbuf,char *outbuf, int size,
END_PROFILE(SMBclose);
return (UNIXERROR(ERRHRD,ERRgeneral));
}
+
+ /*
+ * Now take care of any time sent in the close.
+ */
+
+ mtime = make_unix_date3(inbuf+smb_vwv1);
+
+ /* try and set the date */
+ set_filetime(conn, file_name, mtime);
+
}
/* We have a cached error */