如何在MacOS上实现虚拟文件系统? [英] How to implement a virtual filesystem on macos?

查看:111
本文介绍了如何在MacOS上实现虚拟文件系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到某些应用程序能够将自己表示为MacOS上Finder中的外部磁盘.通常,这些是云存储应用程序,例如 PCloud Drive WD Discovery .我想知道他们是如何做到的.

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.

我意识到云存储可能只是实现一些远程文件系统协议,例如Samba或AFP.但是我仍然不太了解应用程序如何将文件系统直接安装到Finder中.另外,如果不依赖网络存储,是否有更有效的方式挂载虚拟文件系统?

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?

推荐答案

这是一个相当高级的问题,因此我将给出一个高级答案.我不知道您列出的特定示例是如何实现的,但这不难发现.

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.

据我所知,选项如下:

  • 从根本上讲,您可以创建VFS kext.这就是首先在macOS中实现对HFS +,APFS,FAT,SMB,AFP等的支持的方式.Kernel.framework中的此标头主要是< sys/vnode.h> < sys/vnode_if.h> < vfs/vfs_support.h> .这为您提供了最大的功能,但这也很困难,并且安装kexts的用户体验持续恶化.(除非用户进行一些相当复杂的杂技,否则它们根本不会在ARM64 Mac上加载.)
  • 有MacFUSE,它可以为您完成一些繁重的工作.一些许可问题,它又通过kext实现,因此UX问题也适用于此.
  • 使用 NSFileProvider .这是针对云风格的虚拟文件系统的,但在某种程度上可以用于不同但相关的方案.
  • 实施网络文件系统服务器,然后使用API​​进行安装.
  • 通过另一种方法(例如,通过DriverKit SCSI控制器驱动程序或通过iSCSI目标)来实现承载常规文件系统的块设备.只有将数据源合理地表示为块设备,这才有意义.
  • 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.

这篇关于如何在MacOS上实现虚拟文件系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆