Subject: bug#22795: 25.0.91; Can't write read only file on w32

From: "Ota, Takaaki" <[email-masked]>
Date: Mon, 29 Feb 2016 10:05:26 -0800

Mon, 29 Feb 2016 09:53:54 -0800 (Pacific Standard Time): "Ota, Takaaki" <[email-masked]> wrote:

> Mon, 29 Feb 2016 19:13:43 +0200: Eli Zaretskii <[email-masked]> wrote:
> 
> > Finally, what about this part of my questions, did you look into this:
> > 
> > > Also, I think by the time this code is run, the original file should
> > > have been renamed to the backup-file name, so the file you are saving
> > > should not exist on disk by the time we open it.  If that is not the
> > > case with 25.0.91, then perhaps what fails is not the open call, but
> > > the rename call before that.
> > 
> > Does the file that Emacs tries to open here, c:\d\ota\memo, exist when
> > _wopen is called, and if so, is it read-only?  Please check this with
> > both versions of Emacs, and see if there's any differences in what
> > happens.
> 
> In both cases the original file exists right before calling _wopen()
> but there is a difference.  On 25.0.91 the file remains read-only but
> on 24.5 the file is writable right before calling _open().  Now we
> have some clue here.
> 

I set a break pointer at write_region() in fileio.c and then perform
the save-buffer command.  When emacs breaks at write_region() on 24.5
the file's permission is changed to writable while on 25.0.91 the
permission remains read-only.  I will trace in lisp from save-buffer
to write-region on each version to find how this permission difference
is made.

-Tak