Description
I am using the following versions:
- mount.cifs version: 6.9
uname -r
: 5.3.0-23-generic- Ubuntu 19.10
- Rust
nightly-2019-11-17-x86_64-unknown-linux-gnu
I was unable to perform a file copy with std::fs::copy
when copying to a Windows shared folder mounted on Linux with the following options:
rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777
I got OS error 1, which shouldn't happen since everyone has full permissions to the mounted NAS.
Interestingly, I was able to copy the files using cp -r
without issue. I worked around this by writing something close to the following (all same except for error handling that I stripped out):
for file in WalkDir::new(&source)
.into_iter()
.map(|file| file.unwrap())
.filter(|file| file.file_type().is_file())
{
let outpath = dest_dir_name.join(file.file_name());
std::io::copy(&mut File::open(&file.path()), &mut File::create(&outpath).unwrap()).unwrap();
}
It seemed strange to me that I get a permission denied despite that if I manually write the code to create and write the files using walkdir then it works completely file. I believe this is a bug in the code of std::fs::copy since the expected behavior is that it should work like cp
(which just copies it as expected).
I still have access to this setup, so I can test things if need be. Let me know if I can give more information to track down the bug.