version 1.20, 1999/03/03 01:03:51 |
version 1.21, 1999/05/29 20:17:35 |
|
|
size_t to_len; |
size_t to_len; |
{ |
{ |
caddr_t p1, p2; |
caddr_t p1, p2; |
register size_t length, remainder; |
size_t length, remainder; |
|
off_t from_off, to_off; |
int dfound; |
int dfound; |
|
|
if (from_len != to_len) |
if (from_len != to_len) |
return(1); |
return(1); |
|
|
/* Rewind file descriptors. */ |
|
if (lseek(from_fd, (off_t)0, SEEK_SET) == (off_t)-1) |
|
err(EX_OSERR, "lseek: %s", from_name); |
|
if (lseek(to_fd, (off_t)0, SEEK_SET) == (off_t)-1) |
|
err(EX_OSERR, "lseek: %s", to_name); |
|
|
|
/* |
/* |
* Compare the two files being careful not to mmap |
* Compare the two files being careful not to mmap |
* more than 8M at a time. |
* more than 8M at a time. |
*/ |
*/ |
|
from_off = to_off = (off_t)0; |
remainder = from_len; |
remainder = from_len; |
do { |
do { |
length = MIN(remainder, 8 * 1048576); |
length = MIN(remainder, 8 * 1048576); |
remainder -= length; |
remainder -= length; |
|
|
if ((p1 = mmap(NULL, length, PROT_READ, 0, from_fd, (off_t)0)) |
if ((p1 = mmap(NULL, length, PROT_READ, 0, from_fd, from_off)) |
== (caddr_t)-1) |
== MAP_FAILED) |
err(EX_OSERR, "%s", from_name); |
err(EX_OSERR, "%s", from_name); |
if ((p2 = mmap(NULL, length, PROT_READ, 0, to_fd, (off_t)0)) |
if ((p2 = mmap(NULL, length, PROT_READ, 0, to_fd, to_off)) |
== (caddr_t)-1) |
== MAP_FAILED) |
err(EX_OSERR, "%s", to_name); |
err(EX_OSERR, "%s", to_name); |
|
|
dfound = memcmp(p1, p2, length); |
dfound = memcmp(p1, p2, length); |
|
|
(void) munmap(p1, length); |
(void) munmap(p1, length); |
(void) munmap(p2, length); |
(void) munmap(p2, length); |
|
|
|
from_off += length; |
|
to_off += length; |
|
|
} while (!dfound && remainder > 0); |
} while (!dfound && remainder > 0); |
|
|