From 88c30618d512864adab0733b58dd5f48b7f98f74 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Jun 2017 14:27:48 -0700 Subject: QFileSystemEngine::renameFile: use calls that don't overwrite The renameat2(2) Linux system call, new in 3.16, allows for the atomic renaming of a file if and only if it won't clobber an existing file. None of the Linux libcs have enabled this syscall as an API, so we use syscall(3) to place the call. If your libc has SYS_renameat2 but your kernel doesn't support it, we'll keep issuing the unknown syscall, every time. Users in that situation should upgrade (3.16 is from 2014). On Darwin, there's a similar renameatx_np (guessing "np" stands for "non-portable"). I haven't found anything similar on the other BSDs. Change-Id: I1eba2b016de74620bfc8fffd14ccb4e455a3ec9e Reviewed-by: David Faure --- src/corelib/configure.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/corelib/configure.json') diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 44d6ccfdf5..61fc2e16c9 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -379,6 +379,15 @@ ] } }, + "renameat2": { + "label": "renameat2()", + "type": "compile", + "test": { + "head": "#define _ATFILE_SOURCE 1", + "include": [ "fcntl.h", "stdio.h" ], + "main": "renameat2(AT_FDCWD, argv[1], AT_FDCWD, argv[2], RENAME_NOREPLACE | RENAME_WHITEOUT);" + } + }, "syslog": { "label": "syslog", "type": "compile", @@ -576,6 +585,11 @@ "condition": "features.statemachine", "output": [ "publicFeature" ] }, + "renameat2": { + "label": "renameat2()", + "condition": "config.linux && tests.renameat2", + "output": [ "privateFeature" ] + }, "slog2": { "label": "slog2", "condition": "libs.slog2", -- cgit v1.2.3