Don't use mmap() for non-regular files, since st_size is only meaningful
for regular files. This fixes recent breakage of cp'ing from /dev/zero. /dev/zero doesn't support mmap(), but the device driver mmap routines are not called for mapping 0 bytes, so the error was not detected. mmap() can't even be used for cp'ing special files that support mmap(), since there is general way to determine the file size.
This commit is contained in:
parent
4f699173cb
commit
40fc4ee2de
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=41238
@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id: utils.c,v 1.19 1998/06/09 03:38:26 imp Exp $";
|
||||
"$Id: utils.c,v 1.20 1998/06/10 06:29:23 peter Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -124,7 +124,7 @@ copy_file(entp, dne)
|
||||
* wins some CPU back.
|
||||
*/
|
||||
#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
|
||||
if (fs->st_size <= 8 * 1048576) {
|
||||
if (S_ISREG(fs->st_mode) && 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);
|
||||
|
Loading…
Reference in New Issue
Block a user