diff options
Diffstat (limited to 'arch/um/os-Linux/mem.c')
-rw-r--r-- | arch/um/os-Linux/mem.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c index 897e9ad0c108..8b1767668515 100644 --- a/arch/um/os-Linux/mem.c +++ b/arch/um/os-Linux/mem.c | |||
@@ -106,6 +106,17 @@ static int __init make_tempfile(const char *template) | |||
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | #ifdef O_TMPFILE | ||
110 | fd = open(tempdir, O_CLOEXEC | O_RDWR | O_EXCL | O_TMPFILE, 0700); | ||
111 | /* | ||
112 | * If the running system does not support O_TMPFILE flag then retry | ||
113 | * without it. | ||
114 | */ | ||
115 | if (fd != -1 || (errno != EINVAL && errno != EISDIR && | ||
116 | errno != EOPNOTSUPP)) | ||
117 | return fd; | ||
118 | #endif | ||
119 | |||
109 | tempname = malloc(strlen(tempdir) + strlen(template) + 1); | 120 | tempname = malloc(strlen(tempdir) + strlen(template) + 1); |
110 | if (tempname == NULL) | 121 | if (tempname == NULL) |
111 | return -1; | 122 | return -1; |
@@ -142,12 +153,6 @@ static int __init create_tmp_file(unsigned long long len) | |||
142 | if (fd < 0) | 153 | if (fd < 0) |
143 | exit(1); | 154 | exit(1); |
144 | 155 | ||
145 | err = fchmod(fd, 0777); | ||
146 | if (err < 0) { | ||
147 | perror("fchmod"); | ||
148 | exit(1); | ||
149 | } | ||
150 | |||
151 | /* | 156 | /* |
152 | * Seek to len - 1 because writing a character there will | 157 | * Seek to len - 1 because writing a character there will |
153 | * increase the file size by one byte, to the desired length. | 158 | * increase the file size by one byte, to the desired length. |