From owner-freebsd-bugs Sat Nov 3 0:50: 8 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 157DE37B40B for ; Sat, 3 Nov 2001 00:50:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id fA38o2f55553; Sat, 3 Nov 2001 00:50:02 -0800 (PST) (envelope-from gnats) Date: Sat, 3 Nov 2001 00:50:02 -0800 (PST) Message-Id: <200111030850.fA38o2f55553@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Maxim Konovalov Subject: Re: bin/24955:/usr/bin/tail -F in 4.1+ doesn't work if file inode changes (works in 4.0) Reply-To: Maxim Konovalov Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR bin/24955; it has been noted by GNATS. From: Maxim Konovalov 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