[prev in list] [next in list] [prev in thread] [next in thread] 

List:       util-linux-ng
Subject:    Re: [PATCH 11/16] tailf: check printing criteria more carefully
From:       Karel Zak <kzak () redhat ! com>
Date:       2015-02-24 11:53:22
Message-ID: 20150224115322.GM19430 () ws ! net ! home
[Download RAW message or body]

On Sun, Feb 22, 2015 at 02:41:41PM +0000, Sami Kerola wrote:
> -	if (lseek(fd, *size, SEEK_SET) != (off_t)-1) {
> +	if (st.st_ino != old->st_ino || st.st_dev != old->st_dev
> +	    || (old->st_mtime < st.st_mtime && st.st_size <= old->st_size))
> +		old->st_size = 0;

 So.. if I remove (truncate) last line from 1GiB file then tailf will 
 print all the file *again*? Would be better to reset to st.st_size if the
 size is smaller than old->st_size?

 Or maybe if you want to support "echo 1 >| file" use case than add a
 new option (--rewind) or so.

> +	if (lseek(fd, old->st_size, SEEK_SET) != (off_t)-1) {
>  		ssize_t rc, wc;
>  
>  		while ((rc = read(fd, buf, sizeof(buf))) > 0) {
> @@ -123,16 +128,16 @@ roll_file(const char *filename, off_t *size)
>  	 * avoids data duplication. If we read nothing or hit an error, reset
>  	 * to the reported size, this handles truncated files.
>  	 */
> -	*size = (pos != -1 && pos != *size) ? pos : st.st_size;
> +	old->st_size = (pos != -1 && pos != old->st_size) ? pos : 0;

 This way how to reset seems better.

    Karel


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic