Don't mmap(2) and munmap(2) zero-length files.

Submitted by:	Wiktor Niesiobedzki <bsd@w.evip.pl>
This commit is contained in:
Alan Cox 2003-11-13 05:26:55 +00:00
parent 93685685f4
commit b9e25f436b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=122601

View File

@ -133,7 +133,8 @@ copy_file(const FTSENT *entp, int dne)
* wins some CPU back.
*/
#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
if (S_ISREG(fs->st_mode) && fs->st_size <= 8 * 1048576) {
if (S_ISREG(fs->st_mode) && fs->st_size > 0 &&
fs->st_size <= 8 * 1048576) {
if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ,
MAP_SHARED, from_fd, (off_t)0)) == MAP_FAILED) {
warn("%s", entp->fts_path);