delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/07/02/16:36:52

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
X-Injected-Via-Gmane: http://gmane.org/
Path: not-for-mail
From: Joe Buehler <jbuehler AT hekimian DOT 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 DOT 50603 AT hekimian DOT com> <00d001c221fe$e5b242f0$0100a8c0 AT advent02> <3D220183 DOT 50700 AT hekimian DOT com> <018e01c22203$be757450$0100a8c0 AT advent02>
NNTP-Posting-Host: hekimian.com
Mime-Version: 1.0
X-Trace: main.gmane.org 1025642105 18582 206.205.138.10 (2 Jul 2002 20:35:05 GMT)
X-Complaints-To: usenet AT main DOT gmane DOT 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/

- Raw text -


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