What is a Virtual file system or a file system in userspace?
Asked Answered
H

2

15

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?

Hermetic answered 26/5, 2010 at 5:20 Comment(0)
A
9

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.

Armoire answered 26/5, 2010 at 5:32 Comment(0)
F
19

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".

Fouquet answered 8/9, 2010 at 11:42 Comment(0)
A
9

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.

Armoire answered 26/5, 2010 at 5:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.