什么是虚拟文件系统或用户空间中的文件系统?

发布于 2024-09-02 13:59:11 字数 358 浏览 1 评论 0原文

我刚刚在用户空间中遇到了 VFS 和文件系统,例如 FUSE

现在,据我了解,它模拟了一个文件系统,以便应用程序可以拥有标准的文件系统层次结构。但我不明白,为什么我们需要一个单独的文件系统?我们不能只创建一个常规的文件夹结构并放置应用程序将使用的文件吗?

所以,我的问题是:

  1. 什么是 VFS?

  2. 您能否给出一些现实世界的示例,使用 VFS 的用例。

  3. 使用 VFS 有什么好处?

有没有基于Java的VFS?

I just came across a VFS and a filesystem in userspace like FUSE.

Now, as far as I understand, it simulates a file system, so that an application can have a standard file system hierarchy. But I don't understand, why do we need a separate file system for that? Can't we just create a regular folder structure and place files which will be used by the app?

So, my questions are:

  1. What is a VFS?

  2. Can you give some real world examples, use cases where VFS is used.

  3. What is the benefit of using a VFS?

Any Java based VFS?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笔芯 2024-09-09 13:59:11

VFS 和 FUSE 是相关的,但并不完全相同。 FUSE 的主要目的是将几乎类似文件但又不完全一样的东西(例如远程服务器上的文件或 ZIP 文件内的文件)转换为“真实”的目录和文件。请参阅 FUSE 文件系统名册 以了解这是什么有利于;希望这能更清楚地说明为什么 FUSE 在很多情况下优于“普通旧文件”。

VFS 是文件的应用程序接口(API)。如果你不熟悉 API 的概念,我建议你看一下 Wikipedia 页面的“Virtual File System”;它从操作系统内核的角度描述了VFS是什么。是的,您的操作系统内核(无论是 Windows、Linux 还是 MacOS)都有 VFS!一些用户空间程序,例如 GNOME,也有一个(称为 GnomeVFS)。

VFS 的目的是以统一的方式向应用程序呈现文件和目录;它们可以是来自 CD-ROM、硬盘、USB 记忆棒或 RAM 磁盘上的 Linux 或 Windows 文件系统,或者来自网络服务器的文件。操作系统内核对 VFS 的用途可能是显而易见的。那么为什么还有用户空间的,比如 GnomeVFS?答案是,您不希望每个文件系统及其狗都驻留在内核中,因为此类代码以管理员权限运行,其中的任何错误都可能导致整个机器崩溃。当然,缺点是用户空间VFS只对使用它们的应用程序有用,例如只有GNOME应用程序可以通过GnomeVFS“看到”;不能在 GnomeVFS 树中执行“ls”操作。解决方案是 FUSE:它的确切目的和描述是将用户空间 VFS 转变为内核空间 VFS。换句话说,它将 VFS API 桥接到内核中,以便“假”文件可以显示为“真实”文件。

VFS and FUSE are related, but not quite the same thing. The main purpose of FUSE is to turn things-that-are-almost-like-files-but-not-quite (such as files on a remote server, or inside a ZIP file) into "real" directories and files. See the roster of FUSE filesystems to get an idea of what this is good for; this hopefully will make it clearer why FUSE beats "plain old files" in a lot of circumstances.

A VFS is an Application Program Interface (API) for files. In case you are not familiar with the concept of an API, I suggest that you take a look at the Wikipedia page for "Virtual File System"; it describes what a VFS is from the point of view of an operating system kernel. Yes, your OS kernel (be it Windows, Linux or MacOS) has a VFS! Some user-space programs, such as GNOME, have one too (it's called GnomeVFS).

The purpose of a VFS is to present files and directories to applications in a uniform way; be they files from a CD-ROM, from a Linux or Windows filesystem on a hard disk or USB stick or RAM disk, or from a network server. That an OS kernel have a use for a VFS is probably obvious. Then why also have userspace ones, such as GnomeVFS? The answer is that you don't want every filesystem and its dog to reside in the kernel, because such code runs with supervisor privileges and any bug in it can cause the entire machine to crash. Of course, the drawback is that userspace VFSes are only useful for applications that use them, eg only GNOME applications can "see" through GnomeVFS; one cannot do "ls" inside a GnomeVFS tree. The solution is FUSE: its exact purpose and description is to turn a user-space VFS into a kernel one. In other words, it bridges a VFS API into the kernel, so that "fake" files can appear as "real".

悲念泪 2024-09-09 13:59:11

VFS 不是指“假”文件系统,而是指 POSIX 操作系统向应用程序进程呈现的抽象文件系统接口。例如:

  • open()
  • close()
  • read()
  • write()
  • 等。

所有文件系统实现(ext3、 XFS、reiserfs 等)在它们使用的任何特定结构和算法之上公开相同的接口。

FUSE 是一种为该接口提供不在内核中运行的代码的方法。这可以显着提高稳定性和安全性,因为内核代码具有特权,而用户空间代码则没有。这种分离使得编写具有大量外部依赖项的文件系统变得更加明智。 FUSE 网页描述了使用 FUSE 构建的许多文件系统

VFS refers not to a 'fake' file system, but to the abstract filesystem interface presented by POSIX operating systems to application processes. Eg:

  • open()
  • close()
  • read()
  • write()
  • etc.

All filesystem implementations (ext3, XFS, reiserfs, etc.) expose that same interface on top of whatever specific structures and algorithms they use.

FUSE is a means of providing that interface with code that doesn't run in the kernel. This can dramatically improve stability and security, since kernel code is privileged, while userspace code isn't. That separation makes it much more sensible to write filesystems with lots of external dependencies. The FUSE web page describes many filesystems built using FUSE.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文