Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Jan 2001 02:26:13 -0800 (PST)
From:      kazarov@izmiran.rssi.ru
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/24732: cmp can not compare files lager 2GB but smaller 4GB
Message-ID:  <200101301026.f0UAQDc99382@freefall.freebsd.org>

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

>Number:         24732
>Category:       bin
>Synopsis:       cmp can not compare files lager 2GB but smaller 4GB
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 30 02:30:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Dmitry Kazarov
>Release:        FreeBSD-4.2-STABLE
>Organization:
IZMIRAN
>Environment:
>Description:
in /usr/src/usr.bin/cmp/regular.c, line 84, length of files is compared with SIZE_T_MAX which is equal to 0xFFFFFFFF (4GB-1). 
But man mmap says:
BUGS
     len is limited to 2GB.  Mmapping slightly more than 2GB doesn't work, but
     it is possible to map a window of size (filesize % 2GB) for file sizes of
     slightly less than 2G, 4GB, 6GB and 8GB.
And tests shows that cmp cannot mmap two files of silze greate about 1213MB (on my system).
So constant should be decreased to 1GB
>How-To-Repeat:
user$ dd if=/dev/zero of=tmp seek=2048k bs=1k count=1
1+0 records in
1+0 records out
1024 bytes transferred in 0.000258 secs (3969471 bytes/sec)
user$ ln tmp tmp.l
user$ cmp tmp tmp.l
cmp: tmp: Invalid argument
>Fix:
*** regular.c.orig Tue Jan 30 12:36:35 2001
--- regular.c Tue Jan 30 12:37:15 2001
*************** c_regular(fd1, file1, skip1, len1, fd2, 
*** 81,87 ****
  off2 = ROUNDPAGE(skip2);
  
  length = MIN(len1, len2);
! if (length > SIZE_T_MAX)
  return (c_special(fd1, file1, skip1, fd2, file2, skip2));
  
  if ((p1 = (u_char *)mmap(NULL, (size_t)len1 + skip1 % pagesize,
--- 81,87 ----
  off2 = ROUNDPAGE(skip2);
  
  length = MIN(len1, len2);
! if (length > ( 1024*1024*1024 ) ) /* 1GB */
  return (c_special(fd1, file1, skip1, fd2, file2, skip2));
  
  if ((p1 = (u_char *)mmap(NULL, (size_t)len1 + skip1 % pagesize,


>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?200101301026.f0UAQDc99382>