Article View: comp.bugs.sys5
Article #888ln(1) and System V
From: David Harrison
Date: Mon, 31 Oct 1988 19:17
Date: Mon, 31 Oct 1988 19:17
44 lines
2710 bytes
2710 bytes
Recently Geoff Collyer (utstat!geoff) has pointed out that under System
V the command:
ln old new
will destroy "new" if it already exists. Historically and under other
UNIX versions the same command will complain and refuse to make the link.
Geoff calls the System V behaviour "an unintuitive shock". It certainly
breaks any program that relies on `ln' refusing to link to "new" as a way
of doing locks (including parts of Cnews).
There certainly are lock problems under SV: the print spooler will
croak if it is fed a large number of jobs nearly simultaneously; a
number of users changing their passwords nearly simultaneously can
leave you without an /etc/passwd file; etc. Both of these have happened
to me and the fix I use is to write a SV IPC onionskin around these
commands with semaphores to implement real kernel-level locks.
I have some questions and one comment on this situation.
First the questions: if one re-writes ln (as Geoff has done) to
reproduce the old behaviour and replaces the SV `ln' in /bin
with this version what will break? People have been using the
old `ln' behaviour for some years, but are people now relying on
the new behaviour too? If so, how? Will implementing such a change
make passwd and lp more reliable with lots of users? What does
POSIX say?
Finally the comment: if one adheres to traditional UNIX philosophy
the System V `ln' is correct. It now behaves just like its cousins
`cp' and `mv': tell it to do something and it will. If one wishes
to test for the existence of file "new" this philosophy says that
one should use a tool for that, not some behaviour of a program that
is supposed to make links. I know one problem with the above
statement; code like:
if [ !exists new ] # new command `exists'
then
ln old new
fi
leaves a terrible window of vulnerability between the test and the
link. What is needed is a proper lock mechanism, and System V provides
it with its IPC facilities in the kernel where they belong.
--
David Harrison, Dept. of Physics, Univ. of Toronto | "Why do 3 notes make a
UUCP: {utgpu,sq,oscvax}!utfyzx!harrison | triad and not a triangle?"
BITNET: HARRISON@UTORPHYS | - Ernst Mach
Technical Details
Message-ID:
<1988Oct31.141701.11055@utfyzx.uucp>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!utfyzx!harrisonShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!utfyzx!harrison From: harrison@utfyzx.uucp (David Harrison) Date: Mon Oct 31 14:17:01 EST 1988 Message-ID: <1988Oct31.141701.11055@utfyzx.uucp> Organization: Dept. of Physics, Univ. of Toronto Newsgroups: comp.bugs.sys5,comp.unix.wizards,comp.unix.questions Subject: ln(1) and System V Reply-To: harrison@utfyzx.UUCP (David Harrison) Distribution: na Organization: Dept. of Physics, Univ. of Toronto