coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: symlink pointing to itself


From: Eric Blake
Subject: Re: symlink pointing to itself
Date: Tue, 01 Feb 2011 08:27:45 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

On 02/01/2011 07:02 AM, Rafael Torres wrote:
> Hi all,
> 
> I've accidentally created a symbolic link that points to itself :
> 
> [rtorres@rtorres tmp]$ ln -s tst tst
> [rtorres@rtorres tmp]$ ls -la tst
> lrwxrwxrwx 1 rtorres rtorres 3 Feb  1 11:59 tst -> tst

Yep, and it's not a bug in ln.

> Is it a small bug in symlink() or is there any purpose for such "feature" ?

Feature.  POSIX requires it.  Trying to resolve such a symlink will
result in ELOOP; but no one said you have to resolve a dangling or
looping symlink.  It is also possible to create symlinks solely for the
purpose of readlink()ing their contents (symlinks serve as a great
file-system based atomic lock point; and at least emacs uses them for
this purpose, where only the contents of the symlink are worth anything,
the locks that emacs creates are not intended to be resolved as files).

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]