From: Robert Pluim <rpluim@gmail.com>
To: Bernardo <bernardo.bacic@pobox.com>
Cc: 37884@debbugs.gnu.org
Subject: bug#37884: 27.0.50; Cannot write to a file in VirtualBox shared directory
Date: Mon, 28 Oct 2019 13:32:45 +0100 [thread overview]
Message-ID: <m2h83toxsi.fsf@gmail.com> (raw)
In-Reply-To: <874kztdy0l.fsf@pobox.com> (Bernardo's message of "Mon, 28 Oct 2019 20:23:22 +1100")
>>>>> On Mon, 28 Oct 2019 20:23:22 +1100, Bernardo <bernardo.bacic@pobox.com> said:
Bernardo> $ git diff src/filelock.c
Bernardo> diff --git a/src/filelock.c b/src/filelock.c
Bernardo> index ff25d6475d..79eb8fa91e 100644
Bernardo> --- a/src/filelock.c
Bernardo> +++ b/src/filelock.c
Bernardo> @@ -403,7 +403,7 @@ create_lock_file (char *lfname, char *lock_info_str, bool force)
Bernardo> lock_info_len = strlen (lock_info_str);
Bernardo> err = 0;
Bernardo> if (emacs_write (fd, lock_info_str, lock_info_len) != lock_info_len
Bernardo> - || fchmod (fd, S_IRUSR | S_IRGRP | S_IROTH) != 0)
Bernardo> + || fchmod (fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) != 0)
Bernardo> err = errno;
Bernardo> /* There is no need to call fsync here, as the contents of
Bernardo> the lock file need not survive system crashes. */
Bernardo> and Emacs is happy again, no problems with writing to files in
Bernardo> VirtualBox shared directory.
Bernardo> Please let me know if you want me to test anything else.
I think Eli's suggestion was more like the below, which only calls
fchmod if the unlink fails.
diff --git a/src/filelock.c b/src/filelock.c
index ff25d6475d..7fb14774b0 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -732,6 +732,15 @@ unlock_file (Lisp_Object fn)
int err = current_lock_owner (0, lfname);
if (err == -2 && unlink (lfname) != 0 && errno != ENOENT)
err = errno;
+ /* On certain filesystems the file must be writable for unlink to
+ succeed (Bug#37784). */
+ if (errno == EPERM)
+ {
+ fchmod (fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ errno = 0;
+ if (unlink (lfname) != 0 && errno != ENOENT)
+ err = errno;
+ }
if (0 < err)
report_file_errno ("Unlocking file", filename, err);
next prev parent reply other threads:[~2019-10-28 12:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-23 10:28 bug#37884: 27.0.50; Cannot write to a file in VirtualBox shared directory Bernardo
2019-10-24 16:10 ` Robert Pluim
[not found] ` <87blu2emi3.fsf@pobox.com>
2019-10-27 15:34 ` Robert Pluim
2019-10-27 15:52 ` Eli Zaretskii
2019-10-27 16:01 ` Robert Pluim
2019-10-27 16:34 ` Eli Zaretskii
2019-10-28 9:23 ` Bernardo
2019-10-28 12:32 ` Robert Pluim [this message]
2019-10-29 8:50 ` Bernardo
2019-10-29 9:04 ` Andreas Schwab
2019-10-29 13:41 ` Robert Pluim
2019-10-30 8:44 ` Bernardo
2019-10-30 13:31 ` Robert Pluim
2019-10-30 16:25 ` Eli Zaretskii
2019-10-31 1:41 ` Paul Eggert
2019-10-31 7:38 ` Robert Pluim
2019-10-31 14:37 ` Eli Zaretskii
2019-10-31 21:24 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2h83toxsi.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=37884@debbugs.gnu.org \
--cc=bernardo.bacic@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.