On Mac OS X, a filter-scheme driver provides a filtering mechanism between generic I/O requests and content on a media. A media-filter scheme matches on an IOMedia object representing the content present in a partition and publishes in the I/O Registry another IOMedia object that represents the unfiltered content. Because filter-scheme drivers are both consumers and producers of IOMedia objects, there can be an arbitrary number of filter schemes in the mass storage driver stack.
To create your own filter-scheme driver, you subclass IOStorage and implement your filtering functionality in the read and write methods. Other methods you implement, such as init, start, and free, create and initialize the new IOMedia object, attach it to the I/O Registry, and release it.
As described in “Filter Schemes,” a filter-scheme driver should not produce an IOCDMedia or IODVDMedia object, because these objects have provider requirements specific to CD and DVD media that can be met only by an IOCDBlockStorageDriver or IODVDBlockStorageDriver, respectively.
This chapter guides you through the process of creating a filter-scheme driver. It also describes how to test the driver by creating a disk image that contains a partition the driver can match on. The sample code in this chapter is generic and emphasizes the form your driver should take, rather than the implementation of specific filtering functionality. When you use this code as a basis for your own filter-scheme driver, you should replace the generic values, such as MySoftwareCompany, with your own values and add your filtering code to the appropriate methods.
The sample filter scheme described in this chapter includes code that allows you to install the filter scheme on the boot partition. If you do not need to do this, you can skip the portions of the code that implement this.
The sample code in this chapter is from an Xcode project that builds a filter-scheme driver. To download the complete project (which includes debugging and installation information), see SampleFilterScheme in the ADC Reference Library. Note that the SampleFilterScheme project defines two different targets, one of which allows you to install the filter scheme on the boot partition. Be sure to read the comments in the project’s files before you decide which target to build.
For more information on how to develop kernel extensions in general and I/O Kit drivers in particular, see Kernel Extension Programming Topics and I/O Kit Device Driver Design Guidelines.
Important: The sample code in this chapter is designed to work with Mac OS X version 10.1 and later. It will not work with earlier versions.
Edit Your Driver’s Property List
Creating Your Filter Scheme
Testing Your Filter Scheme
Last updated: 2007-04-03