1

Operating System Concepts says

when we add links, the tree structure is destroyed, resulting in a simple graph structure (Figure 11.13).

enter image description here

Could you create the cycle book->avi->book using symbolic links?

Should /avi/text and /avi/mail also appear under /avi/book/? Should /avi/book/count also appear under /avi/? If both answers are no, can you make them happen?

If you have some problem understanding the figure just like I do, here is my guess: The root of the tree is a directory named "root" which contains three directory entries for subdirectory "avi", regular file "tc" and subdirectory "jim" respectively. Similar explanation for other parts.

Thanks.

1

Symlinks can easily create loops. The simplest is to have a symlink point to the current directory.

$ cd /tmp
$ ln -s . XXX
$ cd XXX/XXX/XXX/XXX/XXX/XXX
$ pwd
/tmp/XXX/XXX/XXX/XXX/XXX/XXX

But we can also do it with book and avi as in your diagram by making there be a book symlink inside the avi directory

eg

$ mkdir /tmp/XXXX
$ cd /tmp/XXXX
$ mkdir book book/avi
$ cd book/avi
$ pwd
/tmp/XXXX/book/avi
$ ln -s .. book
$ ls -l
total 0
lrwxrwxrwx 1 sweh sweh 2 Sep 28 22:53 book -> ../
$ cd book/avi/book/avi/book/avi
$ pwd
/tmp/XXXX/book/avi/book/avi/book/avi/book/avi
  • Thanks. In the figure, why do not all of the files "text" "mail" and "count" appear under both the directory and the symbolic link to it? Can you make that happen? – Tim Sep 29 '18 at 3:00
  • The grey "avi" is a different node to the blue "avi" in that diagram. Just because the name is the same doesn't mean they are the same thing. The whole path is important. Otherwise /bin and /opt/bin and /usr/local/bin would be the same, and they're not. – Stephen Harris Sep 29 '18 at 3:02
  • Thanks. Should /avi/text and /avi/mail also appear under /avi/book/? Should /avi/book/count also appear under /avi/? If both answers are no, can you make them happen? – Tim Sep 29 '18 at 3:10
  • In the graph you presented, the answer is "no". But with symlinks you can make any node of the graph link to any other node, so you can build a complete spider's web of connections if you were so inclined ;-) – Stephen Harris Sep 29 '18 at 14:38
  • Between "book" and "avi", one is symlink to another. How can some files under "book" not appear under "avi", and vice versa? – Tim Sep 29 '18 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.