Class: RFuse::Fuse
- Inherits:
-
Object
- Object
- RFuse::Fuse
- Defined in:
- lib/rfuse.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#mountpoint ⇒ Object
(also: #mountname)
readonly
Returns the value of attribute mountpoint.
Instance Method Summary collapse
-
#exit ⇒ Object
(also: #unmount)
Stop processing.
-
#initialize(mountpoint, *argv) ⇒ Fuse
constructor
A new instance of Fuse.
- #loop ⇒ Object
-
#mounted? ⇒ Boolean
Is the filesystem successfully mounted.
-
#run(signals = Signal.list.keys, **run_args) ⇒ void
Convenience method to run a mounted filesystem to completion.
-
#trap_signals(*signames) ⇒ Array<String>
Set traps.
Constructor Details
#initialize(mountpoint, *argv) ⇒ Fuse
Returns a new instance of Fuse.
258 259 260 261 |
# File 'lib/rfuse.rb', line 258 def initialize(mountpoint, *argv) @mountpoint = mountpoint @fuse = FFI::Libfuse::Main.fuse_create(mountpoint, *argv, operations: self, private_data: self) end |
Instance Attribute Details
#mountpoint ⇒ Object (readonly) Also known as: mountname
Returns the value of attribute mountpoint.
255 256 257 |
# File 'lib/rfuse.rb', line 255 def mountpoint @mountpoint end |
Instance Method Details
#exit ⇒ Object Also known as: unmount
Stop processing
289 290 291 |
# File 'lib/rfuse.rb', line 289 def exit @fuse&.exit&.join end |
#loop ⇒ Object
284 285 286 |
# File 'lib/rfuse.rb', line 284 def loop run([] ,single_thread: true, foreground: true) end |
#mounted? ⇒ Boolean
Is the filesystem successfully mounted
@return [Boolean] true if mounted, false otherwise
266 267 268 |
# File 'lib/rfuse.rb', line 266 def mounted? @fuse && @fuse.mounted? end |
#run(signals = Signal.list.keys, **run_args) ⇒ void
This method returns an undefined value.
Convenience method to run a mounted filesystem to completion.
278 279 280 281 282 |
# File 'lib/rfuse.rb', line 278 def run(signals = Signal.list.keys, **run_args) raise Error, 'not mounted' unless @fuse trap_signals(*signals) @fuse.run(traps: @traps, **run_args) end |
#trap_signals(*signames) ⇒ Array<String>
Set traps
The filesystem supports a signal by providing a sig<name>
method. eg #sigint
The fuse #loop is notified of the signal via the self-pipe trick, and calls the corresponding
sig<name>
method, after any current filesystem operation completes.
This method will not override traps that have previously been set to something other than "DEFAULT"
Note: RFuse::Fuse itself provides #sigterm and #sigint.
328 329 330 331 332 333 334 335 |
# File 'lib/rfuse.rb', line 328 def trap_signals(*signames) signames = signames.map { |n| n.to_s.upcase }.map { |n| n.start_with?('SIG') ? n[3..-1] : n } signames.keep_if { |n| Signal.list[n] && respond_sigmethod?(sigmethod(n)) } @traps ||= {} @traps.merge!(signames.map { |n| [ n, ->() { call_sigmethod(sigmethod(n)) }]}.to_h) @traps.keys end |