From 8e33886ec582336564ae11b80023abe93d7599c0 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sat, 25 Jan 2014 20:48:01 -0500 Subject: Replace mkostemp+unlink with open(O_TMPFILE) This will only work on Linux >= 3.11, and probably not on all filesystems. Fallback code is provided. --- src/journal/journal-verify.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/journal/journal-verify.c') diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c index f2422ff841..9434cc925c 100644 --- a/src/journal/journal-verify.c +++ b/src/journal/journal-verify.c @@ -785,9 +785,6 @@ int journal_file_verify( uint64_t n_weird = 0, n_objects = 0, n_entries = 0, n_data = 0, n_fields = 0, n_data_hash_tables = 0, n_field_hash_tables = 0, n_entry_arrays = 0, n_tags = 0; usec_t last_usec = 0; int data_fd = -1, entry_fd = -1, entry_array_fd = -1; - char data_path[] = "/var/tmp/journal-data-XXXXXX", - entry_path[] = "/var/tmp/journal-entry-XXXXXX", - entry_array_path[] = "/var/tmp/journal-entry-array-XXXXXX"; unsigned i; bool found_last; #ifdef HAVE_GCRYPT @@ -808,29 +805,26 @@ int journal_file_verify( } else if (f->seal) return -ENOKEY; - data_fd = mkostemp(data_path, O_CLOEXEC); + data_fd = open_tmpfile("/var/tmp", O_RDWR | O_CLOEXEC); if (data_fd < 0) { log_error("Failed to create data file: %m"); r = -errno; goto fail; } - unlink(data_path); - entry_fd = mkostemp(entry_path, O_CLOEXEC); + entry_fd = open_tmpfile("/var/tmp", O_RDWR | O_CLOEXEC); if (entry_fd < 0) { log_error("Failed to create entry file: %m"); r = -errno; goto fail; } - unlink(entry_path); - entry_array_fd = mkostemp(entry_array_path, O_CLOEXEC); + entry_array_fd = open_tmpfile("/var/tmp", O_RDWR | O_CLOEXEC); if (entry_array_fd < 0) { log_error("Failed to create entry array file: %m"); r = -errno; goto fail; } - unlink(entry_array_path); #ifdef HAVE_GCRYPT if ((le32toh(f->header->compatible_flags) & ~HEADER_COMPATIBLE_SEALED) != 0) -- cgit v1.2.3-54-g00ecf