From: Paul Eggert <eggert@cs.ucla.edu>
To: emacs-devel@gnu.org
Subject: Re: strange build error today: "Renaming: Invalid argument"
Date: Thu, 3 Aug 2017 16:21:29 -0700 [thread overview]
Message-ID: <ba172c71-894c-f936-7f9a-01a931d04e6a@cs.ucla.edu> (raw)
In-Reply-To: <c5f122c8-0984-4c57-49bc-2f72dd20f9d8@cs.ucla.edu>
[-- Attachment #1: Type: text/plain, Size: 125 bytes --]
I managed to reproduce the bug on a RHEL 7 host with NFS, and installed the
attached patch to fix it. Please give it a try.
[-- Attachment #2: 0001-Port-recent-rename-changes-to-RHEL-7-NFS.patch --]
[-- Type: text/x-patch, Size: 2942 bytes --]
From ddc1ff58dec92a782b233d97a254fc41c1c887eb Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 3 Aug 2017 16:18:45 -0700
Subject: [PATCH] Port recent rename changes to RHEL 7 + NFS
Problem reported by Ted Zlatanov in:
http://lists.gnu.org/archive/html/emacs-devel/2017-08/msg00082.html
* src/fileio.c (Frename_file): On RHEL 7 + NFS, renameat2 can fail
with errno == EINVAL when it is not supported. So treat that case
like errno == ENOSYS. Also, when ok_if_already_exists is neither
nil nor an integer, just call plain rename; this avoids an extra
syscall to renameat2 when the latter fails with errno == EINVAL or
ENOSYS or ENOENT.
---
src/fileio.c | 45 ++++++++++++++++++++++++++++++---------------
1 file changed, 30 insertions(+), 15 deletions(-)
diff --git a/src/fileio.c b/src/fileio.c
index 0264c9f..db760d9 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2344,23 +2344,38 @@ This is what happens in interactive use with M-x. */)
encoded_file = ENCODE_FILE (file);
encoded_newname = ENCODE_FILE (newname);
- if (renameat_noreplace (AT_FDCWD, SSDATA (encoded_file),
- AT_FDCWD, SSDATA (encoded_newname))
- == 0)
- return Qnil;
- int rename_errno = errno;
+ /* If the filesystem is case-insensitive and the file names are
+ identical but for the case, don't worry whether the destination
+ already exists: the caller simply wants to change the letter-case
+ of the file name. */
+ bool plain_rename
+ = ((!NILP (ok_if_already_exists) && !INTEGERP (ok_if_already_exists))
+ || (file_name_case_insensitive_p (SSDATA (encoded_file))
+ && ! NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname)))));
+
+ int rename_errno;
+ if (!plain_rename)
+ {
+ if (renameat_noreplace (AT_FDCWD, SSDATA (encoded_file),
+ AT_FDCWD, SSDATA (encoded_newname))
+ == 0)
+ return Qnil;
+
+ rename_errno = errno;
+ switch (rename_errno)
+ {
+ case EEXIST: case EINVAL: case ENOSYS:
+ barf_or_query_if_file_exists (newname, rename_errno == EEXIST,
+ "rename to it",
+ INTEGERP (ok_if_already_exists),
+ false);
+ plain_rename = true;
+ break;
+ }
+ }
- if (rename_errno == EEXIST || rename_errno == ENOSYS)
+ if (plain_rename)
{
- /* If the filesystem is case-insensitive and the file names are
- identical but for the case, don't ask for confirmation: they
- simply want to change the letter-case of the file name. */
- if ((NILP (ok_if_already_exists) || INTEGERP (ok_if_already_exists))
- && (! file_name_case_insensitive_p (SSDATA (encoded_file))
- || NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname)))))
- barf_or_query_if_file_exists (newname, rename_errno == EEXIST,
- "rename to it",
- INTEGERP (ok_if_already_exists), false);
if (rename (SSDATA (encoded_file), SSDATA (encoded_newname)) == 0)
return Qnil;
rename_errno = errno;
--
2.7.4
next prev parent reply other threads:[~2017-08-03 23:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-03 20:41 strange build error today: "Renaming: Invalid argument" Ted Zlatanov
2017-08-03 20:57 ` Paul Eggert
2017-08-03 23:21 ` Paul Eggert [this message]
2017-08-04 13:21 ` Ted Zlatanov
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=ba172c71-894c-f936-7f9a-01a931d04e6a@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
/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.