Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
To: cygwin@cygwin.com
X-Injected-Via-Gmane: http://gmane.org/
Path: not-for-mail
From: Joe Buehler <jbuehler@hekimian.com>
Newsgroups: gmane.os.cygwin
Subject: Re: infinite loop in rm -fr (revisited)
Date: Tue, 02 Jul 2002 16:35:36 -0400
Lines: 32
Message-ID: <3D220E98.2060209@hekimian.com>
References: <3D21F96C.50603@hekimian.com> <00d001c221fe$e5b242f0$0100a8c0@advent02> <3D220183.50700@hekimian.com> <018e01c22203$be757450$0100a8c0@advent02>
NNTP-Posting-Host: hekimian.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: main.gmane.org 1025642105 18582 206.205.138.10 (2 Jul 2002 20:35:05 GMT)
X-Complaints-To: usenet@main.gmane.org
NNTP-Posting-Date: Tue, 2 Jul 2002 20:35:05 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.0) Gecko/20020530
X-Accept-Language: en-us, en

Chris January wrote:

> Possible solutions:
> 1. rename the original file in the directory with a 'special name'.
> e.g.
> if deleting file1 and file1 is in use, rename to ...---file1---....
> Files matching this pattern would not be returned by readdir.
> 2. rename the original file to a special 'holding' directory for pending
> deleted files.
> 3. in file access routines, pretend a file does not exist if it is present
> in delqueue. (e.g. check could be added to path_conv::check). Doesn't cope
> with another file being created with the same name.
> 
> None of the above are ideal.

1 and 3 would fix some things, but it looks to me like #2 is the best,
because the file is really deleted, as far as its former directory
is concerned.  So you don't have problems with Windows locking the directory
down.

But then there is the problem of under what conditions Windows will let
you rename the file.  I ran a test, and, curiously, the following script
works, even though the "info" file is open when "mv" executes.

#!/bin/bash
trap "cd /; rm -fr /tmp/xxx.dir" 0
mkdir /tmp/xxx.dir
exec >/tmp/xxx.dir/info
mv /tmp/xxx.dir/info /tmp/info

Joe Buehler




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

