[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ln and -F
On Sun, Jul 21, 2002 at 01:08:09AM -0500, Chris Humphries wrote:
> yes, i have just been doing some reading on that, and one should still
> be able to use -F for symlinks, correct? so why not enable a logic
> rule that makes it where you have to have -s in conjunction with it,
> or else it will not work?
>
Not correct.
-s works for both files _and_ directories _without_ anything else.
Symbolic links create a new inode in the filesystem and put in its data
blocks a path to the inode which they are linking to. They do _not_
touch the original inode. Hence, it doesn't matter what is the type of
the original inode.
The filesystem lookup() will resolve a symlink by simply continuing
the search for the path it contains in its data block. When it finally
reaches its destination it will recognize from the target inode whether
it is a file or a directory.
Hard links however do _not_ create a new inode. They change the
_original_ inode by changing the corresponding link count in the inode
structure.
Both types of links write an entry in a directory they are linking from
which makes the correspondence between an inode and its name. However,
if you do
ls -li
in a directory containing both types of links to the same file you will
see that hard link has the same inode number as the original inode and
link count (the number next to permission bits rw-r--r--) is 2 or
larger, while the symbolic link has totally different inode number and
link count 1 -- because it's a different inode and nobody else links to
it!
Also the size of a hard link file is the same as the size of the
original file, while the size of a symlink file is the length of the
string containing the path to the original file.
Hard link to a directory would create a loop in the filesystem graph and
that would really confuse the programs relying on the graph traversal
(e.g. fsck).
> I just think that if something is supported, it should be documented
> if, binding it to -s will make it useful and safe? If one wants to
> hardlink to a directory then have them hack the code to get it to
> work, but if it is safe to soft link to a directory, why not enable it
> and bind -F to -s as a logic rule?
>
I hope the above explanation helps you understand that -s already works
just fine and there are good reasons not to advertise -F.
> of course, i am not an expert on all the gnomes that can come to life
> on this. i am still reading. your thoughts?
>
> -chris
>
I see.
Best regards,
--
Zvezdan Petkovic <zvezdan@cs.wm.edu>
http://www.cs.wm.edu/~zvezdan/