Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 101987 - ln dereferences target symlink rather than replacing when using -f
Summary: ln dereferences target symlink rather than replacing when using -f
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-10 07:51 UTC by Stanislav Nikolov
Modified: 2005-08-10 16:08 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stanislav Nikolov 2005-08-10 07:51:19 UTC
When one tries to force the creation of a symlink by using -f option, nothing
happens. I'm using the latest coreutils package (5.2.1-r6)

Example:

stan src # cd /usr/src
stan src # ls -l
total 4
lrwxrwxrwx   1 root root   22 авг  2 20:20 linux -> linux-2.6.12-gentoo-r7
drwxr-xr-x  19 root root 4096 авг 10 17:33 linux-2.6.12-gentoo-r7
stan src # ln -s -f foo linux
stan src # ls -l
total 4
lrwxrwxrwx   1 root root   22 авг  2 20:20 linux -> linux-2.6.12-gentoo-r7
drwxr-xr-x  19 root root 4096 авг 10 17:49 linux-2.6.12-gentoo-r7
stan src # ln -s foo linux
ln: `linux/foo': File exists


Reproducible: Always
Steps to Reproduce:
Comment 1 SpanKY gentoo-dev 2005-08-10 08:44:53 UTC
your foo symlink is being created inside of linux/

looks like ln dereferences the target before creating the symlink, but the -f
option is working fine (as your example shows)
Comment 2 Harald van Dijk (RETIRED) gentoo-dev 2005-08-10 15:49:09 UTC
From the manpage:

       -n, --no-dereference
              When given an explicit destination that is a symlink to a
directory, treat that des-
              tination as if it were a normal file.

              When  the  destination  is  an  actual directory (not a symlink to
one), there is no
              ambiguity.  The link is created in that directory.  But when the
specified  destina-
              tion  is  a  symlink to a directory, there are two ways to treat
the user's request.
              ln can treat the destination just as it would a normal directory
and create the link
              in  it.   On  the other hand, the destination can be viewed as a
non-directory -- as
              the symlink itself.  In that case, ln must delete or backup that
symlink before cre-
              ating  the  new  link.  The default is to treat a destination that
is a symlink to a
              directory just like a directory.

So this looks like the correct behaviour to me.
Comment 3 SpanKY gentoo-dev 2005-08-10 16:08:53 UTC
indeed, thanks for that