git: f35e37750511 - stable/14 - tail(1): Fix -r (reverse) to work on pseudo filesystems
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 01 May 2026 19:21:15 UTC
The branch stable/14 has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=f35e377505110efcc6308567a38894628a16232f
commit f35e377505110efcc6308567a38894628a16232f
Author: Aaron LI <aly@aaronly.me>
AuthorDate: 2026-03-17 04:53:49 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-05-01 16:03:12 +0000
tail(1): Fix -r (reverse) to work on pseudo filesystems
Pseudo filesystems (e.g., procfs) advertise a zero file size.
Fix reverse() to handle such a case similarly as forward() so
that '-r' works on pseudo filesystems.
Signed-off-by: Aaron LI <aly@aaronly.me>
Reviewed by: pouria, Ricardo Branco <rbranco@suse.de>, des
Fixes: 1fb3caee7 ("tail: Do not trust st_size if it equals zero.")
Pull-Request: https://github.com/freebsd/freebsd-src/pull/2080
(cherry picked from commit 4feeca3193c316c18472cd40f215446fda3bd739)
---
usr.bin/tail/reverse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/usr.bin/tail/reverse.c b/usr.bin/tail/reverse.c
index 67d27d487d1c..52e423a8cc08 100644
--- a/usr.bin/tail/reverse.c
+++ b/usr.bin/tail/reverse.c
@@ -85,7 +85,7 @@ reverse(FILE *fp, const char *fn, enum STYLE style, off_t off, struct stat *sbp)
if (style != REVERSE && off == 0)
return;
- if (S_ISREG(sbp->st_mode))
+ if (S_ISREG(sbp->st_mode) && sbp->st_size > 0)
r_reg(fp, fn, style, off, sbp);
else
switch(style) {