🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #1720

Misleading comment in ln.c

#1720
From: bothner
Date: Wed, 07 Feb 1990 18:36
33 lines
1643 bytes
This comment in fileutils-1.0/ln.c seems to misunderstand
the nature of symbolic links:

   This shares one problem with the 4.2BSD ln which is nearly
   impossible to remove in the general case: if you make symbolic links
   to multiple files where the target is a directory, you can lose.
   For example:

   % ln -s foo bar baz subdir
   % cat subdir/foo
   cat: subdir/foo: Too many levels of symbolic links
   % ls -l subdir
   total 3
   -rw-r--r--  1 mouse           3 Apr 10 17:46 foo -> foo
   -rw-r--r--  1 mouse           3 Apr 16 05:08 bar -> bar
   -rw-r--r--  1 mouse           3 Apr 19 03:34 baz -> baz

The problem has nothing to do with multiple files or directories
as targets.
% ln -s Makefile subdir/Makefile
% ls -l subdir
total 1
lrwxrwxr-x  1 bothner         8 Feb  7 12:21 Makefile@ -> Makefile

The same thing happens with both GNU ln, and /bin/ln (on a DECstation 3100).
The "problem" is that the symlink system call does not interpret
the old name, it just copies it into the new symbolic-link file. 
One solution is to use absolute path-names:
% ln -s $PWD/Makefile subdir
% ls -l subdir
total 1
lrwxrwxr-x  1 bothner        40 Feb  7 12:31 Makefile@ -> /var/home/bothner/file
	--Per Bothner
Technical Details
Message-ID: <9002071836.AA01362@sevenlayer.cs.wisc.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!CS.WISC.EDU!bothner

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!CS.WISC.EDU!bothner
From: bothner@CS.WISC.EDU
Newsgroups: gnu.utils.bug
Subject: Misleading comment in ln.c
Message-ID: <9002071836.AA01362@sevenlayer.cs.wisc.edu>
Date: 7 Feb 90 18:36:02 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 33