[Top][All Lists]

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

Re: symlink pointing to itself

From: Rafael Torres
Subject: Re: symlink pointing to itself
Date: Tue, 1 Feb 2011 14:47:01 -0200

Hi Bob and Eric,

Thanks a lot for your promptly explanation. I've never thought that
symlinks could be used as a lock mechanism, and I need to admit that
this is a clever usage.

Rafael Torres

On Tue, Feb 1, 2011 at 1:50 PM, Bob Proulx <address@hidden> wrote:
> Rafael Torres wrote:
>> I've accidentally created a symbolic link that points to itself :
>> address@hidden tmp]$ ln -s tst tst
>> address@hidden tmp]$ ls -la tst
>> lrwxrwxrwx 1 rtorres rtorres 3 Feb  1 11:59 tst -> tst
> Sure.
>> I've search in the list archive and didn't find any discussion about it.
> The topic of symlinks does come up periodically.  I could refer to
> several random discussions in the archives but here are ones that I
> have taken an interest in.
>> Is it a small bug in symlink() or is there any purpose for such "feature" ?
> I think you are not understanding what 'ln -s' actually does.  Let me
> give a little explanation.
> The 'ln -s' creates a symbolic link file.  Symbolic links are special
> files that contain arbitrary strings of data.  They doesn't actually
> link two files together but instead creates a special file with the
> specified string value.  The filesystem will redirect through the
> value of the symbolic link for most filesystem operations.  The
> symlink doesn't need to point to an existing file.  It is a name
> resolution which happens at runtime.  It might resolve to different
> files at different times.  Not all operating systems support symlinks.
> Normally the content value in the symlink is a path to another file.
> However you can give it anything you want there.  You can store the
> name of your dog there if you wish or use it to store a very small
> shopping list.  This flexibility has proved to be a flexible and
> useful interface.  It is often used for lock files storing the name of
> the locker for example.
> Creating a symlink that contains the name of the current file may have
> a use.  I do not know.  But there isn't any content scanning of the
> contents of the symlink file.  Almost certainly someone someplace is
> using such a value as a flag of some sort.  If you try to open such a
> symlink the kernel will redirect back to itself creating a loop that
> will exceed the configured loop count and be detected.
> Bob

reply via email to

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