symlink'ed files

Michael Ju. Tokarev mjt at tls.msk.ru
Wed Dec 29 10:15:52 GMT 1999


Damien Mascord wrote:
> 
> Hi,
> 
> I was wondering if anyone had a work around for the following:
> 
> 1) Create a file , say a Word document
> 2) Edit the file... blah blah
> 3) symlink the file
> 4) open the symlink in word
> 5) edit the symlink and save it
> 6) symlink dies, and in it's place is the actual edited document.
> 
> How would I update the original file while editing the symlink?  or is this
> not possible?
> 

It is "old good problem", and it is exists not only on samba+win box, but on
unix itself.  Basically, there are two methods writing (saving) file from
any editor: it is a) rename old, write new, and b) rewrite old.
With a), you always lost symlink, since it (symlink) will be renamed and
new file will be created.  With b), you will not lost it, but you have a
chance to lost your file (on power failure during write for example).
The same is true also for hard links -- in case a) link will also be
broken.  Note that a) and b) can't always be used both -- there are cases
when only a) or b) can be used.  For example, if you have write access to
directory but no write access to file, only a) method can be used (b will fail),
and opposite -- with write perms on file but without on dir you can use only
b) method.

Some editors (emacs is an example here) offer a configuration option for
what method should them use.  Word does not provide this option :), and,
moreover, it can't work if directory is read-only (it makes temporary file
in same directory, and also makes backups here).  So, probably, you should
simple not allow users to edit files by symlinks, just only real ones.
For this case, make whole share as read only, or rewoke write access to directory.

This can be a good entry for a FAQ.

Regards,
  Michael.


More information about the samba-technical mailing list