This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: stat() whacks st_atime


Chris,

On Thu, Jul 26, 2001 at 10:45:39AM -0400, Christopher Faylor wrote:
> I suspect that a simple test case would help unperplex you.

I did write many simple test cases before bothering the list.  Attached
is, wtest2, one that mimics fstat()'s behavior (with regard to the
Win32 calls).  I also stole the the values passed to CreateFile() from
an strace run of stest (just in case how the file was opened caused
the problem).  For some reason, wtest2 does not affect atime.  Hence,
if CloseHandle() is indeed the culprit, then it isn't one all of the
time.

If you have any hints for a simple test case that would illuminate me,
it would be much appreciated.

> I also suspect that CloseHandle is updating the atime.

That was my "conclusion" too from stepping via gdb -- but, I found it
hard to believe.  I searched the MSDN and google for MS atime issues
but came up empty.

Nevertheless, isn't the the bigger issue about how Cygwin should deal with
this problem?  If Cygwin's stat() affects st_atime (even indirectly),
then this is going to break Unix apps.  I have already found one (i.e.,
mutt), there are bound to be others.

Thanks,
Jason

-- 
Jason Tishler
Director, Software Engineering       Phone: 732.264.8770 x235
Dot Hill Systems Corp.               Fax:   732.264.8798
82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com
#include <windows.h>

int
main(int argc, char* argv[])
{
	HANDLE h;
	BY_HANDLE_FILE_INFORMATION info;
	BOOL s;
	SECURITY_ATTRIBUTES sec_none;

	sec_none.nLength = sizeof (SECURITY_ATTRIBUTES);
	sec_none.bInheritHandle = TRUE;
	sec_none.lpSecurityDescriptor = NULL;

	h = CreateFile(
		argv[1],
		0x80000000,
		0x7,
		&sec_none,
		0x3,
		0x2000080,
		0);
	if (h == INVALID_HANDLE_VALUE)
	{
		printf("CreateFile() failed with error = %ld\n", GetLastError());
		exit(1);
	}

	s = GetFileInformationByHandle(h, &info);
	if (!s)
	{
		printf("GetFileInformationByHandle() failed with error = %ld\n", GetLastError());
		exit(2);
	}

	printf("dwLowDateTime = %lu\n", info.ftLastAccessTime.dwLowDateTime);
	printf("dwHighDateTime = %lu\n", info.ftLastAccessTime.dwHighDateTime);

	CloseHandle(h);
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]