GNU bug report logs - #29259
tail does not seek to the end of block device

Previous Next

Package: coreutils;

Reported by: David Durham <daviddurham01 <at> gmail.com>

Date: Sat, 11 Nov 2017 20:30:02 UTC

Severity: normal

Tags: fixed

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Pádraig Brady <P <at> draigBrady.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>, David Durham <daviddurham01 <at> gmail.com>,  29259 <at> debbugs.gnu.org
Subject: bug#29259: tail does not seek to the end of block device
Date: Sun, 12 Nov 2017 22:21:14 -0800
On 12/11/17 21:52, Paul Eggert wrote:
> Why doesn't lseek work for this?

Good call, it probably would.
Something like the following is more acceptable
since it adds very little complexity:

diff --git a/src/tail.c b/src/tail.c
index 1c7418d..a10470b 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -1846,9 +1846,13 @@ tail_bytes (const char *pretty_filename, int fd, uintmax_
     }
   else
     {
-      off_t end_pos = ((! presume_input_pipe && usable_st_size (&stats)
-                        && n_bytes <= OFF_T_MAX)
-                       ? stats.st_size : -1);
+      off_t end_pos = -1;
+      if (! presume_input_pipe && n_bytes <= OFF_T_MAX)
+        {
+          end_pos = usable_st_size (&stats)
+                    ? stats.st_size
+                    : lseek (fd, n_bytes, SEEK_END);
+        }
       if (end_pos <= ST_BLKSIZE (stats))
         return pipe_bytes (pretty_filename, fd, n_bytes, read_pos);
       off_t current_pos = xlseek (fd, 0, SEEK_CUR, pretty_filename);





This bug report was last modified 6 years and 289 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.