Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com From: "Neil Erskine" To: Subject: Rationale for unlink algorithm in syscalls.cc. What is the race condition? Date: Sun, 6 May 2001 15:39:49 -0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit 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