all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: Paul Eggert <eggert@cs.ucla.edu>,
	Philipp Stephani <p.stephani2@gmail.com>,
	Eli Zaretskii <eliz@gnu.org>
Cc: 27986@debbugs.gnu.org
Subject: bug#27986: 26.0.50; 'rename-file' can rename files without confirmation
Date: Sat, 19 Aug 2017 17:30:01 -0400	[thread overview]
Message-ID: <0720ef94-7787-94e7-a44d-576ec7f75607@cornell.edu> (raw)
In-Reply-To: <6dbd21fd-d191-812a-5810-cb4fbcfbcb20@cornell.edu>

[-- Attachment #1: Type: text/plain, Size: 843 bytes --]

On 8/16/2017 3:33 PM, Ken Brown wrote:
> On 8/14/2017 7:03 PM, Paul Eggert wrote
>> Now that renameat_noreplace works on DOS_NT, would it make sense to 
>> apply the attached further patch as well? If we can get 
>> renameat_noreplace to work on Cygwin the we could simplify the 
>> fileio.c code even further.
> 
> I'm in the process of writing an implementation of something like 
> 'renameat2', which I'll submit to the Cygwin developers.

This is now done.  The implementation will appear in the next Cygwin 
release.  When that release occurs, I'll install something like the 
attached patch.

Question: Is the patch OK as is, or should I make the call to renameat2 
conditional on CYGWIN?  In other words, is it safe to assume that 
renameat2 is defined on any platform on which RENAME_NOREPLACE is 
defined but not SYS_renameat2?

Ken


[-- Attachment #2: 0001-Implement-renameat_noreplace-on-recent-Cygwin.patch --]
[-- Type: text/plain, Size: 1219 bytes --]

From b9ef4ca995350d1a520aba66de1d5e4209f3eb91 Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Sat, 19 Aug 2017 17:17:27 -0400
Subject: [PATCH] Implement renameat_noreplace on recent Cygwin

* src/sysdep.c [CYGWIN]: Include cygwin/fs.h.
(renameat_noreplace) [RENAME_NOREPLACE]: Use renameat2.
(Bug#27986)
---
 src/sysdep.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/sysdep.c b/src/sysdep.c
index 12e9c83ee9..77221097db 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -42,6 +42,10 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 # include <sys/syscall.h>
 #endif
 
+#ifdef CYGWIN
+# include <cygwin/fs.h>
+#endif
+
 #if defined DARWIN_OS || defined __FreeBSD__
 # include <sys/sysctl.h>
 #endif
@@ -2685,6 +2689,8 @@ renameat_noreplace (int srcfd, char const *src, int dstfd, char const *dst)
 {
 #if defined SYS_renameat2 && defined RENAME_NOREPLACE
   return syscall (SYS_renameat2, srcfd, src, dstfd, dst, RENAME_NOREPLACE);
+#elif defined RENAME_NOREPLACE	/* Cygwin >= 2.9.0. */
+  return renameat2 (srcfd, src, dstfd, dst, RENAME_NOREPLACE);
 #elif defined RENAME_EXCL
   return renameatx_np (srcfd, src, dstfd, dst, RENAME_EXCL);
 #else
-- 
2.14.1


  reply	other threads:[~2017-08-19 21:30 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-06 15:40 bug#27986: 26.0.50; `rename-file' can rename files without confirmation Philipp
2017-08-06 17:05 ` Eli Zaretskii
2017-08-14 17:09   ` Philipp Stephani
2017-08-14 17:22     ` Eli Zaretskii
2017-08-11  8:15 ` bug#27986: 26.0.50; 'rename-file' " Paul Eggert
2017-08-13 22:42   ` Paul Eggert
2017-08-14 15:40     ` Eli Zaretskii
2017-08-14 23:31       ` Paul Eggert
2017-08-15 16:04         ` Eli Zaretskii
2017-08-15 17:24           ` Paul Eggert
2017-08-15 17:42             ` Eli Zaretskii
2017-08-15 19:27               ` Paul Eggert
2017-08-16  2:36                 ` Eli Zaretskii
2017-08-16  5:06                   ` Paul Eggert
2017-08-16 14:21                     ` Eli Zaretskii
2017-08-16 15:15                       ` Paul Eggert
2017-08-16 16:06                         ` Eli Zaretskii
2017-08-16 17:19                           ` Paul Eggert
2017-08-16 17:30                             ` Eli Zaretskii
2017-08-16 18:06                               ` Glenn Morris
2017-08-16 22:31                               ` Stefan Monnier
2017-08-16 23:56                                 ` Paul Eggert
2017-08-17  0:04                                   ` Stefan Monnier
2017-08-19  6:54                                 ` Eli Zaretskii
2017-09-10 22:49                                   ` Paul Eggert
2017-09-11  6:07                                     ` Paul Eggert
2017-09-11 14:47                                       ` Eli Zaretskii
2017-09-11 16:45                                         ` Paul Eggert
2017-09-11 17:09                                           ` Eli Zaretskii
2017-09-11 17:25                                             ` Paul Eggert
2017-09-12  9:25                                       ` Michael Albinus
2017-08-13 23:48   ` Paul Eggert
2017-08-14 13:44     ` Ken Brown
2017-08-14 15:21       ` Eli Zaretskii
2017-08-14 15:34     ` Eli Zaretskii
2017-08-14 16:33       ` Eli Zaretskii
2017-08-14 16:58       ` Philipp Stephani
2017-08-14 17:04         ` Eli Zaretskii
2017-08-14 16:50     ` Philipp Stephani
2017-08-14 23:03       ` Paul Eggert
2017-08-15  1:19         ` Paul Eggert
2017-08-15  2:35         ` Eli Zaretskii
2017-08-15  7:00           ` Paul Eggert
2017-08-15 16:08             ` Eli Zaretskii
2017-08-16 19:33         ` Ken Brown
2017-08-19 21:30           ` Ken Brown [this message]
2017-08-19 21:37             ` Paul Eggert
2017-08-19 22:04               ` Ken Brown
2017-08-19 22:38                 ` Paul Eggert
2017-08-15 12:45 ` Andy Moreton
2017-08-15 16:18   ` Eli Zaretskii
2017-08-19 21:33 ` bug#27986: 26.0.50; 'rename-file' can rename files without Richard Stallman
2017-08-20  2:37   ` Eli Zaretskii
2017-08-25 20:33     ` John Wiegley
2017-08-26  7:30       ` Eli Zaretskii

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=0720ef94-7787-94e7-a44d-576ec7f75607@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=27986@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    --cc=p.stephani2@gmail.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.