Fix build

This commit is contained in:
Alexey Milovidov 2021-11-24 03:11:22 +03:00
parent 51ee8fdbb0
commit e59e833cc6
2 changed files with 26 additions and 16 deletions

View File

@ -11,6 +11,30 @@
#include <linux/fs.h>
#endif
/// For old versions of libc.
#if !defined(RENAME_NOREPLACE)
#define RENAME_NOREPLACE 1
#endif
#if !defined(RENAME_EXCHANGE)
#define RENAME_EXCHANGE 2
#endif
#if !defined(__NR_renameat2)
#if defined(__x86_64__)
#define __NR_renameat2 316
#elif defined(__aarch64__)
#define __NR_renameat2 276
#elif defined(__ppc64__)
#define __NR_renameat2 357
#elif defined(__riscv)
#define __NR_renameat2 276
#else
#error "Unsupported architecture"
#endif
#endif
namespace fs = std::filesystem;
namespace DB
@ -27,17 +51,11 @@ namespace ErrorCodes
static bool supportsRenameat2Impl()
{
#if defined(__NR_renameat2)
VersionNumber renameat2_minimal_version(3, 15, 0);
VersionNumber linux_version(Poco::Environment::osVersion());
return linux_version >= renameat2_minimal_version;
#else
return false;
#endif
}
#if defined(__NR_renameat2)
static bool renameat2(const std::string & old_path, const std::string & new_path, int flags)
{
if (!supportsRenameat2())
@ -69,16 +87,6 @@ static bool renameat2(const std::string & old_path, const std::string & new_path
throwFromErrnoWithPath("Cannot rename " + old_path + " to " + new_path, new_path, ErrorCodes::SYSTEM_ERROR);
}
#else
#define RENAME_NOREPLACE -1
#define RENAME_EXCHANGE -1
static bool renameat2(const std::string &, const std::string &, int)
{
return false;
}
#endif
static void renameNoReplaceFallback(const std::string & old_path, const std::string & new_path)
{

View File

@ -30,6 +30,8 @@
#define SYS_preadv2 286
#elif defined(__ppc64__)
#define SYS_preadv2 380
#elif defined(__riscv)
#define SYS_preadv2 286
#else
#error "Unsupported architecture"
#endif