summaryrefslogtreecommitdiff
path: root/src/sysdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index db99f53299c..22446b25d16 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -37,6 +37,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "sysselect.h"
#include "blockinput.h"
+#ifdef HAVE_LINUX_FS_H
+# include <linux/fs.h>
+# include <sys/syscall.h>
+#endif
+
#if defined DARWIN_OS || defined __FreeBSD__
# include <sys/sysctl.h>
#endif
@@ -2678,6 +2683,21 @@ set_file_times (int fd, const char *filename,
timespec[1] = mtime;
return fdutimens (fd, filename, timespec);
}
+
+/* Rename directory SRCFD's entry SRC to directory DSTFD's entry DST.
+ This is like renameat except that it fails if DST already exists,
+ or if this operation is not supported atomically. Return 0 if
+ successful, -1 (setting errno) otherwise. */
+int
+renameat_noreplace (int srcfd, char const *src, int dstfd, char const *dst)
+{
+#ifdef SYS_renameat2
+ return syscall (SYS_renameat2, srcfd, src, dstfd, dst, RENAME_NOREPLACE);
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+}
/* Like strsignal, except async-signal-safe, and this function typically
returns a string in the C locale rather than the current locale. */