Samba 3.0.32 - file last write time

Dina Fine dina at exanet.com
Thu Sep 4 09:56:44 GMT 2008


Hello Jeremy 

Windows client doesn't update the file modification time on write
request if the file last write time was changed via SET_FILE_INFO.
I noticed that you handle this by setting the file mtime using the
pending mtime value on each write request (in real_write function)
But on empty write requests (offset = x, count  = 0) when only the file
size is allocated or shrunk, you don't do this (reply_write() in
reply.c)

So if the client opens a new file, sets the last write time (via
set_file_info request), then the first allocating write (offset = x,
count =0) will change the file mtime. In this case the findfirst on the
file will return the updated mtime and not the 'last write time'.

It seems that the following code (from real_write() function) should be
also called from write_reply when count = 0:

		if (!null_timespec(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 =
timespec_current();
			}
		}


Dina Fine
Software Engineer - Core Technologies
Exanet Ltd.



More information about the samba-technical mailing list