macosiokit

Is it possible to get file system type and disk mount path by BSD name using only IO Registry?


I'm aware that it's possible to find the file system type (apfs, hfs, msdos etc.) and also the disks's mount path by disk's BSD name using the Disk Arbitration framework and also the POSIX statfs() function.

However, I'm wondering if this information is also written somewhere in the IO Registry, so that I could extract it using only IOKit framework?

I've searched my own Mac's IO Registry but didn't find anything like that, but still suspect it's there.

Any ideas?


Solution

  • I/O Kit is not involved with mounted file systems: that happens at the BSD layer, so the only thing IOKit "sees" are the reads, writes, and ioctls to the device coming from the BSD subsystem and being converted into IOStorage method calls by the IOMediaBSDClient. I/O Kit does not care what file system is issuing those IO operations.

    However, it does have the concept of a "content hint" (kIOMediaContentHintKey) property on an IOMedia node. The content hint influences which file system(s) will attempt to mount the block device.

    The content hint comes from the partitioning or volume management scheme: on GPT disks, the content hint will be the partition type GUID. Each file system implementation advertises the content hints it is looking for, and the OS (Disk Arbitration) runs the mount command for any file systems claiming to support the content hint of a newly appeared block device node.

    Note that the content hint is only a hint:

    So in short, no, the precisely equivalent mount point information from the BSD and Disk Arbitration subsystems does not exist in I/O Kit, although there is some information about file system types which the block device claims to contain.