I am bind mounting a single file on top of another one and after making changes with an editor, I don't see the modifications in both files. However, if I make the changes with the shell using redirection, >>, e.g., I do see the changes in both files. Below is an example to demonstrate:
First case:
-bash-3.00# echo foo >| foo
-bash-3.00# echo bar >| bar
-bash-3.00# diff foo bar
1c1
< foo
---
> bar
-bash-3.00# mount --bind foo bar
-bash-3.00# echo modified >> foo
-bash-3.00# diff foo bar
-bash-3.00# umount bar
Everything in the above case is as I expect; the two files show no differences after appending "modified" to the file "foo".
However, if I perform the same test but use vi to edit foo, I get a different result.
Second case:
-bash-3.00# echo foo >| foo
-bash-3.00# echo bar >| bar
-bash-3.00# diff foo bar
1c1
< foo
---
> bar
-bash-3.00# mount --bind foo bar
-bash-3.00# diff foo bar
-bash-3.00# vi foo
# append "modified with vi" and :wq vi
"foo" 2L, 21C written
-bash-3.00# cat foo
foo
modified with vi
-bash-3.00# cat bar
foo
-bash-3.00# diff foo bar
2d1
< modified with vi
-bash-3.00#
Here, the two files are different even though one is bind mounted onto the other. Anyone here know what is going on in this case?
Thanks!