Date: Tue, 30 Jan 2001 09:30:06 -0800 (PST) From: Bruce Evans <bde@zeta.org.au> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/24732: cmp can not compare files lager 2GB but smaller 4GB Message-ID: <200101301730.f0UHU6C07357@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/24732; it has been noted by GNATS. From: Bruce Evans <bde@zeta.org.au> To: Dmitry Kazarov <kazarov@izmiran.rssi.ru> Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: bin/24732: cmp can not compare files lager 2GB but smaller 4GB Date: Wed, 31 Jan 2001 04:24:15 +1100 (EST) On Tue, 30 Jan 2001, Dmitry Kazarov wrote: > Sorry, I do not understand why compare MAX(...) to SIZE_T_MAX. > IMHO, mmap maps the file into process memory so both files together should > fit into process accessible address space which is less then SIZE_T_MAX (my > expirements with cmp showed that is about 2430MB, on Solaris 2.4 it was 2GB > only). mmap()'s `len' arg has type size_t, so lengths larger than SIZE_T_MAX can't be passed to mmap() for it to check (and fail on). > So it's nessesary to compare (len1+skip1%pagesize + len2+skip2%pagesize) to > 2430MB (for my system). mmap() will check this if the full lengths can be passed to it. Since their are 2 mmap()s, there is a machine-dependent amount of space between them. PAGE_SIZE is probably sufficient, but you have to look at the implementation to tell. Your 2430MB must have some slop for this. > Cause, reverting to c_special on mmap failure could be a better way but, > IMHO, the best solution would be proposal of Poul-Henning Kamp > <phk@FreeBSD.org> ( http://www.freebsd.org/cgi/query-pr.cgi?pr=18589 ): > "Add a loop around the mmap/compare operation which operates on some > moderate amount of data each iteration." I agree. cp uses 8MB for the moderate amount. So does xinstall for its file comparison function. xinstall also falls back to read() when mmap() fails, and has a -M flag to prevent use of mmap(). Bruce 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?200101301730.f0UHU6C07357>