Can not get FileHandle on MS-DOS file systems: The operation couldn’t be completed. Operation not permitted

Hello,

I am trying to get a FileHandle for a specific file on an external hard disk.

My app is sandboxed and in order to be able to get a FileHandle I am showing a NSOpenPanel so the user can grant permission to access this disk.

After the user has granted permissions, I use the following code to get the handle:

guard let readDescriptor = try? FileDescriptor.open(readUrl.path, FileDescriptor.AccessMode.readWrite) else { return }

I get the following error when this code runs:

The operation couldn’t be completed. Operation not permitted

What I don't understand is the fact that this code only fails on disks that have the MS-DOS file system. I have tested various USB sticks, SD cards and external hard drives. It works fine for the APFS, but once I format the device as MS-DOS, the code fails.

Has anyone any idea why that is?

Regards, Sascha

Operation not permitted

This is indicative of an EPERM error, which means you’re likely hitting either an App Sandbox or MAC limit. For more background on this, see On File System Permissions.

Given that your app is sandboxed, it’s most likely that. However, let’s just be sure. If you create and mount an MS-DOS (FAT) disk image, does it exhibit the same problem?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hello,

thanks for your reply. If I disable the sandbox, it works as expected, no error is shown. I have created an empty MS-DOS image and this also works, if the sandbox is enabled.

The following error messages are shown in the Console:

error	15:10:01.039684+0200	kernel	System Policy: Process(2659) deny(1) file-read-data /Volumes/SD CARD/File.tmp
error	15:10:01.046855+0200	kernel	System Policy: Process(2659) deny(1) file-write-unlink /Volumes/SD CARD/FileRead.tmp
error	15:10:01.047082+0200	kernel	System Policy: Process(2659) deny(1) file-read-data /Volumes/SD CARD/FileRead.tmp
error	15:10:01.047214+0200	kernel	System Policy: Process(2659) deny(1) file-write-unlink /Volumes/SD CARD/File.tmp
error	15:10:01.047332+0200	kernel	System Policy: Process(2659) deny(1) file-write-unlink /Volumes/SD CARD/FileRead.tmp
error	15:10:01.047454+0200	kernel	System Policy: Process(2659) deny(1) file-write-unlink /Volumes/SD CARD/File.tmp
error	15:10:01.047671+0200	kernel	System Policy: Process(2659) deny(1) file-write-unlink /Volumes/SD CARD/FileRead.tmp

Sometimes, writing to the SD card is successful, but then the read access is denied. Further write attempts also fail, but if I wait a couple of seconds, writing will succeed. Reading always fails though.

Hopefully this explanation helps a little bit.

Regards, Sascha

I have created an empty MS-DOS image and this also works, if the sandbox is enabled.

So, to confirm, with a sandboxed app:

  • Everything works fine on a MS-DOS disk image.

  • But things start to fail on a MS-DOS physical disk.

Is that correct?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Can not get FileHandle on MS-DOS file systems: The operation couldn’t be completed. Operation not permitted
 
 
Q