SMB_COM_CLOSE and LastWriteTime

Jeff Layton jlayton at
Wed Apr 23 13:57:44 GMT 2008

I've had a couple of people open bugs complaining that "cp -p" to a
Linux CIFS mount of a Windows share doesn't properly preserve the
mtime. It appears that the system calls relating to the destination
file are something like:

write(), write(), ...

I wrote a small test program to see where it was falling down, and what
seems to happen is that the futimes() call sets the time properly on
the server but then the close() makes the server clobber the mtime.

On the wire, I can see a SET_PATH_INFO call that sets the mtime, and
then the client sends a close request with the last write time set to
0xffffffff. Wireshark interprets this as "no time specified".

After this Close request, the windows server (win2k3 in this case) sets
the mtime to the current time of the server. Interestingly samba seems
to handle this "correctly" and doesn't change the mtime on the close.

This really seems like a Windows bug IMO, but since windows is really
the reference implementation, perhaps CIFS is doing this wrong. Does
anyone have insight into what value we should be sending in the
LastWriteTime to tell windows not to touch the mtime? Or is there some
other way to make this happen?

Jeff Layton <jlayton at>

More information about the samba-technical mailing list