Create a Filesystem with Ruby and FUSE

Here I’ll show in simple steps how to create a file system (CowFS) with Ruby and FUSE. In 5 minutes you will be able to create your own file system.

Commands

sudo gem install rfusefs

Basic code

# main.rb
require 'rfusefs'

class CowFS
  def contents(path)
    ['rose.txt']
  end

  def file?(path)
    path == '/rose.txt'
  end

  def read_file(path)
    "Moo?!\n"
  end
end

cowfs = CowFS.new
FuseFS.start(cowfs, '/mnt/test')
(more…)

Continue Reading
Close Menu