Re: [PATCH 11/16] tailf: check printing criteria more carefully

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux