The Win32 call SetFileTime() allows setting file access time, creation time, and modification time. Samba allows modification time to be changed, but not access time. If SetFileTime is used to set *only* the atime (passing NULL for the other times), then the atime is not set. If SetFileTime is used to set both atime and mtime, then the atime (and mtime) is set correctly but to the same value. This has been noted occasionally in the past: http://archive.netbsd.se/?ml=samba-technical&a=2004-09&m=365643 http://lists.samba.org/archive/samba-technical/2005-April/040308.html
Do you have a win32 test program I can use to ensure we do the correct thing here ? That would help before I apply either of these patches. Jeremy.
Something like this should do it. This creates a file "thefile.txt". If all is well SetFileTime-wise, the access time (and only the access time) of this file will be set to January 1, 2000. #include <windows.h> #include <stdio.h> int main(int argc,char *argv[]) { HANDLE handle; SYSTEMTIME stime={2000,1,0,1,12,0,0,0}; FILETIME ftime; if(SystemTimeToFileTime(&stime,&ftime)==0) { printf("Can't parse time\n"); exit(1); } handle=CreateFile("thefile.txt", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(handle==INVALID_HANDLE_VALUE) { printf("Can't create file\n"); exit(1); } if(SetFileTime(handle,NULL,&ftime,NULL)==0) { printf("Can't set atime\n"); exit(1); } CloseHandle(handle); return 0; }
works well for me with current samba versions. If you still see a problem with this, please reopen the bug.