delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/05/06/14:43:33

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
From: "Neil Erskine" <neil DOT erskine AT jjmackay DOT ca>
To: <cygwin AT cygwin DOT com>
Subject: Rationale for unlink algorithm in syscalls.cc. What is the race condition?
Date: Sun, 6 May 2001 15:39:49 -0300
Message-ID: <CAEIIBEHOJELFDAHENHIAEIICDAA.neil.erskine@jjmackay.ca>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0)
Importance: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400

I am testing unlink for read-only files, which exhibits some problems.  The
algorithm used is peculiar (at least to my mind), and the only comments
present are cyptic references to known, but not described, bugs.

When attempting to unlink a file, syscalls.cc invokes the following
algorithm:

DeleteFile(name)

if DeleteFile didn't work,
   /* FIXME. There is a race here. */
   CreateFile(name, READONLY, EXISTINGONLY, DELETEONCLOSE)
   if CreateFile worked
      CloseFile
      if Os is NT or can't get file attributes
         if worked, return success
      end if
   end if

   chmod (name, full access rights)
   DeleteFile(name)
   if DeleteFile didn't work
       fail
   end if
end if

The comment about the race condition is in the code.
DeleteFile always fails for read-only files, but the CreateFile operation
succeeds or fails depending on the filesystem type.

Question 1: Why is the Create/Open sequence here at all?

Question 2: What is the race condition?

Question 3: Why does the Create fail on NTFS file systems for read only
files?

Question 4: What is the DELETE_ON_CLOSE flag for? The file is not deleted on
            Novell filesystems (where the Create succeeds).

Neil Erskine

voice 902 423 7727 ext. 230
fax 902 422 8108


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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