texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: install-info atomic dir update


From: Gavin D. Smith
Subject: branch master updated: install-info atomic dir update
Date: Fri, 18 Aug 2023 06:43:29 -0400

This is an automated email from the git hooks/post-receive script.

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new ebc2d42b34 install-info atomic dir update
ebc2d42b34 is described below

commit ebc2d42b347ae15f045127f7b71e2a4cc05f6526
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Fri Aug 18 11:43:22 2023 +0100

    install-info atomic dir update
    
    * install-info/install-info.c (output_dirfile):
    Get name of temp file by appending to dir file name.  This
    ensures that the temporary file is in the same directory and
    thus on the same disk volume.  Report from Bruno Haible.
---
 ChangeLog                   |  9 +++++++++
 install-info/install-info.c | 16 ++++++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1db7bd0783..8618edb27d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-08-18  Gavin Smith <gavinsmith0123@gmail.com>
+
+       install-info atomic dir update
+
+       * install-info/install-info.c (output_dirfile):
+       Get name of temp file by appending to dir file name.  This
+       ensures that the temporary file is in the same directory and
+       thus on the same disk volume.  Report from Bruno Haible.
+
 2023-08-18  Gavin Smith <gavinsmith0123@gmail.com>
 
        * install-info/install-info.c (output_dirfile):
diff --git a/install-info/install-info.c b/install-info/install-info.c
index d14b23215f..dbcc6e24a0 100644
--- a/install-info/install-info.c
+++ b/install-info/install-info.c
@@ -925,8 +925,20 @@ output_dirfile (char *dirfile, int dir_nlines, struct 
line_data *dir_lines,
   int n_entries_added = 0;
   int i;
   FILE *output;
-  int tempfile; /* moved to dirfile when finished */
-  char tempname[] = "infodirXXXXXX";
+  int tempfile;
+  static char *tempname;
+  int dirfile_len;
+
+  /* Create temporary file in the same directory as dirfile.  This ensures
+     it is on the same disk volume and can be renamed to dirfile when
+     finished. */
+  free (tempname);
+#define suffix "-XXXXXX"
+  dirfile_len = strlen (dirfile);
+  tempname = xmalloc (dirfile_len + strlen (suffix) + 1);
+  memcpy (tempname, dirfile, dirfile_len);
+  memcpy (tempname + dirfile_len, suffix, strlen (suffix) + 1);
+#undef suffix
 
   tempfile = mkstemp (tempname);
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]