]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tail: fix support for -F with non seekable files
authorPádraig Brady <P@draigBrady.com>
Mon, 30 Jan 2023 21:44:10 +0000 (21:44 +0000)
committerPádraig Brady <P@draigBrady.com>
Mon, 6 Feb 2023 16:18:12 +0000 (16:18 +0000)
This was seen to be an issue when following a
symlink that was being updated to point to
different underlying devices.

* src/tail.c (recheck): Guard the lseek() call to only
be performed for regular files.
* NEWS: Mention the bug fix.

NEWS
src/tail.c

diff --git a/NEWS b/NEWS
index 27334a595cfc65b0cee73ea362dd4149a032a771..eb8380e117666ad08048133a24622db893a22fd5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -52,6 +52,10 @@ GNU coreutils NEWS                                    -*- outline -*-
   Previously it may have output 1 character too wide for certain widths.
   [bug introduced in coreutils-5.3]
 
+  tail --follow=name works again with non seekable files.  Previously it
+  exited with an "Illegal seek" error when such a file was replaced.
+  [bug introduced in fileutils-4.1.6]
+
   `wc -c` will again efficiently determine the size of large files
   on all systems.  It no longer redundantly reads data from certain
   sized files larger than SIZE_MAX.
index 2244509dd7e13164a172d9080213474cc9df42aa..03061e8bf7a3bc597826959e942d9bf12bcc8ece 100644 (file)
@@ -1122,7 +1122,8 @@ recheck (struct File_spec *f, bool blocking)
     {
       /* Start at the beginning of the file.  */
       record_open_fd (f, fd, 0, &new_stats, (is_stdin ? -1 : blocking));
-      xlseek (fd, 0, SEEK_SET, pretty_name (f));
+      if (S_ISREG (new_stats.st_mode))
+        xlseek (fd, 0, SEEK_SET, pretty_name (f));
     }
 }