From owner-freebsd-stable Thu Apr 12 14:42:11 2001 Delivered-To: freebsd-stable@freebsd.org Received: from hercules.icarz.com (ns1.icarz.com [207.99.22.7]) by hub.freebsd.org (Postfix) with ESMTP id 2C2D237B43E for ; Thu, 12 Apr 2001 14:42:07 -0700 (PDT) (envelope-from kenm@icarz.com) Received: from newken (dhcp113.icarz.com [207.99.22.113]) by hercules.icarz.com (8.10.1/8.10.1) with SMTP id f3CLg6229815 for ; Thu, 12 Apr 2001 17:42:06 -0400 (EDT) Message-ID: <000901c0c399$13f7e680$711663cf@icarz.com> From: "Ken Menzel" To: Subject: Tail of file larger than 2 gig fails (patch) Date: Thu, 12 Apr 2001 17:39:39 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I had a problem today with a very large log file (3.6 gig) I wanted to see the last few lines but 'tail' wanted to show me the last gig or so. Anyway I made it work, I don't know if this is the right list, because I have never submitted a patch before. Could someone committer either advise me where to send this patch or take a look at it and commit it if it looks OK? It should not affect the way tail works for files smaller that 2Gig (1/2 of SIZE_T_MAX). It also fixes the comparison of SIZE_T_MAX which never worked anyway and does print a warning at the top of the tail if the file is larger that 2 gig. Thanks Ken --- ./kentail/forward.c Thu Apr 12 17:18:48 2001 +++ ./tail/forward.c Wed Feb 28 11:18:13 2001 @@ -268,30 +268,20 @@ struct stat *sbp; { off_t size; - off_t max_size; - off_t big_off; - size_t orig_size; - char *p; char *start; if (!(size = sbp->st_size)) return; - max_size=SIZE_T_MAX/2; - big_off=0; - if (size > max_size) { + if (size > SIZE_T_MAX) { errno = EFBIG; ierr(); - // Just look at back of file - big_off=size-max_size; - size=max_size; - // return; + return; } - orig_size=size; if ((start = mmap(NULL, (size_t)size, - PROT_READ, MAP_SHARED, fileno(fp), (off_t)big_off)) == MAP_FAILED) { + PROT_READ, MAP_SHARED, fileno(fp), (off_t)0)) == MAP_FAILED) { ierr(); return; } @@ -304,13 +294,13 @@ } /* Set the file pointer to reflect the length displayed. */ - size = orig_size - size; + size = sbp->st_size - size; WR(p, size); - if (fseeko(fp, sbp->st_size, SEEK_SET) == -1) { + if (fseek(fp, (long)sbp->st_size, SEEK_SET) == -1) { ierr(); return; } - if (munmap(start, orig_size)) { + if (munmap(start, (size_t)sbp->st_size)) { ierr(); return; } ----------------------------------------------------- Ken Menzel ICQ# 9325188 www.icarz.com kenm@icarz.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message