Re: [PATCH 12/16] tailf: count last lines correctly at initial print out

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

 



On Sun, Feb 22, 2015 at 02:41:42PM +0000, Sami Kerola wrote:
> When last lines happen to be greater than string buffer size for fgets()
> the number of printed lines resulted to too few.

 Maybe add a note about mmap() to commit message ?!

> -	if (!(str = fopen(filename, "r")))
> +	if (!(fd = open(filename, O_RDONLY)))
>  		err(EXIT_FAILURE, _("cannot open %s"), filename);
> -
> -	buf = xmalloc((lines ? lines : 1) * BUFSIZ);
> -	p = buf;
> -	while (fgets(p, BUFSIZ, str)) {
> -		if (++tail >= lines) {
> -			tail = 0;
> -			head = 1;
> +	data = mmap(0, old->st_size, PROT_READ, MAP_SHARED, fd, 0);

 It would be nice to compare this it with original implementation on
 large files. I guess mmap will be more effective and faster.

    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