Solved

circular soft links

Posted on 2002-06-20
13
397 Views
Last Modified: 2013-12-26
I think I have softlinks that point to themselves somewhere on my system.  Is there a way to find and
diagnose circular links?
0
Comment
Question by:cotec1
  • 3
  • 3
  • 3
  • +2
13 Comments
 
LVL 20

Expert Comment

by:tfewster
ID: 7096939
ls -l `find . -type l -exec ls -l {} \; | awk '{print $NF}'` |grep "^l"
will list links to links [not very good practice, obviously!] - Hopefully that list will be short enough check manually.
0
 
LVL 20

Expert Comment

by:tfewster
ID: 7096998
In this scenario:
/tmp/junk> ls -lR
total 0
drwxr-xr-x   2 root       sys             96 Jun 20 19:20 d1
lrwxr-xr-x   1 root       sys              2 Jun 20 19:15 l1 -> l2
lrwxr-xr-x   1 root       sys              2 Jun 20 19:14 l2 -> l1

./d1:
total 0
lrwxr-xr-x   1 root       sys             12 Jun 20 19:20 l3 -> /tmp/junk/l1
lrwxr-xr-x   1 root       sys             12 Jun 20 19:17 ld1 -> /tmp/junk/d1

results in:
/tmp/junk> find . -follow -exec ls -ld {} \;
drwxr-xr-x   3 root       sys             96 Jun 20 19:16 .
drwxr-xr-x   2 root       sys             96 Jun 20 19:20 ./d1
find: ./d1/ld1 creates a cycle
lrwxr-xr-x   1 root       sys             12 Jun 20 19:17 ./d1/ld1 -> /tmp/junk/d1
find: cannot stat ./d1/l3
find: cannot stat ./l1
find: cannot stat ./l2

Of course, `find` may return the "cannot stat" error for other reasons, but it's a useful pointer to problems ;-)
0
 
LVL 38

Expert Comment

by:yuzh
ID: 7097708
Hi cotec1,

   You put this question on Soalris area as well, you should create a link for the question to save to points.

    I don't think you can make a  symbolic link to point to themselves.

Just ask yourseft a question, do you think the following command work ?
  ln -s test test
  The answer is NO !
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 51

Expert Comment

by:ahoffmann
ID: 7098034
>  I don't think you can make a  symbolic link to point to themselves.
you can, unfortunately :-(
The answer is YES ! (at least for some flaviours of UNIX)
0
 

Author Comment

by:cotec1
ID: 7098492
They don't actuall point back to themselves.  I should have been more specific in the description.  The links are causing our backups to go in to a loop, for instance:  There may be a link /home/cotec1/link_example > /home/cotec1

It points back to the directory that the link is in causing the backups to get trapped in a loop.

That is what I am trying to find.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7098661
to narrow down all possibilities: you're only interested in links pointing the a part of the physical part where it resides.
That would make a search easyer
0
 
LVL 20

Expert Comment

by:tfewster
ID: 7098668
If you're using Solaris, my earlier suggestions won't work (I guess I can't persuade you to switch to HP-UX? ;-)

However, what are you using for backups? Even tar and cpio will copy links as links, rather than following the link (unless you specify the h option to tar)
0
 

Author Comment

by:cotec1
ID: 7098690
We are using a no-frills, no-cost NT backup to a Mapped drive through Samba.  
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7098700
.. NT .. and which people adicted to NT, know about so sophisticated things like symbolic links? Just joking ...
0
 
LVL 38

Expert Comment

by:yuzh
ID: 7098772
Why don't you just use Solaris to backup, a symbole link cost you no almost no tape space!
0
 

Author Comment

by:cotec1
ID: 7098804
I have been working with our IT department to change our backup process.  The mode we are in now is temporary.  I think for a temp solution I am going to create a tar file for the backup and backup the tar file through NT/Samba.
0
 
LVL 38

Accepted Solution

by:
yuzh earned 100 total points
ID: 7098884
use: tar cvf dev-file-or-file file-list
will do the job for you.

    do not use:
    tar cvhf dev-file-or-file file-list
    -h it follow symbolic links and try to copy the normal
       file, you'll end up have mult-copies of the file in your tape.
0
 
LVL 1

Expert Comment

by:bearware
ID: 7365476
If your backup interperates the likes as it does instead of just copying them as discussed above. Then when you restore a backup you WILL NOT get back to the original data symlinks will be lost, and you make need a biger disk drive.

Also symlinks to directorys closer to the root will probably be common and it will be futile to hunt them.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Tab names are off by one 5 54
has22 challenge 11 104
Dell Alienware Graphics Amplifier Driver for non-Alienware systems 18 336
Problem to App 4 97
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question