Wandering Thoughts archives


What System V did to the poor ln command

On V7, UCB BSD 4.x, SunOS 2.x, 3.x and 4.x, the *BSDs, Linux, and anything using GNU fileutils:

; touch a b
; ln a b && echo oops
ln: b: File exists

On System V, including Solaris 8:

; touch a b
; ln a b && echo oops

That's right: the System V version of ln goes to significant extra work over just calling link(2), and in the process is so unhelpful that people had to make a new utility called link to do the right thing. (Fortunately, this behavior is no longer SuS compliant, per the ln spec.)

This is one of those things that sticks in my mind, because I had the distinction of being the first person to try to run CNews on a System V machine. CNews has a lot of shell scripts and had been developed on V7 and BSD systems, so all of the shell scripts did their locking with 'ln temp LOCK'; the consequences of the locking not actually working were reasonably spectacular and quite memorable. Fortunately the machine wasn't being used by anyone else at the time.

(The authors of CNews were as appalled as I was, and promptly introduced a little newslock program and switched the shell scripts to using it, so they had behavior they could count on.)

I was reminded of this mess recently when I wrote a shell script that needed to both do locking and run on our Solaris 8 systems. I was reasonably displeased to discover that Solaris 8 still has this bit of braindamage.

unix/SystemVLn written at 22:24:01; Add Comment

Page tools: See As Normal.
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.