What level of integration can third-party filesystems get with the Finder?

I develop a third-party network filesystem for the Mac. I've noticed that there are certain Finder behaviors that we don't (perhaps can't) have that built-in networked filesystems do have. For instance, when a folder from an SMB share is added to the Finder sidebar as a favorite, clicking on that favorite will automatically mount the share if it is not already mounted. There is also a "Shared" section of the Finder sidebar. Integrating our filesystem into this section would be ideal, but I imagine that is much less likely than the first example.


I'm wondering if these behaviors come from particular VFS attributes set by a filesystem or are just special magic that Apple reserves for its own filesystem implementations.

Answered by mrbauer1 in 42838022

You can get this level of integration. I have it with my network filesystem. You need to implement a NetFSPlugin to do so. Take a look at the webdav source on http://opensource.apple.com for an example of a NetFSPlugin.

I don't really know anything about the implementation of a network file system, but does yours support querying for a mount URL (as in NSURLVolumeURLForRemountingKey)? And does it support mounting by URL? I suspect that that's what's used under the hood of bookmark/alias resolution, which is what the Finder sidebar is probably using.

Accepted Answer

You can get this level of integration. I have it with my network filesystem. You need to implement a NetFSPlugin to do so. Take a look at the webdav source on http://opensource.apple.com for an example of a NetFSPlugin.

I'm going to look into this. I guess the trick is finding out how these calls work under the covers. Hopefully it is not through a private API. They may only work with the built-in filesystems. I'll check on that. Thanks!

Maybe this is the API I'm looking for. I'll check it out. Thanks!

I've been looking into the WebDAV source, and I stubbed out a plugin based on what they're doing. But I can't find much documentation on this framework. Right now I don't know exactly where these functions are being called, or even if my bundle is formatted (with regard to info.plist entries etc.) so that the system (netauthagent?) actually calls it. WebDAV is not third party either, so it has access to a private API and is resident in /System/Library/Frameworks/. So I also don't know if and how the system treats third-party plugins differently. Do you know about any documentation that might help me get a more complete picture? I'd even be happy with a way to break on my code in a debugger.

You will not find any documentation for anything related to filesystem development on the Mac. Your only way of figuring it out is to reverse engineer things and read through lots of the kernel code. After a while you get a sense of how things 'should' behave. These older parts of OS X have a certain feel nad way of doing things. NetFS is one of those.



In your info.plist you just need to define Plug-in-type 02FE7D14-4E91-481E-946C-CE233C798CC0. Also make sure you use a four alphanumeric string for your media type. Add an underscore it it's not long enough. You can use NetFSMountFromPrefix to set the actual three alphanumeric protocol prefix.

There are no private APIs involved here and placing your plugin in /Library/Filesystems/NetFSPlugins will work just fine. Just make sure to restart NetAuthAgent, NetAuthSysAgent and Finder each time. There are many other processes that will call your NetFSPlugin so don't be surprised if you need to restart your system to see changes.



There are a few other items to point out. Finder really expects the vnode attribute va_fileid for your root vnode to be 2 and it's parent 1. If you set these to other values, the filesystem does mount but Finder won't behave like you expect. There may be something else at play here but I know setting the root vnode to other values does not work.



Welcome to filesystem development on the Mac. Enjoy the pain and celebrate the successes.

This is awesome. Exactly what I needed to make some headway. Thanks!

What level of integration can third-party filesystems get with the Finder?
 
 
Q