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 Message-ID: <377BE2F2.4688C54A@vinschen.de> Date: Thu, 01 Jul 1999 23:51:46 +0200 From: Corinna Vinschen X-Mailer: Mozilla 4.6 [en] (WinNT; I) X-Accept-Language: de,en MIME-Version: 1.0 To: DJ Delorie CC: cygwin-developers AT sourceware DOT cygnus DOT com, Chris Faylor Subject: Re: Change in errno.cc References: <199907011359 DOT JAA05833 AT indy DOT delorie DOT com> Content-Type: multipart/mixed; boundary="------------EA5175D8E21173BF9DADA63C" This is a multi-part message in MIME format. --------------EA5175D8E21173BF9DADA63C Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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. --------------EA5175D8E21173BF9DADA63C Content-Type: text/plain; charset=us-ascii; name="stat_worker-patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="stat_worker-patch" 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); --------------EA5175D8E21173BF9DADA63C--