aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2025-07-22 22:05:17 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2025-08-03 19:48:04 -0700
commitc667ca229f3bed2b6d2ea16312f607d8d385e4c3 (patch)
tree2d1a1bac50ee9a7fae53a0064350ee82043be77b
parentmaint: don’t lseek memory objects (diff)
downloadcoreutils-c667ca229f3bed2b6d2ea16312f607d8d385e4c3.tar.gz
coreutils-c667ca229f3bed2b6d2ea16312f607d8d385e4c3.zip
tail: simplify -c+ on regular files
* src/tail.c (tail_bytes): Simplify the -c+N case by treating regular files like other files; if the lseek fails for whatever reason, fall back on the unoptimized version instead of reporting a fatal error.
-rw-r--r--src/tail.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/tail.c b/src/tail.c
index ac66c9aa5..caf67a050 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -1858,9 +1858,7 @@ tail_bytes (char const *pretty_filename, int fd, uintmax_t n_bytes,
if (from_start)
{
if (! presume_input_pipe && n_bytes <= OFF_T_MAX
- && ((S_ISREG (stats.st_mode)
- && xlseek (fd, n_bytes, SEEK_CUR, pretty_filename) >= 0)
- || lseek (fd, n_bytes, SEEK_CUR) != -1))
+ && 0 <= lseek (fd, n_bytes, SEEK_CUR))
*read_pos += n_bytes;
else
{