diff options
author | bde <bde@FreeBSD.org> | 1998-11-18 11:47:45 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1998-11-18 11:47:45 +0000 |
commit | ad2d958bb791483ae0eed3e827ca04c42bf16dcd (patch) | |
tree | 1b8538391c867d8be4f38e71827a266213dd27af /bin/cp | |
parent | 939b432d02d70b51f4c493b4539d70fc76b85817 (diff) | |
download | FreeBSD-src-ad2d958bb791483ae0eed3e827ca04c42bf16dcd.zip FreeBSD-src-ad2d958bb791483ae0eed3e827ca04c42bf16dcd.tar.gz |
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.
Diffstat (limited to 'bin/cp')
-rw-r--r-- | bin/cp/utils.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/bin/cp/utils.c b/bin/cp/utils.c index 7e001b2..f6c0f0d 100644 --- a/bin/cp/utils.c +++ b/bin/cp/utils.c @@ -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); |