Date: Sat, 3 Nov 2001 00:50:02 -0800 (PST) From: Maxim Konovalov <maxim@macomnet.ru> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/24955:/usr/bin/tail -F in 4.1+ doesn't work if file inode changes (works in 4.0) Message-ID: <200111030850.fA38o2f55553@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/24955; it has been noted by GNATS.
From: Maxim Konovalov <maxim@macomnet.ru>
To: freebsd-gnats-submit@FreeBSD.org
Cc: kmarx@vicor-nb.com
Subject: Re: bin/24955:/usr/bin/tail -F in 4.1+ doesn't work if file inode
changes (works in 4.0)
Date: Sat, 3 Nov 2001 11:43:33 +0300 (MSK)
Hello,
Try this patch:
Index: forward.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/tail/forward.c,v
retrieving revision 1.27
diff -u -r1.27 forward.c
--- forward.c 1 Sep 2001 22:22:44 -0000 1.27
+++ forward.c 2 Nov 2001 21:46:27 -0000
@@ -94,10 +94,10 @@
off_t off;
struct stat *sbp;
{
- int ch, kq = -1;
+ int ch, dirfd, kq = -1;
int action = USE_SLEEP;
- struct kevent ev[2];
- struct stat sb2;
+ struct kevent ev[3];
+ struct stat sb2, sbl;
switch(style) {
case FBYTES:
@@ -179,6 +179,15 @@
action = ADD_EVENTS;
}
+ if (lstat(fname, &sbl) != -1) {
+ if ((sbl.st_mode & S_IFLNK) == S_IFLNK) {
+ dirfd = open((const char *)dirname(fname), O_RDONLY);
+ if (dirfd == -1)
+ err(1, "open");
+ }
+ } else
+ err(1, "lstat");
+
for (;;) {
while ((ch = getc(fp)) != EOF)
if (putchar(ch) == EOF)
@@ -202,6 +211,13 @@
EV_ADD | EV_ENABLE | EV_CLEAR,
NOTE_DELETE | NOTE_RENAME, 0, 0);
n++;
+
+ if ((sbl.st_mode & S_IFLNK) == S_IFLNK) {
+ EV_SET(&ev[n], dirfd, EVFILT_VNODE,
+ EV_ADD | EV_ENABLE | EV_CLEAR,
+ NOTE_WRITE, 0, 0);
+ n++;
+ }
}
EV_SET(&ev[n], fileno(fp), EVFILT_READ,
EV_ADD | EV_ENABLE | EV_CLEAR, 0, 0, 0);
--
Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer
phone: +7 (095) 796-9079, mailto: maxim@macomnet.ru
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200111030850.fA38o2f55553>
