mirror of
https://github.com/systemd/systemd.git
synced 2024-10-30 06:25:37 +03:00
Merge pull request #4052 from yann-morin-1998/yem/o-tmpfile
importd: fix build failure with missing O_TMPFILE (branch yem/o-tmpfile)
This commit is contained in:
commit
4a13100c6a
@ -37,6 +37,7 @@
|
||||
#include "hexdecoct.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "missing.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "random-util.h"
|
||||
@ -1280,12 +1281,10 @@ int open_tmpfile_unlinkable(const char *directory, int flags) {
|
||||
|
||||
/* Returns an unlinked temporary file that cannot be linked into the file system anymore */
|
||||
|
||||
#ifdef O_TMPFILE
|
||||
/* Try O_TMPFILE first, if it is supported */
|
||||
fd = open(directory, flags|O_TMPFILE|O_EXCL, S_IRUSR|S_IWUSR);
|
||||
if (fd >= 0)
|
||||
return fd;
|
||||
#endif
|
||||
|
||||
/* Fall back to unguessable name + unlinking */
|
||||
p = strjoina(directory, "/systemd-tmp-XXXXXX");
|
||||
@ -1313,7 +1312,6 @@ int open_tmpfile_linkable(const char *target, int flags, char **ret_path) {
|
||||
* which case "ret_path" will be returned as NULL. If not possible a the tempoary path name used is returned in
|
||||
* "ret_path". Use link_tmpfile() below to rename the result after writing the file in full. */
|
||||
|
||||
#ifdef O_TMPFILE
|
||||
{
|
||||
_cleanup_free_ char *dn = NULL;
|
||||
|
||||
@ -1329,7 +1327,6 @@ int open_tmpfile_linkable(const char *target, int flags, char **ret_path) {
|
||||
|
||||
log_debug_errno(errno, "Failed to use O_TMPFILE on %s: %m", dn);
|
||||
}
|
||||
#endif
|
||||
|
||||
r = tempfn_random(target, NULL, &tmp);
|
||||
if (r < 0)
|
||||
|
@ -537,12 +537,21 @@ struct btrfs_ioctl_quota_ctl_args {
|
||||
# define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f)
|
||||
#endif
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
|
||||
/* The precise definition of __O_TMPFILE is arch specific, so let's
|
||||
* just define this on x86 where we know the value. */
|
||||
/* The precise definition of __O_TMPFILE is arch specific; use the
|
||||
* values defined by the kernel (note: some are hexa, some are octal,
|
||||
* duplicated as-is from the kernel definitions):
|
||||
* - alpha, parisc, sparc: each has a specific value;
|
||||
* - others: they use the "generic" value.
|
||||
*/
|
||||
|
||||
#ifndef __O_TMPFILE
|
||||
#if defined(__alpha__)
|
||||
#define __O_TMPFILE 0100000000
|
||||
#elif defined(__parisc__) || defined(__hppa__)
|
||||
#define __O_TMPFILE 0400000000
|
||||
#elif defined(__sparc__) || defined(__sparc64__)
|
||||
#define __O_TMPFILE 0x2000000
|
||||
#else
|
||||
#define __O_TMPFILE 020000000
|
||||
#endif
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "import-common.h"
|
||||
#include "missing.h"
|
||||
#include "ratelimit.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
|
Loading…
Reference in New Issue
Block a user