Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::fs::copy failed with OS error 1 on Linux when copying over CIFS from local FS #66760

Open
vadixidav opened this issue Nov 25, 2019 · 1 comment
Labels
C-bug Category: This is a bug. O-linux Operating system: Linux T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@vadixidav
Copy link
Contributor

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.

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. O-linux Operating system: Linux T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Nov 25, 2019
@the8472
Copy link
Member

the8472 commented Nov 25, 2019

can you strace the failure?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-linux Operating system: Linux T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants