Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Aug 2002 09:16:34 +0930
From:      Greg 'groggy' Lehey <grog@FreeBSD.org>
To:        Jerry McAllister <jerrymc@clunix.cl.msu.edu>
Cc:        Roman Neuhauser <neuhauser@bellavista.cz>, Peter Leftwich <Hostmaster@Video2Video.Com>, Matthew Seaman <m.seaman@infracaninophile.co.uk>, Jeff Jirsa <jeff@unixconsults.com>, John Bleichert <syborg@stny.rr.com>, FreeBSD LIST <FreeBSD-Questions@FreeBSD.ORG>
Subject:   Re: Links (was: Is simplicity despised? WAS:
Message-ID:  <20020808234634.GJ8561@wantadilla.lemis.com>
In-Reply-To: <200208081419.g78EJYO14151@clunix.cl.msu.edu>
References:  <20020808141523.GT281@freepuppy.bellavista.cz> <200208081419.g78EJYO14151@clunix.cl.msu.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday,  8 August 2002 at 10:19:34 -0400, Jerry McAllister wrote:
>>>>
>>>> Because symlinks are wasteful and introduce problems.  There are very
>>>> few reasons to ever symlink files in the same file system.
>>>
>>> Because symlinks make it abundantly clear what is linked to what.
>>> Hard links can lead to confusion.   I suppose that's not a problem
>>> For most of you though.   But, for example, if a person doesn't know
>>> which is linked to which, that person wouldn't know that more is
>>> really less.  They might think less is really more (if they discovered
>>> it at all).
>>
>>     No, less is not hardlinked to more, nor is more hardlinked to less.
>>     They're two names for the same file.
>>
>>     So... Yes, you're right: less is really more. But at the same time,
>>     more is less.
>
> Yup.  But was that file created as less or more 

Why should you care?

> and if I want to make a change do I start with the source for less
> or more, etc?

It's the same source.

> Minor maybe, but ln -s makes it clear and is not so onerrous in
> most situations.

No, symlinks impose an order, and they don't clarify, they obfuscate.
If you do this, you'll end up with a broken symlink:

  $ echo foo > bar
  $ ln -s bar baz
  $ rm bar
  $ cat baz
  cat: baz: No such file or directory
  $ 

On the other hand, links are *the* basic mechanism for naming files.
If you do this, it will work:

  $ echo foo > bar
  $ ln bar baz
  $ rm bar
  $ cat baz
  foo

UNIX files consist of three components: the data, the inode and the
name.  The inode is what really describes the file, and where nearly
all the information is stored that you see when you run ls -l (only
the name is stored in a directory).  This is the only part of a file
which *must* exist.  An empty file doesn't have any data.

Strictly speaking, the name isn't necessary unless you want to open
the file.  If it's already open, you can remove the name and still
access the file, but it will go away if you close it for the last
time.

File names are stored in directories, which are simply a list of names
and corresponding inode numbers.  That's the elegance: you can have
more than one name for a file.  They are *absolutely* equivalent.

Symlinks, on the other hands, are a kludge needed to point to files on
different file systems (since inode numbers refer to the same file
system).  They are separate files which point to another file name, so
if that name goes away, the symlink is broken.  They're also slightly
slower to use than links, since you need to access two files instead
of one.

Greg
--
See complete headers for address and phone numbers

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?20020808234634.GJ8561>