Solved

circular soft links

Posted on 2002-06-20
13
398 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 21

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 21

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 21

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET how to use the Vertical ScrollBar 5 120
Generic progress indicator 6 118
child constructor and parent constructor, overriding and overloading 6 93
changeXy challenge 13 93
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

756 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