Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Nov 1999 14:55:41 -0500 (EST)
From:      chris@netmonger.net
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/14786: tail breaks on large files
Message-ID:  <199911081955.OAA11086@gouda.netmonger.net>

next in thread | raw e-mail | index | archive | help

>Number:         14786
>Category:       bin
>Synopsis:       tail breaks on large files
>Confidential:   yes
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov  8 12:00:01 PST 1999
>Closed-Date:
>Last-Modified:
>Originator:     Christopher Masto
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:


>Description:

mmap() doesn't work on files >2GB as documented in its man page.

The following code is in /usr/src/usr.bin/tail/forward.c:

        if ((start = mmap(NULL, (size_t)size,
            PROT_READ, MAP_SHARED, fileno(fp), (off_t)0)) == MAP_FAILED) {
                ierr();
                return;
        }

Unfortunately, after returning from the rlines function which contains
that code, tail attempts to display any data that has come in "since
we read the file".  In this case, the file has not been read and tail
spits out the entire contents of the file.

>How-To-Repeat:

$ tail <file-larger-than-2GB>

>Fix:
	
Probably one of:

  * Detect sizes > mmap()'s limit and exit with an appropriate message.
  * Dump out when mmap() fails.
  * Use a more complicated algorithm that can handle large files.

>Release-Note:
>Audit-Trail:
>Unformatted:


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?199911081955.OAA11086>