Module Name: src Committed By: christos Date: Sun Jan 14 17:37:32 UTC 2024
Modified Files: src/usr.bin/tail: forward.c Log Message: PR/57850: Ricardo Branco: tail does not work in some pseudo-filesystems >From FreeBSD: https://github.com/NetBSD/src/pull/20 To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/usr.bin/tail/forward.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/tail/forward.c diff -u src/usr.bin/tail/forward.c:1.33 src/usr.bin/tail/forward.c:1.34 --- src/usr.bin/tail/forward.c:1.33 Fri Oct 9 13:51:26 2015 +++ src/usr.bin/tail/forward.c Sun Jan 14 12:37:32 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: forward.c,v 1.33 2015/10/09 17:51:26 christos Exp $ */ +/* $NetBSD: forward.c,v 1.34 2024/01/14 17:37:32 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)forward.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: forward.c,v 1.33 2015/10/09 17:51:26 christos Exp $"); +__RCSID("$NetBSD: forward.c,v 1.34 2024/01/14 17:37:32 christos Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -96,7 +96,7 @@ forward(FILE *fp, enum STYLE style, off_ case FBYTES: if (off == 0) break; - if (S_ISREG(sbp->st_mode)) { + if (S_ISREG(sbp->st_mode) && sbp->st_size > 0) { if (sbp->st_size < off) off = sbp->st_size; if (fseeko(fp, off, SEEK_SET) == -1) { @@ -128,7 +128,7 @@ forward(FILE *fp, enum STYLE style, off_ } break; case RBYTES: - if (S_ISREG(sbp->st_mode)) { + if (S_ISREG(sbp->st_mode) && sbp->st_size > 0) { if (sbp->st_size >= off && fseeko(fp, -off, SEEK_END) == -1) { ierr(); @@ -146,7 +146,7 @@ forward(FILE *fp, enum STYLE style, off_ } break; case RLINES: - if (S_ISREG(sbp->st_mode)) { + if (S_ISREG(sbp->st_mode) && sbp->st_size > 0) { if (!off) { if (fseek(fp, 0L, SEEK_END) == -1) { ierr();