Repository navigation
Unable to Copy/Create file on NFS share on macOS #72786
Copy link
Copy link
Closed
Labels
Milestone
Description
Description
dotnet on macOS is not able to copy files to a NFS share.
The NFS share is working perfectly from "Terminal" and "Finder", files can be created/copied and deleted all works.
But from a dotnet (Net6) application I get "UnauthorizedAccess", when writing. Read is working fine.
Reproduction Steps
Setup NFS share on Linux
/etc/exports
/files *(fsid=1,crossmnt,rw,insecure,all_squash,async,no_subtree_check,anonuid=99,anongid=99)
Mount on macOS from Finder "nfs://servername/files" will mount on "/Volumes/files"
Terminal and Finder can read and write.
Expected behavior
Should be able to create directory and copy files
Actual behavior
Type: System.UnauthorizedAccessException
Message: Access to the path '/Volumes/files/p10001-20000/p13001-14000/p13101-13200/13156/70487.pdf' is denied.
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Interop.CheckIo(Error error, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
at System.IO.File.Create(String path)
at OpenMedicus.IO.Files.CopyFileAsync(DbConnection conn, DbTransaction t, String sourceFile, String description, Int32 patientId, Int32 accountId, Boolean isHidden, IProgress`1 progress, Int32 count, Int32 index, CancellationToken token) in /XMedicus/libxcarefiles/Files.cs:line 180
at OpenMedicus.IO.Files.CopyFileAsync(String[] files, String description, Int32 patientId, Int32 accountId, Boolean isHidden, IProgress`1 progress, CancellationToken token) in /XMedicus/libxcarefiles/Files.cs:line 109
at OpenMedicus.IO.FileManager.CopyFileAsync(String[] files, String destpath, Int32 patientId, Int32 accountId, Boolean isHidden, IProgress`1 progress, CancellationToken token) in /XMedicus/libxcarefiles/Manager.cs:line 163
at OpenMedicus.Journal.Summary.CopyFilesAsync(FileManager fm, List`1 files, Int32 episodeId, String desc, List`1 tags) in /XMedicus/components/summary/Summary.cs:line 800
at OpenMedicus.Journal.Summary.AttachFilesAsync(List`1 files, String description) in /XMedicus/components/summary/Summary.cs:line 917
Regression?
Not sure if it has been working before. (On Mono it worked).
Known Workarounds
None
Configuration
dotnet version: 6.0.6
macOS: Catalina
Other information
No response
Reactions are currently unavailable
Activity
danmoseley commentedon Jul 25, 2022
Thanks for the report. It would be interesting to compare IO traces to when this is done successfully (eg in the shell). On Linux one would use strace. I don't have access to a Mac but I believe it has something similar called dtrace?
jozkee commentedon Jul 25, 2022
It works on my macbook using the three ways you mentioned (finder, terminal, and .NET app).
This is my
sudo exportfs -von my Ubuntu NFS server:I also did a
chmod 777 /srv/nfs4/hometo allow the the client to write to the shared folder.I'm not sure what might be different on your mac. Perhaps you could share the strace that @danmoseley mentioned (it's called dtruss on macos).
mikkeljohnsen commentedon Jul 26, 2022
mikkeljohnsen commentedon Jul 26, 2022
@jozkee Could you try using this code:
adamsitnik commentedon Aug 17, 2022
I am 99% sure that it's #55256. The problem is that the fix was tested only on Linux (as there were no macOS bug reports). We need to implement proper file system detection for apple (#69852) and most likely backport the change to 7.0 and 6.0 (it should not be hard; we should be able to reuse the freebsd implementation)