Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
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
    
Is this still an issue? From the question it looks like it's not copying the file, it's dropping the symlink and creating a new file. Would setting -o transform_symlinks be a better alternative? –  vol7ron Mar 23 at 21:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.