On Wed, 2009-01-14 at 01:50 +0800, mobile Parmenides wrote:
> Hi
> 
>     I am reading stable lfs book of 6.3 version. On page 96, I'm
> puzzled to the following two commands:
> 
>                       ln -sv ../usr/bin/cpp /lib
>                       ln -sv gcc /usr/bin/cc
> 
> For the first command, the current dircetory is /source/gcc-build, and
> the path in the command does not exsit. For the second command, the
> intendance is to make /usr/bin/cc point to gcc. But , gcc is in the
> current directory, and after installing, the current directory is to
> be deleted. What's the meaning of the link?

A little late replying, but where others have said read the man page, I
don't personally find it very clear on the subject.

The short version is that if you create a symlink with a relative path,
that path is interpreted relative to the symlink itself, not to the
current directory - hence, the first example should be read
as /lib/../usr/bin/cpp, and the second as /usr/bin/gcc

The reason is that the value you provide isn't interpreted when the
symlink is created - it's interpreted when the symlink is actually
referenced. If you try running ls on the links:

~$ ll /lib/cpp /usr/bin/cc
lrwxrwxrwx 1 root root 14 2008-06-04 21:05 /lib/cpp -> ../usr/bin/cpp
lrwxrwxrwx 1 root root  3 2008-06-04 21:05 /usr/bin/cc -> gcc

See the file sizes - 14 bytes, and 3 bytes. The same number of
characters in the '../usr/bin/cpp' and 'gcc' respectively. Not a
coincidence. :)


Note that as a result, a link pointing from /lib to ../usr/bin/cpp isn't
the same thing as a link pointing to /usr/bin/cpp. The latter will
always point to the same place, but the former will change if the
location of the symlink does - e.g if /lib is mounted as /mnt/lfs/lib at
some point.

Hope that provides a little illumination...

Simon.

Attachment: signature.asc
Description: This is a digitally signed message part

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page

Reply via email to