Skip to content

Instantly share code, notes, and snippets.

@mikermcneil
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikermcneil/a8551ca652d31c0e12aa to your computer and use it in GitHub Desktop.
Save mikermcneil/a8551ca652d31c0e12aa to your computer and use it in GitHub Desktop.
So... what's a filesystem?

On Filesystems

So... what's a filesystem?

According to wikipedia:

In computing, a file system (or filesystem) is used to control how data is stored and retrieved. Without a file system, information placed in a storage area would be one large body of data with no way to tell where one piece of information stops and the next begins. By separating the data into individual pieces, and giving each piece a name, the information is easily separated and identified. Taking its name from the way paper-based information systems are named, each piece of data is called a "file". The structure and logic rules used to manage the groups of information and their names is called a "file system".

While all that is true, it's not quite what I'm looking for, nor particularly useful as a lemma in the grand unified theory of computer science we're reluctantly building in the Node.js community.

I thought about this a bit and came up with some ideas. Here's my take:

  • A filesystem is a key/value database (like Redis) but optimized for storing large binary values (aka "files") with conventionally-named keys (aka "paths")
  • By convention, keys are prefixed with '/'. Most of the time they also end with ".*" where * is a short alphanumeric suffix.
  • Filesystems are optimized to support a concept of "directories" or "folders" which represent a grouping of keys based on shortest prefix (i.e. "/foo/bar/baz.jpg" and "/foo/bar/blah.png" are in the same "directory) Directories don't really exist, but these '/' characters do have special meaning
  • Filesystems sometimes also store metadata for performance reasons, or to provide additional features like permissions and indexed search. A common example is the size (in bytes) of various files, and/or even the calculated size of "directories"
@RichAyotte
Copy link

What about Symbolic link, Named pipe, Socket, Device file and Door? http://en.wikipedia.org/wiki/Unix_file_types.

@devinivy
Copy link

devinivy commented Oct 9, 2014

And what do you think about eventual consistency versus immediate consistency?

@mristroph
Copy link

Interesting way to frame it...

Here is an edit that's a bit more abstract but reconciles with the low level Unix filesystem interface more:

A "filesystem" is just another thing providing an interface for sending and receiving information... but calling an interface a "filesystem" implies it supports a number of specific operations and usage conventions. The most important convention is that information is sent/received through a key/value interface where keys are often short character strings called "paths" and values are often large binary blobs called "files".

Common Key Conventions ("Paths")

  • Generally, there are always a bunch of rules for what keys are allowed for that filesystem.
  • Keys often start with '/' and end with ".*" where * is a short alphanumeric suffix that provides a clue on how to interpret the associated value.
  • Keys will often have several of a special character called a separator (usually '/').
  • Keys prefixes ending in that separator are called "folders" or "directories". (i.e. "/foo/bar/baz.jpg" and "/foo/bar/blah.png" are in the same "directory).

Common Value Conventions ("Files")

  • Information sent for a key is persistently stored, and can be retrieved later through that same key (i.e. fread, fwrite). Values are only changed through the filesystem interface. (Named pipe/character device files are violations).
  • Many different conventions regarding "write locking", many of which can provide immediate consistency (i.e. fopen, fclose, fflush).
  • Given the persistence and large binary conventions, filesystems generally provide highly optimized operations that treat values as a binary streams and allow for fetching only small portions of the large binary (i.e. fseek).

Common Metadata Conventions

  • Filesystems sometimes also store metadata for performance reasons, or to provide additional features like permissions and indexed search (i.e. chmod, umask).
  • A common example is the size (in bytes) of various files, and/or even the calculated size of "directories" (i.e. sizeof).
  • Metadata operations can configure how information for a key or group of keys sharing a certain prefixes is to be handled, that violation the normal persistent filesystem conventions outline above (i.e. mkfifo, mknod).

@mikermcneil
Copy link
Author

Thanks for the comments guys :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment