Subject: Re: FS clean bit, is it reliable?
To: None <current-users@NetBSD.ORG>
From: 51482) <email@example.com (Raymond A. Wiker>
Date: 11/05/1995 13:24:22
Trevin Beattie writes:
> At 04:49 pm 11/4/95 +0100, you wrote:
> > How about simply changing the semantics of install so that,
> >when it copies a file, it first unlinks the existing file? I have been
> >bitten a few times when installing software over a version that is in
> >use (SunOS, if that matters).
> Actually, a un*x system won't allow a file to be removed if the file is in
> use when all links have been deleted. This is proper POSIX behavior. From
> the POSIX Programmer's Guide (Donald Lewine; O'Reilly & Associates, Inc.):
> The unlink() function removes the link named by _path_
> and decrements the link count of the file referenced by
> the link. When the link count goes to zero and no
> process has the file open, the space occupied by the
> file is freed and the file is no longer accessible.
I knew that! The idea was simply that by unlinking the file
first, it would then be safe to write the new file contents (as you
would be sure to get a fresh inode). Applications using the original
file contents would have references to the original inode, and the
inode kept around until the applications closed the file.
With SunOS, at least, it is quite possible to crash an
application by installing a new version - it seems that the executable
is used for swapping. I don't know if NetBSD has the same problem...