OS XでRFuseFSを動かす

RFuseFSFUSERubyで使うためのライブラリで、内部で使っているRFuseは基本的にOS Xをサポートしていないんですが、OS Xで動かすためのプルリクエストが投げられていて、手直ししたら一応動いたのでメモしておきます。

https://github.com/winebarrel/rfuse/commit/cc0d8499ab580b8e9c34be225696a003ced99691

Installation

FUSE for OS Xのインストール

以下からFUSE for OS Xをダウンロードしてインストールします。 https://osxfuse.github.io/

RFuse/RFuseFSのインストール

git clone git@github.com:winebarrel/rfuse.git
cd rfuse
git checkout fix_for_osx
bundle install
bundle exec rake install
gem install rfusefs

hello world filesystem

require 'rfusefs'

class HelloDir

  def contents(path)
    ['hello.txt']
  end

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

  def read_file(path)
    "Hello, World!\n"
  end

end

# Usage: #{$0} mountpoint [mount_options]
FuseFS.main() { |options| HelloDir.new }

動作確認

$ ruby -v
ruby 2.0.0p594 (2014-10-27 revision 48167) [x86_64-darwin13.4.0]
$ mkdir /tmp/hw
$ ruby test.rb /tmp/hw
(..main loop..)
$ ls /tmp/hw
hello.txt
$ cat /tmp/hw/hello.txt
Hello, World!