Technical Q&A QA1242

Developing for VFS

Q:  Does Apple support the development of external file systems (VFS plug-ins) on Mac OS X? Where can I find information about developing such a file system?

A: Does Apple support the development of external file systems (VFS plug-ins) on Mac OS X? Where can I find information about developing such a file system?

The answer depends on what type of file system you're developing.

Leaf File Systems

A leaf file system works independently of other file systems. Leaf file systems include:

Apple supports the development of leaf file systems for all versions of Mac OS X. However, the rules have changed substantially, and for the better, in Mac OS X 10.4 Tiger.

Prior to the introduction of Mac OS X 10.4 Tiger, the BSD portions of the Mac OS X kernel were not architected for binary compatibility. Implementing a VFS plug-in required intimate knowledge of the kernel's internals, and the resulting product embedded that knowledge, making it very brittle. The slightest change to the kernel (reordering the fields within a structure, for example) would break all VFS plug-ins.

With Mac OS X 10.4 Tiger, Apple has solved this problem by introducing a VFS Kernel Programming Interface (KPI). This KPI isolates your VFS plug-in from kernel changes. For example, you no longer access fields in kernel structures directly; rather you call accessor functions that are supplied by the KPI. By using this KPI you can develop a VFS plug-in with the expectation that it will be compatible with future systems.

This sounds like file system nirvana, right? Alas, there are still a few things to worry about.

If you're developing a VFS plug-in, you may find the following resources useful.

If you have technical questions, there are a variety of mailing lists for free community-based support (I recommend the darwin-kernel mailing list) and Apple Developer Technical Support for paid support.

Stacking File Systems

A stacking file system (sometimes called a filter file system) sits on top of another file system and modifies its behavior in some way. The canonical example of a stacking file system is an encryption file system. You could stack this file system on top of any existing file system to provide encryption support.

Apple does not support the development of stacking VFS plug-ins on Mac OS X (r. 4383626) . We've taken this position because, in our opinion, it's not possible to create a stacking VFS plug-in that:

If you have a problem that can only be solved via a stacking file system, please let us know by mailing Developer Technical Support. While we can't support your development, we are interested in gathering information about what developers need and why. This feedback will guide our long-term approach to this question. We may also be able to suggest an alternative design that does not require stacking.

Finally, there are a number of third party developers who are working in this realm. If you are absolutely determined to develop an unsupported stacking VFS plug-in, you will find some help on the Internet.

Alternatives

Developing a VFS plug-in for Mac OS X is hard. There are a number of factors that contribute to the difficulty:

All-in-all, it's much better if you can avoid developing a file system. Moreover, if you must develop a file system, it's better if you can push as much of that development into user space as possible.

There are two well known techniques for minimising the amount of kernel code that you have to write.

Finally, Mac OS X provides specific APIs to solve problems that might otherwise require a stacking file system.



Document Revision History


DateNotes
2006-12-22

Added links to EmptyFS and MFSLives, and the Kauth documentation and sample code. Added a bug number for VFS documentation.

2006-03-16

Added bug number to track stacking VFS requirement.

2005-05-24

Update for Mac OS X 10.4 Tiger.

2003-03-26

New document that describes Apple's position on developing external file systems (VFS plug-ins) for Mac OS X.