delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2001/07/26/11:16:57

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-developers-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-developers-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com
Date: Thu, 26 Jul 2001 11:16:49 -0400
From: Jason Tishler <jason AT tishler DOT net>
To: Cygwin-Developers <cygwin-developers AT sources DOT redhat DOT com>
Subject: Re: stat() whacks st_atime
Message-ID: <20010726111649.C439@dothill.com>
Mail-Followup-To: Cygwin-Developers <cygwin-developers AT sources DOT redhat DOT com>
Mime-Version: 1.0
In-Reply-To: <20010726104539.B16848@redhat.com>
User-Agent: Mutt/1.3.18i
Organization: Dot Hill Systems Corp.

--nhvSkicGhG8PpowP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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 DOT Tishler AT dothill DOT com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com

--nhvSkicGhG8PpowP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="wtest2.c"

#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);
}

--nhvSkicGhG8PpowP--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019