Questions tagged [diskarbitration]

DiskArbitration.framework is available on OS X, and provides mechanisms for registering for mount/unmount notification and blocking mount/unmount events.

DiskArbitration.framework documentation is available here:

http://developer.apple.com/documentation/Darwin/Reference/DiscArbitrationFramework/

NSWorkspace can be used for a subset of the supported actions:

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWorkspace_Class/

52 questions
3
votes
1 answer

Map USB disk BSD Name to actual mounted drive(s) in OSX

I am trying to get from the USB device BSD Name to the actual mounted volume(s) for that device e.g. device has BSD name "disk2" and mounts a single volume with BSD name "disk2s1" at "/Volumes/USBSTICK". Here is what I have been doing so far.…
Tam Toucan
  • 137
  • 10
3
votes
1 answer

Disk Arbitration Objective C: Put All Drives and Partitions in an Array

I am just starting out in this wacky world of programming and I have come across a very frustrating problem: I am trying to use Disk Arbitration Framework to put all Disks in a array. #import "DiskDetector.h" #import "Disk.h" @implementation…
3
votes
0 answers

Why is the Ejectable property of a DADisk always false?

I'm trying to get a list of all ejectable disks using the Disk Arbitration framework. The problem is that the Ejectable property is always false (even when diskutil info says Ejectable: Yes). What's going on? Do I need to do a DADiskClaim first or…
fumoboy007
  • 5,345
  • 4
  • 32
  • 49
3
votes
1 answer

DADiskEject causing problems with error code 12 (kDAReturnUnsupported)

I try to eject external USB drives and Disk Images after being unmounted in the following callback function: void __unmountCallback(DADiskRef disk, DADissenterRef dissenter, void *context ) { ... if (!dissenter) { …
Jan Linxweiler
  • 382
  • 2
  • 9
2
votes
1 answer

Trigger OSX runloop from Qt

I'm writing an application in C++ using Qt on Mac. I want to detect drives being mounted and unmounted so I am using the DiskArbitration framework. I registered some callback functions via DARegisterDiskAppearedCallback and…
koan
  • 3,596
  • 2
  • 25
  • 35
2
votes
2 answers

What is the best way to get BSD drive names on macOS (Swift)?

What's the best way I can get a list of BSD names of all USB devices (and maybe including internal Mac drives) without using a diskutil CLI wrapper? I don't want to use any wrappers that interact with the CLI interface, as this way of interacting is…
ReSophie
  • 121
  • 6
2
votes
1 answer

Get tree-like structure of all volumes using DiskArbitration and IOKit

I am trying to get a tree like structure of all volumes of my computer using Swift. The simplest way to get all the mounted volumes is this code: FileManager.default.mountedVolumeURLs(includingResourceValuesForKeys: nil) Using this URL, I can create…
inexcitus
  • 2,471
  • 2
  • 26
  • 41
2
votes
2 answers

How to distinguish USB hard drives and SSDs from USB keys / pen drives on macOS

How is it possible for code to distinguish between external USB hard drives and solid-state drives on the one hand versus USB sticks on the other hand? I'm not familiar with macOS APIs (or system calls, interrupts, messaging, and other things) but…
hippietrail
  • 15,848
  • 18
  • 99
  • 158
2
votes
1 answer

Unmounting Drive/volume without ejecting

I am want to unmount a disk WITHOUT EJECTING. To do that I tried following code { NSString *path; CFStringRef *volumeName=(__bridge CFStringRef)path; DASessionRef session = DASessionCreate(kCFAllocatorDefault); CFURLRef pathRef =…
2
votes
4 answers

Double callback from Disk Arbitration when mounting disk image

I have a problem using DiskArbitration framework, to catch disk image mounting I register for DARegisterDiskMountApprovalCallback. The problem is that each time a disk image is mounted, the callback is called twice. Why is that and how can I solve…
Nyx0uf
  • 4,609
  • 1
  • 25
  • 26
1
vote
1 answer

Is there an equivalent on Windows to the DiskArbitration framework on Mac OS?

I'm looking into writing a tool that mounts certain external disks as read-only when they are plugged-in to the machine. On MacOS, this was quite trivial with the Disk Arbitration framework. It sends out notifications from the OS when a new drive…
Grant Limberg
  • 20,913
  • 11
  • 63
  • 84
1
vote
0 answers

Formatting a disk in macOS programmatically using DiskManagement.framework

I have a task to implement disk formatting functionality in my code. I am against the use of command line wrappers (e.g. diskutil), as they are slow and unreliable. I'm importing this private framework:…
1
vote
1 answer

How to get disk type (SSD, HDD, Optical) on macOS using DiskArbitration or other framework

I am trying to figure out how I can get some additional disk properties on macOS using Swift. I am especially interested in the type of disk (like SSD, HDD, Optical). I am getting a list of mounted volumes using the following…
inexcitus
  • 2,471
  • 2
  • 26
  • 41
1
vote
1 answer

Find volume serial number using OSX apis

I am looking for a way to get the volume serial number (https://en.wikipedia.org/wiki/Volume_serial_number) for volumes which represent USB drive partitions on OSX, similar to what this function does on Windows…
user1573546
  • 523
  • 5
  • 13
1
vote
1 answer

Cocoa application get size of /dev/disk0s1

How could I get the size in bytes of a partition by it's device name (e.g. /dev/disk0s1) in a Cocoa application? Maybe I should use Disk Arbitration framework somehow?
user663896