From: Miklos S. <mi...@sz...> - 2008-04-16 08:57:52
|
> Actually, the contents of the softlink are relative to the link itself, > not the reader. > > So at the time you readlink, you'll necessarily have the path the link is > relative to. > > So, if /root/d1/d2/link points to ../file1, then file1 is /root/d1/file > and it doesn't matter where the process reading the link is. Well said. But... there still some mystery here: > > My filesystem using FUSE basically routes requests to a read only branch > > or a read write branch with a copy on write mechanism. Initially the > > whole filesystem mirrors an ext3 filesystem rooted at say /read-only. If > > there is an open to a file with RW flag set, for e.g. say > > /home/xyz/file1, then the file is copied from /read-only/home/xyz/file1 > > to say /read-write/home/xyz/file1 (after home and xyz are also created). > > I use a data structure to decide if a particular path is on the read > > only or read write branch. Very much like UnionFS, but instead of the in > > kernel filesystem for metadata, I use my own. > > > > For symlinks, at the time of creation, I just create the symlink in the > > read-write branch and specify the target as whatever it is. The > > filesystem is to be a root file system that can be used to boot off and > > hence the user shouldn't be aware of there being a mountpoint. So when > > you create a symlink say ln -s /home/xyz/file1 linkfile1, then linkfile1 > > is create on the RW branch with the target as'/home/xyz/file1'. When the > > link is read in readlink, I 'prepend' the FUSE mount point to the path > > so that the caller of readlink (say open) also goes through FUSE and Huh? Why would open() need a different path than what you specified in symlink()? Is there a possibility for some processes to access the filesystem as '/mnt/rootfs/foo/bar' and some of them as '/foo/bar'? That obviously won't work with regards to absoulte symlinks, because the filesystem has no idea what root the process is using. This is the typical: "I mounted volume from 'server:/' to '/mnt/server' and symlinks won't work" syndrome. And incidentally it's relative links which continue to work in those situations (as long as they don't point outside the filesystem), because they are insensitive to actual root. Miklos |