Module: FuseFS
- Defined in:
- lib/rfusefs.rb,
lib/fusefs.rb,
lib/fuse/fusedir.rb,
lib/fusefs/dirlink.rb,
lib/fusefs/metadir.rb,
lib/fuse/rfusefs-fuse.rb,
lib/fusefs/pathmapper.rb,
lib/fusefs/sqlitemapper.rb
Overview
This is FuseFS compatible module built over RFuse
Defined Under Namespace
Classes: DirLink, FileHandle, FuseDir, MetaDir, PathMapperFS, RFuseFS, SqliteMapperFS, StatsHelper
Constant Summary collapse
- RFUSEFS_COMPATIBILITY =
Which raw api should we use?
true
- DEFAULT_FS =
FuseDir.new()
Class Method Summary collapse
-
.exit ⇒ Object
Exit the run loop and teardown FUSE Most useful from Signal.trap() or Kernel.at_exit().
- .handle_editor(bool) ⇒ Object deprecated Deprecated.
-
.main(argv = ARGV, options = [], option_usage = "", device = nil, exec = File.basename($0)) {|options| ... } ⇒ Object
Convenience method to launch a FuseFS filesystem with nice error messages.
-
.mount(root, mountpoint, *opts) ⇒ void
Forks FuseFS.start so you can access your filesystem with ruby File operations (eg for testing).
-
.mount_under(mountpoint, *args) ⇒ Object
This will cause FuseFS to virtually mount itself under the given path.
-
.reader_gid ⇒ Fixnum
The calling process gid.
-
.reader_uid ⇒ Fixnum
The calling process uid You can use this in determining your permissions, or even provide different files for different users.
-
.run ⇒ Object
This is the main loop waiting on then executing filesystem operations from the kernel.
-
.set_root(root) ⇒ void
Set the root virtual directory.
-
.start(root, mountpoint, *opts) ⇒ void
Start the FuseFS root at mountpoint with opts.
-
.unmount(mountpoint = nil) ⇒ void
Unmount a filesystem.
Class Method Details
.exit ⇒ Object
Exit the run loop and teardown FUSE
Most useful from Signal.trap() or Kernel.at_exit()
162 163 164 165 166 |
# File 'lib/rfusefs.rb', line 162 def FuseFS.exit if @fuse @fuse.exit end end |
.handle_editor(bool) ⇒ Object
Not supported in RFuseFS.
The original FuseFS had special handling for editor swap/backup files which appears to be a workaround for a bug where zero length files where never written to. This “bug” is fixed since RFuseFS 1.0.2
187 188 189 |
# File 'lib/rfusefs.rb', line 187 def self.handle_editor(bool) #do nothing end |
.main(argv = ARGV, options = [], option_usage = "", device = nil, exec = File.basename($0)) {|options| ... } ⇒ Object
Convenience method to launch a FuseFS filesystem with nice error messages
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rfusefs.rb', line 47 def FuseFS.main(argv=ARGV,=[],option_usage="",device=nil,exec=File.basename($0)) = RFuse.(argv,*) if [:mountpoint] begin fs = yield rescue StandardError => ex puts ex. puts ex.backtrace.join("\n") end puts RFuse.usage(device,exec) if [:help] || !fs puts "Options:\n" if [:help] FuseFS.start(fs,*argv) if fs || [:help] puts option_usage if [:help] else puts "rfusefs: failed, no mountpoint provided",RFuse.usage(device,exec) end end |
.mount(root, mountpoint, *opts) ⇒ void
This is an RFuseFS extension
This method returns an undefined value.
Forks start so you can access your filesystem with ruby File operations (eg for testing).
94 95 96 97 98 99 100 101 |
# File 'lib/rfusefs.rb', line 94 def FuseFS.mount(root,mountpoint,*opts) pid = Kernel.fork do FuseFS.start(root,mountpoint,*opts) end @mounts[mountpoint] = pid pid end |
.mount_under(mountpoint, *args) ⇒ Object
This will cause FuseFS to virtually mount itself under the given path. set_root must have been called previously.
143 144 145 |
# File 'lib/rfusefs.rb', line 143 def FuseFS.mount_under(mountpoint, *args) @fuse = RFuse::FuseDelegator.new(@fs,mountpoint,*args) end |
.reader_gid ⇒ Fixnum
Returns the calling process gid.
176 177 178 |
# File 'lib/rfusefs.rb', line 176 def self.reader_gid Thread.current[:fusefs_reader_gid] end |
.reader_uid ⇒ Fixnum
Returns the calling process uid You can use this in determining your permissions, or even provide different files for different users.
171 172 173 |
# File 'lib/rfusefs.rb', line 171 def self.reader_uid Thread.current[:fusefs_reader_uid] end |
.run ⇒ Object
RFuseFS extension
This is the main loop waiting on then executing filesystem operations from the kernel.
Note: Running in a separate thread is generally not useful. In particular
you cannot access your filesystem using ruby File operations.
153 154 155 156 157 158 |
# File 'lib/rfusefs.rb', line 153 def FuseFS.run @fs.mounted() @fuse.loop if @fuse.mounted? ensure @fs.unmounted() end |
.set_root(root) ⇒ void
This method returns an undefined value.
Set the root virtual directory
132 133 134 |
# File 'lib/rfusefs.rb', line 132 def FuseFS.set_root(root) @fs=RFuseFS.new(root) end |
.start(root, mountpoint, *opts) ⇒ void
RFuseFS extension
This method returns an undefined value.
Start the FuseFS root at mountpoint with opts.
If not previously set, Signal traps for “TERM” and “INT” are added to exit the filesystem
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/rfusefs.rb', line 79 def FuseFS.start(root,mountpoint,*opts) set_default_traps("TERM","INT") { FuseFS.exit } FuseFS.set_root(root) begin FuseFS.mount_under(mountpoint,*opts) FuseFS.run ensure FuseFS.unmount() end end |
.unmount(mountpoint = nil) ⇒ void
RFuseFS extension
This method returns an undefined value.
Unmount a filesystem
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/rfusefs.rb', line 109 def FuseFS.unmount(mountpoint=nil) if (mountpoint) if @mounts.has_key?(mountpoint) pid = @mounts[mountpoint] Process.kill("TERM",pid) Process.waitpid(pid) else raise "Unknown mountpoint #{mountpoint}" end else #Local unmount, make sure we only try to unmount once if @fuse && @fuse.mounted? print "Unmounting #{@fuse.mountname}\n" @fuse.unmount() end @fuse = nil end end |