Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
269 views
in Technique[技术] by (71.8m points)

finder - How to implement a virtual filesystem on macos?

I have seen that some applications are able to represent themselves as external disks within Finder on MacOS. Typically, these are cloud storage applications such as PCloud Drive and WD Discovery. I'm wondering how they do this.

I realize that cloud storage might just implement some remote filesystem protocol such as Samba or AFP. But I still don't quite understand how an app mounts the filesystem directly into Finder. Also, is there a more efficient way to mount a virtual filesystem if it doesn't rely on network storage?

question from:https://stackoverflow.com/questions/65856395/how-to-implement-a-virtual-filesystem-on-macos

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is a fairly high-level question, so I'll give a high-level answer. I don't know how the specific examples you list implement it, but this shouldn't be too hard to find out.

As far as I'm aware, the options are as follows:

  • At a fundamental level, you can create a VFS kext. This is how support for HFS+, APFS, FAT, SMB, AFP, etc. is implemented in macOS in the first place. The headers for this in the Kernel.framework are primarily <sys/vnode.h>, <sys/vnode_if.h>, and <vfs/vfs_support.h>. This gives you the most power, but it's also difficult, and the user experience for installing kexts continues to deteriorate. (They won't load at all on ARM64 Macs unless the user does some fairly complicated acrobatics.)
  • There's MacFUSE, which does some of the heavy lifting for you. Some licensing issues and it's in turn implemented via a kext so the UX issues apply here too.
  • Use NSFileProvider. This is intended for cloud-style virtual file systems but can to some extent be used for different but related scenarios.
  • Implement a network file system server, then use APIs to mount.
  • Implement a block device hosting a regular file system via another method, such through a DriverKit SCSI controller driver, or via a iSCSI target. This only really makes sense if the data source is sensibly representable as a block device.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...