delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1999/07/01/19:31:10

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 <corinna AT vinschen DOT de>
X-Mailer: Mozilla 4.6 [en] (WinNT; I)
X-Accept-Language: de,en
MIME-Version: 1.0
To: DJ Delorie <dj AT delorie DOT com>
CC: cygwin-developers AT sourceware DOT cygnus DOT com, Chris Faylor <cgf AT cygnus DOT com>
Subject: Re: Change in errno.cc
References: <199907011359 DOT JAA05833 AT indy DOT delorie DOT com>

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  <corinna AT vinschen DOT 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.
--------------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--



- Raw text -


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