From 464be62df69151c73a387a4e7266b0755f563f2e Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?= Date: Tue, 18 Jul 2023 18:55:30 +0100 Subject: [PATCH] split: honor $TMPDIR for temp files * bootstrap.conf: Depend on tmpdir rather than tmpfile, as the standard tmpfile() doesn't honor $TMPDIR. * src/split.c (copy_to_tmpfile): Adjust to call temp_stream() rather than tmpfile(); * NEWS: Mention the improvement. --- NEWS | 2 ++ bootstrap.conf | 2 +- src/local.mk | 1 + src/split.c | 5 +++-- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 2708371c6..7d2ca7f6b 100644 --- a/NEWS +++ b/NEWS @@ -68,6 +68,8 @@ GNU coreutils NEWS -*- outline -*- split now uses more tuned access patterns for its potentially large input. This was seen to improve throughput by 5% when reading from SSD. + split now supports a configurable $TMPDIR for handling any temporary files. + tac now falls back to '/tmp' if a configured $TMPDIR is unavailable. diff --git a/bootstrap.conf b/bootstrap.conf index aaec1fb03..6ce27d5dd 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -274,7 +274,7 @@ gnulib_modules=" time_rz timer-time timespec - tmpfile + tmpdir tzset uname unicodeio diff --git a/src/local.mk b/src/local.mk index dd50ba7ae..cb9b39274 100644 --- a/src/local.mk +++ b/src/local.mk @@ -396,6 +396,7 @@ src_arch_SOURCES = src/uname.c src/uname-arch.c src_cut_SOURCES = src/cut.c src/set-fields.c src_numfmt_SOURCES = src/numfmt.c src/set-fields.c +src_split_SOURCES = src/split.c src/temp-stream.c src_tac_SOURCES = src/tac.c src/temp-stream.c src_tail_SOURCES = src/tail.c src/iopoll.c diff --git a/src/split.c b/src/split.c index bfe391728..cf776364c 100644 --- a/src/split.c +++ b/src/split.c @@ -40,6 +40,7 @@ #include "quote.h" #include "sig2str.h" #include "sys-limits.h" +#include "temp-stream.h" #include "xbinary-io.h" #include "xdectoint.h" #include "xstrtol.h" @@ -279,8 +280,8 @@ CHUNKS may be:\n\ static off_t copy_to_tmpfile (int fd, char *buf, idx_t bufsize) { - FILE *tmp = tmpfile (); - if (!tmp) + FILE *tmp; + if (!temp_stream (&tmp, nullptr)) return -1; off_t copied = 0; off_t r; -- 2.11.4.GIT