Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a Virtual file system or a file system in userspace?

Tags:

fuse

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?

like image 214
zengr Avatar asked May 26 '10 05:05

zengr


People also ask

What is meant by virtual file system?

A virtual file system (VFS) is programming that forms an interface between an operating system's kernel and a more concrete file system. The VFS serves as an abstraction layer that gives applications access to different types of file systems and local and network storage devices.

Why do we need virtual file system?

The purpose of a VFS is to allow client applications to access different types of concrete file systems in a uniform way. A VFS can, for example, be used to access local and network storage devices transparently without the client application noticing the difference.

Which is the virtual filesystem containing system information?

The proc file system is a virtual file system that the system mounts it on /proc directory.

What are the three types of file system?

Disk/tape file systems, network file systems, and special-purpose file systems are the three main categories of file systems. The different types of File Systems are: Disk file systems.


2 Answers

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

like image 118
DomQ Avatar answered Sep 21 '22 08:09

DomQ


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.

like image 25
Phil Miller Avatar answered Sep 22 '22 08:09

Phil Miller