Fixed NT modify timestamp issue.
authorJeremy Allison <jra@samba.org>
Tue, 17 Nov 1998 23:44:52 +0000 (23:44 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 17 Nov 1998 23:44:52 +0000 (23:44 +0000)
If a client does a modify timestamp on an open file (which will
do no good at all on UNIX :-) then keep the modify request pending
in the files_struct and apply it at close instead.
Jeremy.
(This used to be commit 92a7a86f0e0255e3812dd35bebfcd653091514ae)

source3/include/smb.h
source3/smbd/reply.c
source3/smbd/trans2.c

index 63aa7c098d2c6f7f3fb284661f2faf89a53bf663..47dde8c31f70ee3b3d7e9d8f7bbaf9e2906c681f 100644 (file)
@@ -623,6 +623,7 @@ typedef struct files_struct
        write_bmpx_struct *wbmpx_ptr;
        struct timeval open_time;
        int share_mode;
+       time_t pending_modtime;
        BOOL open;
        BOOL can_lock;
        BOOL can_read;
index 78a09e46e704c573239fc2fd1697d5a1bd712395..12bf098a94124287f8a043533ee21da2f747e46c 100644 (file)
@@ -2492,6 +2492,17 @@ int reply_close(connection_struct *conn,
                /*
                 * Close ordinary file.
                 */
+
+               /*
+                * 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 */
index f1d415e290ce53332a684748d2115bcc247cff07..81ba511c77d32b91d738c83518c19505a1f7b6c6 100644 (file)
@@ -1496,14 +1496,16 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
   char *fname;
   int fd = -1;
   BOOL bad_path = False;
+  files_struct *fsp = NULL;
 
   if (!CAN_WRITE(conn))
     return(ERROR(ERRSRV,ERRaccess));
 
   if (tran_call == TRANSACT2_SETFILEINFO) {
-    files_struct *fsp = file_fsp(params,0);
     info_level = SVAL(params,2);    
 
+    fsp = file_fsp(params,0);
+
     if(fsp && fsp->open && fsp->is_directory) {
       /*
        * This is actually a SETFILEINFO on a directory
@@ -1802,7 +1804,18 @@ dev = %x, inode = %.0f\n", iterate_fsp->fnum, (unsigned int)dev, (double)inode))
    */
   if (st.st_mtime != tvs.modtime || st.st_atime != tvs.actime)
   {
-    if(file_utime(conn, fname, &tvs)!=0)
+    if(fsp != NULL)
+    {
+      /*
+       * This was a setfileinfo on an open file.
+       * NT does this a lot. It's actually pointless
+       * setting the time here, as it will be overwritten
+       * on the next write, so we save the request
+       * away and will set it on file code. JRA.
+       */
+      fsp->pending_modtime = tvs.modtime;
+    }
+    else if(file_utime(conn, fname, &tvs)!=0)
     {
       return(UNIXERROR(ERRDOS,ERRnoaccess));
     }