Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Aug 2002 05:24:34 +0200
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        Adam Weinberger <adam@vectors.cx>
Cc:        Steve Mazerski <smazerski@yahoo.co.jp>, freebsd-questions@FreeBSD.ORG
Subject:   Re: Re: Why hard, not soft links?
Message-ID:  <20020803052434.B2058@student.uu.se>
In-Reply-To: <20020803014757.GC9210@vectors.cx>; from adam@vectors.cx on Fri, Aug 02, 2002 at 06:47:57PM -0700
References:  <200208030344.27552.smazerski@yahoo.co.jp> <20020803014757.GC9210@vectors.cx>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Aug 02, 2002 at 06:47:57PM -0700, Adam Weinberger wrote:
> if /usr/bin/nvi were a softlink to /usr/bin/vi, and you moved
> /usr/bin/vi to /usr/bin/myeditor, then /usr/bin/nvi wouldn't point to
> the correct place anymore, and would die.
> 
> furthermore, a softlink implies "this is a shortcut to running this
> command," whereas a hardlink implies "this is another name for this
> command."
> 
> FURTHERMORE, does $0 get set to the name of the calling softlink?

Yes, actually it does.

Another reason is that hardlinks are somewhat more efficient.
A hardlink is just another name for a file, so all the hardlinks pointing
to the same file are equally fast. (Since they are the same file.)
For a soft link you first need to read the soft link to get the name of the
file it points to, and then find that file. For a hardlink you only need
the second step.
I would also expect a hardlink to use less space in a directory than a
softlink.

> 
> -Adam
> 
> 
> >> (08.02.2002 @ 1844 PST): Steve Mazerski said, in 0.4K: <<
> > 
> > Is there any particular reason why FreeBSD makes frequent use
> > of hard links instead of soft links when defining "alternative"
> > names for commands and other files?
> > 
> > e.g.  /usr/bin/nvi and /usr/bin/vi are the same file.
> > 
> > Linux distros tend to use  soft links for the same thing.
> > 
> > Just wondering
> > 
> > S.Mazerski




-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020803052434.B2058>