]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tail: simplify -c+ on regular files
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 23 Jul 2025 05:05:17 +0000 (22:05 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 Aug 2025 02:48:04 +0000 (19:48 -0700)
* 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.

src/tail.c

index ac66c9aa502376a9c9ce575398be635961cfb542..caf67a0500c30d6335bbdf045d0664eb08359fa9 100644 (file)
@@ -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
         {