Module RFuse
In: lib/rfuse/version.rb
lib/rfuse.rb

Ruby FUSE (Filesystem in USErspace) binding

Methods

create   main   packxattr   parse_options   usage  

Classes and Modules

Class RFuse::Context
Class RFuse::FileInfo
Class RFuse::Filler
Class RFuse::Fuse
Class RFuse::FuseDelegator
Class RFuse::Stat
Class RFuse::StatVfs

Constants

VERSION = "1.1.2"

Public Class methods

@private Helper to create a {Fuse} from variety of #{.main} yield results

Convenience method to launch a fuse filesystem, with nice usage messages and default signal traps

@param [Array<String>] argv command line arguments @param [Array<Symbol>] extra_options list of additional options @param [String] extra_options_usage describing additional option usage @param [String] device a description of the device field @param [String] exec the executable file

@yieldparam [Hash<Symbol,String>] options See {.parse_options} @yieldparam [Array<String>] argv Cleaned argv See {.parse_options}

@yieldreturn [Class<Fuse>]

  a subclass of {Fuse} that implements your filesystem. Will receive `.new(*extra_options,*argv)`

@yieldreturn [Class]

  a class that implements {FuseDelegator::FUSE_METHODS}. Will receive `.new(*extra_options)`
  and the resulting instance sent with `*argv` to {FuseDelegator}

@yieldreturn [Fuse]

  Your initialised (and therefore already mounted) filesystem

@yieldreturn [Object]

  An object that implements the {Fuse} methods, to be passed with `*argv` to {FuseDelegator}

@yieldreturn [Error]

  raise {Error} with appropriate message for invalid options

@since 1.1.0

@example

  class MyFuse < Fuse
     def initialize(myfs,*argv)
        @myfs = myfs # my filesystem local option value
        super(*argv)
     end
     # ... implementations for filesystem methods ...
  end

  class MyFSClass  # not a subclass of Fuse, FuseDelegator used
     def initialize(myfs)
      @myfs = myfs # my filesystem local option value
     end
     # ...
  end

  MY_OPTIONS = [ :myfs ]
  OPTION_USAGE = "  -o myfs=VAL how to use the myfs option"
  DEVICE_USAGE = "how to use device arg"

  # Normally from the command line...
  ARGV = [ "some/device", "/mnt/point", "-h", "-o", "debug,myfs=aValue" ]

  RFuse.main(ARGV, MY_OPTIONS, OPTION_USAGE, DEVICE_USAGE, $0) do |options, argv|

      # options ==
         { :device => "some/device",
           :mountpoint => "/mnt/point",
           :help => true,
           :debug => true,
           :myfs => "aValue"
         }

      # ... validate options...
      raise RFuse::Error, "Bad option" unless options[:myfs]

      # return the filesystem class to be initialised by RFuse
      MyFuse
      # or
      MyFSClass

      # OR take full control over initialisation yourself and return the object
      MyFuse.new(options[:myfs],*argv)
      # or
      MyFSClass.new(options[:myfs])

  end

@private Used by listxattr

Parse mount arguments and options

@param [Array<String>] argv

       normalised fuse options

@param [Array<Symbol>] local_opts local options

       if these are found in the argv entry following "-o" they are removed
       from argv, ie so argv is a clean set of options that can be passed
       to {RFuse::Fuse} or {RFuse::FuseDelegator}

@return [Hash<Symbol,String|Boolean>]

        the extracted options

@since 1.0.3

Fuse itself will normalise arguments

    mount -t fuse </path/to/fs.rb>#<device> mountpoint [options...]
    mount.fuse </path/to/fs.rb>#<device> mountpoint [options...]

both result in the following command execution

    /path/to/fs.rb [device] mountpoint [-h] [-d] [-o [opt,optkey=value,...]]

which this method will parse into a Hash with the following special keys

 * `:device` - the optional mount device, removed from argv if present
 * `:mountpoint` - required mountpoint
 * `:help` - if -h was supplied - will print help text (and not mount the filesystem!)
 * `:debug` - if -d (or -o debug) was supplied - will print debug output from the underlying FUSE library

and any other supplied options.

@example

  ARGV = [ "some/device", "/mnt/point", "-h", "-o", "debug,myfs=aValue" ]
  options = RFuse.parse_options(ARGV,:myfs)

  # options ==
  { :device => "some/device",
    :mountpoint => "/mnt/point",
    :help => true,
    :debug => true,
    :myfs => "aValue"
  }
  # and ARGV ==
  [ "/mnt/point","-h","-o","debug" ]

  fs = create_filesystem(options)
  fuse = RFuse::FuseDelegator.new(fs,*ARGV)

Generate a usage string

@param [String] device a description of how the device field should be used @param [String] exec the executable @return [String] the usage string

[Validate]