Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
0642ce47
Commit
0642ce47
authored
Aug 21, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/io/FileOutputStream: make linkat() mandatory on Linux
parent
d11e1d58
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
11 deletions
+7
-11
configure.ac
configure.ac
+0
-4
FileOutputStream.cxx
src/fs/io/FileOutputStream.cxx
+6
-6
FileOutputStream.hxx
src/fs/io/FileOutputStream.hxx
+1
-1
No files found.
configure.ac
View file @
0642ce47
...
...
@@ -240,10 +240,6 @@ fi
AC_SEARCH_LIBS([socket], [network socket])
AC_SEARCH_LIBS([gethostbyname], [nsl])
if test x$host_is_linux = xyes; then
AC_CHECK_FUNCS(linkat)
fi
AC_CHECK_FUNCS(getpwnam_r getpwuid_r)
AC_CHECK_FUNCS(initgroups)
AC_CHECK_FUNCS(fnmatch)
...
...
src/fs/io/FileOutputStream.cxx
View file @
0642ce47
...
...
@@ -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
());
...
...
src/fs/io/FileOutputStream.hxx
View file @
0642ce47
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment