I want to write a disk image (ISO, img) to an SD card, but I always get permission errno 13 (permission denied).
let diskPath = "/dev/rdisk99"
guard let diskHandle = FileHandle(forWritingAtPath: diskPath) else {
throw NSError(domain: "DiskWriter", code: Int(errno), userInfo: [NSLocalizedDescriptionKey: "errno \(errno)"])
}
It seems that when other macOS applications try to read from a raw block device it triggers an Access Removable Media prompt and when other applications try to write to a raw block device it triggers a Full Disk Access prompt.
How can I trigger that prompt? And then how do I elevate my write to use that permission?
P.S. I'm not a Swift coder, but I'd like to be... if it weren't that every "simple" thing I've tried launches me directly into a brick wall.
What I've tried
- I did change
Sandbox App
to NO inMyApp.entitlements
- I have tried manually adding my Debug Archive to Full Disk Access
Why?
As to why I'm I interested in this: Well, it just seems silly that UI tools that do what dd
does are hundreds of megabytes. Can't we do this in a UI that uses all the default macOS libraries and is just a few kilobytes (or megabytes at worst)?
Update: notes to self:
- looks like it may be a hacky-do of using a uri to open system preferences, polling until a known-inaccessible file becomes accessible, and then forking a call to authopen, dupilating a descriptor, and carrying on...
- rpi-imager/src/mac at qml · raspberrypi/rpi-imager · GitHub
- PermissionsKit/PermissionsKit/Private/FullDiskAccess/MPFullDiskAccessAuthorizer.m at master · MacPaw/PermissionsKit · GitHub