From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: strange build error today: "Renaming: Invalid argument" Date: Thu, 3 Aug 2017 16:21:29 -0700 Organization: UCLA Computer Science Department Message-ID: References: <87d18c8ju9.fsf@lifelogs.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1AF189D857A98726FAF3427F" X-Trace: blaine.gmane.org 1501802552 23283 195.159.176.226 (3 Aug 2017 23:22:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 3 Aug 2017 23:22:32 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 04 01:22:27 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddPRb-0005TL-3q for ged-emacs-devel@m.gmane.org; Fri, 04 Aug 2017 01:22:19 +0200 Original-Received: from localhost ([::1]:33933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddPRh-0006pp-8e for ged-emacs-devel@m.gmane.org; Thu, 03 Aug 2017 19:22:25 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddPQz-0006oo-Py for emacs-devel@gnu.org; Thu, 03 Aug 2017 19:21:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddPQw-0005Ks-Jo for emacs-devel@gnu.org; Thu, 03 Aug 2017 19:21:41 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:57214) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ddPQw-0005HM-As for emacs-devel@gnu.org; Thu, 03 Aug 2017 19:21:38 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id F241F160727 for ; Thu, 3 Aug 2017 16:21:35 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id dOluLYlFtdRu for ; Thu, 3 Aug 2017 16:21:33 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 723AB160732 for ; Thu, 3 Aug 2017 16:21:33 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id E-RAgy7QNGm9 for ; Thu, 3 Aug 2017 16:21:33 -0700 (PDT) Original-Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 46DB1160727 for ; Thu, 3 Aug 2017 16:21:33 -0700 (PDT) In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:217276 Archived-At: This is a multi-part message in MIME format. --------------1AF189D857A98726FAF3427F Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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. --------------1AF189D857A98726FAF3427F Content-Type: text/x-patch; name="0001-Port-recent-rename-changes-to-RHEL-7-NFS.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Port-recent-rename-changes-to-RHEL-7-NFS.patch" >From ddc1ff58dec92a782b233d97a254fc41c1c887eb Mon Sep 17 00:00:00 2001 From: Paul Eggert 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 --------------1AF189D857A98726FAF3427F--