franzinc / nfs

Allegro NFS Server for Microsoft Windows, written in Common Lisp
http://www.nfsforwindows.com
Other
46 stars 12 forks source link

Fixing time read/write in `nfsd-getattr` and `nfsd-setattr` #3

Closed john-peterson closed 12 years ago

john-peterson commented 12 years ago
Patch

0003-stat.utime.wrong.time.patch

Discussion

Calling _wstat64 from nfs.exe returns an atime, mtime and ctime that is 3600 into the future compared to the value presented in explorer.exe and the value returned by _wstat64 called from a VC++ program (all in the same Windows environment).

This VC++ code

#include <windows.h>
#include <string>
#include <iostream>
using namespace std;
int main() {
    struct _stat64 stbuf;
    wstring file = L"file";
    _wstat64(file.c_str(), &stbuf);
    cout << stbuf.st_ctime << " " << stbuf.st_atime << " " << stbuf.st_mtime;
    // 1337555068 1337560750 1337560750
    return 0;
}

return a different value than this code placed in unicode-file.cl:unicode-stat

(logit "~%~d ~d ~d~%" (slot 'ctime :low) (slot 'atime :low) (slot 'mtime :low))
; 1337558668 1337564350 1337564350

that can also be retrieved by the bash command

stat 'file' -c "%W %X %Y"
#0 1337564350 1337564350

on the NFS mount. The output from the command is given in the commented line. The 3600 difference is the same regardless of the Windows time setting. (The file system saves the UTC on which _stat64 add a timezone and DST offset from the Windows settings.)

Files less than 3600 old will therefore have a time in the future which cause problems in some programs. For example make will output "make: warning: Clock skew detected" when it comes across such files.

Calling _wutime (and _futime) from nfs.exe also results in an incorrect value, it writes an UTC that is 3600 in the past.

Having some files 3600 too old cause problems when files are compared, for example the automake mtime comparison between Makefile and config.status

Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
    @case '$?' in \
      *config.status*) \

can fail and run config.status in an endless loop.

(Please keep me as commit author when applying the patch (apply with git am) so that the commit is tracked for my Ohloh account.)

Environment

nfs.exe compiled and run on

Windows 7 x64
Allegro CL 8.2 Express
john-peterson commented 12 years ago

Closing the issue because I can't reproduce this anymore.