bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#10257: 23.3.1 Cygwin: network drives - file is write protected (fals


From: Ken Brown
Subject: bug#10257: 23.3.1 Cygwin: network drives - file is write protected (false positive)
Date: Tue, 13 Dec 2011 22:27:11 -0500
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 12/13/2011 9:54 PM, Stefan Monnier wrote:
The code I'm talking about is near the beginning of the definition of
basic-save-buffer-2' in files.el:

Thanks.

I'm not (yet) proposing a change.  I'm simply asking what the rationale is
for calling `yes-or-no-p' and making the user confirm that s/he wants to try
to save the file.

I'm not sure what was the intention, but I know that this code is
triggered in cases such as:
- running as root: write will always succeed.
- saving to a read-only file that you own: while `write' will fail,
   you can make it succeed by changing the access rights (which is what
   tempsetmodes is for).
- saving to a read-only file in a writable dir: write will fail, but
   you can make it succeed by calling unlink first [Not sure if this
   works in Emacs right now].
In all these cases, Emacs is able to write the file, but the read-only
bit expresses an intention not to modify the file so it makes sense to
ask for confirmation.

There's a fourth case, and that's what led to the present bug report (by Jari): - saving to a file that is in fact writable, for which file-writable-p gives the wrong answer.

This said, the code you quote should never prevent you from saving
a file, it should only ask for confirmation (i.e. it might be annoying
but it shouldn't prevent you from getting your work done).

Jari was annoyed to the point where he felt he couldn't get his work done. He's in a situation where file-writable-p will consistently report that a file is not writable, but writing will in fact succeed. I was trying to help him find a way to avoid having to repeatedly confirm that he wants to save.

But other than for the "running as root" case, the above two cases could
replace the `file-writable-p' test with a `write-region' test:
file-writable-p is documented (via POSIX's documentation of `access') to
be an approximation, whereas `write-region' should reliably tell us
whether we can write to the file.

So that sounds like a solution to Jari's problem. I'll leave it to him to propose a patch along those lines.

Ken






reply via email to

[Prev in Thread] Current Thread [Next in Thread]