Solved

circular soft links

Posted on 2002-06-20
13
385 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 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

13 Experts available now in Live!

Get 1:1 Help Now