diff options
author | Max Kellermann <max@musicpd.org> | 2018-08-21 18:59:03 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-08-21 19:02:03 +0200 |
commit | 0642ce4795583ac264dfb85c13ef7ab0938067ba (patch) | |
tree | 016c65f264136323dc77873431e20298e0a62177 /src/fs | |
parent | d11e1d588076a88299e638e675d73c566384b587 (diff) |
fs/io/FileOutputStream: make linkat() mandatory on Linux
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/io/FileOutputStream.cxx | 12 | ||||
-rw-r--r-- | src/fs/io/FileOutputStream.hxx | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/fs/io/FileOutputStream.cxx b/src/fs/io/FileOutputStream.cxx index 67b9318af..f76a44e5d 100644 --- a/src/fs/io/FileOutputStream.cxx +++ b/src/fs/io/FileOutputStream.cxx @@ -138,7 +138,7 @@ FileOutputStream::Cancel() noexcept #include <unistd.h> #include <errno.h> -#ifdef HAVE_LINKAT +#ifdef __linux__ #ifndef O_TMPFILE /* supported since Linux 3.11 */ #define __O_TMPFILE 020000000 @@ -159,12 +159,12 @@ OpenTempFile(FileDescriptor &fd, Path path) return fd.Open(directory.c_str(), O_TMPFILE|O_WRONLY, 0666); } -#endif /* HAVE_LINKAT */ +#endif /* __linux__ */ inline void FileOutputStream::OpenCreate(bool visible) { -#ifdef HAVE_LINKAT +#ifdef __linux__ /* try Linux's O_TMPFILE first */ is_tmpfile = !visible && OpenTempFile(fd, GetPath()); if (!is_tmpfile) { @@ -175,7 +175,7 @@ FileOutputStream::OpenCreate(bool visible) 0666)) throw FormatErrno("Failed to create %s", GetPath().c_str()); -#ifdef HAVE_LINKAT +#ifdef __linux__ } #else (void)visible; @@ -218,7 +218,7 @@ FileOutputStream::Commit() { assert(IsDefined()); -#ifdef HAVE_LINKAT +#ifdef __linux__ if (is_tmpfile) { unlink(GetPath().c_str()); @@ -251,7 +251,7 @@ FileOutputStream::Cancel() noexcept switch (mode) { case Mode::CREATE: -#ifdef HAVE_LINKAT +#ifdef __linux__ if (!is_tmpfile) #endif unlink(GetPath().c_str()); diff --git a/src/fs/io/FileOutputStream.hxx b/src/fs/io/FileOutputStream.hxx index d96e044d5..9dfea4019 100644 --- a/src/fs/io/FileOutputStream.hxx +++ b/src/fs/io/FileOutputStream.hxx @@ -57,7 +57,7 @@ class FileOutputStream final : public OutputStream { FileDescriptor fd = FileDescriptor::Undefined(); #endif -#ifdef HAVE_LINKAT +#ifdef __linux__ /** * Was O_TMPFILE used? If yes, then linkat() must be used to * create a link to this file. |