]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tail: disable inotify with only non existent files
authorPádraig Brady <P@draigBrady.com>
Tue, 19 Jan 2016 13:22:42 +0000 (13:22 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 19 Jan 2016 14:07:10 +0000 (14:07 +0000)
tests/tail-2/F-headers.sh and test/tail-2/retry.sh fail on
on remote file systems due to tail going into inotify mode
due to not being able to determine the remoteness of the
non existent files.

* src/tail.c (any_non_remote_file): A new function used
to disable inotify when there are no open files, as
we can't determine remoteness in that case.
* NEWS: Mention the bug fix.

NEWS
src/tail.c

diff --git a/NEWS b/NEWS
index 45ee103a91c8868809f8047661f67b3f02c89525..5983ead1973fc921b665e01f76d8c9c9b85b76d0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   that specify an offset for the first field.
   [bug introduced with the --debug feature in coreutils-8.6]
 
+  tail -F now works with initially non existent files on a remote file system.
+  [bug introduced in coreutils-7.5]
+
 ** New commands
 
   base32 is added to complement the existing base64 command,
index 781adf200df150b295e8a559373fb2698aaa5e44..2a72a93f0e1d9dba8c59b1ebd3a30afbf70d673a 100644 (file)
@@ -1270,6 +1270,20 @@ any_remote_file (const struct File_spec *f, size_t n_files)
   return false;
 }
 
+/* Return true if any of the N_FILES files in F is non remote, i.e., has
+   an open file descriptor and is not on a network file system.  */
+
+static bool
+any_non_remote_file (const struct File_spec *f, size_t n_files)
+{
+  size_t i;
+
+  for (i = 0; i < n_files; i++)
+    if (0 <= f[i].fd && ! f[i].remote)
+      return true;
+  return false;
+}
+
 /* Return true if any of the N_FILES files in F is a symlink.
    Note we don't worry about the edge case where "-" exists,
    since that will have the same consequences for inotify,
@@ -2313,6 +2327,11 @@ main (int argc, char **argv)
          in this case because it would miss any updates to the file
          that were not initiated from the local system.
 
+         any_non_remote_file() checks if the user has specified any
+         files that don't reside on remote file systems.  inotify is not used
+         if there are no open files, as we can't determine if those file
+         will be on a remote file system.
+
          any_symlinks() checks if the user has specified any symbolic links.
          inotify is not used in this case because it returns updated _targets_
          which would not match the specified names.  If we tried to always
@@ -2339,6 +2358,7 @@ main (int argc, char **argv)
          for one name when a name is specified multiple times.  */
       if (!disable_inotify && (tailable_stdin (F, n_files)
                                || any_remote_file (F, n_files)
+                               || ! any_non_remote_file (F, n_files)
                                || any_symlinks (F, n_files)
                                || (!ok && follow_mode == Follow_descriptor)))
         disable_inotify = true;