aboutsummaryrefslogtreecommitdiff
path: root/busybox/coreutils/tail.c
diff options
context:
space:
mode:
Diffstat (limited to 'busybox/coreutils/tail.c')
-rw-r--r--busybox/coreutils/tail.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/busybox/coreutils/tail.c b/busybox/coreutils/tail.c
index e3f89d2ee..1db1e2b0f 100644
--- a/busybox/coreutils/tail.c
+++ b/busybox/coreutils/tail.c
@@ -79,7 +79,13 @@ static void tail_xbb_full_write(const char *buf, size_t len)
79static ssize_t tail_read(int fd, char *buf, size_t count) 79static 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;
82 84
85 end = current = lseek(fd, 0, SEEK_CUR);
86 if (!fstat(fd, &sbuf))
87 end = sbuf.st_size;
88 lseek(fd, end < current ? 0 : current, SEEK_SET);
83 if ((r = safe_read(fd, buf, count)) < 0) { 89 if ((r = safe_read(fd, buf, count)) < 0) {
84 bb_perror_msg("read"); 90 bb_perror_msg("read");
85 status = EXIT_FAILURE; 91 status = EXIT_FAILURE;