git: 4feeca3193c3 - main - tail(1): Fix -r (reverse) to work on pseudo filesystems
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 26 Apr 2026 21:02:05 UTC
The branch main has been updated by pouria:
URL: https://cgit.FreeBSD.org/src/commit/?id=4feeca3193c316c18472cd40f215446fda3bd739
commit 4feeca3193c316c18472cd40f215446fda3bd739
Author: Aaron LI <aly@aaronly.me>
AuthorDate: 2026-03-17 04:53:49 +0000
Commit: Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-04-26 20:54:52 +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
---
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 1fa8784dec6d..690101c0b803 100644
--- a/usr.bin/tail/reverse.c
+++ b/usr.bin/tail/reverse.c
@@ -78,7 +78,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) {