Solved

circular soft links

Posted on 2002-06-20
13
392 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

919 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now