Subject: Re: Symlink ownership (let's go back)
To: None <current-users@NetBSD.ORG>
From: Mike Long <mike.long@analog.com>
List: current-users
Date: 08/10/1995 10:35:52
>Date: Wed, 9 Aug 95 09:59:54 PDT
>From: greywolf@tomcat.VAS.viewlogic.com (James Graham (Captech))

>I think that, given that symlinks in directories which consist of ALL sym-
>links will at least double (likely more!) the size of a directory, and
>seeing that directories are kept relatively small on purpose (there are
>always exceptions, so don't bother telling me that!), putting symlinks in
>the directories themselves would be tantamount to having directory entries
>consist of full pathnames, which, of course, would be patently absurd.

I would like to second this.

If you keep the symlink target in an inode, then you need to access
the disk once more than if you keep the target in the dirent.  This is
a one-time cost when open("symlink",...) is called.

If you bloat the directory by keeping symlink targets in the dirent,
then you potentially slow down ALL filename lookups in that directory.

I'd much prefer that we keep directories small by keeping symlinks in
inodes.

>Worst case would be a heavily loaded machine with many directories chock
>full of symbolic links with pathnames that could pave the road to hell
>-- twice.

Install XFree86, then use /usr/X11R6/bin/lndir a lot.

People who wish to avoid this entire thing may want to check out the
script below.  It turns symbolic links into hard links, where
possible.  It worked fine for me on /usr/X11R6/man/cat[13], but YMMV
if you use it elsewhere (watch out for relative links).

#!/bin/sh
# usage: harden file [file...]
for i in $*
do
    ls -lF $i |awk '/^l/ {sub("@$","",$9);\
     system("ln -f " $11 " " $9 " || test -h " $9 " || ln -s " $11 " " $9)'
done
-- 
Mike Long <mike.long@analog.com>           http://www.shore.net/~mikel
VLSI Design Engineer         finger mikel@shore.net for PGP public key
Analog Devices, CPD Division          CCBF225E7D3F7ECB2C8F7ABB15D9BE7B
Norwood, MA 02062 USA                assert(*this!=opinionof(Analog));