This is the mail archive of the cygwin-developers@sourceware.cygnus.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: Change in errno.cc


DJ Delorie wrote:
> 
> ETXTBSY may only be returned if you're trying to run a program that's
> being written to, or write to a program that's currently running.
> 
> If two programs open a data file for exclusive writing, one of them
> should get EACCES.
> 
> Is this still the case after your patch is applied?

Hmm, it seems I misinterpreted something. Forget the patch. I hope,
the following is more devised.

The problem is the output of `ls -l' e.g. in the root directory of the
system drive:

  ls: pagefile.sys: No such file or directory

An strace shows the following:

  stat_worker calls real_path.file_attributes() which calls
  GetFileAttributesA(). This call fails with ERROR_ACCESS_DENIED.
  This would give a correct error message but unfortunately,
  stat_worker tries it again with an additional .exe suffix that
  isn't erased later, if the corresponding GetFileAttributesA() call
  returns -1. Whenever now fhandler_disk_file::fstat() is called,
  it tries to read a non existant file. The resulting error code is
  ERROR_FILE_NOT_FOUND :(

The following patch only resets the filename to the input filename,
if it was extended by the .exe suffix and the corresponding call to
GetFileAttributesA() returns -1 and GetLastError() returns
ERROR_FILE_NOT_FOUND.

Regards,
Corinna

ChangeLog:
==========

Thu Jul 1 23:47:00  Corinna Vinschen  <corinna@vinschen.de>

	* syscalls.cc (stat_worker): Reset the filename to the input
	filename, if it was extended by the .exe suffix and the
	corresponding call to GetFileAttributesA() returns -1 and
	GetLastError() returns ERROR_FILE_NOT_FOUND.
Index: syscalls.cc
===================================================================
RCS file: /src/cvsroot/winsup-990627/syscalls.cc,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 syscalls.cc
--- syscalls.cc	1999/06/28 09:00:09	1.1.1.1
+++ syscalls.cc	1999/07/01 21:38:14
@@ -917,6 +917,8 @@ stat_worker (const char *caller, const c
       debug_printf ("trying with .exe suffix");
       strcat (win32_name, ".exe");
       atts = GetFileAttributesA (win32_name);
+      if (atts == -1 && GetLastError () == ERROR_FILE_NOT_FOUND)
+        win32_name[strlen (win32_name) - 4] = '\0';
     }
 
   debug_printf ("%d = GetFileAttributesA (%s)", atts, win32_name);

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