Post

Replies

Boosts

Views

Activity

Get the amount of free space of an unmounted storage device in Swift
Hi, i am working on a swift package library that gets information about all the disks connected to the mac and displays it organised into a tree structure, including the non-mounted storage devices attached to the machine. My question is how can i get informations about unmounted devices like: The amount of free space (when possible) of a partition or an APFS container The space occupied by a single APFS volume I am already using a combination of IOKit and Disk Arbitration for my library and i don't see this information anywhere in those frameworks, including the description dictionaries provided by Disk Arbitration. Instead the terminal command diskutil info -plist [volume/partition BSD name here] gives me this info, but i can't just use it's output in my swift program (and obtaining it via a process object for example) since it doesn't work with the app sandbox, so i am looking for a sandbox-friendly way using just the API. I hope you can help me figure this out, really any help is appreciated, thank you for your attention.
1
0
1.5k
Aug ’21
Get APFS container's physical store using the API - Swift
Hi, i have made some code in Swift that allows me to get a list of the storage disks and the relative partitions present in a mac (everything made using the IOKit api), this of course includes the APFS containers that are managed by the OS as separate storage devices. To have a proper representation of the partitions tree in my code i need to know which are the actual partitions housing a given APFS container. I have tried to look for this information on documentation and on the internet, then into the IORegistry (using the registry explorer app) and searching for this info into the description dictionaries provided by Disk arbitration but so far no luck, even by comparing the UUIDs. In IORegistry explorer in the IOService plane I can also see that the APFS Container in my mac's ssd is listed as a sub-node of it's physical storage a partition, but since i am using an IOIterator object to scan the IORegistry i have no idea of how i should look into sub-nodes for a given node. Also i think that some particular storage configurations might have an APFS container split across multiple physical storage devices, in fact the diskutil list -plist command shows the physical store for each APFS containers as an array in the plist output, so the child approach might not be effective there. So how can i do this? I am doing all of this stuff because i am working to a sandbox-friendly open source swift package for macOS apps to easily get a complete tree structure of disks and partitions, in a similar fashion to the above mentioned diskutil list -plist command, my goal is actually to have the exact same structure provided by that command, with the same info.
1
0
1k
Aug ’21