Sha256: 0b3bc42751f5d8b6739ed7b22cc8b4b7688e6452b25b8bdf6d41239ee3dbfb26
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require 'ffi/libfuse' # Hello World! class HelloFS include FFI::Libfuse::Adapter::Ruby include FFI::Libfuse::Adapter::Fuse2Compat # FUSE Configuration methods def fuse_options(args) args.parse!({ 'subject=' => :subject }) do |key:, value:, **| raise FFI::Libfuse::Error, 'subject option must be at least 2 characters' unless value.size >= 2 @subject = value if key == :subject :handled end end def fuse_help '-o subject=<subject> a target to say hello to' end def fuse_configure @subject ||= 'World!' @content = "Hello #{@subject}\n" end # FUSE callbacks def getattr(path, stat, *_args) case path when '/' stat.directory(mode: 0o550) when '/hello.txt' stat.file(mode: 0o440, size: @content.size) else raise Errno::ENOENT end end def readdir(_path, *_args) yield 'hello.txt' end def read(_path, *_args) @content end end # Start the file system exit(FFI::Libfuse.fuse_main(operations: HelloFS.new)) if __FILE__ == $0
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ffi-libfuse-0.4.1 | sample/hello_fs.rb |
ffi-libfuse-0.4.0 | sample/hello_fs.rb |