Skip to content

Unable to Copy/Create file on NFS share on macOS #72786

@mikkeljohnsen

Description

@mikkeljohnsen

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions