Note when we're setting change time, not write time, and send
authorJeremy Allison <jra@samba.org>
Wed, 31 Oct 2007 23:32:48 +0000 (16:32 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 31 Oct 2007 23:32:48 +0000 (16:32 -0700)
message accordingly. Apart from not supporting create time we
now pass the S4 RAW-NOTIFY torture.
Jeremy.

source/smbd/dosmode.c
source/smbd/fileio.c
source/smbd/trans2.c

index 18e6439be452f64e5c1f1577e735008dc94e33ab..8e3c9b4c91b20aed18ab375c643bf40471e23b37 100644 (file)
@@ -591,7 +591,7 @@ int file_ntimes(connection_struct *conn, const char *fname, const struct timespe
 
        return ret;
 }
 
        return ret;
 }
-  
+
 /*******************************************************************
  Change a filetime - possibly allowing DOS semantics.
 *******************************************************************/
 /*******************************************************************
  Change a filetime - possibly allowing DOS semantics.
 *******************************************************************/
@@ -609,12 +609,13 @@ bool set_filetime(connection_struct *conn, const char *fname,
        ts[0] = ts[1]; /* atime. */
 
        if (file_ntimes(conn, fname, ts)) {
        ts[0] = ts[1]; /* atime. */
 
        if (file_ntimes(conn, fname, ts)) {
-               DEBUG(4,("set_filetime(%s) failed: %s\n",fname,strerror(errno)));
+               DEBUG(4,("set_filetime(%s) failed: %s\n",
+                                       fname,strerror(errno)));
                return False;
        }
 
        notify_fname(conn, NOTIFY_ACTION_MODIFIED,
                return False;
        }
 
        notify_fname(conn, NOTIFY_ACTION_MODIFIED,
-                    FILE_NOTIFY_CHANGE_LAST_WRITE, fname);
-  
-       return True;
+               FILE_NOTIFY_CHANGE_LAST_WRITE, fname);
+
+       return true;
 }
 }
index 74f2c6774f9e04a298642d4425036d560e7268e1..8037510d8058b8240e5ac497b3beba6cbed83b51 100644 (file)
@@ -153,7 +153,8 @@ static ssize_t real_write_file(struct smb_request *req,
                 */
 
                if (!null_timespec(fsp->pending_modtime)) {
                 */
 
                if (!null_timespec(fsp->pending_modtime)) {
-                       set_filetime(fsp->conn, fsp->fsp_name, 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 we didn't get the "set modtime" call ourselves, we must
                           store the last write time to restore on close. JRA. */
index 58d44a856b566c48701b677503bd3853f13869e0..09a8fcc8767df9d64e44c975d0d0cf38d276922f 100644 (file)
@@ -4467,13 +4467,13 @@ static NTSTATUS smb_set_file_time(connection_struct *conn,
                                files_struct *fsp,
                                const char *fname,
                                const SMB_STRUCT_STAT *psbuf,
                                files_struct *fsp,
                                const char *fname,
                                const SMB_STRUCT_STAT *psbuf,
-                               struct timespec ts[2])
+                               struct timespec ts[2],
+                               bool setting_write_time)
 {
        uint32 action =
                FILE_NOTIFY_CHANGE_LAST_ACCESS
                |FILE_NOTIFY_CHANGE_LAST_WRITE;
 
 {
        uint32 action =
                FILE_NOTIFY_CHANGE_LAST_ACCESS
                |FILE_NOTIFY_CHANGE_LAST_WRITE;
 
-       
        if (!VALID_STAT(*psbuf)) {
                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
        }
        if (!VALID_STAT(*psbuf)) {
                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
        }
@@ -4489,6 +4489,11 @@ static NTSTATUS smb_set_file_time(connection_struct *conn,
                action &= ~FILE_NOTIFY_CHANGE_LAST_WRITE;
        }
 
                action &= ~FILE_NOTIFY_CHANGE_LAST_WRITE;
        }
 
+       if (!setting_write_time) {
+               /* ts[1] comes from change time, not write time. */
+               action &= ~FILE_NOTIFY_CHANGE_LAST_WRITE;
+       }
+
        DEBUG(6,("smb_set_file_time: actime: %s " , time_to_asc(convert_timespec_to_time_t(ts[0])) ));
        DEBUG(6,("smb_set_file_time: modtime: %s ", time_to_asc(convert_timespec_to_time_t(ts[1])) ));
 
        DEBUG(6,("smb_set_file_time: actime: %s " , time_to_asc(convert_timespec_to_time_t(ts[0])) ));
        DEBUG(6,("smb_set_file_time: modtime: %s ", time_to_asc(convert_timespec_to_time_t(ts[1])) ));
 
@@ -4528,9 +4533,8 @@ static NTSTATUS smb_set_file_time(connection_struct *conn,
        if(file_ntimes(conn, fname, ts)!=0) {
                return map_nt_error_from_unix(errno);
        }
        if(file_ntimes(conn, fname, ts)!=0) {
                return map_nt_error_from_unix(errno);
        }
-       if (action != 0) {
-               notify_fname(conn, NOTIFY_ACTION_MODIFIED, action, fname);
-       }
+       notify_fname(conn, NOTIFY_ACTION_MODIFIED, action, fname);
+
        return NT_STATUS_OK;
 }
 
        return NT_STATUS_OK;
 }
 
@@ -5226,7 +5230,8 @@ static NTSTATUS smb_set_info_standard(connection_struct *conn,
                                fsp,
                                fname,
                                psbuf,
                                fsp,
                                fname,
                                psbuf,
-                               ts);
+                               ts,
+                               true);
 }
 
 /****************************************************************************
 }
 
 /****************************************************************************
@@ -5246,6 +5251,7 @@ static NTSTATUS smb_set_file_basic_info(connection_struct *conn,
        uint32 dosmode = 0;
        struct timespec ts[2];
        NTSTATUS status = NT_STATUS_OK;
        uint32 dosmode = 0;
        struct timespec ts[2];
        NTSTATUS status = NT_STATUS_OK;
+       bool setting_write_time = true;
 
        if (total_data < 36) {
                return NT_STATUS_INVALID_PARAMETER;
 
        if (total_data < 36) {
                return NT_STATUS_INVALID_PARAMETER;
@@ -5278,7 +5284,12 @@ static NTSTATUS smb_set_file_basic_info(connection_struct *conn,
 
        /* Prefer a defined time to an undefined one. */
        if (null_timespec(ts[1])) {
 
        /* Prefer a defined time to an undefined one. */
        if (null_timespec(ts[1])) {
-               ts[1] = null_timespec(write_time) ? changed_time : write_time;
+               if (null_timespec(write_time)) {
+                       ts[1] = changed_time;
+                       setting_write_time = false;
+               } else {
+                       ts[1] = write_time;
+               }
        }
 
        DEBUG(10,("smb_set_file_basic_info: file %s\n",
        }
 
        DEBUG(10,("smb_set_file_basic_info: file %s\n",
@@ -5288,7 +5299,8 @@ static NTSTATUS smb_set_file_basic_info(connection_struct *conn,
                                fsp,
                                fname,
                                psbuf,
                                fsp,
                                fname,
                                psbuf,
-                               ts);
+                               ts,
+                               setting_write_time);
 }
 
 /****************************************************************************
 }
 
 /****************************************************************************
@@ -5349,7 +5361,8 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn,
                         * This is equivalent to a write. Ensure it's seen immediately
                         * if there are no pending writes.
                         */
                         * This is equivalent to a write. Ensure it's seen immediately
                         * if there are no pending writes.
                         */
-                       set_filetime(fsp->conn, fsp->fsp_name, timespec_current());
+                       set_filetime(fsp->conn, fsp->fsp_name,
+                                       timespec_current());
                }
                return NT_STATUS_OK;
        }
                }
                return NT_STATUS_OK;
        }
@@ -5682,7 +5695,8 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
                                fsp,
                                fname,
                                psbuf,
                                fsp,
                                fname,
                                psbuf,
-                               ts);
+                               ts,
+                               true);
 }
 
 /****************************************************************************
 }
 
 /****************************************************************************