Module: RFuse
- Defined in:
- lib/rfuse.rb,
lib/rfuse/version.rb,
ext/rfuse/filler.c,
ext/rfuse/context.c,
ext/rfuse/file_info.c,
ext/rfuse/rfuse_mod.c
Overview
Ruby FUSE (Filesystem in USErspace) binding
Defined Under Namespace
Classes: Context, Error, FileInfo, Filler, Fuse, FuseDelegator, Stat, StatVfs
Constant Summary collapse
- VERSION =
"1.0.5"
Class Method Summary collapse
-
.packxattr(xattrs) ⇒ Object
Used by listxattr.
-
.parse_options(argv, *local_opts) ⇒ Hash{Symbol => String,Boolean}
Parse mount arguments and options.
-
.usage(device = nil, exec = File.basename($0)) ⇒ String
Generate a usage string.
Class Method Details
.packxattr(xattrs) ⇒ Object
Used by listxattr
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rfuse.rb', line 10 def self.packxattr(xattrs) case xattrs when Array xattrs.join("\000").concat("\000") when String #assume already \0 separated list of keys xattrs else raise RFuse::Error, ":listxattr must return Array or String, got #{xattrs.inspect}" end end |
.parse_options(argv, *local_opts) ⇒ Hash{Symbol => String,Boolean}
Parse mount arguments and options
Fuse itself will normalise arguments
mount -t fuse </path/to/fs>#<device> mountpoint [options...]
mount.fuse </path/to/fs>#<device> mountpoint [options...]
both result in a call to /path/to/fs with arguments…
[device] mountpoint [-h] [-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 - true if -h was supplied
and any other supplied options.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/rfuse.rb', line 72 def self.(argv,*local_opts) result = Hash.new(nil) first_opt_index = (argv.find_index() { |opt| opt =~ /-.*/ } || argv.length ) result[:device] = argv.shift if first_opt_index > 1 result[:mountpoint] = argv[0] if argv.length > 0 if argv.include?("-h") result[:help] = true end if argv.include?("-d") result[:debug] = true end opt_index = ( argv.find_index("-o") || -1 ) + 1 if opt_index > 1 && opt_index < argv.length = argv[opt_index].split(",") .delete_if() do |opt| opt.strip! opt,value = opt.split("=",2) value = true unless value opt_sym = opt.to_sym result[opt_sym] = value #result of delete if local_opts.include?(opt_sym) end if .empty? argv.slice!(opt_index - 1,2) else argv[opt_index] = .join(",") end end result end |
.usage(device = nil, exec = File.basename($0)) ⇒ String
Generate a usage string
120 121 122 |
# File 'lib/rfuse.rb', line 120 def self.usage(device=nil,exec=File.basename($0)) "Usage:\n\t #{exec} #{device} mountpoint [-h] [-o [opt,optkey=value,...]]\n" end |