User-defined mountpoints in GVFS
vladc6 at yahoo.com
Sun Jul 29 17:48:14 PDT 2007
Alexander Larsson wrote:
>On Sat, 2007-07-21 at 08:00 -0700, Vlad wrote:
>> Will the user be allowed to choose the mountpoint of a
>> GVFS-managed resource? For example, someone may want to
>> have >> sftp:/username at server.school.edu/home/username/research
>> mounted at /home/username/research/school on their local
> No, all fuse mountpoints are handled by one mount, and that
> will be put in somewhere like ~/.gvfs. However, you could
> make symlinks to make it appear in other places.
Yes, symlinks would work.
> We really need the mapping between GVFS location and fuse
> mount to be "simple" to do in both directions (i.e. doing
> no blocking i/o).
I suggest storing a user's remote resources and
corresponding mountpoints in a tab-delimited text file
such as ~/.gvfs/mounts. Every line would represent one remote
resource, the first column containing the remote URL and
connection parameters (username, port #, protocol, etc)
while the second column contains the local FUSE mountpoint. Here is
a sample syntax:
sftp:22:username at server.school.edu/home/username/research
smb:137:username at 192.168.1.100/C/Program\ Files
Let's assume /home/username/research/school is a symlink to
/home/username/.gvfs/mountpoint1. When a GVFS-aware application tries
to open the file /home/username/research/school/article.odt, GVFS will
do the following things behind the scene:
1) Resolve all symlinks to reveal the file's real path on the local
system. In our example, this is
2) Check if any of the mountpoints listed in the second column of
~/.gvfs/mounts is actually a prefix of the file's local path. In our
example, /home/username/.gvfs/mountpoint1 is indeed a prefix of
3) Remove the local prefix from the file's local path to reveal the
file's relative path on the remote server. In our example, this is
4) Append the result of step 3 to the remote URL listed in the first
column of the corresponding line of ~/.gvfs/mounts. In our example,
sftp:22:username at server.school.edu/home/username/research/article.odt
and completes the mapping in the forward direction.
Now let's step through the mapping in the reverse direction. If GVFS
wants to know what is the local mountpoint of
sftp:22:username at server.school.edu/home/username/research/article.odt,
it will do the following things:
1) Check if any of the entries listed in the first column of
~/.gvfs/mounts is actually a prefix of the remote URL in question. In
our example, sftp:22:username at server.school.edu/home/username/research
is indeed a prefix of
sftp:22:username at server.school.edu/home/username/research/article.odt.
2) Remove the remote prefix to reveal the file's relative path on the
local system. In our example, this is article.odt.
3) Append the result of step 2 to the local mountpoint listed in the
second column of the corresponding line of ~/.gvfs/mounts. In our
example, this yields /home/username/.gvfs/mountpoint1/article.odt.
As you can see, the above steps only involve manipulating strings
through regular expressions and do _not_ require communicating to the
remote server at all. The only I/O operation here is reading the
~/.gvfs/mounts file, but this can easily be resolved by caching the
contents of ~/.gvfs/mounts in memory.
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
More information about the xdg