Tanktalus has asked for the wisdom of the Perl Monks concerning the following question:
Following symbolic links (symlink/readlink) seems to me to be a hard problem. As in, if you don't watch out for all the minutae, you can get hammered.
So, I'm hoping someone already has solved that problem in a way accessible in perl.
I'm not looking to follow a symlink all the way to its end - the filesystem does a superb job of that already. I'm actually looking, in my case, for a particular actual symlink. I want to evaluate each symlink in the chain to determine whether I want to archive the target file, or the symlink itself. The criteria is simple, and thus less interesting (if a symlink matches a particular regular expression, I want to go to the next one in the chain, which could be the target file, otherwise I want to keep the symlink as is). However, trying to determine the symlink chain is difficult.
For example, using a simple chain of "S" (for "Symlink"), we could have:
foo -> S/foo S/foo -> S/foo # that's not a circular loop - there's an S in S S/S/foo -> ../lib/foo # keep the symlink because it doesn't start with + "S/"
Note that the filesystem I'm looking at is NFS-mounted, and read-only. And the directory structure I'm looking at is multiple-GB in size, so copying the whole thing becomes somewhat prohibitive in time (not so much in space). Especially following the symlinks during such a copy - we start jumping around from NFS server to NFS server.
Has anyone had to deal with this type of thing before? Are there modules out there that I missed which would help me go through this? Or is there a simplification that I'm just not seeing?
Thanks,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Following symlinks manually
by merlyn (Sage) on Jan 15, 2007 at 22:31 UTC | |
|
Re: Following symlinks manually
by sgifford (Prior) on Jan 15, 2007 at 23:44 UTC | |
by Anonymous Monk on Jul 07, 2010 at 21:57 UTC | |
|
Re: Following symlinks manually (historical code)
by shmem (Chancellor) on Jan 16, 2007 at 00:09 UTC | |
|
Re: Following symlinks manually
by kyle (Abbot) on Jan 15, 2007 at 22:39 UTC | |
by Tanktalus (Canon) on Jan 15, 2007 at 22:47 UTC | |
by davidrw (Prior) on Jan 15, 2007 at 23:06 UTC | |
by Tanktalus (Canon) on Jan 16, 2007 at 00:20 UTC | |
|
Re: Following symlinks manually
by sgt (Deacon) on Jan 15, 2007 at 23:53 UTC | |
|
Re: Following symlinks manually
by Tux (Canon) on Jan 15, 2007 at 23:47 UTC |