I'm having some trouble with symlinks and sshfs. I use the '-o follow_symlinks' option to follow symlinks on the server side, but whenever I edit a symlinked file on the client side with vim, a copy of it is made on the server side, i.e. it's no longer a symlink.

Set up a symlink on the server side:

me@machine1:~$ echo foo > test.txt
me@machine1:~$ mkdir test
me@machine1:~$ cd test
me@machine1:~/test$ ln -s ../test.txt test.txt
me@machine1:~/test$ ls -al test.txt
lrwxrwxrwx 1 me me 11 Jan  5 21:13 test.txt -> ../test.txt
me@machine1:~/test$ cat test.txt
foo
me@machine1:~/test$ cat ../test.txt
foo

So far so good. Now:

me@machine2:~$ mkdir test
me@machine2:~$ sshfs me@machine1:test test -o follow_symlinks
me@machine2:~$ cd test
me@machine2:~/test$ vim test.txt
[in vim, add a new line "bar" to the file]
me@machine2:~/test$ cat test.txt
foo
bar

Now observe what this does to the file on the server side:

me@machine1:~/test$ ls -al test.txt
-rw-r--r-- 1 me me 19 Jan  5 21:24 test.txt
me@machine1:~/test$ cat test.txt
foo
bar
me@machine1:~/test$ cat ../test.txt
foo

As you can see, it made a copy and only edited the copy.

How can I get it to work so it actually follows the symlink when editing the file?

link|improve this question

71% accept rate
is any other programm 'respecting the symlink' either? i mean, vim opens what is given by the filesystem... – akira Jan 6 '11 at 8:03
@akira: echo bar >> test.txt on the client machine preserves the symlink – HighCommander4 Jan 6 '11 at 18:37
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.