diff options
Diffstat (limited to 'coreutils/tail.c')
-rw-r--r-- | coreutils/tail.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/coreutils/tail.c b/coreutils/tail.c index e3f89d2ee..d49539916 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c | |||
@@ -79,7 +79,19 @@ static void tail_xbb_full_write(const char *buf, size_t len) | |||
79 | static ssize_t tail_read(int fd, char *buf, size_t count) | 79 | static ssize_t tail_read(int fd, char *buf, size_t count) |
80 | { | 80 | { |
81 | ssize_t r; | 81 | ssize_t r; |
82 | off_t current,end; | ||
83 | struct stat sbuf; | ||
84 | int ret; | ||
82 | 85 | ||
86 | end = current = lseek (fd, 0, SEEK_CUR); | ||
87 | if (!fstat(fd, &sbuf)){ | ||
88 | end = sbuf.st_size; | ||
89 | } | ||
90 | if ( end < current) { | ||
91 | lseek(fd, 0, SEEK_SET); | ||
92 | } else { | ||
93 | lseek(fd, current, SEEK_SET); | ||
94 | } | ||
83 | if ((r = safe_read(fd, buf, count)) < 0) { | 95 | if ((r = safe_read(fd, buf, count)) < 0) { |
84 | bb_perror_msg("read"); | 96 | bb_perror_msg("read"); |
85 | status = EXIT_FAILURE; | 97 | status = EXIT_FAILURE; |