GNU bug report logs -
#29259
tail does not seek to the end of block device
Previous Next
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
Message #14 received at 29259 <at> debbugs.gnu.org (full text, mbox):
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.