www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/06/18/05:47:54

X-Authentication-Warning: acp3bf.physik.rwth-aachen.de: broeker owned process doing -bs
Date: Mon, 18 Jun 2001 11:47:42 +0200 (MET DST)
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
X-Sender: broeker AT acp3bf
To: djgpp-workers AT delorie DOT com
cc: Tim Van Holder <tim DOT van DOT holder AT pandora DOT be>
Subject: Re: Our unlink() isn't POSIX
In-Reply-To: <Pine.SUN.3.91.1010618095339.22931A@is>
Message-ID: <Pine.LNX.4.10.10106181138520.5716-100000@acp3bf>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Mon, 18 Jun 2001, Eli Zaretskii wrote:

> But I don't really understand what problem is this close-all code
> supposed to solve?  Could you elaborate on what does lclint do that
> forces you to use such techniques?

It's the old usual Unix technique for getting a 'safe' temporary file:
open() a file under /tmp or wherever, then immediately unlink() it. The
result is an open file handle the program can work with, which will
automatically be closed as the process ends, since that open handle is the
only reason for the OS not to have deleted the file, yet.

Since there is no other way left to access that file, in particular no
telltale directory entry below /tmp, both accidental and purposeful
attacks upon that temporary file are less likely to occur.  On Linux,
this not quite true any longer: you can `ls /proc/<PID>/fd' to get a list
of all file handles owned by an application, as pseudo-symlinks to their
numeric inode representation.

The whole idea is based upon Unix' way of decoupling a file's content
(essentially, the inode) from it's name entry in one or more directory
listings.  And upon the fact that there is a multi-processing-aware
filesystem layer in the OS, in the first place :-)

Within DOS philosophy, the rationale would be: there is only one app
active, and this app is supposed to *know* which files it has opened,
at any time, so it can easily avoid removing them accidentally.
-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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