Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com Date: Thu, 1 Jul 1999 23:20:49 -0400 From: Chris Faylor To: Corinna Vinschen Cc: DJ Delorie , cygwin-developers AT sourceware DOT cygnus DOT com Subject: Re: Change in errno.cc Message-ID: <19990701232049.A2754@cygnus.com> References: <199907011359 DOT JAA05833 AT indy DOT delorie DOT com> <377BE2F2 DOT 4688C54A AT vinschen DOT de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.3i In-Reply-To: <377BE2F2.4688C54A@vinschen.de>; from Corinna Vinschen on Thu, Jul 01, 1999 at 11:51:46PM +0200 I just checked in a patch that did things slightly differently. I changed stat_worker to tack on the .exe extension iff the previous operation failed due to a ERROR_FILE_NOT_FOUND and the file ddid not already contain an extension. I also restored the file to the "non .exe" state as Corrinna did below if GetFileAttributes Does this sound reasonable? -chris On Thu, Jul 01, 1999 at 11:51:46PM +0200, Corinna Vinschen wrote: >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 > > * 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); -- cgf AT cygnus DOT com http://www.cygnus.com/