Bug 17389

Summary: /bin/cp failed on some synthetic vfs
Product: Base System Reporter: aef <aef>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-CURRENT   
Hardware: Any   
OS: Any   

Description aef 2000-03-15 09:50:01 UTC
When i copy file from synthetic vfs (portalfs), /bin/cp
use mmap for source file and failed with EINVAL error
cp /portal/tcp/localhost/daytime somefile

Fix: 

Check st_blocks value. For synthetic file - always 0.
Simple path for src/bin/cp/utils.c

128c128
<       if (S_ISREG(fs->st_mode) && fs->st_size <= 8 * 1048576) {
---
>       if (S_ISREG(fs->st_mode) && fs->st_size <= 8 * 1048576 && fs->st_blocks
> 0) {
How-To-Repeat: 100%
Comment 1 Kris Kennaway freebsd_committer freebsd_triage 2003-07-13 06:45:00 UTC
State Changed
From-To: open->closed

As you discovered, there are a number of problems with 
certain FS implementations on FreeBSD, but hacking cp so it 
won't work with any of them isn't the solution.