Re: [AVFS] ~/.avfs and symlinks

Peter <[email protected]> Mon, 06 Mar 2006 08:12:08 -0500
Newsgroups gmane.comp.file-systems.avfs.user
Message-ID <[email protected]>
On Tue, 31 Jan 2006 10:41:12 -0500, Peter wrote:

> Don't know if this is even a bug, but avfs has problems when a symlinked
> directory is used. For example,
> 
> ~/backup --> /mnt/backup
> 
> cd ~/backup
> ls ~/.avfs/$PWD/file.tar# causes an error
> 
> /home/peter/.avfs//home/peter/backup/file.tar#: No such file or directory
> 
> While readlink will work on a first level dir, if a file was in
> ~/backup/january readlink will fail since january is not symlinked.
> 
> This comes up more frequently when using a dir manager like ROX which
> won't care how it gets to a directory or whether or not it's linked.
> 
> Don't know if there's an elegant solution to this, but thought I'd
> bring it up for consideration.

Just one additional clarification. The symlink problem ONLY occurs when
the link is on a different filesystem. For example, this type of link will
work:

~/foo/bar -> ~/foo/baz
cd ~/foo/bar
ls ~/.avfs/$PWD/file.tar#

will list the contents of file.tar

however, when

~/foo -> /mnt/foo
cd ~/foo/bar
ls ~/.avfs/$PWD/file.tar#
will return an error

ls: /home/peter/.avfs//home/peter/foo/bar/file.tar#: No such file or directory

I suppose one way out of this, and maybe Miklos' code snippet does this is
to walk the entire PWD tree and check each node and see if it's a symlink.
If so, build the filename and pathname from that point.

For example
PWD=/home/peter/foo/bar
~/foo -> /mnt/foo

in bash-like pseudo code

for each dir in $PWD
   node = `dirname $PWD`
   symlink = `readlink "$node"`
   is symlink not empty?
   yes, substitute path and break
   no, go up one level
end for loop

So, I suppose there are really two tests. One, that if it works, don't do
any checks. Or, if there is an error, trap it first and check for symlinks?

Hope this helps.

-- 
Do not reply to this email address. It is a spam trap and not monitored.
If you wish to contact me, please use pete4abw at comcast dot net.




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642