私はあなたが何を求めているのか完全には理解していません。よくわからない場合は、ファイルを処理している最中にこれを検出する方法があるかどうかを尋ねていたと思います。これが可能だとは思わない。
私が思いつくことができる唯一の方法は、ディレクトリツリー内の特定のブランチを具体的に調べ始める場所を見つけることです。
例
$ tree 
.
`-- a
    `-- b
        |-- c
        |   `-- d
        |       `-- e -> ../../../../a/b
        `-- e -> e
5 directories, 1 file
findコマンドは、このループを検出したが、本当にあなたにそれについての全体の多くを教えてくれません。
$ find -L . -mindepth 15
find: File system loop detected; `./a/b/c/d/e' is part of the same file system loop as `./a/b'.
find: `./a/b/e': Too many levels of symbolic links
で表示される出力をブロックするために、15レベルを任意に選択しましたfind。ただし-mindepth、表示されているディレクトリツリーを気にしない場合は、そのスイッチ()をドロップできます。findこのコマンドは、まだループと停止を検出します。
$ find -L . 
.
./a
./a/b
./a/b/c
./a/b/c/d
find: File system loop detected; `./a/b/c/d/e' is part of the same file system loop as `./a/b'.
find: `./a/b/e': Too many levels of symbolic links
ちなみに、MAXSYMLINKSLinux(カーネルの新しい3.xバージョン)で明らかに40であるデフォルトをオーバーライドしたい場合は、「MAXSYMLINKSを増やすにはどうすればよいですか?」というタイトルのこのU&L Q&Aを参照できます。
symlinksコマンドを使用する
FTPサイトのメンテナーが使用できるツールがあります。これは、symlinksシンボリックリンクによって引き起こされたツールの長いツリーやぶら下がりツリーの問題を明らかにするのに役立ちます。
場合によっては、このsymlinksツールを使用して問題のリンクも削除できます。
例
$ symlinks -srv a
lengthy:  /home/saml/tst/99159/a/b/c/d/e -> ../../../../a/b
dangling: /home/saml/tst/99159/a/b/e -> e
glibcライブラリ
glibcライブラリは、これに関するC関数をいくつか提供するように見えますが、それらの役割や実際の使用方法は完全にはわかりません。だから私はあなたにそれらを単に指摘することができるだけです。
マニュアルページにman symlinkは、と呼ばれる関数の関数定義が表示されsymlink()ます。説明は次のようになります。
  symlink()は、文字列oldpathを含むnewpathという名前のシンボリックリンクを作成します。
エラーの1つは、この関数が返すことを示しています。
  ELOOP newpathの解決中に検出されたシンボリックリンクが多すぎます。
また、manページに移動して、man path_resolutionディスク上のアイテムへのパスをUnixが決定する方法について説明します。具体的にはこの段落。
If  the component is found and is a symbolic link (symlink), we first 
resolve this symbolic link (with the current lookup directory as starting 
lookup directory).  Upon error, that error is returned.  If the result is 
not a directory, an ENOTDIR error is returned.  If the resolution of the 
symlink is successful and returns a directory, we set the current lookup
directory to that directory, and go to the next component.  Note that the 
resolution process here involves recursion.  In order  to  protect  the 
kernel against stack overflow, and also to protect against denial of 
service, there are limits on the maximum recursion depth, and on the maximum 
number of symbolic links followed.  An ELOOP error is returned  when  the
maximum is exceeded ("Too many levels of symbolic links").
               
              
readlink ...上記の状況について、コマンドラインツールは何と言いますか?