]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
split: honor $TMPDIR for temp files
authorPádraig Brady <P@draigBrady.com>
Tue, 18 Jul 2023 17:55:30 +0000 (18:55 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 18 Jul 2023 22:11:24 +0000 (23:11 +0100)
* 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
bootstrap.conf
src/local.mk
src/split.c

diff --git a/NEWS b/NEWS
index 2708371c6b07ee1cdde1a2d0f295377d2bb4d9f4..7d2ca7f6b575dc0d8b8cf25e8312f7d8fba13cd1 100644 (file)
--- 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.
 
 
index aaec1fb03a62e8955f2f8081c5244bc8e8691297..6ce27d5dd23a33f8a5effa6ee5d127ef92380d43 100644 (file)
@@ -274,7 +274,7 @@ gnulib_modules="
   time_rz
   timer-time
   timespec
-  tmpfile
+  tmpdir
   tzset
   uname
   unicodeio
index dd50ba7aef3f93e0a45a281d1df8f358ff20e137..cb9b392743c4722846669041ceab5d4b87e088c5 100644 (file)
@@ -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
index bfe391728b5c57f6946a7173858d5ec40a1c8fea..cf776364cd2e450dcc72eb24b94a6267da68074b 100644 (file)
@@ -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;